[PATCH] D16201: [ELF/AArch64] - Implemented set of R_AARCH64_TLSDESC_* relocations.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 26 05:22:23 PST 2016

grimar added a comment.

I found that I can run the next helloworld app fine with this:


  int method();
  int main(void) {
    return method();


  int puts(const char *);
  __thread int foo;
  int method() {
    puts("Hello, World");
    foo = 0;

/home/umb/LLVM/build/bin/clang -fuse-ld=lld  -target aarch64-linux-gnu -fPIC -shared shared.c -o shared.so
/home/umb/LLVM/build/bin/clang -fuse-ld=lld  -target aarch64-linux-gnu -fPIC main.c shared.so -o test
root at ubuntu:/home# ./test 
Hello, World

but if I switch lines:

  foo = 0;
  puts("Hello, World");

Then it crashes:

root at ubuntu:/home# ./test 
Inconsistency detected by ld.so: dl-runtime.c: 79: _dl_fixup: Assertion `((reloc->r_info) & 0xffffffff) == 1026' failed!
(source code of dynamic linker for that place: https://github.com/lattera/glibc/blob/master/elf/dl-runtime.c#L86)

My guess that it is because TLSDESC is placed not at the end in that case:
000000003020  000100000402 R_AARCH64_JUMP_SL 0000000000000000 __gmon_start__ + 0
000000003028  000e00000402 R_AARCH64_JUMP_SL 00000000000011b0 __cxa_finalize + 0
000000003030  000c00000407 R_AARCH64_TLSDESC 0000000000000000 foo + 0
000000003040  000500000402 R_AARCH64_JUMP_SL 0000000000000000 puts + 0

I think gold/bfd place it at the end and that is the root of problem of this patch. I am fixing it.
I think this is the first relocation we meet that requires placing after all JUMP_SLOTs ones.
I can remember that also IFunc relocations were placed to the end for dynamic case by gold, but
we did not implement dynamic case for IFunc`s.


More information about the llvm-commits mailing list