https://sourceware.org/bugzilla/show_bug.cgi?id=32131
Bug ID: 32131 Summary: Linker should always check TLS relocation Product: binutils Version: 2.44 (HEAD) Status: NEW Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: hjl.tools at gmail dot com Target Milestone: --- Target: i386, x86-64 [hjl@gnu-cfl-3 tls-3]$ vi tls-main1.c [hjl@gnu-cfl-3 tls-3]$ make gcc -B./ -m32 -O2 -g -mtls-dialect=gnu2 -c -o tls-main1.o tls-main1.c gcc -B./ -m32 -o x tls-main1.o tls-gd1.o tls-gd1.o: TLS transition from R_386_TLS_GD to R_386_TLS_IE_32 against `gd' at 0x12 in section `.text' failed ./ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status make: *** [Makefile:24: x] Error 1 [hjl@gnu-cfl-3 tls-3]$ make clean rm -f *.o foo* *.so [hjl@gnu-cfl-3 tls-3]$ ls ld Makefile tls-def1.c tls-gd1.S tls-main1.c y [hjl@gnu-cfl-3 tls-3]$ cat tls-gd1.S .text .p2align 4,,15 .globl get_gd .type get_gd, @function get_gd: pushl %ebx call __x86.get_pc_thunk.bx addl $_GLOBAL_OFFSET_TABLE_, %ebx subl $8, %esp movl gd@tlsgd(,%ebx,1), %eax call ___tls_get_addr@PLT addl $8, %esp popl %ebx ret .size get_gd, .-get_gd .section .text,"axG",@progbits,__x86.get_pc_thunk.bx,comdat,unique,1 .globl __x86.get_pc_thunk.bx .hidden __x86.get_pc_thunk.bx .type __x86.get_pc_thunk.bx, @function __x86.get_pc_thunk.bx: movl (%esp), %ebx ret .section .note.GNU-stack,"",@progbits [hjl@gnu-cfl-3 tls-3]$ cat tls-main1.c extern int * get_gd (void); __thread int gd = 4; int main () { return get_gd () == &gd ? 0 : 1; } [hjl@gnu-cfl-3 tls-3]$ make y gcc -B./ -m32 -O2 -g -c -o tls-main1.o tls-main1.c gcc -B./ -m32 -g -shared -o libtls-gd1.so tls-gd1.S gcc -B./ -m32 -o y tls-main1.o libtls-gd1.so -Wl,-R,. [hjl@gnu-cfl-3 tls-3]$ ./y Segmentation fault (core dumped) [hjl@gnu-cfl-3 tls-3]$ make x gcc -B./ -m32 -c -o tls-gd1.o tls-gd1.S gcc -B./ -m32 -o x tls-main1.o tls-gd1.o tls-gd1.o: TLS transition from R_386_TLS_GD to R_386_TLS_IE_32 against `gd' at 0x12 in section `.text' failed ./ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status make: *** [Makefile:24: x] Error 1 [hjl@gnu-cfl-3 tls-3]$ Linker should always issue an error for movl gd@tlsgd(,%ebx,1), %eax -- You are receiving this mail because: You are on the CC list for the bug.