mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 01:07:04 +08:00
[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. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D61583 llvm-svn: 361792
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user