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.cpp43
1 files changed, 17 insertions, 26 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 7f8391080f6..ad3c68b608c 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -111,8 +111,8 @@ StringRef elf::getOutputSectionName(StringRef Name) {
}
for (StringRef V :
- {".text.", ".rodata.", ".data.rel.ro.", ".data.", ".bss.",
- ".init_array.", ".fini_array.", ".ctors.", ".dtors.", ".tbss.",
+ {".text.", ".rodata.", ".data.rel.ro.", ".data.", ".bss.rel.ro.",
+ ".bss.", ".init_array.", ".fini_array.", ".ctors.", ".dtors.", ".tbss.",
".gcc_except_table.", ".tdata.", ".ARM.exidx."}) {
StringRef Prefix = V.drop_back();
if (Name.startswith(V) || Name == Prefix)
@@ -327,11 +327,6 @@ template <class ELFT> void Writer<ELFT>::createSyntheticSections() {
auto Add = [](InputSectionBase *Sec) { InputSections.push_back(Sec); };
- // Create singleton output sections.
- Out::Bss = make<OutputSection>(".bss", SHT_NOBITS, SHF_ALLOC | SHF_WRITE);
- Out::BssRelRo =
- make<OutputSection>(".bss.rel.ro", SHT_NOBITS, SHF_ALLOC | SHF_WRITE);
-
In<ELFT>::DynStrTab = make<StringTableSection>(".dynstr", true);
In<ELFT>::Dynamic = make<DynamicSection<ELFT>>();
In<ELFT>::RelaDyn = make<RelocationSection<ELFT>>(
@@ -369,6 +364,11 @@ template <class ELFT> void Writer<ELFT>::createSyntheticSections() {
Add(Common);
}
+ In<ELFT>::Bss = make<BssSection>(".bss");
+ Add(In<ELFT>::Bss);
+ In<ELFT>::BssRelRo = make<BssSection>(".bss.rel.ro");
+ Add(In<ELFT>::BssRelRo);
+
// Add MIPS-specific sections.
bool HasDynSymTab =
!Symtab<ELFT>::X->getSharedFiles().empty() || Config->pic() ||
@@ -617,7 +617,7 @@ template <class ELFT> bool elf::isRelroSection(const OutputSection *Sec) {
return true;
if (In<ELFT>::Got && Sec == In<ELFT>::Got->OutSec)
return true;
- if (Sec == Out::BssRelRo)
+ if (Sec == In<ELFT>::BssRelRo->OutSec)
return true;
StringRef S = Sec->Name;
@@ -1163,14 +1163,15 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
// Dynamic section must be the last one in this list and dynamic
// symbol table section (DynSymTab) must be the first one.
- applySynthetic({In<ELFT>::DynSymTab, In<ELFT>::GnuHashTab, In<ELFT>::HashTab,
- In<ELFT>::SymTab, In<ELFT>::ShStrTab, In<ELFT>::StrTab,
- In<ELFT>::VerDef, In<ELFT>::DynStrTab, In<ELFT>::GdbIndex,
- In<ELFT>::Got, In<ELFT>::MipsGot, In<ELFT>::IgotPlt,
- In<ELFT>::GotPlt, In<ELFT>::RelaDyn, In<ELFT>::RelaIplt,
- In<ELFT>::RelaPlt, In<ELFT>::Plt, In<ELFT>::Iplt,
- In<ELFT>::Plt, In<ELFT>::EhFrameHdr, In<ELFT>::VerSym,
- In<ELFT>::VerNeed, In<ELFT>::Dynamic},
+ applySynthetic({In<ELFT>::DynSymTab, In<ELFT>::Bss, In<ELFT>::BssRelRo,
+ In<ELFT>::GnuHashTab, In<ELFT>::HashTab, In<ELFT>::SymTab,
+ In<ELFT>::ShStrTab, In<ELFT>::StrTab, In<ELFT>::VerDef,
+ In<ELFT>::DynStrTab, In<ELFT>::GdbIndex, In<ELFT>::Got,
+ In<ELFT>::MipsGot, In<ELFT>::IgotPlt, In<ELFT>::GotPlt,
+ In<ELFT>::RelaDyn, In<ELFT>::RelaIplt, In<ELFT>::RelaPlt,
+ In<ELFT>::Plt, In<ELFT>::Iplt, In<ELFT>::Plt,
+ In<ELFT>::EhFrameHdr, In<ELFT>::VerSym, In<ELFT>::VerNeed,
+ In<ELFT>::Dynamic},
[](SyntheticSection *SS) { SS->finalizeContents(); });
// Some architectures use small displacements for jump instructions.
@@ -1199,16 +1200,6 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
}
template <class ELFT> void Writer<ELFT>::addPredefinedSections() {
- // Add BSS sections.
- auto Add = [=](OutputSection *Sec) {
- if (!Sec->Sections.empty()) {
- Sec->assignOffsets();
- OutputSections.push_back(Sec);
- }
- };
- Add(Out::Bss);
- Add(Out::BssRelRo);
-
// ARM ABI requires .ARM.exidx to be terminated by some piece of data.
// We have the terminater synthetic section class. Add that at the end.
auto *OS = dyn_cast_or_null<OutputSection>(findSection(".ARM.exidx"));
OpenPOWER on IntegriCloud