[uClinux-dev] Re: [uClibc] [PATCH] fix libptrhead build for m68k
davidm at snapgear.com
Thu Oct 9 00:32:18 UTC 2003
Jivin D.Jeff Dionne lays it down ...
> On Sunday, October 5, 2003, at 10:43 PM, Erik Andersen wrote:
> >On Mon Oct 06, 2003 at 01:06:25AM +0200, Bernardo Innocenti wrote:
> >>The real reason for this exception is that uClinux binaries
> >>are not linked with crtbegin.o/crtend.o.
> >Why? Without them, how will constructors and destructors work?
> Which means stdio busted... And on 68k the A5 world might not be right,
> You certainly do need the C Run Time init code!
So then we know it must be called or nothing would work right :-) :-)
Here's what happens. In the latest tool chains crtbegin.o and crtend.o
are not linked in as Bernie pointed out. How does it work then ?
The elf2flt linker script implements the constructor/destructor lists
(actually the info pages for ld show you how to do this).
And the calling of constructors is then taken care of by __main which comes
from libgcc. destructors are called by __main registering then with
The reason is was done this way was mainly to maintain compatibility
with existing source based (current comon usage of compilers and
options) and yet ensure that pthreads and C++ would work. I found during
testing that various combinations messed up the constructor table, some
put double lead in and some combos left out the lead in (ie number of
constructors). The current implementation ensured the constructor lists
were always correct and usable.
I haven't done it yet but there is a way to re-instate crtbegin and crtend
using the ld wrapper script that achieves the same outcome and this is
preferrable and my intention eventually.
Either way though, the final binaries operate as expected whichever
method you choose,
David McCullough, davidm at snapgear.com Ph:+61 7 34352815 http://www.SnapGear.com
Custom Embedded Solutions + Security Fx:+61 7 38913630 http://www.uCdot.org
More information about the uClibc