shared libstdc++

David McCullough davidm at snapgear.com
Wed Jan 18 01:33:25 UTC 2006


Jivin Lei Sun lays it down ...
> >Jivin Lei Sun lays it down ...
> >>Hi:
> >>  I am having trouble runing C++ application uClinux, the elf2flt 
> >>couldn't product correct binary with pic_and_got set, I disabled the 
> >>shared lib support in uClibc, so all the C program is OK. But I got 
> >>"reloc outside program"error when loading C++ application, the problem is 
> >>that buildroot automatically built the gcclib and libstdc++ with PIC and 
> >>GOT,  the elf2flt linker script grep the C++ binary and found 
> >>"GLOBAL_OFFSET_TABLE"  and then set the pic_and_got, therefore , created 
> >>faulty binary( I think it has some bugs).
> >>  As Mike pointed that uClinux list doesn't response question regarding 
> >>elf2flt.
> >
> >Thats unusual,  and I haven't seen too many questions go unanswered.
> >On the uClinux-dve list,  no answer usually means no one knows the answer 
> >:-)
> >
> >>My question is, do i have to build gcc with -enable-shared option? as 
> >>specified in buildroot's Makefile? if not, should buildroot add an option 
> >>to let user select shared option when building gcclib?
> >
> >First I would ask what platform are you building for ?
> >What compiler version are you building ?
> 
> I was using ARM platform with NO-MMU, compiler is gcc-3.4.2
> 
> >You can only do shared libraries for uClinux on m68k at the moment,  and
> >no one has gone close to making a libstdc++ shared lib for uClinux on
> >m68k.
> 
> Take a look at the buildroot script, on 2nd stage of buidling gcc, the 
> script configured the gcc with --enable-shared , that's where libstdc++ 
> shared were created.

My guess is that buildroot on !MMU is not that well tested.
You do not want --enable-shared for a !MMU toolchain,  in fact you
probably want to force it off.  That is providing it affects the
generated libs and not the generated compiler (ie., a cross compiler can
use shared libs,  but the libs it uses to build target apps with should
not be shared).


> >My guess is that you are mixing up MMU shared libraries with uClinux and
> >they just don't work.  Under uClinux you will never used the '-shared'
> >compile option and you are unlikely to use -fPIC (except for XIP on arm
> >platforms,  and then you need the XIP support in the compiler).
> 
> What do you mean by "MMU shared libraries" ,  I finally figured out that 

ELF shared libs

> libgcc.a  was built with -fPIC flag! thus every lib depends on libgcc.a 
> will has GOT in it.  the file gcc-3.4.2/gcc/config/arm/t-linux  is the evil 
> that silently set the -fPIC. I was able to removed that and rebuilt the 
> stdlibc++.a  , now I could compile C++ application.
> Still don't quite understand why -fPIC was used for libgcc.a

Who knows,  but the -fPIC will make elf2flt think that everything is
XIP, and the compiler doesn't support XIP as elf2flt knows it.

When you configure elf2flt you could add:

	--disable-got-check

That should allow elf2flt to handle the -fPIC libs without a problem,

Cheers,
Davidm

-- 
David McCullough, davidm at cyberguard.com.au, Custom Embedded Solutions + Security
Ph:+61 734352815 Fx:+61 738913630 http://www.uCdot.org http://www.cyberguard.com



More information about the uClibc mailing list