[PATCH] D93367: [ELF] --emit-relocs: fix a crash if .rela.dyn is an empty output section
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 16 01:36:01 PST 2020
grimar added inline comments.
================
Comment at: lld/ELF/OutputSections.cpp:406
// all InputSections in the OutputSection have the same dependency.
if (auto *ex = dyn_cast<ARMExidxSyntheticSection>(first))
link = ex->getLinkOrderDep()->getParent()->sectionIndex;
----------------
MaskRay wrote:
> grimar wrote:
> > I wonder if the same crash can happen here with an empty `.ARM.exidx`?
> It can't (I believe `flags & SHF_LINK_ORDER` ensures there is at least one input section but it is very late for me and I don't think carefully though:( )
>
> There are many `arm-exidx-*` tests and someone may need to check whether this is missing test coverage.
`SHF_LINK_ORDER` case seems is fine. We don't keep any special flags for empty output
sections:
```
// We do not want to keep any special flags for output section
// in case it is empty.
bool isEmpty = (getFirstInputSection(sec) == nullptr);
if (isEmpty)
sec->flags = flags & ((sec->nonAlloc ? 0 : (uint64_t)SHF_ALLOC) |
SHF_WRITE | SHF_EXECINSTR);
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93367/new/
https://reviews.llvm.org/D93367
More information about the llvm-commits
mailing list