[PATCH] D34541: [COFF] Fix SECTION and SECREL relocation handling for absolute symbols

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 22 16:21:00 PDT 2017


rnk created this revision.
Herald added a subscriber: aprantl.

For SECTION relocations against absolute symbols, MSVC emits the largest
output section index plus one. I've implemented that by threading a
global variable through DefinedAbsolute that is filled in by the Writer.
A more library-oriented approach would be to thread the Writer through
Chunk::writeTo and SectionChunk::applyRel*, but Rui seems to prefer
doing it this way.

MSVC rejects SECREL relocations against absolute symbols, but only when
the relocation is in a real output section. When the relocation is in a
CodeView debug info section destined for the PDB, it seems that this
relocation error is suppressed, and absolute symbols become zeros in the
object file. This is easily implemented by checking the input section
from which we're applying relocations.

This should fix errors about __safe_se_handler_table and
__guard_fids_table when linking the CRT and generating a PDB.


https://reviews.llvm.org/D34541

Files:
  lld/COFF/Chunks.cpp
  lld/COFF/Symbols.cpp
  lld/COFF/Symbols.h
  lld/COFF/Writer.cpp
  lld/test/COFF/pdb-secrel-absolute.yaml
  lld/test/COFF/secidx-absolute.s
  lld/test/COFF/secrel-absolute.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34541.103660.patch
Type: text/x-patch
Size: 9137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170622/2207e6e0/attachment.bin>


More information about the llvm-commits mailing list