<< "' in file '" << File->getName() << "'\n";
}
+template <class ELFT> static bool needsInterpSection() {
+ return !Symtab<ELFT>::X->getSharedFiles().empty() &&
+ !Config->DynamicLinker.empty();
+}
+
template <class ELFT> void elf::writeResult(SymbolTable<ELFT> *Symtab) {
typedef typename ELFT::uint uintX_t;
typedef typename ELFT::Ehdr Elf_Ehdr;
DynamicSection<ELFT> Dynamic;
EhOutputSection<ELFT> EhFrame;
GotSection<ELFT> Got;
- InterpSection<ELFT> Interp;
PltSection<ELFT> Plt;
RelocationSection<ELFT> RelaDyn(Config->Rela ? ".rela.dyn" : ".rel.dyn",
Config->ZCombreloc);
ProgramHeaders.updateAlignment(sizeof(uintX_t));
// Instantiate optional output sections if they are needed.
+ std::unique_ptr<InterpSection<ELFT>> Interp;
std::unique_ptr<BuildIdSection<ELFT>> BuildId;
std::unique_ptr<EhFrameHeader<ELFT>> EhFrameHdr;
std::unique_ptr<GnuHashTableSection<ELFT>> GnuHashTab;
std::unique_ptr<OutputSection<ELFT>> MipsRldMap;
std::unique_ptr<VersionDefinitionSection<ELFT>> VerDef;
+ if (needsInterpSection<ELFT>())
+ Interp.reset(new InterpSection<ELFT>);
+
if (Config->BuildId == BuildIdKind::Fnv1)
BuildId.reset(new BuildIdFnv1<ELFT>);
else if (Config->BuildId == BuildIdKind::Md5)
Out<ELFT>::Got = &Got;
Out<ELFT>::GotPlt = GotPlt.get();
Out<ELFT>::HashTab = HashTab.get();
- Out<ELFT>::Interp = &Interp;
+ Out<ELFT>::Interp = Interp.get();
Out<ELFT>::Plt = &Plt;
Out<ELFT>::RelaDyn = &RelaDyn;
Out<ELFT>::RelaPlt = RelaPlt.get();
return Ret;
}
-// Various helper functions
-template <class ELFT> bool elf::needsInterpSection() {
- return !Symtab<ELFT>::X->getSharedFiles().empty() &&
- !Config->DynamicLinker.empty();
-}
-
template <class ELFT> bool elf::isOutputDynamic() {
return !Symtab<ELFT>::X->getSharedFiles().empty() || Config->Pic;
}
// Add .interp at first because some loaders want to see that section
// on the first page of the executable file when loaded into memory.
- if (needsInterpSection<ELFT>())
+ if (Out<ELFT>::Interp)
OutputSections.insert(OutputSections.begin(), Out<ELFT>::Interp);
// This order is not the same as the final output order
Hdr.add(Out<ELFT>::ProgramHeaders);
// PT_INTERP must be the second entry if exists.
- if (needsInterpSection<ELFT>()) {
+ if (Out<ELFT>::Interp) {
Phdr &Hdr = *AddHdr(PT_INTERP, toPhdrFlags(Out<ELFT>::Interp->getFlags()));
Hdr.add(Out<ELFT>::Interp);
}
template struct elf::PhdrEntry<ELF64LE>;
template struct elf::PhdrEntry<ELF64BE>;
-template bool elf::needsInterpSection<ELF32LE>();
-template bool elf::needsInterpSection<ELF32BE>();
-template bool elf::needsInterpSection<ELF64LE>();
-template bool elf::needsInterpSection<ELF64BE>();
-
template bool elf::isOutputDynamic<ELF32LE>();
template bool elf::isOutputDynamic<ELF32BE>();
template bool elf::isOutputDynamic<ELF64LE>();