mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 20:23:39 +08:00
[ELF] - Recommit "[ELF] - Make Bss and BssRelRo sections to be synthetic (#3)."
Was fixed, details on review page. Original commit message: That removes CopyRelSection class completely, making Bss/BssRelRo to be just regular synthetics. This is splitted from D30541 and polished. Difference from D30541 that all logic of SharedSymbol converting to DefinedRegular was removed for now and probably will be posted as separate patch. Differential revision: https://reviews.llvm.org/D30892 llvm-svn: 298062
This commit is contained in:
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user