[PATCH] D32887: [ELF] Emit __ehdr_start when there is a segment containing program headers

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 4 17:36:05 PDT 2017


phosek created this revision.

The current logic for defining __ehdr_start doesn't match the GNU linkers, whereas LLD does not define __ehdr_start whenever a linker script is being used, while GNU linkers defined the symbol whenever there's a loadable segment which contains ELF headers. This change modifies LLD to use the same logic as GNU linkers.

This is complicated by the fact that LLD checks undefined symbols while scanning relocations, which happens before binary layout is finalized and program headers have been created. To handle this, we define the __ehdr_start symbol unconditionally, and only check whether it should have been defined after program headers have been created; if not and there are references to this symbol, we report an error.

Fixes https://bugs.llvm.org/show_bug.cgi?id=32367


Repository:
  rL LLVM

https://reviews.llvm.org/D32887

Files:
  ELF/Relocations.cpp
  ELF/Relocations.h
  ELF/Symbols.cpp
  ELF/Symbols.h
  ELF/Writer.cpp
  test/ELF/linkerscript/ehdr_start.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32887.97893.patch
Type: text/x-patch
Size: 5004 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170505/4d0c2734/attachment.bin>


More information about the llvm-commits mailing list