Skip to content

Commit 78ce19b

Browse files
committed
[LLD] [COFF] Fix post-commit suggestions for absolute symbol equality
Differential Revision: https://reviews.llvm.org/D72252
1 parent 1e25109 commit 78ce19b

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

lld/COFF/SymbolTable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ Symbol *SymbolTable::addAbsolute(StringRef n, COFFSymbolRef sym) {
592592
if (wasInserted || isa<Undefined>(s) || s->isLazy())
593593
replaceSymbol<DefinedAbsolute>(s, n, sym);
594594
else if (auto *da = dyn_cast<DefinedAbsolute>(s)) {
595-
if (!da->isEqual(sym))
595+
if (da->getVA() != sym.getValue())
596596
reportDuplicate(s, nullptr);
597597
} else if (!isa<DefinedCOFF>(s))
598598
reportDuplicate(s, nullptr);
@@ -607,7 +607,7 @@ Symbol *SymbolTable::addAbsolute(StringRef n, uint64_t va) {
607607
if (wasInserted || isa<Undefined>(s) || s->isLazy())
608608
replaceSymbol<DefinedAbsolute>(s, n, va);
609609
else if (auto *da = dyn_cast<DefinedAbsolute>(s)) {
610-
if (!da->isEqual(va))
610+
if (da->getVA() != va)
611611
reportDuplicate(s, nullptr);
612612
} else if (!isa<DefinedCOFF>(s))
613613
reportDuplicate(s, nullptr);

lld/COFF/Symbols.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,7 @@ class DefinedAbsolute : public Defined {
228228

229229
uint64_t getRVA() { return va - config->imageBase; }
230230
void setVA(uint64_t v) { va = v; }
231-
232-
bool isEqual(COFFSymbolRef s) const {
233-
return va == s.getValue();
234-
}
235-
236-
bool isEqual(uint64_t otherVa) const {
237-
return va == otherVa;
238-
}
231+
uint64_t getVA() const { return va; }
239232

240233
// Section index relocations against absolute symbols resolve to
241234
// this 16 bit number, and it is the largest valid section index

lld/test/COFF/duplicate-absolute-same.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// RUN: llvm-mc -triple x86_64-windows-msvc -filetype obj -o %t.obj %s
33
// RUN: echo -e ".globl myabsolute\nmyabsolute = 0" > %t.dupl.s
44
// RUN: llvm-mc -triple x86_64-windows-msvc -filetype obj -o %t.dupl.obj %t.dupl.s
5-
// RUN: lld-link /out:%t.exe %t.obj %t.dupl.obj -subsystem:console -entry:entry 2>&1 | FileCheck --allow-empty %s
5+
// RUN: lld-link /out:%t.exe %t.obj %t.dupl.obj -subsystem:console -entry:entry 2>&1 | count 0
66

7-
// CHECK-NOT: error: duplicate symbol: myabsolute
7+
// This shouldn't produce any duplicate symbol error.
88

99
.globl myabsolute
1010
myabsolute = 0

0 commit comments

Comments
 (0)