Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 06 Dec 2003 17:16:00 -0800
From:      Peter Wemm <peter@wemm.org>
To:        Daniel Eischen <eischen@vigrid.com>
Cc:        cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/lib/libc/amd64/gen makecontext.c 
Message-ID:  <20031207011600.E70C32A7EA@canning.wemm.org>
In-Reply-To: <Pine.GSO.4.10.10312042042001.1477-100000@pcnet5.pcnet.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
Daniel Eischen wrote:
> On Thu, 4 Dec 2003, Peter Wemm wrote:
> 
> > peter       2003/12/04 17:36:44 PST
> > 
> >   FreeBSD src repository
> > 
> >   Modified files:
> >     lib/libc/amd64/gen   makecontext.c 
> >   Log:
> >   "Fix" makecontext() so that the C code begins execution with its
> >   ABI-required stack alignment.  C code expects that the push of the
> >   return address disturbed the 16 byte alignment and it will take correctiv
    e
> >   measures to fix it before making another call.  Of course, if its wrong
> >   to start with, then all hell breaks loose.  Essentially we "fix" this
> >   by making the stack alignment odd to start with.
> 
> Hey, you didn't include this little bit of knowledge in your amd64 "notes"
> that you sent me ;-)

Heh. I never get it right.  I've had to resort to things like this:

  assert((((long)__builtin_frame_address(0)) & 15 == 0), "misaligned stack!");

The trick of course is that gcc-3.3.3 is broken and __builtin_frame_address(0)
doesn't actually work unless you compile *also* with -fno-omit-frame-pointer
on amd64.

Anyway, thats the only way I've ever been able to get this stuff sorted out. :-)

Cheers,
-Peter
--
Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031207011600.E70C32A7EA>