[lld] a27a7b9 - [ELF] --warn-backrefs: don't warn if -u/--export-dynamic-symbol
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 09:34:48 PDT 2020
Author: Fangrui Song
Date: 2020-04-08T09:33:22-07:00
New Revision: a27a7b98cd19975e6f2c2e24e4abc1c3a213b15e
URL: https://github.com/llvm/llvm-project/commit/a27a7b98cd19975e6f2c2e24e4abc1c3a213b15e
DIFF: https://github.com/llvm/llvm-project/commit/a27a7b98cd19975e6f2c2e24e4abc1c3a213b15e.diff
LOG: [ELF] --warn-backrefs: don't warn if -u/--export-dynamic-symbol
Reviewed By: grimar
Differential Revision: https://reviews.llvm.org/D77630
Added:
Modified:
lld/ELF/Driver.cpp
lld/test/ELF/warn-backrefs.s
Removed:
################################################################################
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index c90ac589d2d1..2aeeb84f5af9 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1448,6 +1448,10 @@ static void handleUndefined(Symbol *sym) {
// eliminate it. Mark the symbol as "used" to prevent it.
sym->isUsedInRegularObj = true;
+ // GNU linkers allow -u foo -ldef -lref. We should not treat it as a backward
+ // reference.
+ backwardReferences.erase(sym);
+
if (sym->isLazy())
sym->fetch();
}
diff --git a/lld/test/ELF/warn-backrefs.s b/lld/test/ELF/warn-backrefs.s
index 3d6bcb933100..5dec458232ee 100644
--- a/lld/test/ELF/warn-backrefs.s
+++ b/lld/test/ELF/warn-backrefs.s
@@ -62,6 +62,12 @@
## --warn-backrefs does not warn.
# RUN: ld.lld --fatal-warnings --warn-backrefs %t2.a %t1.o %t2.so %t2.a -o /dev/null
+## In GNU linkers, -u does not make a backward reference.
+# RUN: ld.lld --fatal-warnings --warn-backrefs -u foo %t2.a %t1.o -o /dev/null
+
+## In GNU gold, --export-dynamic-symbol does not make a backward reference.
+# RUN: ld.lld --fatal-warnings --warn-backrefs --export-dynamic-symbol foo %t2.a %t1.o -o /dev/null
+
.globl _start, foo
_start:
call foo
More information about the llvm-commits
mailing list