[ELF][ARM] Fix /DISCARD/ of section with .ARM.exidx section
authorPeter Smith <peter.smith@linaro.org>
Tue, 6 Aug 2019 14:13:38 +0000 (14:13 +0000)
committerPeter Smith <peter.smith@linaro.org>
Tue, 6 Aug 2019 14:13:38 +0000 (14:13 +0000)
commit7f320d4bf074047080962b8eb4adf60663cb23e6
tree9cfff2c767e9d5c0dec08fe5cbd481dfdf033e91
parente49c417ed1847a3b8e7595ddb8212ea8d13df5df
[ELF][ARM] Fix /DISCARD/ of section with .ARM.exidx section

The combineEhSections runs, by design, before processSectionCommands so
that input exception sections like .ARM.exidx and .eh_frame are not assigned
to OutputSections. Unfortunately if /DISCARD/ removes InputSections that
have associated .ARM.exidx sections without discarding the .ARM.exidx
synthetic section then we will end up crashing when trying to sort the
InputSections in ascending address order.

We fix this by filtering out the sections that have been discarded prior
to processing the InputSections in finalizeContents().

fixes pr42890

Differential Revision: https://reviews.llvm.org/D65759

llvm-svn: 368041
lld/ELF/SyntheticSections.cpp
lld/test/ELF/arm-exidx-partial-discard.s [new file with mode: 0644]