diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 5f94fc9338a4..fe036a644f41 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -383,9 +383,9 @@ elf::ObjectFile::createInputSection(const Elf_Shdr &Sec, // we see. The eglibc ARM dynamic loaders require the presence of an // attribute section for dlopen to work. // In a full implementation we would merge all attribute sections. - if (In::ARMAttributes == nullptr) { - In::ARMAttributes = make(this, &Sec, Name); - return In::ARMAttributes; + if (InX::ARMAttributes == nullptr) { + InX::ARMAttributes = make(this, &Sec, Name); + return InX::ARMAttributes; } return &InputSection::Discarded; case SHT_RELA: diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 9b1cd1de4e6b..4071b065d351 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -518,7 +518,7 @@ template static void addCopyRelSymbol(SharedSymbol *SS) { // See if this symbol is in a read-only segment. If so, preserve the symbol's // memory protection by reserving space in the .bss.rel.ro section. bool IsReadOnly = isReadOnly(SS); - BssSection *Sec = IsReadOnly ? In::BssRelRo : In::Bss; + BssSection *Sec = IsReadOnly ? InX::BssRelRo : InX::Bss; uint64_t Off = Sec->reserveSpace(SymSize, SS->getAlignment()); // Look through the DSO's dynamic symbol table for aliases and create a @@ -874,7 +874,7 @@ static void scanRelocs(InputSectionBase &Sec, ArrayRef Rels) { // If a relocation needs PLT, we create PLT and GOTPLT slots for the symbol. if (needsPlt(Expr) && !Body.isInPlt()) { if (Body.isGnuIFunc() && !Preemptible) - addPltEntry(InX::Iplt, In::IgotPlt, In::RelaIplt, + addPltEntry(InX::Iplt, InX::IgotPlt, In::RelaIplt, Target->IRelativeRel, Body, true); else addPltEntry(InX::Plt, InX::GotPlt, In::RelaPlt, Target->PltRel, diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 595350ec0e46..072f945b4ba6 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -1028,15 +1028,15 @@ template void DynamicSection::addEntries() { // Add strings to .dynstr early so that .dynstr's size will be // fixed early. for (StringRef S : Config->AuxiliaryList) - add({DT_AUXILIARY, In::DynStrTab->addString(S)}); + add({DT_AUXILIARY, InX::DynStrTab->addString(S)}); if (!Config->Rpath.empty()) add({Config->EnableNewDtags ? DT_RUNPATH : DT_RPATH, - In::DynStrTab->addString(Config->Rpath)}); + InX::DynStrTab->addString(Config->Rpath)}); for (SharedFile *F : Symtab::X->getSharedFiles()) if (F->isNeeded()) - add({DT_NEEDED, In::DynStrTab->addString(F->SoName)}); + add({DT_NEEDED, InX::DynStrTab->addString(F->SoName)}); if (!Config->SoName.empty()) - add({DT_SONAME, In::DynStrTab->addString(Config->SoName)}); + add({DT_SONAME, InX::DynStrTab->addString(Config->SoName)}); if (!Config->Shared && !Config->Relocatable) add({DT_DEBUG, (uint64_t)0}); @@ -1072,7 +1072,7 @@ template void DynamicSection::finalizeContents() { if (DtFlags1) add({DT_FLAGS_1, DtFlags1}); - this->Link = In::DynStrTab->OutSec->SectionIndex; + this->Link = InX::DynStrTab->OutSec->SectionIndex; if (In::RelaDyn->OutSec->Size > 0) { bool IsRela = Config->IsRela; add({IsRela ? DT_RELA : DT_REL, In::RelaDyn}); @@ -1099,8 +1099,8 @@ template void DynamicSection::finalizeContents() { add({DT_SYMTAB, In::DynSymTab}); add({DT_SYMENT, sizeof(Elf_Sym)}); - add({DT_STRTAB, In::DynStrTab}); - add({DT_STRSZ, In::DynStrTab->getSize()}); + add({DT_STRTAB, InX::DynStrTab}); + add({DT_STRSZ, InX::DynStrTab->getSize()}); if (!Config->ZText) add({DT_TEXTREL, (uint64_t)0}); if (In::GnuHashTab) @@ -1149,8 +1149,8 @@ template void DynamicSection::finalizeContents() { else add({DT_MIPS_GOTSYM, In::DynSymTab->getNumSymbols()}); add({DT_PLTGOT, InX::MipsGot}); - if (In::MipsRldMap) - add({DT_MIPS_RLD_MAP, In::MipsRldMap}); + if (InX::MipsRldMap) + add({DT_MIPS_RLD_MAP, InX::MipsRldMap}); } this->OutSec->Link = this->Link; @@ -1951,11 +1951,11 @@ static StringRef getFileDefName() { } template void VersionDefinitionSection::finalizeContents() { - FileDefNameOff = In::DynStrTab->addString(getFileDefName()); + FileDefNameOff = InX::DynStrTab->addString(getFileDefName()); for (VersionDefinition &V : Config->VersionDefinitions) - V.NameOff = In::DynStrTab->addString(V.Name); + V.NameOff = InX::DynStrTab->addString(V.Name); - this->OutSec->Link = In::DynStrTab->OutSec->SectionIndex; + this->OutSec->Link = InX::DynStrTab->OutSec->SectionIndex; // sh_info should be set to the number of definitions. This fact is missed in // documentation, but confirmed by binutils community: @@ -2051,14 +2051,14 @@ void VersionNeedSection::addSymbol(SharedSymbol *SS) { // to create one by adding it to our needed list and creating a dynstr entry // for the soname. if (File->VerdefMap.empty()) - Needed.push_back({File, In::DynStrTab->addString(File->SoName)}); + Needed.push_back({File, InX::DynStrTab->addString(File->SoName)}); typename SharedFile::NeededVer &NV = File->VerdefMap[Ver]; // If we don't already know that we need an Elf_Vernaux for this Elf_Verdef, // prepare to create one by allocating a version identifier and creating a // dynstr entry for the version name. if (NV.Index == 0) { - NV.StrTab = In::DynStrTab->addString(File->getStringTable().data() + - Ver->getAux()->vda_name); + NV.StrTab = InX::DynStrTab->addString(File->getStringTable().data() + + Ver->getAux()->vda_name); NV.Index = NextIndex++; } SS->symbol()->VersionId = NV.Index; @@ -2100,7 +2100,7 @@ template void VersionNeedSection::writeTo(uint8_t *Buf) { } template void VersionNeedSection::finalizeContents() { - this->OutSec->Link = In::DynStrTab->OutSec->SectionIndex; + this->OutSec->Link = InX::DynStrTab->OutSec->SectionIndex; this->OutSec->Info = Needed.size(); } diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index 7a70bb9e8771..21efc226a12a 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -461,7 +461,7 @@ void X86TargetInfo::writePltHeader(uint8_t *Buf) const { memcpy(Buf, V, sizeof(V)); uint32_t Ebx = In::Got->getVA() + In::Got->getSize(); - uint32_t GotPlt = In::GotPlt->getVA() - Ebx; + uint32_t GotPlt = InX::GotPlt->getVA() - Ebx; write32le(Buf + 2, GotPlt + 4); write32le(Buf + 8, GotPlt + 8); return; @@ -473,7 +473,7 @@ void X86TargetInfo::writePltHeader(uint8_t *Buf) const { 0x90, 0x90, 0x90, 0x90 // nop }; memcpy(Buf, PltData, sizeof(PltData)); - uint32_t GotPlt = In::GotPlt->getVA(); + uint32_t GotPlt = InX::GotPlt->getVA(); write32le(Buf + 2, GotPlt + 4); write32le(Buf + 8, GotPlt + 8); } @@ -737,7 +737,7 @@ void X86_64TargetInfo::writePltHeader(uint8_t *Buf) const { }; memcpy(Buf, PltData, sizeof(PltData)); uint64_t GotPlt = InX::GotPlt->getVA(); - uint64_t Plt = In::Plt->getVA(); + uint64_t Plt = InX::Plt->getVA(); write32le(Buf + 2, GotPlt - Plt + 2); // GOTPLT+8 write32le(Buf + 8, GotPlt - Plt + 4); // GOTPLT+16 } @@ -1369,7 +1369,7 @@ bool AArch64TargetInfo::isPicRel(uint32_t Type) const { } void AArch64TargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &) const { - write64le(Buf, In::Plt->getVA()); + write64le(Buf, InX::Plt->getVA()); } // Page(Expr) is the page address of the expression Expr, defined @@ -1392,8 +1392,8 @@ void AArch64TargetInfo::writePltHeader(uint8_t *Buf) const { }; memcpy(Buf, PltData, sizeof(PltData)); - uint64_t Got = In::GotPlt->getVA(); - uint64_t Plt = In::Plt->getVA(); + uint64_t Got = InX::GotPlt->getVA(); + uint64_t Plt = InX::Plt->getVA(); relocateOne(Buf + 4, R_AARCH64_ADR_PREL_PG_HI21, getAArch64Page(Got + 16) - getAArch64Page(Plt + 4)); relocateOne(Buf + 8, R_AARCH64_LDST64_ABS_LO12_NC, Got + 16); @@ -1746,7 +1746,7 @@ uint32_t ARMTargetInfo::getDynRel(uint32_t Type) const { } void ARMTargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &) const { - write32le(Buf, In::Plt->getVA()); + write32le(Buf, InX::Plt->getVA()); } void ARMTargetInfo::writeIgotPlt(uint8_t *Buf, const SymbolBody &S) const { @@ -1763,8 +1763,8 @@ void ARMTargetInfo::writePltHeader(uint8_t *Buf) const { 0x00, 0x00, 0x00, 0x00, // L2: .word &(.got.plt) - L1 - 8 }; memcpy(Buf, PltData, sizeof(PltData)); - uint64_t GotPlt = In::GotPlt->getVA(); - uint64_t L1 = In::Plt->getVA() + 8; + uint64_t GotPlt = InX::GotPlt->getVA(); + uint64_t L1 = InX::Plt->getVA() + 8; write32le(Buf + 16, GotPlt - L1 - 8); } @@ -2134,7 +2134,7 @@ uint32_t MipsTargetInfo::getDynRel(uint32_t Type) const { template void MipsTargetInfo::writeGotPlt(uint8_t *Buf, const SymbolBody &) const { - write32(Buf, In::Plt->getVA()); + write32(Buf, InX::Plt->getVA()); } template diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 6c119b14b169..54688dc08659 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -312,11 +312,11 @@ template void Writer::createSyntheticSections() { auto Add = [](InputSectionBase *Sec) { InputSections.push_back(Sec); }; - In::DynStrTab = make(".dynstr", true); + InX::DynStrTab = make(".dynstr", true); In::Dynamic = make>(); In::RelaDyn = make>( Config->IsRela ? ".rela.dyn" : ".rel.dyn", Config->ZCombreloc); - In::ShStrTab = make(".shstrtab", false); + InX::ShStrTab = make(".shstrtab", false); Out::ElfHeader = make("", 0, SHF_ALLOC); Out::ElfHeader->Size = sizeof(Elf_Ehdr); @@ -324,41 +324,41 @@ template void Writer::createSyntheticSections() { Out::ProgramHeaders->updateAlignment(Config->Wordsize); if (needsInterpSection()) { - In::Interp = createInterpSection(); - Add(In::Interp); + InX::Interp = createInterpSection(); + Add(InX::Interp); } else { - In::Interp = nullptr; + InX::Interp = nullptr; } if (!Config->Relocatable) Add(createCommentSection()); if (Config->Strip != StripPolicy::All) { - In::StrTab = make(".strtab", false); - In::SymTab = make>(*In::StrTab); + InX::StrTab = make(".strtab", false); + In::SymTab = make>(*InX::StrTab); } if (Config->BuildId != BuildIdKind::None) { - In::BuildId = make(); - Add(In::BuildId); + InX::BuildId = make(); + Add(InX::BuildId); } - In::Common = createCommonSection(); - if (In::Common) + InX::Common = createCommonSection(); + if (InX::Common) Add(InX::Common); - In::Bss = make(".bss"); - Add(In::Bss); - In::BssRelRo = make(".bss.rel.ro"); - Add(In::BssRelRo); + InX::Bss = make(".bss"); + Add(InX::Bss); + InX::BssRelRo = make(".bss.rel.ro"); + Add(InX::BssRelRo); // Add MIPS-specific sections. bool HasDynSymTab = !Symtab::X->getSharedFiles().empty() || Config->Pic || Config->ExportDynamic; if (Config->EMachine == EM_MIPS) { if (!Config->Shared && HasDynSymTab) { - In::MipsRldMap = make(); - Add(In::MipsRldMap); + InX::MipsRldMap = make(); + Add(InX::MipsRldMap); } if (auto *Sec = MipsAbiFlagsSection::create()) Add(Sec); @@ -369,7 +369,7 @@ template void Writer::createSyntheticSections() { } if (HasDynSymTab) { - In::DynSymTab = make>(*In::DynStrTab); + In::DynSymTab = make>(*InX::DynStrTab); Add(In::DynSymTab); In::VerSym = make>(); @@ -394,7 +394,7 @@ template void Writer::createSyntheticSections() { } Add(In::Dynamic); - Add(In::DynStrTab); + Add(InX::DynStrTab); Add(In::RelaDyn); } @@ -410,12 +410,12 @@ template void Writer::createSyntheticSections() { InX::GotPlt = make(); Add(InX::GotPlt); - In::IgotPlt = make(); - Add(In::IgotPlt); + InX::IgotPlt = make(); + Add(InX::IgotPlt); if (Config->GdbIndex) { - In::GdbIndex = make(); - Add(In::GdbIndex); + InX::GdbIndex = make(); + Add(InX::GdbIndex); } // We always need to add rel[a].plt to output if it has entries. @@ -431,10 +431,10 @@ template void Writer::createSyntheticSections() { false /*Sort*/); Add(In::RelaIplt); - In::Plt = make(Target->PltHeaderSize); - Add(In::Plt); - In::Iplt = make(0); - Add(In::Iplt); + InX::Plt = make(Target->PltHeaderSize); + Add(InX::Plt); + InX::Iplt = make(0); + Add(InX::Iplt); if (!Config->Relocatable) { if (Config->EhFrameHdr) { @@ -447,9 +447,9 @@ template void Writer::createSyntheticSections() { if (In::SymTab) Add(In::SymTab); - Add(In::ShStrTab); - if (In::StrTab) - Add(In::StrTab); + Add(InX::ShStrTab); + if (InX::StrTab) + Add(InX::StrTab); } static bool shouldKeepInSymtab(SectionBase *Sec, StringRef SymName, @@ -633,7 +633,7 @@ template bool elf::isRelroSection(const OutputSection *Sec) { // Since the dynamic linker needs to process copy relocations, the // section cannot be read-only, but once initialized, they shouldn't // change. - if (Sec == In::BssRelRo->OutSec) + if (Sec == InX::BssRelRo->OutSec) return true; // Sections with some special names are put into RELRO. This is a @@ -1125,10 +1125,10 @@ template void Writer::finalizeSections() { // we can correctly decide if a dynamic relocation is needed. forEachRelSec(scanRelocations); - if (In::Plt && !In::Plt->empty()) - In::Plt->addSymbols(); - if (In::Iplt && !In::Iplt->empty()) - In::Iplt->addSymbols(); + if (InX::Plt && !InX::Plt->empty()) + InX::Plt->addSymbols(); + if (InX::Iplt && !InX::Iplt->empty()) + InX::Iplt->addSymbols(); // Now that we have defined all possible global symbols including linker- // synthesized ones. Visit all symbols to give the finishing touches. @@ -1167,7 +1167,7 @@ template void Writer::finalizeSections() { unsigned I = 1; for (OutputSection *Sec : OutputSections) { Sec->SectionIndex = I++; - Sec->ShName = In::ShStrTab->addString(Sec->Name); + Sec->ShName = InX::ShStrTab->addString(Sec->Name); } // Binary and relocatable output does not have PHDRS. @@ -1181,15 +1181,14 @@ template void Writer::finalizeSections() { // Dynamic section must be the last one in this list and dynamic // symbol table section (DynSymTab) must be the first one. - applySynthetic({In::DynSymTab, In::Bss, In::BssRelRo, + applySynthetic({In::DynSymTab, InX::Bss, InX::BssRelRo, In::GnuHashTab, In::HashTab, In::SymTab, - In::ShStrTab, In::StrTab, In::VerDef, - In::DynStrTab, In::GdbIndex, In::Got, - InX::MipsGot, In::IgotPlt, InX::GotPlt, + InX::ShStrTab, InX::StrTab, In::VerDef, + InX::DynStrTab, InX::GdbIndex, In::Got, + InX::MipsGot, InX::IgotPlt, InX::GotPlt, In::RelaDyn, In::RelaIplt, In::RelaPlt, - In::Plt, In::Iplt, In::Plt, - In::EhFrameHdr, In::VerSym, In::VerNeed, - In::Dynamic}, + InX::Plt, InX::Iplt, In::EhFrameHdr, + In::VerSym, In::VerNeed, In::Dynamic}, [](SyntheticSection *SS) { SS->finalizeContents(); }); // Some architectures use small displacements for jump instructions. @@ -1220,7 +1219,7 @@ template void Writer::finalizeSections() { [](OutputSection *S) { S->maybeCompress(); }); // createThunks may have added local symbols to the static symbol table - applySynthetic({In::SymTab, In::ShStrTab, In::StrTab}, + applySynthetic({In::SymTab, InX::ShStrTab, InX::StrTab}, [](SyntheticSection *SS) { SS->postThunkContents(); }); } @@ -1655,7 +1654,7 @@ template void Writer::writeHeader() { EHdr->e_phnum = Phdrs.size(); EHdr->e_shentsize = sizeof(Elf_Shdr); EHdr->e_shnum = OutputSections.size() + 1; - EHdr->e_shstrndx = In::ShStrTab->OutSec->SectionIndex; + EHdr->e_shstrndx = InX::ShStrTab->OutSec->SectionIndex; if (Config->EMachine == EM_ARM) // We don't currently use any features incompatible with EF_ARM_EABI_VER5, @@ -1749,13 +1748,13 @@ template void Writer::writeSections() { } template void Writer::writeBuildId() { - if (!In::BuildId || !In::BuildId->OutSec) + if (!InX::BuildId || !InX::BuildId->OutSec) return; // Compute a hash of all sections of the output file. uint8_t *Start = Buffer->getBufferStart(); uint8_t *End = Start + FileSize; - In::BuildId->writeBuildId({Start, End}); + InX::BuildId->writeBuildId({Start, End}); } template void elf::writeResult();