[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

git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@306071 91177308-0d34-0410-b5e6-96231b3b80d8
7 files changed
tree: d5e417258e1b089481907a5943378a5f6a35de2a
  1. cmake/
  2. COFF/
  3. docs/
  4. ELF/
  5. include/
  6. lib/
  7. test/
  8. tools/
  9. unittests/
  10. .arcconfig
  11. .clang-format
  12. .gitignore
  13. CMakeLists.txt
  14. CODE_OWNERS.TXT
  15. LICENSE.TXT
  16. README.md
README.md

LLVM Linker (lld)

This directory and its subdirectories contain source code for the LLVM Linker, a modular cross platform linker which is built as part of the LLVM compiler infrastructure project.

lld is open source software. You may freely distribute it under the terms of the license agreement found in LICENSE.txt.