[LLD] [COFF] Try to report source locations for duplicate symbols
authorMartin Storsjo <martin@martin.st>
Fri, 18 Oct 2019 10:43:15 +0000 (10:43 +0000)
committerMartin Storsjo <martin@martin.st>
Fri, 18 Oct 2019 10:43:15 +0000 (10:43 +0000)
commitb38f577c015c210605c2e463e9ac6a03249225a2
treeafef882288eb3fc9add890f129b199a6b82b0e40
parent651f07908a149b8eb861a1b109f98eeb3d4f1517
[LLD] [COFF] Try to report source locations for duplicate symbols

This fixes the second part of PR42407.

For files with dwarf debug info, it manually loads and iterates
.debug_info to find the declared location of variables, to allow
reporting them. (This matches the corresponding code in the ELF
linker.)

For functions, it uses the existing getFileLineDwarf which uses
LLVMSymbolizer for translating addresses to file lines.

In object files with codeview debug info, only the source location
of duplicate functions is printed. (And even there, only for the
first input file. The getFileLineCodeView function requires the
object file to be fully loaded and initialized to properly resolve
source locations, but duplicate symbols are reported at a stage when
the second object file isn't fully loaded yet.)

Differential Revision: https://reviews.llvm.org/D68975

llvm-svn: 375218
lld/COFF/InputFiles.cpp
lld/COFF/InputFiles.h
lld/COFF/SymbolTable.cpp
lld/COFF/SymbolTable.h
lld/test/COFF/conflict-mangled.test
lld/test/COFF/conflict.test
lld/test/COFF/duplicate-cv.s [new file with mode: 0644]
lld/test/COFF/duplicate-dwarf.s [new file with mode: 0644]
lld/test/COFF/duplicate.test