[PATCH] D54145: [ELF] - Fix R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX when target is IFUNC.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 8 06:05:48 PST 2018


grimar added a comment.

In https://reviews.llvm.org/D54145#1288739, @peter.smith wrote:

> I've tested this out on X86, Arm and AArch64 and it works for X86 and Arm. Unfortunately, it doesn't seem to work with AArch64 yet. I don't see any R_AARCH64_IRELATIVE relocations.


I see the `R_AARCH64_IRELATIVE` for some reason. Am I doing something differently?

> I haven't found out why as yet. I'll do some digging to see if there is anything obvious that we are missing. If you have access to a X86 Linux box this is reproducible with a GCC aarch64-linux-gnu cross compilation toolchain and the linux user mode emulator qemu-aarch64.

It seems there is something different on AArch64 perhaps. If I take **user.cpp** and **library.cpp** files from description
and `clang version 8.0.0 (trunk 346310)` + `LLD 8.0.0 (trunk 345820)` (without this patch applied) I have:

  clang -target aarch64-linux-gnueabi user.cpp -c -o user.o
  clang -target aarch64-linux-gnueabi library.cpp -c -o library.o
  clang -target aarch64-linux-gnueabi user.o library.o -static -fuse-ld=lld -o out
  qemu-aarch64 -L /usr/aarch64-linux-gnu out
  qemu: uncaught target signal 11 (Segmentation fault) - core dumped
  Segmentation fault (core dumped) 

And output has `IRELATIVE`:

  readelf -r out -W
  
  Relocation section '.rela.plt' at offset 0x238 contains 1 entries:
      Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
  00000000002819f0  0000000000000408 R_AARCH64_IRELATIVE                       2201c8

If I use `gcc` (`gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.9`) 
to produce objects instead, a signal code is different, but the situation is about the same in general:

  aarch64-linux-gnu-gcc library.cpp -c -o library.o
  aarch64-linux-gnu-gcc user.cpp -c -o user.o
  ~/LLVM/build_lldb/bin/clang -target aarch64-linux-gnueabi user.o library.o -static -fuse-ld=lld -o out



   qemu-aarch64 -L /usr/aarch64-linux-gnu out
  �S����[����#qemu: uncaught target signal 6 (Aborted) - core dumped
  Aborted (core dumped)



  readelf -r out -W
  Relocation section '.rela.plt' at offset 0x238 contains 1 entries:
      Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
  00000000002819f0  0000000000000408 R_AARCH64_IRELATIVE                       2201bc

If I stop using LLD (so, use default `/usr/lib/gcc-cross/aarch64-linux-gnu/5.4.0/../../../../aarch64-linux-gnu/bin/ld -vGNU ld (GNU Binutils for Ubuntu) 2.28`)
it works fine.

So I am observing `R_AARCH64_IRELATIVE` is present in both cases, but it crashes even without this patch.

I would start tracking `AArch64` issue status separately probably and I think we can land this patch first.


https://reviews.llvm.org/D54145





More information about the llvm-commits mailing list