[lld] r278093 - Separate {Preinit, Init, Fini}Arrays from Out<ELFT>::Dynamic.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 8 21:25:20 PDT 2016
Author: ruiu
Date: Mon Aug 8 23:25:20 2016
New Revision: 278093
URL: http://llvm.org/viewvc/llvm-project?rev=278093&view=rev
Log:
Separate {Preinit,Init,Fini}Arrays from Out<ELFT>::Dynamic.
Even if an output is not a dynamic object, the output may have
.{preinit,init,fini} sections. Therefore, managing these sections
as Out<ELFT>::Dynamic's members is not correct.
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=278093&r1=278092&r2=278093&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Mon Aug 8 23:25:20 2016
@@ -678,17 +678,17 @@ template <class ELFT> void DynamicSectio
if (Out<ELFT>::HashTab)
Add({DT_HASH, Out<ELFT>::HashTab});
- if (PreInitArraySec) {
- Add({DT_PREINIT_ARRAY, PreInitArraySec});
- Add({DT_PREINIT_ARRAYSZ, PreInitArraySec->getSize()});
+ if (Out<ELFT>::PreinitArray) {
+ Add({DT_PREINIT_ARRAY, Out<ELFT>::PreinitArray});
+ Add({DT_PREINIT_ARRAYSZ, Out<ELFT>::PreinitArray->getSize()});
}
- if (InitArraySec) {
- Add({DT_INIT_ARRAY, InitArraySec});
- Add({DT_INIT_ARRAYSZ, (uintX_t)InitArraySec->getSize()});
+ if (Out<ELFT>::InitArray) {
+ Add({DT_INIT_ARRAY, Out<ELFT>::InitArray});
+ Add({DT_INIT_ARRAYSZ, (uintX_t)Out<ELFT>::InitArray->getSize()});
}
- if (FiniArraySec) {
- Add({DT_FINI_ARRAY, FiniArraySec});
- Add({DT_FINI_ARRAYSZ, (uintX_t)FiniArraySec->getSize()});
+ if (Out<ELFT>::FiniArray) {
+ Add({DT_FINI_ARRAY, Out<ELFT>::FiniArray});
+ Add({DT_FINI_ARRAYSZ, (uintX_t)Out<ELFT>::FiniArray->getSize()});
}
if (SymbolBody *B = Symtab<ELFT>::X->find(Config->Init))
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=278093&r1=278092&r2=278093&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Mon Aug 8 23:25:20 2016
@@ -527,10 +527,6 @@ public:
explicit DynamicSection();
void finalize() override;
void writeTo(uint8_t *Buf) override;
-
- OutputSectionBase<ELFT> *PreInitArraySec = nullptr;
- OutputSectionBase<ELFT> *InitArraySec = nullptr;
- OutputSectionBase<ELFT> *FiniArraySec = nullptr;
};
template <class ELFT>
@@ -657,6 +653,10 @@ template <class ELFT> struct Out {
static Elf_Phdr *TlsPhdr;
static OutputSectionBase<ELFT> *ElfHeader;
static OutputSectionBase<ELFT> *ProgramHeaders;
+
+ static OutputSectionBase<ELFT> *PreinitArray;
+ static OutputSectionBase<ELFT> *InitArray;
+ static OutputSectionBase<ELFT> *FiniArray;
};
template <bool Is64Bits> struct SectionKey {
@@ -716,6 +716,9 @@ template <class ELFT> VersionNeedSection
template <class ELFT> typename ELFT::Phdr *Out<ELFT>::TlsPhdr;
template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ElfHeader;
template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::ProgramHeaders;
+template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::PreinitArray;
+template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::InitArray;
+template <class ELFT> OutputSectionBase<ELFT> *Out<ELFT>::FiniArray;
} // namespace elf
} // namespace lld
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=278093&r1=278092&r2=278093&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Aug 8 23:25:20 2016
@@ -211,6 +211,10 @@ template <class ELFT> void elf::writeRes
Out<ELFT>::ElfHeader = &ElfHeader;
Out<ELFT>::ProgramHeaders = &ProgramHeaders;
+ Out<ELFT>::PreinitArray = nullptr;
+ Out<ELFT>::InitArray = nullptr;
+ Out<ELFT>::FiniArray = nullptr;
+
Writer<ELFT>().run();
}
@@ -658,13 +662,13 @@ template <class ELFT> void Writer<ELFT>:
// Create output section objects and add them to OutputSections.
template <class ELFT> void Writer<ELFT>::finalizeSections() {
- Out<ELFT>::Dynamic->PreInitArraySec = findSection(".preinit_array");
- Out<ELFT>::Dynamic->InitArraySec = findSection(".init_array");
- Out<ELFT>::Dynamic->FiniArraySec = findSection(".fini_array");
+ Out<ELFT>::PreinitArray = findSection(".preinit_array");
+ Out<ELFT>::InitArray = findSection(".init_array");
+ Out<ELFT>::FiniArray = findSection(".fini_array");
// Sort section contents for __attribute__((init_priority(N)).
- sortInitFini(Out<ELFT>::Dynamic->InitArraySec);
- sortInitFini(Out<ELFT>::Dynamic->FiniArraySec);
+ sortInitFini(Out<ELFT>::InitArray);
+ sortInitFini(Out<ELFT>::FiniArray);
sortCtorsDtors(findSection(".ctors"));
sortCtorsDtors(findSection(".dtors"));
@@ -867,11 +871,9 @@ template <class ELFT> void Writer<ELFT>:
};
Define("__preinit_array_start", "__preinit_array_end",
- Out<ELFT>::Dynamic->PreInitArraySec);
- Define("__init_array_start", "__init_array_end",
- Out<ELFT>::Dynamic->InitArraySec);
- Define("__fini_array_start", "__fini_array_end",
- Out<ELFT>::Dynamic->FiniArraySec);
+ Out<ELFT>::PreinitArray);
+ Define("__init_array_start", "__init_array_end", Out<ELFT>::InitArray);
+ Define("__fini_array_start", "__fini_array_end", Out<ELFT>::FiniArray);
}
// If a section name is valid as a C identifier (which is rare because of
More information about the llvm-commits
mailing list