summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputSection.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-05-28 14:34:28 +0000
committerFangrui Song <maskray@google.com>2019-05-28 14:34:28 +0000
commit5d3b3188f722456a6470c7effcacf17656406429 (patch)
treed1412ac4231c03430883ee92695b3be0c5c4d564 /lld/ELF/InputSection.cpp
parent49e432d030d804fada7452460d6871722799f682 (diff)
downloadbcm5719-llvm-5d3b3188f722456a6470c7effcacf17656406429.tar.gz
bcm5719-llvm-5d3b3188f722456a6470c7effcacf17656406429.zip
Reland D61583 [ELF] Error on relocations to STT_SECTION symbols if the sections were discarded
This is implemented by creating Undefined (instead of Defined) for such local STT_SECTION symbols. It allows us to catch errors when there are relocations to such discarded sections (e.g. in PR41693, ld.bfd and gold error but we don't). Updated comdat-discarded-error.s checks we emit friendly error message. For relocatable-eh-frame.s, ld.lld -r a.o a.o will now error "STT_SECTION symbol should be defined" because the section .eh_frame refers to is now an Undefined instead of a Defined. So I have to change `error()` to `warn()` to retain the output. rLLD361144 inadvertently enabled the error for --gdb-index (in LLDDwarfObj<ELFT>::findAux()). Relocations from .debug_info (not in comdat) to .text.* (in comdat) for DW_AT_low_pc are common. If an .text.* was discarded, rLLD361144 would error, which was unexpected. (Note, if we don't error as this patch does, InputSection::relocateNonAlloc() will resolve such relocations). llvm-svn: 361830
Diffstat (limited to 'lld/ELF/InputSection.cpp')
-rw-r--r--lld/ELF/InputSection.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 07a30ed57c4..74878931afb 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -438,7 +438,8 @@ void InputSection::copyRelocations(uint8_t *Buf, ArrayRef<RelTy> Rels) {
// hopefully creates a frame that is ignored at runtime.
auto *D = dyn_cast<Defined>(&Sym);
if (!D) {
- error("STT_SECTION symbol should be defined");
+ warn("STT_SECTION symbol should be defined");
+ P->setSymbolAndType(0, 0, false);
continue;
}
SectionBase *Section = D->Section->Repl;
OpenPOWER on IntegriCloud