summaryrefslogtreecommitdiff
path: root/libc/misc/internals/__uClibc_main.c
diff options
context:
space:
mode:
authorRoman I Khimov <khimov@altell.ru>2010-05-04 14:00:47 +0400
committerAustin Foxley <austinf@cetoncorp.com>2010-05-05 08:43:22 -0700
commit0b7acfa800444525498442032b47bfd7d066c72b (patch)
tree0a01157af61958014f0b0dc957d1dd5061df5d26 /libc/misc/internals/__uClibc_main.c
parentc1505e73d00ed26b7c250e331b213e63a948b1dd (diff)
ldso: fix x86_64 R_X86_64_TPOFF64 and R_X86_64_DTPOFF64 relocations
R_X86_64_TPOFF64 revealed by trivial testcase: =================================================================== #include <stdio.h> #include <errno.h> int main() { void *a = &errno; printf("errno addr: %llx\n", a); __asm__("movq errno@gottpoff(%%rip), %0;\n" "add %%fs:0x0,%0;" : "=r"(a) ); printf("got errno addr: %llx\n", a); return 0; } =================================================================== The addresses application got with R_X86_64_TPOFF64 was different than the once libc internal __errno_location returned. R_X86_64_DTPOFF64 testcase is even simpler than that: =================================================================== #include <stdio.h> #include <errno.h> #include <netdb.h> #undef h_errno extern __thread int h_errno; int main() { printf("h_errno addr: %llx\n", &h_errno); printf("__h_errno_location addr: %llx\n", __h_errno_location()); return 0; } =================================================================== but needs to be linked with "-lpthread". This way we've got h_errno relocation via R_X86_64_TPOFF64 in application and h_errno relocation via R_X86_64_DTPOFF64 in libpthread which has its own __h_errno_location() (probably we can kill it later?). And addresses were different again. The problem is that both relocations resolve symbols in external modules and thus should use symbol_addr instead of sym->st_value. Signed-off-by: Roman I Khimov <khimov@altell.ru> Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Diffstat (limited to 'libc/misc/internals/__uClibc_main.c')
0 files changed, 0 insertions, 0 deletions