[PATCH] D77630: [ELF] --warn-backrefs: don't warn if -u/--export-dynamic-symbol

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 7 11:23:20 PDT 2020


MaskRay updated this revision to Diff 255738.
MaskRay marked an inline comment as done.
MaskRay added a comment.

Add missing --warn-backrefs


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77630/new/

https://reviews.llvm.org/D77630

Files:
  lld/ELF/Driver.cpp
  lld/test/ELF/warn-backrefs.s


Index: lld/test/ELF/warn-backrefs.s
===================================================================
--- lld/test/ELF/warn-backrefs.s
+++ 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
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -1448,6 +1448,10 @@
   // 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();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77630.255738.patch
Type: text/x-patch
Size: 1113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200407/2d9ff9ff/attachment.bin>


More information about the llvm-commits mailing list