[PATCH] D71679: [LLD] [COFF] Fix reporting duplicate errors for absolute symbols
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 19 02:15:49 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG29d8c27c6528: [LLD] [COFF] Fix reporting duplicate errors for absolute symbols (authored by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71679/new/
https://reviews.llvm.org/D71679
Files:
lld/COFF/SymbolTable.cpp
lld/test/COFF/duplicate-absolute.s
Index: lld/test/COFF/duplicate-absolute.s
===================================================================
--- /dev/null
+++ lld/test/COFF/duplicate-absolute.s
@@ -0,0 +1,14 @@
+// REQUIRES: x86
+// RUN: llvm-mc -triple x86_64-windows-msvc -filetype obj -o %t.obj %s
+// RUN: echo -e ".globl myabsolute\nmyabsolute = 0" > %t.dupl.s
+// RUN: llvm-mc -triple x86_64-windows-msvc -filetype obj -o %t.dupl.obj %t.dupl.s
+// RUN: not lld-link /out:%t.exe %t.obj %t.dupl.obj 2>&1 | FileCheck %s
+
+// CHECK: error: duplicate symbol: myabsolute
+
+.globl myabsolute
+myabsolute = 0
+
+.globl entry
+entry:
+ ret
Index: lld/COFF/SymbolTable.cpp
===================================================================
--- lld/COFF/SymbolTable.cpp
+++ lld/COFF/SymbolTable.cpp
@@ -545,6 +545,8 @@
static std::string getSourceLocation(InputFile *file, SectionChunk *sc,
uint32_t offset, StringRef name) {
+ if (!file)
+ return "";
if (auto *o = dyn_cast<ObjFile>(file))
return getSourceLocationObj(o, sc, offset, name);
if (auto *b = dyn_cast<BitcodeFile>(file))
@@ -566,7 +568,7 @@
llvm::raw_string_ostream os(msg);
os << "duplicate symbol: " << toString(*existing);
- DefinedRegular *d = cast<DefinedRegular>(existing);
+ DefinedRegular *d = dyn_cast<DefinedRegular>(existing);
if (d && isa<ObjFile>(d->getFile())) {
os << getSourceLocation(d->getFile(), d->getChunk(), d->getValue(),
existing->getName());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71679.234681.patch
Type: text/x-patch
Size: 1503 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191219/3197c77b/attachment.bin>
More information about the llvm-commits
mailing list