[PATCH] D47098: [ELF] Make R_GOTONLY_PC_FROM_END R_GOTREL_FROM_END relative to _GLOBAL_OFFSET_TABLE_ instead of end of .got
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 29 15:26:51 PDT 2018
grimar added inline comments.
================
Comment at: test/ELF/i386-gotoff-shared.s:26
-// 0x1000 - (0x2050 + 4) = -4180
+// 0x1000 (bar) - 0x2000 (_GLOBAL_OFFSET_TABLE_) = -4096
----------------
I think there were too many different comments from me and probably them confused things, my apologies.
(It took some time to realize/refresh how it should work and how we can fix for me either.)
To summarize:
This new calculation is incorrect. Original was. The explanation is here:
https://reviews.llvm.org/D47098#1114071
The solution I am suggesting to implement R_X86_64_GOTPC32/R_X86_64_GOTPC64 is in the latest reply:
https://reviews.llvm.org/D47098#1114909
(the main point is that with that we will not need to change the code in getRelocTargetVA it seems)
================
Comment at: test/ELF/x86-64-reloc-shared.s:6
+
+// 0x2000 (_GLOBAL_OFFSET_TABLE_) - 0x1000 = 4096
+
----------------
The same. I believe it is incorrect because of the same reasons as for i386.
If you would not add code to InputSection.cpp, it would resolve to:
```
0000000000001000 <R_X86_64_GOTPC64>:
1000: 49 bb 70 20 00 00 00 mov $0x2070,%r11
```
0x1000 + 0x2070 = 0x3070 = address of .got end.
_GLOBAL_OFFSET_TABLE_ in symbol table has value of 0x2000, but it is should not be a real problem.
Why do you want to resolve it to .got.plt? Which code would use it and for what?
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D47098
More information about the llvm-commits
mailing list