PltSection<ELFT> Plt;
RelocationSection<ELFT> RelaDyn(Config->Rela ? ".rela.dyn" : ".rel.dyn",
Config->ZCombreloc);
- StringTableSection<ELFT> DynStrTab(".dynstr", true);
StringTableSection<ELFT> ShStrTab(".shstrtab", false);
- SymbolTableSection<ELFT> DynSymTab(DynStrTab);
VersionTableSection<ELFT> VerSym;
VersionNeedSection<ELFT> VerNeed;
// Instantiate optional output sections if they are needed.
std::unique_ptr<InterpSection<ELFT>> Interp;
std::unique_ptr<BuildIdSection<ELFT>> BuildId;
+ std::unique_ptr<StringTableSection<ELFT>> DynStrTab;
+ std::unique_ptr<SymbolTableSection<ELFT>> DynSymTab;
std::unique_ptr<EhFrameHeader<ELFT>> EhFrameHdr;
std::unique_ptr<GnuHashTableSection<ELFT>> GnuHashTab;
std::unique_ptr<GotPltSection<ELFT>> GotPlt;
else if (Config->BuildId == BuildIdKind::Hexstring)
BuildId.reset(new BuildIdHexstring<ELFT>);
+ if (!Symtab<ELFT>::X->getSharedFiles().empty() || Config->Pic) {
+ DynStrTab.reset(new StringTableSection<ELFT>(".dynstr", true));
+ DynSymTab.reset(new SymbolTableSection<ELFT>(*DynStrTab));
+ }
+
if (Config->EhFrameHdr)
EhFrameHdr.reset(new EhFrameHeader<ELFT>);
Out<ELFT>::Bss = &Bss;
Out<ELFT>::BuildId = BuildId.get();
- Out<ELFT>::DynStrTab = &DynStrTab;
- Out<ELFT>::DynSymTab = &DynSymTab;
+ Out<ELFT>::DynStrTab = DynStrTab.get();
+ Out<ELFT>::DynSymTab = DynSymTab.get();
Out<ELFT>::Dynamic = &Dynamic;
Out<ELFT>::EhFrame = &EhFrame;
Out<ELFT>::EhFrameHdr = EhFrameHdr.get();
return false;
}
-template <class ELFT> bool elf::isOutputDynamic() {
- return !Symtab<ELFT>::X->getSharedFiles().empty() || Config->Pic;
-}
-
template <class ELFT> static bool isDiscarded(InputSectionBase<ELFT> *S) {
return !S || S == &InputSection<ELFT>::Discarded || !S->Live;
}
// need these symbols, since IRELATIVE relocs are resolved through GOT
// and PLT. For details, see http://www.airs.com/blog/archives/403.
template <class ELFT> void Writer<ELFT>::addRelIpltSymbols() {
- if (isOutputDynamic<ELFT>() || !Out<ELFT>::RelaPlt)
+ if (Out<ELFT>::DynSymTab || !Out<ELFT>::RelaPlt)
return;
StringRef S = Config->Rela ? "__rela_iplt_start" : "__rel_iplt_start";
addOptionalSynthetic(S, Out<ELFT>::RelaPlt, 0);
// static linking the linker is required to optimize away any references to
// __tls_get_addr, so it's not defined anywhere. Create a hidden definition
// to avoid the undefined symbol error.
- if (!isOutputDynamic<ELFT>())
+ if (!Out<ELFT>::DynSymTab)
Symtab<ELFT>::X->addIgnored("__tls_get_addr");
// If linker script do layout we do not need to create any standart symbols.
// It should be okay as no one seems to care about the type.
// Even the author of gold doesn't remember why gold behaves that way.
// https://sourceware.org/ml/binutils/2002-03/msg00360.html
- if (isOutputDynamic<ELFT>())
+ if (Out<ELFT>::DynSymTab)
Symtab<ELFT>::X->addSynthetic("_DYNAMIC", Out<ELFT>::Dynamic, 0);
// Define __rel[a]_iplt_{start,end} symbols if needed.
if (Out<ELFT>::SymTab)
Out<ELFT>::SymTab->addSymbol(Body);
- if (isOutputDynamic<ELFT>() && S->includeInDynsym()) {
+ if (Out<ELFT>::DynSymTab && S->includeInDynsym()) {
Out<ELFT>::DynSymTab->addSymbol(Body);
if (auto *SS = dyn_cast<SharedSymbol<ELFT>>(Body))
if (SS->file()->isNeeded())
// Finalizers fix each section's size.
// .dynsym is finalized early since that may fill up .gnu.hash.
- if (isOutputDynamic<ELFT>())
+ if (Out<ELFT>::DynSymTab)
Out<ELFT>::DynSymTab->finalize();
// Fill other section headers. The dynamic table is finalized
if (Sec != Out<ELFT>::DynStrTab && Sec != Out<ELFT>::Dynamic)
Sec->finalize();
- if (isOutputDynamic<ELFT>())
+ if (Out<ELFT>::DynSymTab)
Out<ELFT>::Dynamic->finalize();
// Now that all output offsets are fixed. Finalize mergeable sections
Add(Out<ELFT>::SymTab);
Add(Out<ELFT>::ShStrTab);
Add(Out<ELFT>::StrTab);
- if (isOutputDynamic<ELFT>()) {
+ if (Out<ELFT>::DynSymTab) {
Add(Out<ELFT>::DynSymTab);
bool HasVerNeed = Out<ELFT>::VerNeed->getNeedNum() != 0;
Ret.push_back(std::move(TlsHdr));
// Add an entry for .dynamic.
- if (isOutputDynamic<ELFT>()) {
+ if (Out<ELFT>::DynSymTab) {
Phdr &H = *AddHdr(PT_DYNAMIC, Out<ELFT>::Dynamic->getPhdrFlags());
H.add(Out<ELFT>::Dynamic);
}
template struct elf::PhdrEntry<ELF64LE>;
template struct elf::PhdrEntry<ELF64BE>;
-template bool elf::isOutputDynamic<ELF32LE>();
-template bool elf::isOutputDynamic<ELF32BE>();
-template bool elf::isOutputDynamic<ELF64LE>();
-template bool elf::isOutputDynamic<ELF64BE>();
-
template bool elf::isRelroSection<ELF32LE>(OutputSectionBase<ELF32LE> *);
template bool elf::isRelroSection<ELF32BE>(OutputSectionBase<ELF32BE> *);
template bool elf::isRelroSection<ELF64LE>(OutputSectionBase<ELF64LE> *);