diff options
author | Reid Kleckner <rnk@google.com> | 2017-06-22 23:33:04 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-06-22 23:33:04 +0000 |
commit | 8456411e3bd4d50c807cc6b785cb49d344081dd3 (patch) | |
tree | c1ecb32d3acc0daf7999ea407b3be6433c87f2a8 /lld/COFF/Symbols.cpp | |
parent | d49711996f94cc73908d03d51938ffaaa40c3da9 (diff) | |
download | bcm5719-llvm-8456411e3bd4d50c807cc6b785cb49d344081dd3.tar.gz bcm5719-llvm-8456411e3bd4d50c807cc6b785cb49d344081dd3.zip |
[COFF] Fix SECTION and SECREL relocation handling for absolute symbols
Summary:
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.
Reviewers: ruiu
Subscribers: aprantl, llvm-commits
Differential Revision: https://reviews.llvm.org/D34541
llvm-svn: 306071
Diffstat (limited to 'lld/COFF/Symbols.cpp')
-rw-r--r-- | lld/COFF/Symbols.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lld/COFF/Symbols.cpp b/lld/COFF/Symbols.cpp index 5c185a511dd..1cf2934a355 100644 --- a/lld/COFF/Symbols.cpp +++ b/lld/COFF/Symbols.cpp @@ -61,6 +61,8 @@ COFFSymbolRef DefinedCOFF::getCOFFSymbol() { return COFFSymbolRef(reinterpret_cast<const coff_symbol32 *>(Sym)); } +uint16_t DefinedAbsolute::OutputSectionIndex = 0; + static Chunk *makeImportThunk(DefinedImportData *S, uint16_t Machine) { if (Machine == AMD64) return make<ImportThunkChunkX64>(S); |