Index: ELF/Arch/AArch64.cpp =================================================================== --- ELF/Arch/AArch64.cpp +++ ELF/Arch/AArch64.cpp @@ -17,13 +17,14 @@ using namespace llvm; using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { // Page(Expr) is the page address of the expression Expr, defined // as (Expr & ~0xFFF). (This applies even if the machine page size // supported by the platform has a different value.) -uint64_t elf::getAArch64Page(uint64_t expr) { +uint64_t getAArch64Page(uint64_t expr) { return expr & ~static_cast(0xFFF); } @@ -679,4 +680,7 @@ return &t; } -TargetInfo *elf::getAArch64TargetInfo() { return getTargetInfo(); } +TargetInfo *getAArch64TargetInfo() { return getTargetInfo(); } + +} // namespace elf +} // namespace lld Index: ELF/Arch/AMDGPU.cpp =================================================================== --- ELF/Arch/AMDGPU.cpp +++ ELF/Arch/AMDGPU.cpp @@ -17,8 +17,9 @@ using namespace llvm::object; using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { namespace { class AMDGPU final : public TargetInfo { @@ -107,7 +108,10 @@ return R_AMDGPU_NONE; } -TargetInfo *elf::getAMDGPUTargetInfo() { +TargetInfo *getAMDGPUTargetInfo() { static AMDGPU target; return ⌖ } + +} // namespace elf +} // namespace lld Index: ELF/Arch/ARM.cpp =================================================================== --- ELF/Arch/ARM.cpp +++ ELF/Arch/ARM.cpp @@ -18,8 +18,9 @@ using namespace llvm; using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { namespace { class ARM final : public TargetInfo { @@ -600,7 +601,10 @@ } } -TargetInfo *elf::getARMTargetInfo() { +TargetInfo *getARMTargetInfo() { static ARM target; return ⌖ } + +} // namespace elf +} // namespace lld Index: ELF/Arch/AVR.cpp =================================================================== --- ELF/Arch/AVR.cpp +++ ELF/Arch/AVR.cpp @@ -36,8 +36,9 @@ using namespace llvm::object; using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { namespace { class AVR final : public TargetInfo { @@ -70,7 +71,10 @@ } } -TargetInfo *elf::getAVRTargetInfo() { +TargetInfo *getAVRTargetInfo() { static AVR target; return ⌖ } + +} // namespace elf +} // namespace lld Index: ELF/Arch/Hexagon.cpp =================================================================== --- ELF/Arch/Hexagon.cpp +++ ELF/Arch/Hexagon.cpp @@ -19,8 +19,9 @@ using namespace llvm::object; using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { namespace { class Hexagon final : public TargetInfo { @@ -318,7 +319,10 @@ return R_HEX_NONE; } -TargetInfo *elf::getHexagonTargetInfo() { +TargetInfo *getHexagonTargetInfo() { static Hexagon target; return ⌖ } + +} // namespace elf +} // namespace lld Index: ELF/Arch/MSP430.cpp =================================================================== --- ELF/Arch/MSP430.cpp +++ ELF/Arch/MSP430.cpp @@ -26,8 +26,9 @@ using namespace llvm::object; using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { namespace { class MSP430 final : public TargetInfo { @@ -87,7 +88,10 @@ } } -TargetInfo *elf::getMSP430TargetInfo() { +TargetInfo *getMSP430TargetInfo() { static MSP430 target; return ⌖ } + +} // namespace elf +} // namespace lld Index: ELF/Arch/Mips.cpp =================================================================== --- ELF/Arch/Mips.cpp +++ ELF/Arch/Mips.cpp @@ -18,9 +18,9 @@ using namespace llvm; using namespace llvm::object; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; +namespace lld { +namespace elf { namespace { template class MIPS final : public TargetInfo { public: @@ -721,7 +721,7 @@ } // Return true if the symbol is a PIC function. -template bool elf::isMipsPIC(const Defined *sym) { +template bool isMipsPIC(const Defined *sym) { if (!sym->isFunc()) return false; @@ -739,17 +739,20 @@ return file->getObj().getHeader()->e_flags & EF_MIPS_PIC; } -template TargetInfo *elf::getMipsTargetInfo() { +template TargetInfo *getMipsTargetInfo() { static MIPS target; return ⌖ } -template TargetInfo *elf::getMipsTargetInfo(); -template TargetInfo *elf::getMipsTargetInfo(); -template TargetInfo *elf::getMipsTargetInfo(); -template TargetInfo *elf::getMipsTargetInfo(); +template TargetInfo *getMipsTargetInfo(); +template TargetInfo *getMipsTargetInfo(); +template TargetInfo *getMipsTargetInfo(); +template TargetInfo *getMipsTargetInfo(); -template bool elf::isMipsPIC(const Defined *); -template bool elf::isMipsPIC(const Defined *); -template bool elf::isMipsPIC(const Defined *); -template bool elf::isMipsPIC(const Defined *); +template bool isMipsPIC(const Defined *); +template bool isMipsPIC(const Defined *); +template bool isMipsPIC(const Defined *); +template bool isMipsPIC(const Defined *); + +} // namespace elf +} // namespace lld Index: ELF/Arch/MipsArchTree.cpp =================================================================== --- ELF/Arch/MipsArchTree.cpp +++ ELF/Arch/MipsArchTree.cpp @@ -23,8 +23,8 @@ using namespace llvm::object; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; +namespace lld { +namespace elf { namespace { struct ArchTreeEdge { @@ -294,7 +294,7 @@ return ret; } -template uint32_t elf::calcMipsEFlags() { +template uint32_t calcMipsEFlags() { std::vector v; for (InputFile *f : objectFiles) v.push_back({f, cast>(f)->getObj().getHeader()->e_flags}); @@ -350,8 +350,7 @@ } } -uint8_t elf::getMipsFpAbiFlag(uint8_t oldFlag, uint8_t newFlag, - StringRef fileName) { +uint8_t getMipsFpAbiFlag(uint8_t oldFlag, uint8_t newFlag, StringRef fileName) { if (compareMipsFpAbi(newFlag, oldFlag) >= 0) return newFlag; if (compareMipsFpAbi(oldFlag, newFlag) < 0) @@ -367,7 +366,7 @@ return false; } -bool elf::isMipsN32Abi(const InputFile *f) { +bool isMipsN32Abi(const InputFile *f) { switch (config->ekind) { case ELF32LEKind: return isN32Abi(f); @@ -382,14 +381,17 @@ } } -bool elf::isMicroMips() { return config->eflags & EF_MIPS_MICROMIPS; } +bool isMicroMips() { return config->eflags & EF_MIPS_MICROMIPS; } -bool elf::isMipsR6() { +bool isMipsR6() { uint32_t arch = config->eflags & EF_MIPS_ARCH; return arch == EF_MIPS_ARCH_32R6 || arch == EF_MIPS_ARCH_64R6; } -template uint32_t elf::calcMipsEFlags(); -template uint32_t elf::calcMipsEFlags(); -template uint32_t elf::calcMipsEFlags(); -template uint32_t elf::calcMipsEFlags(); +template uint32_t calcMipsEFlags(); +template uint32_t calcMipsEFlags(); +template uint32_t calcMipsEFlags(); +template uint32_t calcMipsEFlags(); + +} // namespace elf +} // namespace lld Index: ELF/Arch/PPC.cpp =================================================================== --- ELF/Arch/PPC.cpp +++ ELF/Arch/PPC.cpp @@ -16,8 +16,9 @@ using namespace llvm; using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { namespace { class PPC final : public TargetInfo { @@ -61,7 +62,7 @@ write32(config->isLE ? loc : loc - 2, insn); } -void elf::writePPC32GlinkSection(uint8_t *buf, size_t numEntries) { +void writePPC32GlinkSection(uint8_t *buf, size_t numEntries) { // On PPC Secure PLT ABI, bl foo@plt jumps to a call stub, which loads an // absolute address from a specific .plt slot (usually called .got.plt on // other targets) and jumps there. @@ -435,7 +436,10 @@ } } -TargetInfo *elf::getPPCTargetInfo() { +TargetInfo *getPPCTargetInfo() { static PPC target; return ⌖ } + +} // namespace elf +} // namespace lld Index: ELF/Arch/PPC64.cpp =================================================================== --- ELF/Arch/PPC64.cpp +++ ELF/Arch/PPC64.cpp @@ -16,8 +16,9 @@ using namespace llvm::object; using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { static uint64_t ppc64TocOffset = 0x8000; static uint64_t dynamicThreadPointerOffset = 0x8000; @@ -59,7 +60,7 @@ ADDI = 14 }; -uint64_t elf::getPPC64TocBase() { +uint64_t getPPC64TocBase() { // The TOC consists of sections .got, .toc, .tocbss, .plt in that order. The // TOC starts where the first of these sections starts. We always create a // .got when we see a relocation that uses it, so for us the start is always @@ -73,7 +74,7 @@ return tocVA + ppc64TocOffset; } -unsigned elf::getPPC64GlobalEntryToLocalEntryOffset(uint8_t stOther) { +unsigned getPPC64GlobalEntryToLocalEntryOffset(uint8_t stOther) { // The offset is encoded into the 3 most significant bits of the st_other // field, with some special values described in section 3.4.1 of the ABI: // 0 --> Zero offset between the GEP and LEP, and the function does NOT use @@ -98,7 +99,7 @@ return 0; } -bool elf::isPPC64SmallCodeModelTocReloc(RelType type) { +bool isPPC64SmallCodeModelTocReloc(RelType type) { // The only small code model relocations that access the .toc section. return type == R_PPC64_TOC16 || type == R_PPC64_TOC16_DS; } @@ -153,8 +154,8 @@ // ld/lwa 3, 0(3) # load the value from the address // // Returns true if the relaxation is performed. -bool elf::tryRelaxPPC64TocIndirection(RelType type, const Relocation &rel, - uint8_t *bufLoc) { +bool tryRelaxPPC64TocIndirection(RelType type, const Relocation &rel, + uint8_t *bufLoc) { assert(config->tocOptimize); if (rel.addend < 0) return false; @@ -458,7 +459,7 @@ } } -unsigned elf::getPPCDFormOp(unsigned secondaryOp) { +unsigned getPPCDFormOp(unsigned secondaryOp) { switch (secondaryOp) { case LBZX: return LBZ; @@ -1093,7 +1094,10 @@ return true; } -TargetInfo *elf::getPPC64TargetInfo() { +TargetInfo *getPPC64TargetInfo() { static PPC64 target; return ⌖ } + +} // namespace elf +} // namespace lld Index: ELF/Arch/RISCV.cpp =================================================================== --- ELF/Arch/RISCV.cpp +++ ELF/Arch/RISCV.cpp @@ -14,8 +14,9 @@ using namespace llvm::object; using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { namespace { @@ -436,7 +437,10 @@ } } -TargetInfo *elf::getRISCVTargetInfo() { +TargetInfo *getRISCVTargetInfo() { static RISCV target; return ⌖ } + +} // namespace elf +} // namespace lld Index: ELF/Arch/SPARCV9.cpp =================================================================== --- ELF/Arch/SPARCV9.cpp +++ ELF/Arch/SPARCV9.cpp @@ -16,8 +16,9 @@ using namespace llvm; using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { namespace { class SPARCV9 final : public TargetInfo { @@ -143,7 +144,10 @@ relocateOne(buf + 4, R_SPARC_WDISP19, -(off + 4 - pltEntrySize)); } -TargetInfo *elf::getSPARCV9TargetInfo() { +TargetInfo *getSPARCV9TargetInfo() { static SPARCV9 target; return ⌖ } + +} // namespace elf +} // namespace lld Index: ELF/Arch/X86.cpp =================================================================== --- ELF/Arch/X86.cpp +++ ELF/Arch/X86.cpp @@ -16,8 +16,9 @@ using namespace llvm; using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { namespace { class X86 : public TargetInfo { @@ -539,7 +540,7 @@ write32le(buf + 22, -off - 26); } -TargetInfo *elf::getX86TargetInfo() { +TargetInfo *getX86TargetInfo() { if (config->zRetpolineplt) { if (config->isPic) { static RetpolinePic t; @@ -552,3 +553,6 @@ static X86 t; return &t; } + +} // namespace elf +} // namespace lld Index: ELF/Arch/X86_64.cpp =================================================================== --- ELF/Arch/X86_64.cpp +++ ELF/Arch/X86_64.cpp @@ -18,8 +18,9 @@ using namespace llvm::object; using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { namespace { class X86_64 : public TargetInfo { @@ -698,4 +699,7 @@ return &t; } -TargetInfo *elf::getX86_64TargetInfo() { return getTargetInfo(); } +TargetInfo *getX86_64TargetInfo() { return getTargetInfo(); } + +} // namespace elf +} // namespace lld Index: ELF/CallGraphSort.cpp =================================================================== --- ELF/CallGraphSort.cpp +++ ELF/CallGraphSort.cpp @@ -48,8 +48,9 @@ #include using namespace llvm; -using namespace lld; -using namespace lld::elf; + +namespace lld { +namespace elf { namespace { struct Edge { @@ -264,6 +265,9 @@ // This first builds a call graph based on the profile data then merges sections // according to the C³ huristic. All clusters are then sorted by a density // metric to further improve locality. -DenseMap elf::computeCallGraphProfileOrder() { +DenseMap computeCallGraphProfileOrder() { return CallGraphSort().run(); } + +} // namespace elf +} // namespace lld Index: ELF/DWARF.cpp =================================================================== --- ELF/DWARF.cpp +++ ELF/DWARF.cpp @@ -22,9 +22,9 @@ using namespace llvm; using namespace llvm::object; -using namespace lld; -using namespace lld::elf; +namespace lld { +namespace elf { template LLDDwarfObj::LLDDwarfObj(ObjFile *obj) { for (InputSectionBase *sec : obj->getSections()) { if (!sec) @@ -124,7 +124,10 @@ return findAux(*sec.sec, pos, sec.sec->template rels()); } -template class elf::LLDDwarfObj; -template class elf::LLDDwarfObj; -template class elf::LLDDwarfObj; -template class elf::LLDDwarfObj; +template class LLDDwarfObj; +template class LLDDwarfObj; +template class LLDDwarfObj; +template class LLDDwarfObj; + +} // namespace elf +} // namespace lld Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -66,17 +66,16 @@ using namespace llvm::sys; using namespace llvm::support; -using namespace lld; -using namespace lld::elf; +namespace lld { +namespace elf { -Configuration *elf::config; -LinkerDriver *elf::driver; +Configuration *config; +LinkerDriver *driver; static void setConfigs(opt::InputArgList &args); static void readConfigs(opt::InputArgList &args); -bool elf::link(ArrayRef args, bool canExitEarly, - raw_ostream &error) { +bool link(ArrayRef args, bool canExitEarly, raw_ostream &error) { errorHandler().logName = args::getFilenameWithoutExe(args[0]); errorHandler().errorLimitExceededMsg = "too many errors emitted, stopping now (use " @@ -1970,3 +1969,6 @@ // Write the result to the file. writeResult(); } + +} // namespace elf +} // namespace lld Index: ELF/DriverUtils.cpp =================================================================== --- ELF/DriverUtils.cpp +++ ELF/DriverUtils.cpp @@ -30,8 +30,8 @@ using namespace llvm::sys; using namespace llvm::opt; -using namespace lld; -using namespace lld::elf; +namespace lld { +namespace elf { // Create OptTable @@ -143,7 +143,7 @@ return args; } -void elf::printHelp() { +void printHelp() { ELFOptTable().PrintHelp( outs(), (config->progName + " [options] file...").str().c_str(), "lld", false /*ShowHidden*/, true /*ShowAllAliases*/); @@ -165,7 +165,7 @@ // Reconstructs command line arguments so that so that you can re-run // the same command with the same inputs. This is for --reproduce. -std::string elf::createResponseFile(const opt::InputArgList &args) { +std::string createResponseFile(const opt::InputArgList &args) { SmallString<0> data; raw_svector_ostream os(data); os << "--chroot .\n"; @@ -216,7 +216,7 @@ return None; } -Optional elf::findFromSearchPaths(StringRef path) { +Optional findFromSearchPaths(StringRef path) { for (StringRef dir : config->searchPaths) if (Optional s = findFile(dir, path)) return s; @@ -225,7 +225,7 @@ // This is for -l. We'll look for lib.so or lib.a from // search paths. -Optional elf::searchLibraryBaseName(StringRef name) { +Optional searchLibraryBaseName(StringRef name) { for (StringRef dir : config->searchPaths) { if (!config->isStatic) if (Optional s = findFile(dir, "lib" + name + ".so")) @@ -237,17 +237,20 @@ } // This is for -l. -Optional elf::searchLibrary(StringRef name) { - if (name.startswith(":")) - return findFromSearchPaths(name.substr(1)); - return searchLibraryBaseName (name); +Optional searchLibrary(StringRef name) { + if (name.startswith(":")) + return findFromSearchPaths(name.substr(1)); + return searchLibraryBaseName(name); } // If a linker/version script doesn't exist in the current directory, we also // look for the script in the '-L' search paths. This matches the behaviour of // '-T', --version-script=, and linker script INPUT() command in ld.bfd. -Optional elf::searchScript(StringRef name) { +Optional searchScript(StringRef name) { if (fs::exists(name)) return name.str(); return findFromSearchPaths(name); } + +} // namespace elf +} // namespace lld Index: ELF/EhFrame.cpp =================================================================== --- ELF/EhFrame.cpp +++ ELF/EhFrame.cpp @@ -30,9 +30,8 @@ using namespace llvm::dwarf; using namespace llvm::object; -using namespace lld; -using namespace lld::elf; - +namespace lld { +namespace elf { namespace { class EhReader { public: @@ -57,7 +56,7 @@ }; } -size_t elf::readEhRecordSize(InputSectionBase *s, size_t off) { +size_t readEhRecordSize(InputSectionBase *s, size_t off) { return EhReader(s, s->data().slice(off)).readEhRecordSize(); } @@ -149,7 +148,7 @@ d = d.slice(size); } -uint8_t elf::getFdeEncoding(EhSectionPiece *p) { +uint8_t getFdeEncoding(EhSectionPiece *p) { return EhReader(p->sec, p->data()).getFdeEncoding(); } @@ -195,3 +194,6 @@ } return DW_EH_PE_absptr; } + +} // namespace elf +} // namespace lld Index: ELF/ICF.cpp =================================================================== --- ELF/ICF.cpp +++ ELF/ICF.cpp @@ -88,12 +88,12 @@ #include #include -using namespace lld; -using namespace lld::elf; using namespace llvm; using namespace llvm::ELF; using namespace llvm::object; +namespace lld { +namespace elf { namespace { template class ICF { public: @@ -512,9 +512,12 @@ } // ICF entry point function. -template void elf::doIcf() { ICF().run(); } +template void doIcf() { ICF().run(); } -template void elf::doIcf(); -template void elf::doIcf(); -template void elf::doIcf(); -template void elf::doIcf(); +template void doIcf(); +template void doIcf(); +template void doIcf(); +template void doIcf(); + +} // namespace elf +} // namespace lld Index: ELF/InputFiles.h =================================================================== --- ELF/InputFiles.h +++ ELF/InputFiles.h @@ -33,15 +33,13 @@ } // namespace llvm namespace lld { -namespace elf { -class InputFile; -class InputSectionBase; -} // Returns "", "foo.a(bar.o)" or "baz.o". std::string toString(const elf::InputFile *f); namespace elf { +class InputFile; +class InputSectionBase; using llvm::object::Archive; Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -37,18 +37,31 @@ using namespace llvm::sys::fs; using namespace llvm::support::endian; -using namespace lld; -using namespace lld::elf; +namespace lld { +// Returns "", "foo.a(bar.o)" or "baz.o". +std::string toString(const elf::InputFile *f) { + if (!f) + return ""; + if (f->toStringCache.empty()) { + if (f->archiveName.empty()) + f->toStringCache = f->getName(); + else + f->toStringCache = (f->archiveName + "(" + f->getName() + ")").str(); + } + return f->toStringCache; +} + +namespace elf { bool InputFile::isInGroup; uint32_t InputFile::nextGroupId; -std::vector elf::binaryFiles; -std::vector elf::bitcodeFiles; -std::vector elf::lazyObjFiles; -std::vector elf::objectFiles; -std::vector elf::sharedFiles; +std::vector binaryFiles; +std::vector bitcodeFiles; +std::vector lazyObjFiles; +std::vector objectFiles; +std::vector sharedFiles; -std::unique_ptr elf::tar; +std::unique_ptr tar; static ELFKind getELFKind(MemoryBufferRef mb, StringRef archiveName) { unsigned char size; @@ -88,7 +101,7 @@ ++nextGroupId; } -Optional elf::readFile(StringRef path) { +Optional readFile(StringRef path) { // The --chroot option changes our virtual root directory. // This is useful when you are dealing with files created by --reproduce. if (!config->chroot.empty() && path.startswith("/")) @@ -188,7 +201,7 @@ } // Add symbols in File to the symbol table. -void elf::parseFile(InputFile *file) { +void parseFile(InputFile *file) { switch (config->ekind) { case ELF32LEKind: doParseFile(file); @@ -356,20 +369,6 @@ return None; } -// Returns "", "foo.a(bar.o)" or "baz.o". -std::string lld::toString(const InputFile *f) { - if (!f) - return ""; - - if (f->toStringCache.empty()) { - if (f->archiveName.empty()) - f->toStringCache = f->getName(); - else - f->toStringCache = (f->archiveName + "(" + f->getName() + ")").str(); - } - return f->toStringCache; -} - ELFFileBase::ELFFileBase(Kind k, MemoryBufferRef mb) : InputFile(k, mb) { ekind = getELFKind(mb, ""); @@ -1530,8 +1529,8 @@ STV_DEFAULT, STT_OBJECT, data.size(), 0, nullptr}); } -InputFile *elf::createObjectFile(MemoryBufferRef mb, StringRef archiveName, - uint64_t offsetInArchive) { +InputFile *createObjectFile(MemoryBufferRef mb, StringRef archiveName, + uint64_t offsetInArchive) { if (isBitcode(mb)) return make(mb, archiveName, offsetInArchive); @@ -1622,7 +1621,7 @@ } } -std::string elf::replaceThinLTOSuffix(StringRef path) { +std::string replaceThinLTOSuffix(StringRef path) { StringRef suffix = config->thinLTOObjectSuffixReplace.first; StringRef repl = config->thinLTOObjectSuffixReplace.second; @@ -1641,12 +1640,15 @@ template void LazyObjFile::parse(); template void LazyObjFile::parse(); -template class elf::ObjFile; -template class elf::ObjFile; -template class elf::ObjFile; -template class elf::ObjFile; +template class ObjFile; +template class ObjFile; +template class ObjFile; +template class ObjFile; template void SharedFile::parse(); template void SharedFile::parse(); template void SharedFile::parse(); template void SharedFile::parse(); + +} // namespace elf +} // namespace lld Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -37,16 +37,15 @@ using namespace llvm::support::endian; using namespace llvm::sys; -using namespace lld; -using namespace lld::elf; - -std::vector elf::inputSections; - +namespace lld { // Returns a string to construct an error message. -std::string lld::toString(const InputSectionBase *sec) { +std::string toString(const elf::InputSectionBase *sec) { return (toString(sec->file) + ":(" + sec->name + ")").str(); } +namespace elf { +std::vector inputSections; + template static ArrayRef getSectionContents(ObjFile &file, const typename ELFT::Shdr &hdr) { @@ -619,7 +618,7 @@ // Variant 2. Static TLS blocks, followed by alignment padding are placed // before TP. The alignment padding is added so that (TP - padding - // p_memsz) is congruent to p_vaddr modulo p_align. - elf::PhdrEntry *tls = Out::tlsPhdr; + PhdrEntry *tls = Out::tlsPhdr; switch (config->emachine) { // Variant 1. case EM_ARM: @@ -1082,7 +1081,7 @@ end, f->stOther)) continue; if (!getFile()->someNoSplitStack) - error(lld::toString(this) + ": " + f->getName() + + error(toString(this) + ": " + f->getName() + " (with -fsplit-stack) calls " + rel.sym->getName() + " (without -fsplit-stack), but couldn't adjust its prologue"); } @@ -1345,3 +1344,6 @@ template void EhInputSection::split(); template void EhInputSection::split(); template void EhInputSection::split(); + +} // namespace elf +} // namespace lld Index: ELF/LTO.cpp =================================================================== --- ELF/LTO.cpp +++ ELF/LTO.cpp @@ -42,8 +42,8 @@ using namespace llvm::object; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; +namespace lld { +namespace elf { // Creates an empty file to store a list of object files for final // linking of distributed ThinLTO. @@ -303,3 +303,6 @@ ret.push_back(createObjectFile(*file)); return ret; } + +} // namespace elf +} // namespace lld Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -43,10 +43,10 @@ using namespace llvm::ELF; using namespace llvm::object; using namespace llvm::support::endian; -using namespace lld; -using namespace lld::elf; -LinkerScript *elf::script; +namespace lld { +namespace elf { +LinkerScript *script; static uint64_t getOutputSectionVA(SectionBase *sec) { OutputSection *os = sec->getOutputSection(); @@ -1202,3 +1202,6 @@ } return ret; } + +} // namespace elf +} // namespace lld Index: ELF/MapFile.cpp =================================================================== --- ELF/MapFile.cpp +++ ELF/MapFile.cpp @@ -34,9 +34,8 @@ using namespace llvm; using namespace llvm::object; -using namespace lld; -using namespace lld::elf; - +namespace lld { +namespace elf { using SymbolMapTy = DenseMap>; static constexpr char indent8[] = " "; // 8 spaces @@ -139,7 +138,7 @@ } } -void elf::writeMapFile() { +void writeMapFile() { if (config->mapFile.empty()) return; @@ -228,7 +227,7 @@ // // In this case, strlen is defined by libc.so.6 and used by other two // files. -void elf::writeCrossReferenceTable() { +void writeCrossReferenceTable() { if (!config->cref) return; @@ -259,3 +258,6 @@ print("", toString(file)); } } + +} // namespace elf +} // namespace lld Index: ELF/MarkLive.cpp =================================================================== --- ELF/MarkLive.cpp +++ ELF/MarkLive.cpp @@ -37,11 +37,11 @@ using namespace llvm; using namespace llvm::ELF; using namespace llvm::object; -using namespace llvm::support::endian; -using namespace lld; -using namespace lld::elf; +namespace endian = llvm::support::endian; +namespace lld { +namespace elf { namespace { template class MarkLive { public: @@ -141,7 +141,7 @@ if (firstRelI == (unsigned)-1) continue; - if (read32(piece.data().data() + 4) == 0) { + if (endian::read32(piece.data().data() + 4) == 0) { // This is a CIE, we only need to worry about the first relocation. It is // known to point to the personality function. resolveReloc(eh, rels[firstRelI], false); @@ -317,7 +317,7 @@ // Before calling this function, Live bits are off for all // input sections. This function make some or all of them on // so that they are emitted to the output file. -template void elf::markLive() { +template void markLive() { // If -gc-sections is not given, no sections are removed. if (!config->gcSections) { for (InputSectionBase *sec : inputSections) @@ -379,7 +379,10 @@ message("removing unused section " + toString(sec)); } -template void elf::markLive(); -template void elf::markLive(); -template void elf::markLive(); -template void elf::markLive(); +template void markLive(); +template void markLive(); +template void markLive(); +template void markLive(); + +} // namespace elf +} // namespace lld Index: ELF/OutputSections.cpp =================================================================== --- ELF/OutputSections.cpp +++ ELF/OutputSections.cpp @@ -27,9 +27,8 @@ using namespace llvm::support::endian; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; - +namespace lld { +namespace elf { uint8_t *Out::bufferStart; uint8_t Out::first; PhdrEntry *Out::tlsPhdr; @@ -39,7 +38,7 @@ OutputSection *Out::initArray; OutputSection *Out::finiArray; -std::vector elf::outputSections; +std::vector outputSections; uint32_t OutputSection::getPhdrFlags() const { uint32_t ret = 0; @@ -226,7 +225,7 @@ in[i] = v[i].second; } -uint64_t elf::getHeaderSize() { +uint64_t getHeaderSize() { if (config->oFormatBinary) return 0; return Out::elfHeader->size + Out::programHeaders->size; @@ -446,7 +445,7 @@ // If an input string is in the form of "foo.N" where N is a number, // return N. Otherwise, returns 65536, which is one greater than the // lowest priority. -int elf::getPriority(StringRef s) { +int getPriority(StringRef s) { size_t pos = s.rfind('.'); if (pos == StringRef::npos) return 65536; @@ -456,7 +455,7 @@ return v; } -std::vector elf::getInputSections(OutputSection *os) { +std::vector getInputSections(OutputSection *os) { std::vector ret; for (BaseCommand *base : os->sectionCommands) if (auto *isd = dyn_cast(base)) @@ -497,3 +496,6 @@ template void OutputSection::maybeCompress(); template void OutputSection::maybeCompress(); template void OutputSection::maybeCompress(); + +} // namespace elf +} // namespace lld Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -62,9 +62,8 @@ using namespace llvm::object; using namespace llvm::support::endian; -using namespace lld; -using namespace lld::elf; - +namespace lld { +namespace elf { static Optional getLinkerScriptLocation(const Symbol &sym) { for (BaseCommand *base : script->sectionCommands) if (auto *cmd = dyn_cast(base)) @@ -823,7 +822,7 @@ error(msg); } -template void elf::reportUndefinedSymbols() { +template void reportUndefinedSymbols() { // Find the first "undefined symbol" diagnostic for each diagnostic, and // collect all "referenced from" lines at the first diagnostic. DenseMap firstRef; @@ -1405,7 +1404,7 @@ }); } -template void elf::scanRelocations(InputSectionBase &s) { +template void scanRelocations(InputSectionBase &s) { if (s.areRelocsRela) scanRelocs(s, s.relas()); else @@ -1832,11 +1831,14 @@ return addressesChanged; } -template void elf::scanRelocations(InputSectionBase &); -template void elf::scanRelocations(InputSectionBase &); -template void elf::scanRelocations(InputSectionBase &); -template void elf::scanRelocations(InputSectionBase &); -template void elf::reportUndefinedSymbols(); -template void elf::reportUndefinedSymbols(); -template void elf::reportUndefinedSymbols(); -template void elf::reportUndefinedSymbols(); +template void scanRelocations(InputSectionBase &); +template void scanRelocations(InputSectionBase &); +template void scanRelocations(InputSectionBase &); +template void scanRelocations(InputSectionBase &); +template void reportUndefinedSymbols(); +template void reportUndefinedSymbols(); +template void reportUndefinedSymbols(); +template void reportUndefinedSymbols(); + +} // namespace elf +} // namespace lld Index: ELF/ScriptLexer.cpp =================================================================== --- ELF/ScriptLexer.cpp +++ ELF/ScriptLexer.cpp @@ -36,9 +36,9 @@ #include "llvm/ADT/Twine.h" using namespace llvm; -using namespace lld; -using namespace lld::elf; +namespace lld { +namespace elf { // Returns a whole line containing the current token. StringRef ScriptLexer::getLine() { StringRef s = getCurrentMB().getBuffer(); @@ -298,3 +298,6 @@ return mb; llvm_unreachable("getCurrentMB: failed to find a token"); } + +} // namespace elf +} // namespace lld Index: ELF/ScriptParser.cpp =================================================================== --- ELF/ScriptParser.cpp +++ ELF/ScriptParser.cpp @@ -37,9 +37,9 @@ using namespace llvm; using namespace llvm::ELF; using namespace llvm::support::endian; -using namespace lld; -using namespace lld::elf; +namespace lld { +namespace elf { namespace { class ScriptParser final : ScriptLexer { public: @@ -1268,7 +1268,7 @@ return [=] { return cmd->size; }; } if (tok == "SIZEOF_HEADERS") - return [=] { return elf::getHeaderSize(); }; + return [=] { return getHeaderSize(); }; // Tok is the dot. if (tok == ".") @@ -1511,18 +1511,19 @@ return {flags, negFlags}; } -void elf::readLinkerScript(MemoryBufferRef mb) { +void readLinkerScript(MemoryBufferRef mb) { ScriptParser(mb).readLinkerScript(); } -void elf::readVersionScript(MemoryBufferRef mb) { +void readVersionScript(MemoryBufferRef mb) { ScriptParser(mb).readVersionScript(); } -void elf::readDynamicList(MemoryBufferRef mb) { - ScriptParser(mb).readDynamicList(); -} +void readDynamicList(MemoryBufferRef mb) { ScriptParser(mb).readDynamicList(); } -void elf::readDefsym(StringRef name, MemoryBufferRef mb) { +void readDefsym(StringRef name, MemoryBufferRef mb) { ScriptParser(mb).readDefsym(name); } + +} // namespace elf +} // namespace lld Index: ELF/SymbolTable.cpp =================================================================== --- ELF/SymbolTable.cpp +++ ELF/SymbolTable.cpp @@ -27,10 +27,9 @@ using namespace llvm::object; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; - -SymbolTable *elf::symtab; +namespace lld { +namespace elf { +SymbolTable *symtab; void SymbolTable::wrap(Symbol *sym, Symbol *real, Symbol *wrap) { // Swap symbols as instructed by -wrap. @@ -265,3 +264,6 @@ // --dynamic-list. handleDynamicList(); } + +} // namespace elf +} // namespace lld Index: ELF/Symbols.h =================================================================== --- ELF/Symbols.h +++ ELF/Symbols.h @@ -21,6 +21,13 @@ #include "llvm/Object/ELF.h" namespace lld { +std::string toString(const elf::Symbol &); + +// There are two different ways to convert an Archive::Symbol to a string: +// One for Microsoft name mangling and one for Itanium name mangling. +// Call the functions toCOFFString and toELFString, not just toString. +std::string toELFString(const llvm::object::Archive::Symbol &); + namespace elf { class CommonSymbol; class Defined; @@ -30,16 +37,6 @@ class SharedSymbol; class Symbol; class Undefined; -} // namespace elf - -std::string toString(const elf::Symbol &); - -// There are two different ways to convert an Archive::Symbol to a string: -// One for Microsoft name mangling and one for Itanium name mangling. -// Call the functions toCOFFString and toELFString, not just toString. -std::string toELFString(const elf::Archive::Symbol &); - -namespace elf { // This is a StringRef-like container that doesn't run strlen(). // Index: ELF/Symbols.cpp =================================================================== --- ELF/Symbols.cpp +++ ELF/Symbols.cpp @@ -23,9 +23,20 @@ using namespace llvm::object; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; +namespace lld { +// Returns a symbol for an error message. +static std::string demangle(StringRef symName) { + if (elf::config->demangle) + return demangleItanium(symName); + return symName; +} +std::string toString(const elf::Symbol &b) { return demangle(b.getName()); } +std::string toELFString(const Archive::Symbol &b) { + return demangle(b.getName()); +} + +namespace elf { Defined *ElfSym::bss; Defined *ElfSym::etext1; Defined *ElfSym::etext2; @@ -42,19 +53,6 @@ Defined *ElfSym::riscvGlobalPointer; Defined *ElfSym::tlsModuleBase; -// Returns a symbol for an error message. -static std::string demangle(StringRef symName) { - if (config->demangle) - return demangleItanium(symName); - return symName; -} -namespace lld { -std::string toString(const Symbol &b) { return demangle(b.getName()); } -std::string toELFString(const Archive::Symbol &b) { - return demangle(b.getName()); -} -} // namespace lld - static uint64_t getSymVA(const Symbol &sym, int64_t &addend) { switch (sym.kind()) { case Symbol::DefinedKind: { @@ -298,7 +296,7 @@ } // Print out a log message for --trace-symbol. -void elf::printTraceSymbol(const Symbol *sym) { +void printTraceSymbol(const Symbol *sym) { std::string s; if (sym->isUndefined()) s = ": reference to "; @@ -314,7 +312,7 @@ message(toString(sym->file) + s + sym->getName()); } -void elf::maybeWarnUnorderableSymbol(const Symbol *sym) { +void maybeWarnUnorderableSymbol(const Symbol *sym) { if (!config->warnSymbolOrdering) return; @@ -655,3 +653,6 @@ referenced = true; } } + +} // namespace elf +} // namespace lld Index: ELF/SyntheticSections.cpp =================================================================== --- ELF/SyntheticSections.cpp +++ ELF/SyntheticSections.cpp @@ -45,13 +45,12 @@ using namespace llvm::object; using namespace llvm::support; -using namespace lld; -using namespace lld::elf; - using llvm::support::endian::read32le; using llvm::support::endian::write32le; using llvm::support::endian::write64le; +namespace lld { +namespace elf { constexpr size_t MergeNoTailSection::numShards; static uint64_t readUint(uint8_t *buf) { @@ -82,7 +81,7 @@ // With this feature, you can identify LLD-generated binaries easily // by "readelf --string-dump .comment ". // The returned object is a mergeable string section. -MergeInputSection *elf::createCommentSection() { +MergeInputSection *createCommentSection() { return make(SHF_MERGE | SHF_STRINGS, SHT_PROGBITS, 1, getVersion(), ".comment"); } @@ -138,7 +137,7 @@ flags.ases |= s->ases; flags.flags1 |= s->flags1; flags.flags2 |= s->flags2; - flags.fp_abi = elf::getMipsFpAbiFlag(flags.fp_abi, s->fp_abi, filename); + flags.fp_abi = getMipsFpAbiFlag(flags.fp_abi, s->fp_abi, filename); }; if (create) @@ -252,7 +251,7 @@ return make>(reginfo); } -InputSection *elf::createInterpSection() { +InputSection *createInterpSection() { // StringSaver guarantees that the returned string ends with '\0'. StringRef s = saver.save(config->dynamicLinker); ArrayRef contents = {(const uint8_t *)s.data(), s.size() + 1}; @@ -261,8 +260,8 @@ ".interp"); } -Defined *elf::addSyntheticLocal(StringRef name, uint8_t type, uint64_t value, - uint64_t size, InputSectionBase §ion) { +Defined *addSyntheticLocal(StringRef name, uint8_t type, uint64_t value, + uint64_t size, InputSectionBase §ion) { auto *s = make(section.file, name, STB_LOCAL, STV_DEFAULT, type, value, size, §ion); if (in.symTab) @@ -1274,7 +1273,7 @@ // Add remaining entries to complete .dynamic contents. template void DynamicSection::finalizeContents() { - elf::Partition &part = getPartition(); + Partition &part = getPartition(); bool isMain = part.name.empty(); for (StringRef s : config->filterList) @@ -2940,7 +2939,7 @@ return getPartition().verDef || getPartition().verNeed->isNeeded(); } -void elf::addVerneed(Symbol *ss) { +void addVerneed(Symbol *ss) { auto &file = cast(*ss->file); if (ss->verdefIndex == VER_NDX_GLOBAL) { ss->versionId = VER_NDX_GLOBAL; @@ -3123,16 +3122,16 @@ }); } -MergeSyntheticSection *elf::createMergeSynthetic(StringRef name, uint32_t type, - uint64_t flags, - uint32_t alignment) { +MergeSyntheticSection *createMergeSynthetic(StringRef name, uint32_t type, + uint64_t flags, + uint32_t alignment) { bool shouldTailMerge = (flags & SHF_STRINGS) && config->optimize >= 2; if (shouldTailMerge) return make(name, type, flags, alignment); return make(name, type, flags, alignment); } -template void elf::splitSections() { +template void splitSections() { // splitIntoPieces needs to be called on each MergeInputSection // before calling finalizeContents(). parallelForEach(inputSections, [](InputSectionBase *sec) { @@ -3486,7 +3485,7 @@ return 0; } -template void elf::writeEhdr(uint8_t *buf, Partition &part) { +template void writeEhdr(uint8_t *buf, Partition &part) { // For executable segments, the trap instructions are written before writing // the header. Setting Elf header bytes to zero ensures that any unused bytes // in header are zero-cleared, instead of having trap instructions. @@ -3512,7 +3511,7 @@ } } -template void elf::writePhdrs(uint8_t *buf, Partition &part) { +template void writePhdrs(uint8_t *buf, Partition &part) { // Write the program header table. auto *hBuf = reinterpret_cast(buf); for (PhdrEntry *p : part.phdrs) { @@ -3587,87 +3586,90 @@ } } -InStruct elf::in; +InStruct in; -std::vector elf::partitions; -Partition *elf::mainPart; +std::vector partitions; +Partition *mainPart; template GdbIndexSection *GdbIndexSection::create(); template GdbIndexSection *GdbIndexSection::create(); template GdbIndexSection *GdbIndexSection::create(); template GdbIndexSection *GdbIndexSection::create(); -template void elf::splitSections(); -template void elf::splitSections(); -template void elf::splitSections(); -template void elf::splitSections(); +template void splitSections(); +template void splitSections(); +template void splitSections(); +template void splitSections(); template void PltSection::addEntry(Symbol &Sym); template void PltSection::addEntry(Symbol &Sym); template void PltSection::addEntry(Symbol &Sym); template void PltSection::addEntry(Symbol &Sym); -template class elf::MipsAbiFlagsSection; -template class elf::MipsAbiFlagsSection; -template class elf::MipsAbiFlagsSection; -template class elf::MipsAbiFlagsSection; +template class MipsAbiFlagsSection; +template class MipsAbiFlagsSection; +template class MipsAbiFlagsSection; +template class MipsAbiFlagsSection; -template class elf::MipsOptionsSection; -template class elf::MipsOptionsSection; -template class elf::MipsOptionsSection; -template class elf::MipsOptionsSection; +template class MipsOptionsSection; +template class MipsOptionsSection; +template class MipsOptionsSection; +template class MipsOptionsSection; -template class elf::MipsReginfoSection; -template class elf::MipsReginfoSection; -template class elf::MipsReginfoSection; -template class elf::MipsReginfoSection; +template class MipsReginfoSection; +template class MipsReginfoSection; +template class MipsReginfoSection; +template class MipsReginfoSection; -template class elf::DynamicSection; -template class elf::DynamicSection; -template class elf::DynamicSection; -template class elf::DynamicSection; +template class DynamicSection; +template class DynamicSection; +template class DynamicSection; +template class DynamicSection; -template class elf::RelocationSection; -template class elf::RelocationSection; -template class elf::RelocationSection; -template class elf::RelocationSection; +template class RelocationSection; +template class RelocationSection; +template class RelocationSection; +template class RelocationSection; -template class elf::AndroidPackedRelocationSection; -template class elf::AndroidPackedRelocationSection; -template class elf::AndroidPackedRelocationSection; -template class elf::AndroidPackedRelocationSection; +template class AndroidPackedRelocationSection; +template class AndroidPackedRelocationSection; +template class AndroidPackedRelocationSection; +template class AndroidPackedRelocationSection; -template class elf::RelrSection; -template class elf::RelrSection; -template class elf::RelrSection; -template class elf::RelrSection; +template class RelrSection; +template class RelrSection; +template class RelrSection; +template class RelrSection; -template class elf::SymbolTableSection; -template class elf::SymbolTableSection; -template class elf::SymbolTableSection; -template class elf::SymbolTableSection; +template class SymbolTableSection; +template class SymbolTableSection; +template class SymbolTableSection; +template class SymbolTableSection; -template class elf::VersionNeedSection; -template class elf::VersionNeedSection; -template class elf::VersionNeedSection; -template class elf::VersionNeedSection; +template class VersionNeedSection; +template class VersionNeedSection; +template class VersionNeedSection; +template class VersionNeedSection; -template void elf::writeEhdr(uint8_t *Buf, Partition &Part); -template void elf::writeEhdr(uint8_t *Buf, Partition &Part); -template void elf::writeEhdr(uint8_t *Buf, Partition &Part); -template void elf::writeEhdr(uint8_t *Buf, Partition &Part); +template void writeEhdr(uint8_t *Buf, Partition &Part); +template void writeEhdr(uint8_t *Buf, Partition &Part); +template void writeEhdr(uint8_t *Buf, Partition &Part); +template void writeEhdr(uint8_t *Buf, Partition &Part); -template void elf::writePhdrs(uint8_t *Buf, Partition &Part); -template void elf::writePhdrs(uint8_t *Buf, Partition &Part); -template void elf::writePhdrs(uint8_t *Buf, Partition &Part); -template void elf::writePhdrs(uint8_t *Buf, Partition &Part); +template void writePhdrs(uint8_t *Buf, Partition &Part); +template void writePhdrs(uint8_t *Buf, Partition &Part); +template void writePhdrs(uint8_t *Buf, Partition &Part); +template void writePhdrs(uint8_t *Buf, Partition &Part); -template class elf::PartitionElfHeaderSection; -template class elf::PartitionElfHeaderSection; -template class elf::PartitionElfHeaderSection; -template class elf::PartitionElfHeaderSection; +template class PartitionElfHeaderSection; +template class PartitionElfHeaderSection; +template class PartitionElfHeaderSection; +template class PartitionElfHeaderSection; -template class elf::PartitionProgramHeadersSection; -template class elf::PartitionProgramHeadersSection; -template class elf::PartitionProgramHeadersSection; -template class elf::PartitionProgramHeadersSection; +template class PartitionProgramHeadersSection; +template class PartitionProgramHeadersSection; +template class PartitionProgramHeadersSection; +template class PartitionProgramHeadersSection; + +} // namespace elf +} // namespace lld Index: ELF/Target.cpp =================================================================== --- ELF/Target.cpp +++ ELF/Target.cpp @@ -34,19 +34,19 @@ using namespace llvm; using namespace llvm::object; using namespace llvm::ELF; -using namespace lld; -using namespace lld::elf; -const TargetInfo *elf::target; - -std::string lld::toString(RelType type) { +namespace lld { +std::string toString(elf::RelType type) { StringRef s = getELFRelocationTypeName(elf::config->emachine, type); if (s == "Unknown") return ("Unknown (" + Twine(type) + ")").str(); return s; } -TargetInfo *elf::getTarget() { +namespace elf { +const TargetInfo *target; + +TargetInfo *getTarget() { switch (config->emachine) { case EM_386: case EM_IAMCU: @@ -103,7 +103,7 @@ return {}; } -ErrorPlace elf::getErrorPlace(const uint8_t *loc) { +ErrorPlace getErrorPlace(const uint8_t *loc) { switch (config->ekind) { case ELF32LEKind: return getErrPlace(loc); @@ -179,3 +179,6 @@ return *config->imageBase; return config->isPic ? 0 : defaultImageBase; } + +} // namespace elf +} // namespace lld Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -36,9 +36,8 @@ using namespace llvm::support; using namespace llvm::support::endian; -using namespace lld; -using namespace lld::elf; - +namespace lld { +namespace elf { namespace { // The writer writes a SymbolTable result to a file. template class Writer { @@ -92,7 +91,7 @@ return name.startswith(prefix) || name == prefix.drop_back(); } -StringRef elf::getOutputSectionName(const InputSectionBase *s) { +StringRef getOutputSectionName(const InputSectionBase *s) { if (config->relocatable) return s->name; @@ -140,7 +139,7 @@ script->needsInterpSection(); } -template void elf::writeResult() { Writer().run(); } +template void writeResult() { Writer().run(); } static void removeEmptyPTLoad(std::vector &phdrs) { llvm::erase_if(phdrs, [&](const PhdrEntry *p) { @@ -153,7 +152,7 @@ }); } -void elf::copySectionsIntoPartitions() { +void copySectionsIntoPartitions() { std::vector newSections; for (unsigned part = 2; part != partitions.size() + 1; ++part) { for (InputSectionBase *s : inputSections) { @@ -175,7 +174,7 @@ newSections.end()); } -void elf::combineEhSections() { +void combineEhSections() { for (InputSectionBase *&s : inputSections) { // Ignore dead sections and the partition end marker (.part.end), // whose partition number is out of bounds. @@ -216,7 +215,7 @@ // The linker is expected to define some symbols depending on // the linking result. This function defines such symbols. -void elf::addReservedSymbols() { +void addReservedSymbols() { if (config->emachine == EM_MIPS) { // Define _gp for MIPS. st_value of _gp symbol will be updated by Writer // so that it points to an absolute address which by default is relative @@ -309,7 +308,7 @@ return nullptr; } -template void elf::createSyntheticSections() { +template void createSyntheticSections() { // Initialize all pointers with NULL. This is needed because // you can call lld::elf::main more than once as a library. memset(&Out::first, 0, sizeof(Out)); @@ -2737,12 +2736,15 @@ part.buildId->writeBuildId(buildId); } -template void elf::createSyntheticSections(); -template void elf::createSyntheticSections(); -template void elf::createSyntheticSections(); -template void elf::createSyntheticSections(); +template void createSyntheticSections(); +template void createSyntheticSections(); +template void createSyntheticSections(); +template void createSyntheticSections(); -template void elf::writeResult(); -template void elf::writeResult(); -template void elf::writeResult(); -template void elf::writeResult(); +template void writeResult(); +template void writeResult(); +template void writeResult(); +template void writeResult(); + +} // namespace elf +} // namespace lld