forked from OSchip/llvm-project
Linker script: fix crash when discarding section
If section contains local symbols ldd crashes, because local symbols are added to symbol table before section is discarded by linker script processor. This patch calls copyLocalSymbols() after createSections, so discarded section symbols are not copied llvm-svn: 282244
This commit is contained in:
parent
c8ccd1f1c5
commit
d4dea164dd
|
@ -244,8 +244,6 @@ template <class ELFT> static std::vector<DefinedCommon *> getCommonSymbols() {
|
|||
|
||||
// The main function of the writer.
|
||||
template <class ELFT> void Writer<ELFT>::run() {
|
||||
if (Config->Discard != DiscardPolicy::All)
|
||||
copyLocalSymbols();
|
||||
addReservedSymbols();
|
||||
|
||||
if (Target->NeedsThunks)
|
||||
|
@ -262,6 +260,9 @@ template <class ELFT> void Writer<ELFT>::run() {
|
|||
Script<ELFT>::X->processCommands(Factory);
|
||||
}
|
||||
|
||||
if (Config->Discard != DiscardPolicy::All)
|
||||
copyLocalSymbols();
|
||||
|
||||
finalizeSections();
|
||||
if (HasError)
|
||||
return;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
||||
# RUN: echo "SECTIONS { /DISCARD/ : { *(.aaa*) } }" > %t.script
|
||||
# RUN: ld.lld -o %t1 --script %t.script %t
|
||||
# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
|
||||
# CHECK-NOT: .aaa
|
||||
|
||||
.section .aaa,"a"
|
||||
aaa:
|
||||
.quad 0
|
Loading…
Reference in New Issue