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 ?
- From: "Joakim Tjernlund" <Joakim dot Tjernlund at lumentis dot se>
- To: "Daniel Jacobowitz" <drow at false dot org>
- Cc: "Peter S. Mazinger" <ps dot m at gmx dot net>, <binutils at sourceware dot org>
- Date: Fri, 20 May 2005 00:59:07 +0200
- Subject: RE: is main() provided by a library valid C ?
- Reply-to: <Joakim dot Tjernlund at lumentis dot se>
>
> 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.
OK, thanks.
>
> > 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.
hmm probably, but it is a little strange to require 16-byte aligned stack ptr before
calling a function instead of having the called function begin execution with a 16-byte aligned
stack ptr.
Jocke