[PATCH] COFF: Symbol resolution for common and comdat symbols defined in bitcode.

Peter Collingbourne peter at pcc.me.uk
Mon Jun 8 16:45:38 PDT 2015


Hi ruiu,

In the case where either a bitcode file and a regular file or two bitcode
files export a common or comdat symbol with the same name, the linker needs
to pick one of them following COFF semantics. This patch implements a design
for resolving such symbols that pushes most of the work onto either LLD's
regular mechanism for resolving common or comdat symbols or the IR linker's
mechanism for doing the same.

We modify SymbolBody::compare to always prefer non-bitcode symbols, so that
during the initial phase of symbol resolution, the symbol table always contains
a regular symbol in any case where we need to choose between a regular and
a bitcode symbol. In SymbolTable::addCombinedLTOObject, we force export
any bitcode symbols that were initially pre-empted by a regular symbol,
and later use SymbolBody::compare to choose between the regular symbol in
the symbol table and the regular symbol from the combined LTO object file.

This design seems to be sound, so long as the resolution mechanism is defined
to be commutative and associative modulo arbitrary choices between symbols
(which seems to be the case for COFF).

http://reviews.llvm.org/D10329

Files:
  COFF/InputFiles.cpp
  COFF/SymbolTable.cpp
  COFF/Symbols.cpp
  COFF/Symbols.h
  test/COFF/Inputs/lto-comdat1.ll
  test/COFF/Inputs/lto-comdat2.ll
  test/COFF/lto-comdat.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10329.27349.patch
Type: text/x-patch
Size: 10184 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150608/a27886ad/attachment.bin>


More information about the llvm-commits mailing list