diff options
author | George Rimar <grimar@accesssoftek.com> | 2017-01-13 16:18:15 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2017-01-13 16:18:15 +0000 |
commit | 1e799942b37d04f30b73f6a9e792d551dadafeea (patch) | |
tree | e25b1ebf6eba76323c9f0685fc7dff6bde378734 | |
parent | 435aaeefe99c3ee93b4dc4061d1732fa0b14c317 (diff) | |
download | bcm5719-llvm-1e799942b37d04f30b73f6a9e792d551dadafeea.tar.gz bcm5719-llvm-1e799942b37d04f30b73f6a9e792d551dadafeea.zip |
[ELF] - Move the addition of synthetics from addPredefinedSections()
These were 3 last synthetics that were added in addPredefinedSections() instead
of createSyntheticSections(). Now it is possible to move addition to correct common place.
Also patch fixes testcase which discards .shstrtab, by restricting doing that.
Differential revision: https://reviews.llvm.org/D28561
llvm-svn: 291908
-rw-r--r-- | lld/ELF/Writer.cpp | 12 | ||||
-rw-r--r-- | lld/test/ELF/linkerscript/sections.s | 19 |
2 files changed, 12 insertions, 19 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index a14db206445..6ece57f8e4e 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -119,6 +119,8 @@ StringRef elf::getOutputSectionName(StringRef Name) { } template <class ELFT> void elf::reportDiscarded(InputSectionBase<ELFT> *IS) { + if (IS == In<ELFT>::ShStrTab) + error("discarding .shstrtab section is not allowed"); if (!Config->PrintGcSections) return; errs() << "removing unused section from '" << IS->Name << "' in file '" @@ -377,6 +379,12 @@ template <class ELFT> void Writer<ELFT>::createSyntheticSections() { In<ELFT>::EhFrameHdr = make<EhFrameHeader<ELFT>>(); Symtab<ELFT>::X->Sections.push_back(In<ELFT>::EhFrameHdr); } + + if (In<ELFT>::SymTab) + Symtab<ELFT>::X->Sections.push_back(In<ELFT>::SymTab); + Symtab<ELFT>::X->Sections.push_back(In<ELFT>::ShStrTab); + if (In<ELFT>::StrTab) + Symtab<ELFT>::X->Sections.push_back(In<ELFT>::StrTab); } template <class ELFT> @@ -1089,10 +1097,6 @@ template <class ELFT> void Writer<ELFT>::addPredefinedSections() { auto OS = dyn_cast_or_null<OutputSection<ELFT>>(findSection(".ARM.exidx")); if (OS && !OS->Sections.empty() && !Config->Relocatable) OS->addSection(make<ARMExidxSentinelSection<ELFT>>()); - - addInputSec(In<ELFT>::SymTab); - addInputSec(In<ELFT>::ShStrTab); - addInputSec(In<ELFT>::StrTab); } // The linker is expected to define SECNAME_start and SECNAME_end diff --git a/lld/test/ELF/linkerscript/sections.s b/lld/test/ELF/linkerscript/sections.s index 2cb9395e669..8e149728816 100644 --- a/lld/test/ELF/linkerscript/sections.s +++ b/lld/test/ELF/linkerscript/sections.s @@ -66,22 +66,11 @@ # SEC-SWAP-NAMES: 7 .shstrtab 0000003b {{[0-9a-f]*}} # SEC-SWAP-NAMES: 8 .strtab 00000008 {{[0-9a-f]*}} -# .shstrtab from the input object file is discarded. -# RUN: echo "SECTIONS { \ -# RUN: /DISCARD/ : { *(.shstrtab) } }" > %t.script -# RUN: ld.lld -o %t5 --script %t.script %t -# RUN: llvm-objdump -section-headers %t5 | \ +# Attemp to discard .shstrtab section. +# RUN: echo "SECTIONS { /DISCARD/ : { *(.shstrtab) } }" > %t.script +# RUN: not ld.lld -o %t5 --script %t.script %t 2>&1 | \ # RUN: FileCheck -check-prefix=SEC-DISCARD %s - -# Idx Name Size -# SEC-DISCARD: 1 .text 0000000e {{[0-9a-f]*}} TEXT DATA -# SEC-DISCARD: 2 .data 00000020 {{[0-9a-f]*}} DATA -# SEC-DISCARD: 3 other 00000003 {{[0-9a-f]*}} DATA -# SEC-DISCARD: 4 .bss 00000002 {{[0-9a-f]*}} BSS -# SEC-DISCARD: 5 .comment 00000008 {{[0-9a-f]*}} -# SEC-DISCARD: 6 .symtab 00000030 {{[0-9a-f]*}} -# SEC-DISCARD: 7 .shstrtab 0000003b {{[0-9a-f]*}} -# SEC-DISCARD: 8 .strtab 00000008 {{[0-9a-f]*}} +# SEC-DISCARD: discarding .shstrtab section is not allowed # Multiple SECTIONS command specifying additional input section descriptions # for the same output section description - input sections are merged into |