summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Leviant <eleviant@accesssoftek.com>2017-03-14 08:33:45 +0000
committerEugene Leviant <eleviant@accesssoftek.com>2017-03-14 08:33:45 +0000
commit29685479972e71c1ff3442dbb11aed91186355bc (patch)
tree8c8492428c77adb3fcfe5b5694c12e1576fa94ac
parentd614b3e6bd729184c33e7bcfb868589e2b7f7df8 (diff)
downloadbcm5719-llvm-29685479972e71c1ff3442dbb11aed91186355bc.tar.gz
bcm5719-llvm-29685479972e71c1ff3442dbb11aed91186355bc.zip
[ELF] Fix error reporting for synthetic sections
Synthetic sections don't belong to any input file, but still they are input sections. Whenever problem occurs with relocations in these sections lld crashes in error reporting, trying to print input file name. Differential revision: https://reviews.llvm.org/D30889 llvm-svn: 297711
-rw-r--r--lld/ELF/InputSection.cpp5
-rw-r--r--lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s27
2 files changed, 32 insertions, 0 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index eba84fd9bc4..79a04fc3441 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -172,6 +172,11 @@ InputSectionBase *InputSectionBase::getLinkOrderDep() const {
// Returns a source location string. Used to construct an error message.
template <class ELFT>
std::string InputSectionBase::getLocation(uint64_t Offset) {
+ // We don't have file for synthetic sections.
+ if (getFile<ELFT>() == nullptr)
+ return (Config->OutputFile + ":(" + Name + "+0x" + utohexstr(Offset) + ")")
+ .str();
+
// First check if we can get desired values from debugging information.
std::string LineInfo = getFile<ELFT>()->getLineInfo(this, Offset);
if (!LineInfo.empty())
diff --git a/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s b/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s
new file mode 100644
index 00000000000..54c0cc74d39
--- /dev/null
+++ b/lld/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s
@@ -0,0 +1,27 @@
+## Check that error is correctly reported when .eh_frame reloc
+## is out of range
+
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "PHDRS { eh PT_LOAD; text PT_LOAD; } \
+# RUN: SECTIONS { . = 0x10000; \
+# RUN: .eh_frame_hdr : { *(.eh_frame_hdr*) } : eh \
+# RUN: .eh_frame : { *(.eh_frame) } : eh \
+# RUN: . = 0xF00000000; \
+# RUN: .text : { *(.text*) } : text \
+# RUN: }" > %t.script
+# RUN: not ld.lld %t.o -T %t.script -o %t 2>&1 | FileCheck %s
+
+# CHECK: error: {{.*}}:(.eh_frame+0x20): relocation R_X86_64_PC32 out of range
+
+ .text
+ .globl _start
+_start:
+ .cfi_startproc
+ .cfi_lsda 0, _ex
+ nop
+ .cfi_endproc
+
+ .data
+_ex:
+ .word 0
OpenPOWER on IntegriCloud