[K42-discussion] c++ -> c calling conventions and assembly
Bryan S Rosenburg
rosnbrg at us.ibm.com
Thu Oct 5 05:34:31 EST 2006
Donour Sizemore wrote on 10/04/2006 02:43:46 PM:
> Bryan S Rosenburg wrote:
> >
> > Thanks, Livio. That sounds like the option I was hoping for. Donour,
> > can you try it out?
> >
> >
>
> Yup, this does seem to emit the symbol. Thanks Livio!
>
> A brief conversation with David Edelsohn indicates that maybe we
> shouldn't be doing this. Shouldn't we follow the ppc64-linux API?
Well, there's magic here that I don't understand yet. For function calls
(not virtual method invocations), the g++3.4.4 compiler generates an
instruction such as:
bl .foo
where .foo is the symbol that equates to the text address of the function
foo. I've learned that the g++4.0.1 compiler generates a different
instruction:
bl foo
where foo is the symbol that equates to the DATA address of the function
descriptor for foo.
Now, you can't branch to the data address. But somehow the assembler and
linker turn the instruction into a proper branch to the text address. And
I mean a direct branch, not an indirect branch through the function
descriptor.
So it's possible that the same sort of magic will work for us. Maybe we
can just change the assembler code to branch to the data address, silly as
that sounds, and the assembler will figure it out and turn it into a
proper direct branch to the text address.
I used to know how assemblers and linkers worked, but I'm not so sure
anymore.
- Bryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ozlabs.org/pipermail/k42-discussion/attachments/20061004/b1d62bd9/attachment.htm
More information about the K42-discussion
mailing list