Bug 2713

Summary: build failure on amd64 due to unresolveable __GI___chk_fail symbol
Product: uClibc Reporter: William Pitcock <nenolod>
Component: OtherAssignee: Carmelo Amoroso <carmelo.amoroso>
Status: ASSIGNED ---    
Severity: minor CC: ncopa, nenolod, uclibc-cvs
Priority: P5    
Version: 0.9.32   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:
Attachments: entirely lame method of fixing this bug
same method applied to libpthread...
use libc_hidden_proto / libc_hidden_def
same for nptl

Description William Pitcock 2010-10-17 19:58:14 UTC
Trying to build GIT pulled from today results in this linker error:

nenolod@neon:~/build/uClibc$ make VERBOSE=1
rm -f lib/libc.so lib/libc.so.0 lib/libuClibc-0.9.32-git.so

gcc -Wl,-EL -shared -Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc -Wl,-z,relro -Wl,-z,now -Wl,-z,defs -Wl,-s   -Wl,-init,__uClibc_init -Wl,-soname=libc.so.0 -nostdlib -o lib/libuClibc-0.9.32-git.so  -Wl,--whole-archive libc/libc_so.a -Wl,--no-whole-archive ./lib/interp.os ./lib/ld64-uClibc.so.0 ./lib/uclibc_nonshared.a /usr/lib/gcc/x86_64-linux-gnu/4.3.2/libgcc.a 
libc/libc_so.a(bzero.os): In function `__bzero_chk':
(.text+0x5): undefined reference to `__GI___chk_fail'
/usr/bin/ld: libc/libc_so.a(bzero.os): relocation R_X86_64_PC32 against undefined symbol `__GI___chk_fail' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status
make: *** [lib/libc.so] Error 1

However, this works:

nenolod@neon:~/build/uClibc$ gcc -Wl,-EL -shared -Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc -Wl,-z,relro -Wl,-z,now -Wl,-z,defs -Wl,-s   -Wl,-init,__uClibc_init -Wl,-soname=libc.so.0 -nostdlib -o lib/libuClibc-0.9.32-git.so  -Wl,--whole-archive -Wl,--no-whole-archive ./lib/interp.os ./lib/ld64-uClibc.so.0 ./lib/uclibc_nonshared.a /usr/lib/gcc/x86_64-linux-gnu/4.3.2/libgcc.a ./lib/libc.a

I'm pretty sure that command is wrong, however.
Comment 1 William Pitcock 2010-10-20 14:58:35 UTC
Created attachment 2617 [details]
entirely lame method of fixing this bug
Comment 2 William Pitcock 2010-10-20 14:59:03 UTC
Created attachment 2623 [details]
same method applied to libpthread...
Comment 3 Carmelo Amoroso 2011-02-01 10:55:13 UTC
Hi William,
both patches look fine, but I'm wondering if it should be better to add the alias using libc_hidden_proto / libc_hidden_def.

Currently on uClibc only x86_64 has the _chk version of string functions, but in the future it could be extended to other arch as well.
Comment 4 William Pitcock 2011-02-11 19:02:21 UTC
hi carmelo!

i agree that the solution you propose is better.  unfortunately, we wanted to make x86_64 a release goal for alpine and getting that going early on in the development process was a goal of mine, so i just took the hacktastic way of doing it and got out my sledgehammer.

if you want, i'll take a look at creating a patch that does it this way this weekend.
Comment 5 William Pitcock 2011-03-08 08:24:26 UTC
Created attachment 3127 [details]
use libc_hidden_proto / libc_hidden_def

following patch uses libc_hidden_proto and is a git format signed-off patch that can just be git am'd.

i'll also send this to the list by hand.
Comment 6 William Pitcock 2011-03-08 08:25:51 UTC
Created attachment 3133 [details]
same for nptl

this patch makes nptl match the behaviour as seen on sh, using the GETOFF macro.

nptl is working with this patch on x86_64 by the way.
Comment 7 Carmelo Amoroso 2011-03-09 08:35:35 UTC
Thanks William,
I'll manage to include them.
Comment 8 Sérgio 2011-03-24 00:13:05 UTC
Just FYI.
I got this error with libuClibc-0.9.31, when I use as target x86_64, generic or core2. 
I back to libuClibc-0.9.30.
Comment 9 Sérgio 2011-03-28 18:03:34 UTC
(In reply to comment #8)
> Just FYI.
> I got this error with libuClibc-0.9.31, when I use as target x86_64, generic or
> core2. 

Hi, seems this is fixed on 0.9.32-rc3.
Comment 10 Sérgio 2011-03-28 20:16:07 UTC
Sorry I made a little confusion. 
I hit this problem using builroot-2011.02, and as I had report, with buildroot git version and toolchain with uClibc0.9.32-rc3 this bug is fixed.

thanks,