[ELF] Change duplicate symbol errors to use errorOrWarn
so that --noinhibit-exec downgrades the error to a warning, which
matches GNU ld. Most recoverable errors should use errorOrWarn.
GitOrigin-RevId: acdba090f2724335cf6cf6ecbfb68f67f0cd2def
diff --git a/ELF/Symbols.cpp b/ELF/Symbols.cpp
index cd2b9e2..93653de 100644
--- a/ELF/Symbols.cpp
+++ b/ELF/Symbols.cpp
@@ -539,8 +539,8 @@
if (!d->section && !errSec && errOffset && d->value == errOffset)
return;
if (!d->section || !errSec) {
- error("duplicate symbol: " + toString(sym) + "\n>>> defined in " +
- toString(sym.file) + "\n>>> defined in " + toString(newFile));
+ errorOrWarn("duplicate symbol: " + toString(sym) + "\n>>> defined in " +
+ toString(sym.file) + "\n>>> defined in " + toString(newFile));
return;
}
@@ -564,7 +564,7 @@
if (!src2.empty())
msg += src2 + "\n>>> ";
msg += obj2;
- error(msg);
+ errorOrWarn(msg);
}
void Symbol::checkDuplicate(const Defined &other) const {
diff --git a/test/ELF/allow-multiple-definition.s b/test/ELF/allow-multiple-definition.s
index 492784a..96fa262 100644
--- a/test/ELF/allow-multiple-definition.s
+++ b/test/ELF/allow-multiple-definition.s
@@ -9,6 +9,9 @@
# RUN: llvm-objdump --no-print-imm-hex -d %t3 | FileCheck %s
# RUN: llvm-objdump --no-print-imm-hex -d %t4 | FileCheck --check-prefix=REVERT %s
+# RUN: ld.lld --noinhibit-exec %t2 %t1 -o /dev/null 2>&1 | FileCheck %s --check-prefix=WARN
+# WARN: warning: duplicate symbol: _bar
+
# RUN: ld.lld -z muldefs --fatal-warnings %t1 %t2 -o %t3
# RUN: ld.lld -z muldefs --fatal-warnings %t2 %t1 -o %t4
# RUN: llvm-objdump --no-print-imm-hex -d %t3 | FileCheck %s