summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Writer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/Writer.cpp')
-rw-r--r--lld/ELF/Writer.cpp12
1 files changed, 8 insertions, 4 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
OpenPOWER on IntegriCloud