Skip to content

Commit

Permalink
[ELF] --warn-backrefs: don't warn if -u/--export-dynamic-symbol
Browse files Browse the repository at this point in the history
Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D77630
  • Loading branch information
MaskRay committed Apr 8, 2020
1 parent 4007e5f commit a27a7b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lld/ELF/Driver.cpp
Expand Up @@ -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();
}
Expand Down
6 changes: 6 additions & 0 deletions lld/test/ELF/warn-backrefs.s
Expand Up @@ -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

0 comments on commit a27a7b9

Please sign in to comment.