[PATCH] D47098: [ELF] Make R_GOTONLY_PC_FROM_END R_GOTREL_FROM_END relative to _GLOBAL_OFFSET_TABLE_ instead of end of .got

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 26 10:45:54 PDT 2018


MaskRay added inline comments.


================
Comment at: test/ELF/got-i386.s:41
-// 0x1200A - 10 = addr(.got) = 0x12000
-// 0x1200A + 5 - 15 = addr(.got) = 0x12000
 // DISASM:      Disassembly of section .text:
----------------
grimar wrote:
> You should update these calculations and keep them instead of dropping.
I kept `// 0x13000 (bar) - 0x12000 (_GLOBAL_OFFSET_TABLE_) = 4096`.


================
Comment at: test/ELF/relocation-i686.s:3
 // RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/shared.s -o %t2.o
-// RUN: ld.lld -shared %t2.o -o %t2.so
+// RUN: ld.lld -shared %t2.o -soname t2.so -o %t2.so
 // RUN: ld.lld --hash-style=sysv %t %t2.so -o %t2
----------------
grimar wrote:
> Why you had to do that?
In case the pathname of %t2.o is too long in some environment and makes `DT_NEEDED` of `%t2` longer and changes addresses of other fields.


================
Comment at: test/ELF/x86-64-reloc-shared.s:17
+R_X86_64_GOTPC64:
+  movabsq $_GLOBAL_OFFSET_TABLE_-., %r11
----------------
grimar wrote:
> What I see is that llvm-mc produce following relocations here for me:
> 
> ```
> 000000000003  000300000002 R_X86_64_PC32     0000000000000000 _GLOBAL_OFFSET_TABLE_ - 4
> 000000000009  00030000001d R_X86_64_GOTPC64  0000000000000000 _GLOBAL_OFFSET_TABLE_ + 2
> ```
> 
> So R_X86_64_GOTPC32 seems to be uncovered be this test.
`R_X86_64_GOTPC32` is a special case of `R_X86_64_PC32` where the symbol is `_GLOBAL_OFFSET_TABLE_`. GNU as emits `R_X86_64_GOTPC32` but llvm-mc emits `R_X86_64_PC32`. I have also tested GNU as 


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D47098





More information about the llvm-commits mailing list