summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>2020-01-15 14:32:14 +0000
committerHans Wennborg <hans@chromium.org>2020-01-17 10:12:05 +0100
commitafbebff6cd7be7329bda4500dbfacfc94ff8edba (patch)
tree3fa540503c2f4e5ccdbc4de224cfb62a0552ceee
parentf06cd8c8c8e2adc5dad66a851bc1df1ecdd1b58e (diff)
downloadbcm5719-llvm-afbebff6cd7be7329bda4500dbfacfc94ff8edba.tar.gz
bcm5719-llvm-afbebff6cd7be7329bda4500dbfacfc94ff8edba.zip
[ELF] Avoid false-positive assert in getErrPlace()
This assertion was added as part of D70659 but did not account for .bss input sections. I noticed that this assert was incorrectly triggering while building FreeBSD for MIPS64. Fixed by relaxing the assert to also account for SHT_NOBITS input sections and adjust the test mips-jalr-non-function.s to link a file with a .bss section first. Reviewed By: MaskRay, grimar Differential Revision: https://reviews.llvm.org/D72567 (cherry picked from commit 441410be471d5d0a5d1d47cf363de155e397a0c2)
-rw-r--r--lld/ELF/Target.cpp2
-rw-r--r--lld/test/ELF/mips-jalr-non-functions.s7
2 files changed, 7 insertions, 2 deletions
diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp
index 70a68fd8db9..d3899d0f18f 100644
--- a/lld/ELF/Target.cpp
+++ b/lld/ELF/Target.cpp
@@ -95,7 +95,7 @@ template <class ELFT> static ErrorPlace getErrPlace(const uint8_t *loc) {
assert(loc != nullptr);
for (InputSectionBase *d : inputSections) {
auto *isec = cast<InputSection>(d);
- if (!isec->getParent())
+ if (!isec->getParent() || (isec->type & SHT_NOBITS))
continue;
const uint8_t *isecLoc =
diff --git a/lld/test/ELF/mips-jalr-non-functions.s b/lld/test/ELF/mips-jalr-non-functions.s
index cdb60cd39e8..70f899c48f6 100644
--- a/lld/test/ELF/mips-jalr-non-functions.s
+++ b/lld/test/ELF/mips-jalr-non-functions.s
@@ -6,7 +6,12 @@
## relocations to avoid generating binaries that crash when executed.
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t.o
-# RUN: ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s -check-prefix WARNING-MESSAGE
+## Link in another object file with a .bss as a regression test:
+## Previously LLD asserted when skipping over .bss sections when determining the
+## location for a warning/error message. By adding another file with a .bss
+## section before the actual %t.o we can reproduce this case.
+# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %S/Inputs/common.s -o %t-common.o
+# RUN: ld.lld -shared %t-common.o %t.o -o %t.so 2>&1 | FileCheck %s -check-prefix WARNING-MESSAGE
# RUN: llvm-objdump --no-show-raw-insn --no-leading-addr -d %t.so | FileCheck %s
.set noreorder
OpenPOWER on IntegriCloud