[uclibc-ng-devel] problem with stack protection, threads and static binaries

Daniel Fahlgren daniel at fahlgren.se
Thu Sep 10 14:53:29 CEST 2015


I'm experiencing problems with uClibc-ng when creating static binaries
that uses threads. I originally reported this to the buildroot mailing
list but got redirected here instead.

The problem is when using a combination of stack protection, threads and
static binaries. The program will during start up get a sigsegv in
__pthread_initialize_minimal_internal(), and gdb says the instruction is

  mov    %fs:0x28,%rax

where %fs is 0x00. The reason for that is that the pthread library is
compiled with stack protection but __pthread_initialize_minimal_internal
is called before __libc_setup_tls in static binaries.

I have created an ugly patch to verify my hypothesis (attached). With
that patch the test program works, but what is the proper way to solve
this issue?

With uClibc 0.9.33.x the same thing happens. With glibc the program

Best regards,
Daniel Fahlgren
-------------- next part --------------
A non-text attachment was scrubbed...
Name: static-pthread.patch
Type: text/x-patch
Size: 515 bytes
Desc: not available
URL: <http://mailman.uclibc-ng.org/pipermail/devel/attachments/20150910/3ca934ff/attachment.bin>

More information about the devel mailing list