[lld] d94526b - [ELF] --warn-backrefs: check that D79300 fixed an issue due to `mb = {}`
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 26 20:33:12 PDT 2020
Author: Fangrui Song
Date: 2020-06-26T20:31:47-07:00
New Revision: d94526bb5fa5a22645240aa5bee5a3163fa193a9
URL: https://github.com/llvm/llvm-project/commit/d94526bb5fa5a22645240aa5bee5a3163fa193a9
DIFF: https://github.com/llvm/llvm-project/commit/d94526bb5fa5a22645240aa5bee5a3163fa193a9.diff
LOG: [ELF] --warn-backrefs: check that D79300 fixed an issue due to `mb = {}`
D79300 forgot to change `getBuffer().empty()` in LazyObjFile::parse to
`fetched`. This caused incorrect iterating after the current LazyObjFile was
fetched. This issue is benign and can just cause loss of "undefined symbols"
and "backward reference" diagnostics.
Before D79300 `mb = {}` caused --warn-backrefs-exclude to be useless for
a fetched LazyObjFile.
Add two test cases.
Added:
Modified:
lld/ELF/InputFiles.cpp
lld/test/ELF/warn-backrefs.s
Removed:
################################################################################
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index b0bec7349eb8..e59bf626be50 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -1711,8 +1711,9 @@ template <class ELFT> void LazyObjFile::parse() {
continue;
sym->resolve(LazyObject{*this, sym->getName()});
- // MemoryBuffer is emptied if this file is instantiated as ObjFile.
- if (mb.getBuffer().empty())
+ // If fetched, stop iterating because this->symbols has been transferred
+ // to the instantiated ObjFile.
+ if (fetched)
return;
}
return;
diff --git a/lld/test/ELF/warn-backrefs.s b/lld/test/ELF/warn-backrefs.s
index 34d105d3036f..a1b186fc98b1 100644
--- a/lld/test/ELF/warn-backrefs.s
+++ b/lld/test/ELF/warn-backrefs.s
@@ -51,6 +51,12 @@
# OBJECT: warning: backward reference detected: foo in {{.*}}1.o refers to {{.*}}2.o
+## Back reference from an fetched --start-lib to a previous --start-lib.
+# RUN: ld.lld -m elf_x86_64 -u _start --warn-backrefs --start-lib %/t2.o --end-lib \
+# RUN: --start-lib %t1.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=OBJECT %s
+## --warn-backrefs-exclude=%/t2.o can be used for a fetched --start-lib.
+# RUN: ld.lld --fatal-warnings -m elf_x86_64 -u _start --warn-backrefs --warn-backrefs-exclude=%/t2.o --start-lib %/t2.o --end-lib --start-lib %t1.o --end-lib -o /dev/null
+
## Don't warn if the definition and the backward reference are in a group.
# RUN: echo '.globl bar; bar:' | llvm-mc -filetype=obj -triple=x86_64 - -o %t3.o
# RUN: echo '.globl foo; foo: call bar' | llvm-mc -filetype=obj -triple=x86_64 - -o %t4.o
More information about the llvm-commits
mailing list