* [Linux-ia64] ld-linux.so
@ 2000-04-23 6:45 Laurent Morichetti
2000-04-23 9:02 ` Jes Sorensen
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Laurent Morichetti @ 2000-04-23 6:45 UTC (permalink / raw)
To: linux-ia64
In glibc/sysdeps/ia64/dl-machine.h the macro TRAMPOLINE_TEMPLATE saves the
input registers but not r8 (pointer to value returned in memory). r8 should
be preserved across the runtime fixup.
The following example fails on linux-ia64:
foo.hpp:
===
class foo {
public:
long _a;
long _b;
foo(long a, long b) : _a(a), _b(b) {}
};
extern foo bar(long a, long b);
bar.cpp:
===
#include "foo.hpp"
foo bar(long a, long b) { return foo(a, b); }
foo.cpp:
===
#include <stdlib.h>
#include <stdio.h>
#include "foo.hpp"
int main() {
foo f = bar(1, 2);
fprintf(stdout, "a=%ld, b=%ld\n", f._a, f._b);
return EXIT_SUCCESS;
}
$ g++ -fPIC -shared -o libbar.so bar.cpp
$ g++ -o foo foo.cpp -L. -lbar
-Laurent
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Linux-ia64] ld-linux.so
2000-04-23 6:45 [Linux-ia64] ld-linux.so Laurent Morichetti
@ 2000-04-23 9:02 ` Jes Sorensen
2000-04-23 16:52 ` Kevin Buettner
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Jes Sorensen @ 2000-04-23 9:02 UTC (permalink / raw)
To: linux-ia64
>>>>> "Laurent" = Laurent Morichetti <laurentm@cup.hp.com> writes:
Laurent> In glibc/sysdeps/ia64/dl-machine.h the macro
Laurent> TRAMPOLINE_TEMPLATE saves the input registers but not r8
Laurent> (pointer to value returned in memory). r8 should be preserved
Laurent> across the runtime fixup.
I know very little about the C++ ABI so this may be C++ specific. I
thought r8 was meant to be a return register and not an input
register and that it's valid to clobber it in any function call,
whether the function returns a value or void?
I am sitting at home right now and all my documents are in the office
so I can't look it up.
Jes
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Linux-ia64] ld-linux.so
2000-04-23 6:45 [Linux-ia64] ld-linux.so Laurent Morichetti
2000-04-23 9:02 ` Jes Sorensen
@ 2000-04-23 16:52 ` Kevin Buettner
2000-04-24 9:01 ` Jes Sorensen
2000-04-24 11:08 ` Jes Sorensen
3 siblings, 0 replies; 5+ messages in thread
From: Kevin Buettner @ 2000-04-23 16:52 UTC (permalink / raw)
To: linux-ia64
On Apr 23, 11:02am, Jes Sorensen wrote:
> Laurent> In glibc/sysdeps/ia64/dl-machine.h the macro
> Laurent> TRAMPOLINE_TEMPLATE saves the input registers but not r8
> Laurent> (pointer to value returned in memory). r8 should be preserved
> Laurent> across the runtime fixup.
>
> I know very little about the C++ ABI so this may be C++ specific. I
> thought r8 was meant to be a return register and not an input
> register and that it's valid to clobber it in any function call,
> whether the function returns a value or void?
When the function in question returns an (non-HFA) aggregate that's
larger than 32 bytes (256 bits), r8 is an input register containing
the address of the region of memory into which to write the return
structure. When this is the case, r8 is not an output register. I.e,
the calling conventions do not mandate restoring the struct address.
When the aggregate happens to be an HFA, the HFA is returned in
floating point registers f8 thru f15 for HFAs of up to 8 elements.
When they're larger than 8 elements, the above convention regarding
r8 is used.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Linux-ia64] ld-linux.so
2000-04-23 6:45 [Linux-ia64] ld-linux.so Laurent Morichetti
2000-04-23 9:02 ` Jes Sorensen
2000-04-23 16:52 ` Kevin Buettner
@ 2000-04-24 9:01 ` Jes Sorensen
2000-04-24 11:08 ` Jes Sorensen
3 siblings, 0 replies; 5+ messages in thread
From: Jes Sorensen @ 2000-04-24 9:01 UTC (permalink / raw)
To: linux-ia64
>>>>> "Kevin" = Kevin Buettner <kev@primenet.com> writes:
Kevin> On Apr 23, 11:02am, Jes Sorensen wrote:
>> I know very little about the C++ ABI so this may be C++ specific.
>> I thought r8 was meant to be a return register and not an input
>> register and that it's valid to clobber it in any function call,
>> whether the function returns a value or void?
Kevin> When the function in question returns an (non-HFA) aggregate
Kevin> that's larger than 32 bytes (256 bits), r8 is an input register
Kevin> containing the address of the region of memory into which to
Kevin> write the return structure. When this is the case, r8 is not
Kevin> an output register. I.e, the calling conventions do not
Kevin> mandate restoring the struct address.
ARGH!
Thats nasty, I would much have preferred to see something like r32
used as the input pointer and have it returned in r8 afterwards. This
way it is going to cause overhead on every single lookup ;-(
Well it's still a bug so we better fix it.
Jes
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Linux-ia64] ld-linux.so
2000-04-23 6:45 [Linux-ia64] ld-linux.so Laurent Morichetti
` (2 preceding siblings ...)
2000-04-24 9:01 ` Jes Sorensen
@ 2000-04-24 11:08 ` Jes Sorensen
3 siblings, 0 replies; 5+ messages in thread
From: Jes Sorensen @ 2000-04-24 11:08 UTC (permalink / raw)
To: linux-ia64
>>>>> "Jes" = Jes Sorensen <Jes.Sorensen@cern.ch> writes:
>>>>> "Kevin" = Kevin Buettner <kev@primenet.com> writes:
Kevin> On Apr 23, 11:02am, Jes Sorensen wrote:
>>> I know very little about the C++ ABI so this may be C++ specific.
>>> I thought r8 was meant to be a return register and not an input
>>> register and that it's valid to clobber it in any function call,
>>> whether the function returns a value or void?
Kevin> When the function in question returns an (non-HFA) aggregate
Kevin> that's larger than 32 bytes (256 bits), r8 is an input register
Kevin> containing the address of the region of memory into which to
Kevin> write the return structure. When this is the case, r8 is not
Kevin> an output register. I.e, the calling conventions do not
Kevin> mandate restoring the struct address.
Jes> ARGH!
Jes> Thats nasty, I would much have preferred to see something like
Jes> r32 used as the input pointer and have it returned in r8
Jes> afterwards. This way it is going to cause overhead on every
Jes> single lookup ;-(
Hmmm ok, a bit of overreacting since we can store r8 in a local
register, we don't need to flush it onto the stack as I was thinking
at first.
However, I just checked the code and r8 is already being saved in loc2
across the lookup call. I suspect this was put in when Richard
Henderson optimized the packaging of the bundles.
Jes
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2000-04-24 11:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-04-23 6:45 [Linux-ia64] ld-linux.so Laurent Morichetti
2000-04-23 9:02 ` Jes Sorensen
2000-04-23 16:52 ` Kevin Buettner
2000-04-24 9:01 ` Jes Sorensen
2000-04-24 11:08 ` Jes Sorensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox