[PATCH] D19844: ELF: Forbid all relative relocations to absolute symbols in PIC, except for weak undefined.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Mon May 2 17:37:54 PDT 2016


pcc created this revision.
pcc added reviewers: rafael, ruiu.
pcc added a subscriber: llvm-commits.

Weak undefined symbols resolve to the image base. This is a little strange,
but it allows us to link function calls to such symbols. Normally such a
call will be guarded with a comparison, which will load a zero from the GOT.

There's one example of such a function call in crti.o in Linux's CRT.

As part of this change, I also needed to make the synthetic start and end
symbols image base relative in the case where their sections were empty,
so that PC-relative references to those symbols would continue to work.

http://reviews.llvm.org/D19844

Files:
  ELF/OutputSections.cpp
  ELF/SymbolTable.cpp
  ELF/SymbolTable.h
  ELF/Symbols.cpp
  ELF/Symbols.h
  ELF/Writer.cpp
  test/ELF/relocation-relative-absolute.s
  test/ELF/relocation-relative-synthetic.s
  test/ELF/relocation-relative-weak.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19844.55926.patch
Type: text/x-patch
Size: 9852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160503/215454e6/attachment.bin>


More information about the llvm-commits mailing list