[PATCH] D59559: [ELF] Make R_I386_GOTPC and R_X86_64_GOTPC32/64 resolve to .got.plt.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 19 20:14:06 PDT 2019


MaskRay added a comment.

I believe the patch in the current form will break some `_GLOBAL_OFFSET_TABLE_` use cases (see https://reviews.llvm.org/D48095) so I volunteer to be a reviewer :)

`_GLOBAL_OFFSET_TABLE_ : specifies the offset to the base of the GOT from the current code location.`

The issue has been discussed a lot in https://bugs.llvm.org/show_bug.cgi?id=36555 . Some aspects in that thread no longer apply nowadays. I believe the remaining issue is that we have `_GLOBAL_OFFSET_TABLE_ = end(.got)` (lld's generalized `R_*_FROM_END` relocation types require this) but `end(.got) != start(.got.plt)` (we don't have a section rank rule for this).

As I noted in https://reviews.llvm.org/D56828 , after that patch we can make `end(.got) = start(.got.plt)` if we want and thus address the issue this patch intends to address. AFAIK no user application needs that but some ld.so implementations may want to have this property.

- More specifically, it allows to get rid of one lld-compatibility patch to glibc https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commit;h=575707c22f901b0adcce2478cc32da62afff287e
- Another instance I ran into was that llvm-mc  emitted `R_X86_64_GOTPC32` instead of `R_X86_64_PC32` for `leaq _GLOBAL_OFFSET_TABLE(%rip), %r15`. I fixed that rule.

If people think that making `end(.got) = start(.got.plt)` is desirable I volunteer to do that, but it requires some more rules in `Writer.cpp:getSectionRank`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59559/new/

https://reviews.llvm.org/D59559





More information about the llvm-commits mailing list