This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Static libc.a and weak __pthread_unwind symbol problem


Hello, I'm trying to diagnose a problem I am getting when linking against glibc's libc.a. This is for glibc version 2.13 (with glibc-ports-2.13 although I don't think any ports files are being used).

The BUILD and HOST are x86_64-unknown-linux-gnu, and the TARGET is mips-unknown-linux-gnu.

I build a purely static version of glibc in an early stage of a 'bootstrapping' process of building gcc, glibc, and binutils as a cross-compiler. Then I use that static glibc when building gcc. This works fine when the BUILD and HOST are i686-unknown-linux-gnu, but the pthreads implementation for x86_64 is different and causes problems.

I don't understand weak symbols and their use in static libraries very well, but the basic problem has something to do with the symbol __pthread_unwind, which, when gcc's link of libgcc_s.so occurs, produces this error:

> /home/bji/buildtools/output/build/stage2/x86_64-unknown-linux-gnu/gcc/./gcc/xgcc

> -B/home/bji/buildtools/output/build/stage2/x86_64-unknown-linux-gnu/gcc/./gcc/

> -B/home/bji/buildtools/output/install/stage2/x86_64-unknown-linux-gnu/usr/x86_64-unknown-linux-gnu/bin/
> -B/home/bji/buildtools/output/install/stage2/x86_64-unknown-linux-gnu/usr/x86_64-unknown-linux-gnu/lib/
> -isystem
> /home/bji/buildtools/output/install/stage2/x86_64-unknown-linux-gnu/usr/x86_64-unknown-linux-gnu/include
> -isystem
> /home/bji/buildtools/output/install/stage2/x86_64-unknown-linux-gnu/usr/x86_64-unknown-linux-gnu/sys-include
> -O2 -g -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall
> -Wwrite-strings -Wcast-qual -Wstrict-prototypes
> -Wmissing-prototypes -Wold-style-definition -isystem ./include
> -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2
> -D__GCC_FLOAT_NOT_NEEDED -fno-stack-protector -shared
> -nodefaultlibs -Wl,--soname=libgcc_s.so.1
> -Wl,--version-script=libgcc.map -o ./libgcc_s.so.1.tmp -g -B./
> _muldi3_s.o _negdi2_s.o _lshrdi3_s.o _ashldi3_s.o _ashrdi3_s.o
> _cmpdi2_s.o _ucmpdi2_s.o _clear_cache_s.o
> _enable_execute_stack_s.o _trampoline_s.o __main_s.o _absvsi2_s.o
> _absvdi2_s.o _addvsi3_s.o _addvdi3_s.o _subvsi3_s.o _subvdi3_s.o
> _mulvsi3_s.o _mulvdi3_s.o _negvsi2_s.o _negvdi2_s.o _ctors_s.o
> _ffssi2_s.o _ffsdi2_s.o _clz_s.o _clzsi2_s.o _clzdi2_s.o
> _ctzsi2_s.o _ctzdi2_s.o _popcount_tab_s.o _popcountsi2_s.o
> _popcountdi2_s.o _paritysi2_s.o _paritydi2_s.o _powisf2_s.o
> _powidf2_s.o _powixf2_s.o _mulsc3_s.o _muldc3_s.o _mulxc3_s.o
> _divsc3_s.o _divdc3_s.o _divxc3_s.o _bswapsi2_s.o _bswapdi2_s.o
> _fixunssfsi_s.o _fixunsdfsi_s.o _fixunsxfsi_s.o _fixsfdi_s.o
> _fixdfdi_s.o _fixxfdi_s.o _fixunssfdi_s.o _fixunsdfdi_s.o
> _fixunsxfdi_s.o _floatdisf_s.o _floatdidf_s.o _floatdixf_s.o
> _floatundisf_s.o _floatundidf_s.o _floatundixf_s.o _divdi3_s.o
> _moddi3_s.o _udivdi3_s.o _umoddi3_s.o _udiv_w_sdiv_s.o
> _udivmoddi4_s.o addtf3_s.o divtf3_s.o multf3_s.o negtf2_s.o
> subtf3_s.o unordtf2_s.o fixtfsi_s.o fixunstfsi_s.o floatsitf_s.o
> floatunsitf_s.o fixtfdi_s.o fixunstfdi_s.o floatditf_s.o
> floatunditf_s.o fixtfti_s.o fixunstfti_s.o floattitf_s.o
> floatuntitf_s.o extendsftf2_s.o extenddftf2_s.o extendxftf2_s.o
> trunctfsf2_s.o trunctfdf2_s.o trunctfxf2_s.o getf2_s.o letf2_s.o
> eqtf2_s.o _divtc3_s.o _multc3_s.o _powitf2_s.o unwind-dw2_s.o
> unwind-dw2-fde-glibc_s.o unwind-sjlj_s.o gthr-gnat_s.o
> unwind-c_s.o emutls_s.o -lc && rm -f ./libgcc_s.so && if [ -f
> ./libgcc_s.so.1 ]; then mv -f ./libgcc_s.so.1
> ./libgcc_s.so.1.backup; else true; fi && mv ./libgcc_s.so.1.tmp
> ./libgcc_s.so.1 && ln -s libgcc_s.so.1 ./libgcc_s.so
> /home/bji/buildtools/output/install/stage2/x86_64-unknown-linux-gnu/usr/x86_64-unknown-linux-gnu/bin/ld:
> /home/bji/buildtools/output/install/stage1/x86_64-unknown-linux-gnu/usr/lib/libc.a(libc-cancellation.o):
> relocation R_X86_64_PC32 against undefined symbol
> `__pthread_unwind' can not be used when making a shared object;
> recompile with -fPIC
> /home/bji/buildtools/output/install/stage2/x86_64-unknown-linux-gnu/usr/x86_64-unknown-linux-gnu/bin/ld:
> final link failed: Bad value


The symbol __pthread_unwind does exist in libc.a, although it is a weak symbol:

sleep.o:
                 U _GLOBAL_OFFSET_TABLE_
                 U __libc_errno
                 U __nanosleep
                 w __pthread_unwind
                 U __sigaction
                 U __sigprocmask
0000000000000000 T __sleep
0000000000000000 W sleep

libc-cancellation.o:
0000000000000060 T __libc_disable_asynccancel
0000000000000000 T __libc_enable_asynccancel
                 w __pthread_unwind

I find that if I *don't* explicitly include the -lc directive when linking libgcc_s.so, the link proceeds fine. But I also find that any linking of executables by gcc needs an expliciy -lc which doesn't seem normal.

Really I just don't understand what it means for __pthread_unwind to be listed as a weak symbol in libc.a; how does this affect linking of a shared object library against this static libc.a? And what about executables?

When libc.so is linked against, how does the linker *not* get an error for __pthread_unwind that it *does* get when linking libc.a?

Any advice at all would be greatly appreciated.

Thanks,
Bryan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]