This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: is main() provided by a library valid C ?
On Thu, May 19, 2005 at 11:14:25PM +0200, Joakim Tjernlund wrote:
> >
> > On Thu, May 19, 2005 at 10:40:07PM +0200, Joakim Tjernlund wrote:
> > > If my memory serves me right, to build libc w/ -z defs, main needs to be declared
> > > weak in libc.
> >
> > Incorrect. Libc doesn't need to mention main at all. Please look at
> > glibc's CRT files.
>
> Ahh, now I understand why you pass main as argument from start.S to libc, right?
> Is this the only reason you do that or is there more to it?
I didn't write it; I have no idea. It seems like a sounder design.
> Aligns the stack to 16-byte, then the code below does 8 pushl at which point the
> stack is 16-byte aligned again and finally a call to __libc_start_main. The call to
> __libc_start_main will add 4 bytes to the stack ptr and now the stack isn't 16-byte
> aligned when __libc_start_main starts to execute. Is this the way it is supposed to work?
Presumably this is the ABI-mandated behavior.
--
Daniel Jacobowitz
CodeSourcery, LLC