From owner-svn-src-vendor@freebsd.org Tue May 16 19:47:45 2017 Return-Path: Delivered-To: svn-src-vendor@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A72A2D704B4; Tue, 16 May 2017 19:47:45 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 44D2D1FC0; Tue, 16 May 2017 19:47:45 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4GJli2Q097332; Tue, 16 May 2017 19:47:44 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4GJlg3g097308; Tue, 16 May 2017 19:47:42 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201705161947.v4GJlg3g097308@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Tue, 16 May 2017 19:47:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r318376 - in vendor/lld/dist: COFF ELF docs include/lld/Core lib/Core lib/ReaderWriter/MachO test/COFF test/ELF test/ELF/Inputs test/ELF/linkerscript unittests unittests/CoreTests X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 May 2017 19:47:45 -0000 Author: dim Date: Tue May 16 19:47:41 2017 New Revision: 318376 URL: https://svnweb.freebsd.org/changeset/base/318376 Log: Vendor import of lld trunk r303197: https://llvm.org/svn/llvm-project/lld/trunk@303197 Added: vendor/lld/dist/test/ELF/gdb-index-empty.s (contents, props changed) vendor/lld/dist/test/ELF/gdb-index-gc-sections.s (contents, props changed) vendor/lld/dist/test/ELF/linkerscript/early-assign-symbol.s (contents, props changed) vendor/lld/dist/test/ELF/linkerscript/symbol-memoryexpr.s (contents, props changed) vendor/lld/dist/test/ELF/many-alloc-sections.s (contents, props changed) vendor/lld/dist/test/ELF/x86-64-reloc-tpoff32-fpic.s (contents, props changed) Deleted: vendor/lld/dist/include/lld/Core/Parallel.h vendor/lld/dist/include/lld/Core/TaskGroup.h vendor/lld/dist/lib/Core/TaskGroup.cpp vendor/lld/dist/test/COFF/constant-export.yaml vendor/lld/dist/test/ELF/Inputs/i386-static-tls-model1.s vendor/lld/dist/test/ELF/Inputs/i386-static-tls-model2.s vendor/lld/dist/test/ELF/Inputs/i386-static-tls-model3.s vendor/lld/dist/test/ELF/Inputs/i386-static-tls-model4.s vendor/lld/dist/test/ELF/i386-static-tls-model.s vendor/lld/dist/unittests/CoreTests/ Modified: vendor/lld/dist/COFF/Driver.cpp vendor/lld/dist/COFF/ICF.cpp vendor/lld/dist/COFF/MapFile.cpp vendor/lld/dist/COFF/Writer.cpp vendor/lld/dist/ELF/Config.h vendor/lld/dist/ELF/Driver.cpp vendor/lld/dist/ELF/GdbIndex.h vendor/lld/dist/ELF/ICF.cpp vendor/lld/dist/ELF/InputFiles.cpp vendor/lld/dist/ELF/InputSection.cpp vendor/lld/dist/ELF/LinkerScript.cpp vendor/lld/dist/ELF/LinkerScript.h vendor/lld/dist/ELF/MapFile.cpp vendor/lld/dist/ELF/OutputSections.cpp vendor/lld/dist/ELF/OutputSections.h vendor/lld/dist/ELF/Relocations.cpp vendor/lld/dist/ELF/ScriptParser.cpp vendor/lld/dist/ELF/Strings.cpp vendor/lld/dist/ELF/Symbols.cpp vendor/lld/dist/ELF/Symbols.h vendor/lld/dist/ELF/SyntheticSections.cpp vendor/lld/dist/ELF/SyntheticSections.h vendor/lld/dist/ELF/Target.cpp vendor/lld/dist/ELF/Threads.h vendor/lld/dist/ELF/Thunks.cpp vendor/lld/dist/ELF/Writer.cpp vendor/lld/dist/ELF/Writer.h vendor/lld/dist/docs/CMakeLists.txt vendor/lld/dist/lib/Core/CMakeLists.txt vendor/lld/dist/lib/ReaderWriter/MachO/LayoutPass.cpp vendor/lld/dist/test/COFF/constant-export.test vendor/lld/dist/test/ELF/i386-tls-ie-shared.s vendor/lld/dist/test/ELF/incompatible-section-types2.s vendor/lld/dist/test/ELF/linkerscript/ehdr_start.s vendor/lld/dist/test/ELF/linkerscript/sections-constraint.s vendor/lld/dist/test/ELF/linkerscript/sections.s vendor/lld/dist/test/ELF/many-sections.s vendor/lld/dist/test/ELF/tls-dynamic-i686.s vendor/lld/dist/test/ELF/tls-opt-iele-i686-nopic.s vendor/lld/dist/unittests/CMakeLists.txt Modified: vendor/lld/dist/COFF/Driver.cpp ============================================================================== --- vendor/lld/dist/COFF/Driver.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/COFF/Driver.cpp Tue May 16 19:47:41 2017 (r318376) @@ -18,7 +18,6 @@ #include "lld/Driver/Driver.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringSwitch.h" -#include "llvm/LibDriver/LibDriver.h" #include "llvm/Object/ArchiveWriter.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" @@ -29,6 +28,7 @@ #include "llvm/Support/TarWriter.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/ToolDrivers/llvm-lib/LibDriver.h" #include #include Modified: vendor/lld/dist/COFF/ICF.cpp ============================================================================== --- vendor/lld/dist/COFF/ICF.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/COFF/ICF.cpp Tue May 16 19:47:41 2017 (r318376) @@ -21,9 +21,9 @@ #include "Chunks.h" #include "Error.h" #include "Symbols.h" -#include "lld/Core/Parallel.h" #include "llvm/ADT/Hashing.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/Parallel.h" #include "llvm/Support/raw_ostream.h" #include #include @@ -192,7 +192,7 @@ void ICF::forEachClass(std::function getSymbolStrings(ArrayRef Syms) { std::vector Str(Syms.size()); - parallel_for((size_t)0, Syms.size(), [&](size_t I) { + for_each_n(parallel::par, (size_t)0, Syms.size(), [&](size_t I) { raw_string_ostream OS(Str[I]); writeHeader(OS, Syms[I]->getRVA(), 0, 0); OS << indent(2) << toString(*Syms[I]); Modified: vendor/lld/dist/COFF/Writer.cpp ============================================================================== --- vendor/lld/dist/COFF/Writer.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/COFF/Writer.cpp Tue May 16 19:47:41 2017 (r318376) @@ -17,13 +17,13 @@ #include "PDB.h" #include "SymbolTable.h" #include "Symbols.h" -#include "lld/Core/Parallel.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Endian.h" #include "llvm/Support/FileOutputBuffer.h" +#include "llvm/Support/Parallel.h" #include "llvm/Support/RandomNumberGenerator.h" #include "llvm/Support/raw_ostream.h" #include @@ -745,8 +745,8 @@ void Writer::writeSections() { // ADD instructions). if (Sec->getPermissions() & IMAGE_SCN_CNT_CODE) memset(SecBuf, 0xCC, Sec->getRawSize()); - parallel_for_each(Sec->getChunks().begin(), Sec->getChunks().end(), - [&](Chunk *C) { C->writeTo(SecBuf); }); + for_each(parallel::par, Sec->getChunks().begin(), Sec->getChunks().end(), + [&](Chunk *C) { C->writeTo(SecBuf); }); } } @@ -760,16 +760,14 @@ void Writer::sortExceptionTable() { uint8_t *End = Begin + Sec->getVirtualSize(); if (Config->Machine == AMD64) { struct Entry { ulittle32_t Begin, End, Unwind; }; - parallel_sort( - (Entry *)Begin, (Entry *)End, - [](const Entry &A, const Entry &B) { return A.Begin < B.Begin; }); + sort(parallel::par, (Entry *)Begin, (Entry *)End, + [](const Entry &A, const Entry &B) { return A.Begin < B.Begin; }); return; } if (Config->Machine == ARMNT) { struct Entry { ulittle32_t Begin, Unwind; }; - parallel_sort( - (Entry *)Begin, (Entry *)End, - [](const Entry &A, const Entry &B) { return A.Begin < B.Begin; }); + sort(parallel::par, (Entry *)Begin, (Entry *)End, + [](const Entry &A, const Entry &B) { return A.Begin < B.Begin; }); return; } errs() << "warning: don't know how to handle .pdata.\n"; Modified: vendor/lld/dist/ELF/Config.h ============================================================================== --- vendor/lld/dist/ELF/Config.h Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/Config.h Tue May 16 19:47:41 2017 (r318376) @@ -73,7 +73,6 @@ struct VersionDefinition { // Most fields are initialized by the driver. struct Configuration { InputFile *FirstElf = nullptr; - bool HasStaticTlsModel = false; uint8_t OSABI = 0; llvm::CachePruningPolicy ThinLTOCachePolicy; llvm::StringMap SectionStartMap; Modified: vendor/lld/dist/ELF/Driver.cpp ============================================================================== --- vendor/lld/dist/ELF/Driver.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/Driver.cpp Tue May 16 19:47:41 2017 (r318376) @@ -284,7 +284,7 @@ static int getInteger(opt::InputArgList int V = Default; if (auto *Arg = Args.getLastArg(Key)) { StringRef S = Arg->getValue(); - if (S.getAsInteger(10, V)) + if (!to_integer(S, V, 10)) error(Arg->getSpelling() + ": number expected, but got " + S); } return V; @@ -311,7 +311,7 @@ static uint64_t getZOptionValue(opt::Inp if (Pos != StringRef::npos && Key == Value.substr(0, Pos)) { Value = Value.substr(Pos + 1); uint64_t Result; - if (Value.getAsInteger(0, Result)) + if (!to_integer(Value, Result)) error("invalid " + Key + ": " + Value); return Result; } @@ -522,7 +522,7 @@ static uint64_t parseSectionAddress(Stri uint64_t VA = 0; if (S.startswith("0x")) S = S.drop_front(2); - if (S.getAsInteger(16, VA)) + if (!to_integer(S, VA, 16)) error("invalid argument: " + toString(Arg)); return VA; } @@ -886,7 +886,7 @@ static uint64_t getImageBase(opt::InputA StringRef S = Arg->getValue(); uint64_t V; - if (S.getAsInteger(0, V)) { + if (!to_integer(S, V)) { error("-image-base: number expected, but got " + S); return 0; } Modified: vendor/lld/dist/ELF/GdbIndex.h ============================================================================== --- vendor/lld/dist/ELF/GdbIndex.h Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/GdbIndex.h Tue May 16 19:47:41 2017 (r318376) @@ -21,7 +21,7 @@ class InputSection; // Struct represents single entry of address area of gdb index. struct AddressEntry { - InputSectionBase *Section; + InputSection *Section; uint64_t LowAddress; uint64_t HighAddress; size_t CuIndex; Modified: vendor/lld/dist/ELF/ICF.cpp ============================================================================== --- vendor/lld/dist/ELF/ICF.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/ICF.cpp Tue May 16 19:47:41 2017 (r318376) @@ -325,7 +325,7 @@ void ICF::forEachClass(std::functi // Split sections into 256 shards and call Fn in parallel. size_t NumShards = 256; size_t Step = Sections.size() / NumShards; - parallelFor(0, NumShards, [&](size_t I) { + parallelForEachN(0, NumShards, [&](size_t I) { forEachClassRange(I * Step, (I + 1) * Step, Fn); }); forEachClassRange(Step * NumShards, Sections.size(), Fn); Modified: vendor/lld/dist/ELF/InputFiles.cpp ============================================================================== --- vendor/lld/dist/ELF/InputFiles.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/InputFiles.cpp Tue May 16 19:47:41 2017 (r318376) @@ -383,9 +383,9 @@ elf::ObjectFile::createInputSectio // 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: Modified: vendor/lld/dist/ELF/InputSection.cpp ============================================================================== --- vendor/lld/dist/ELF/InputSection.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/InputSection.cpp Tue May 16 19:47:41 2017 (r318376) @@ -324,7 +324,7 @@ void InputSection::copyRelocations(uint8 // section, but for --emit-relocs it is an virtual address. P->r_offset = RelocatedSection->OutSec->Addr + RelocatedSection->getOffset(Rel.r_offset); - P->setSymbolAndType(In::SymTab->getSymbolIndex(&Body), Type, + P->setSymbolAndType(InX::SymTab->getSymbolIndex(&Body), Type, Config->IsMips64EL); if (Body.Type == STT_SECTION) { @@ -400,40 +400,40 @@ getRelocTargetVA(uint32_t Type, int64_t return Body.getVA(A); case R_GOT: case R_RELAX_TLS_GD_TO_IE_ABS: - return Body.getGotVA() + A; + return Body.getGotVA() + A; case R_GOTONLY_PC: - return In::Got->getVA() + A - P; + return InX::Got->getVA() + A - P; case R_GOTONLY_PC_FROM_END: - return In::Got->getVA() + A - P + In::Got->getSize(); + return InX::Got->getVA() + A - P + InX::Got->getSize(); case R_GOTREL: - return Body.getVA(A) - In::Got->getVA(); + return Body.getVA(A) - InX::Got->getVA(); case R_GOTREL_FROM_END: - return Body.getVA(A) - In::Got->getVA() - In::Got->getSize(); + return Body.getVA(A) - InX::Got->getVA() - InX::Got->getSize(); case R_GOT_FROM_END: case R_RELAX_TLS_GD_TO_IE_END: - return Body.getGotOffset() + A - In::Got->getSize(); + return Body.getGotOffset() + A - InX::Got->getSize(); case R_GOT_OFF: return Body.getGotOffset() + A; case R_GOT_PAGE_PC: case R_RELAX_TLS_GD_TO_IE_PAGE_PC: - return getAArch64Page(Body.getGotVA() + A) - getAArch64Page(P); + return getAArch64Page(Body.getGotVA() + A) - getAArch64Page(P); case R_GOT_PC: case R_RELAX_TLS_GD_TO_IE: - return Body.getGotVA() + A - P; + return Body.getGotVA() + A - P; case R_HINT: case R_NONE: case R_TLSDESC_CALL: llvm_unreachable("cannot relocate hint relocs"); case R_MIPS_GOTREL: - return Body.getVA(A) - In::MipsGot->getGp(); + return Body.getVA(A) - InX::MipsGot->getGp(); case R_MIPS_GOT_GP: - return In::MipsGot->getGp() + A; + return InX::MipsGot->getGp() + A; case R_MIPS_GOT_GP_PC: { // R_MIPS_LO16 expression has R_MIPS_GOT_GP_PC type iif the target // is _gp_disp symbol. In that case we should use the following // formula for calculation "AHL + GP - P + 4". For details see p. 4-19 at // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf - uint64_t V = In::MipsGot->getGp() + A - P; + uint64_t V = InX::MipsGot->getGp() + A - P; if (Type == R_MIPS_LO16) V += 4; return V; @@ -442,24 +442,21 @@ getRelocTargetVA(uint32_t Type, int64_t // If relocation against MIPS local symbol requires GOT entry, this entry // should be initialized by 'page address'. This address is high 16-bits // of sum the symbol's value and the addend. - return In::MipsGot->getVA() + - In::MipsGot->getPageEntryOffset(Body, A) - - In::MipsGot->getGp(); + return InX::MipsGot->getVA() + InX::MipsGot->getPageEntryOffset(Body, A) - + InX::MipsGot->getGp(); case R_MIPS_GOT_OFF: case R_MIPS_GOT_OFF32: // In case of MIPS if a GOT relocation has non-zero addend this addend // should be applied to the GOT entry content not to the GOT entry offset. // That is why we use separate expression type. - return In::MipsGot->getVA() + - In::MipsGot->getBodyEntryOffset(Body, A) - - In::MipsGot->getGp(); + return InX::MipsGot->getVA() + InX::MipsGot->getBodyEntryOffset(Body, A) - + InX::MipsGot->getGp(); case R_MIPS_TLSGD: - return In::MipsGot->getVA() + In::MipsGot->getTlsOffset() + - In::MipsGot->getGlobalDynOffset(Body) - - In::MipsGot->getGp(); + return InX::MipsGot->getVA() + InX::MipsGot->getTlsOffset() + + InX::MipsGot->getGlobalDynOffset(Body) - InX::MipsGot->getGp(); case R_MIPS_TLSLD: - return In::MipsGot->getVA() + In::MipsGot->getTlsOffset() + - In::MipsGot->getTlsIndexOff() - In::MipsGot->getGp(); + return InX::MipsGot->getVA() + InX::MipsGot->getTlsOffset() + + InX::MipsGot->getTlsIndexOff() - InX::MipsGot->getGp(); case R_PAGE_PC: case R_PLT_PAGE_PC: if (Body.isUndefined() && !Body.isLocal() && Body.symbol()->isWeak()) @@ -523,19 +520,18 @@ getRelocTargetVA(uint32_t Type, int64_t case R_SIZE: return Body.getSize() + A; case R_TLSDESC: - return In::Got->getGlobalDynAddr(Body) + A; + return InX::Got->getGlobalDynAddr(Body) + A; case R_TLSDESC_PAGE: - return getAArch64Page(In::Got->getGlobalDynAddr(Body) + A) - + return getAArch64Page(InX::Got->getGlobalDynAddr(Body) + A) - getAArch64Page(P); case R_TLSGD: - return In::Got->getGlobalDynOffset(Body) + A - - In::Got->getSize(); + return InX::Got->getGlobalDynOffset(Body) + A - InX::Got->getSize(); case R_TLSGD_PC: - return In::Got->getGlobalDynAddr(Body) + A - P; + return InX::Got->getGlobalDynAddr(Body) + A - P; case R_TLSLD: - return In::Got->getTlsIndexOff() + A - In::Got->getSize(); + return InX::Got->getTlsIndexOff() + A - InX::Got->getSize(); case R_TLSLD_PC: - return In::Got->getTlsIndexVA() + A - P; + return InX::Got->getTlsIndexVA() + A - P; } llvm_unreachable("Invalid expression"); } Modified: vendor/lld/dist/ELF/LinkerScript.cpp ============================================================================== --- vendor/lld/dist/ELF/LinkerScript.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/LinkerScript.cpp Tue May 16 19:47:41 2017 (r318376) @@ -48,8 +48,12 @@ using namespace lld::elf; LinkerScript *elf::Script; uint64_t ExprValue::getValue() const { - if (Sec) - return Sec->getOffset(Val) + Sec->getOutputSection()->Addr; + if (Sec) { + if (Sec->getOutputSection()) + return Sec->getOffset(Val) + Sec->getOutputSection()->Addr; + error("unable to evaluate expression: input section " + Sec->Name + + " has no output section assigned"); + } return Val; } @@ -411,6 +415,7 @@ void LinkerScript::processCommands(Outpu if (OutputSection *Sec = Cmd->Sec) { assert(Sec->SectionIndex == INT_MAX); Sec->SectionIndex = I; + SecToCommand[Sec] = Cmd; } } } @@ -440,6 +445,7 @@ void LinkerScript::fabricateDefaultComma auto *OSCmd = make(Sec->Name); OSCmd->Sec = Sec; + SecToCommand[Sec] = OSCmd; // Prefer user supplied address over additional alignment constraint auto I = Config->SectionStartMap.find(Sec->Name); @@ -484,6 +490,7 @@ void LinkerScript::addOrphanSections(Out auto *Cmd = cast(*I); Factory.addInputSec(S, Name, Cmd->Sec); if (OutputSection *Sec = Cmd->Sec) { + SecToCommand[Sec] = Cmd; unsigned Index = std::distance(Opt.Commands.begin(), I); assert(Sec->SectionIndex == INT_MAX || Sec->SectionIndex == Index); Sec->SectionIndex = Index; @@ -699,6 +706,7 @@ void LinkerScript::adjustSectionsBeforeS OutSec->SectionIndex = I; OutputSections->push_back(OutSec); Cmd->Sec = OutSec; + SecToCommand[OutSec] = Cmd; } } @@ -822,16 +830,14 @@ void LinkerScript::placeOrphanSections() // If there is no command corresponding to this output section, // create one and put a InputSectionDescription in it so that both // representations agree on which input sections to use. - auto Pos = std::find_if(CmdIter, E, [&](BaseCommand *Base) { - auto *Cmd = dyn_cast(Base); - return Cmd && Cmd->Name == Name; - }); - if (Pos == E) { - auto *Cmd = make(Name); + OutputSectionCommand *Cmd = getCmd(Sec); + if (!Cmd) { + Cmd = make(Name); Opt.Commands.insert(CmdIter, Cmd); ++CmdIndex; Cmd->Sec = Sec; + SecToCommand[Sec] = Cmd; auto *ISD = make(""); for (InputSection *IS : Sec->Sections) ISD->Sections.push_back(IS); @@ -841,7 +847,11 @@ void LinkerScript::placeOrphanSections() } // Continue from where we found it. - CmdIndex = (Pos - Opt.Commands.begin()) + 1; + while (*CmdIter != Cmd) { + ++CmdIter; + ++CmdIndex; + } + ++CmdIndex; } } @@ -1000,7 +1010,7 @@ std::vector LinkerScript::cre break; // Assign headers specified by linker script - for (size_t Id : getPhdrIndices(Sec->Name)) { + for (size_t Id : getPhdrIndices(Sec)) { Ret[Id].add(Sec); if (Opt.PhdrsCommands[Id].Flags == UINT_MAX) Ret[Id].p_flags |= Sec->getPhdrFlags(); @@ -1020,11 +1030,16 @@ bool LinkerScript::ignoreInterpSection() return true; } -Optional LinkerScript::getFiller(StringRef Name) { - for (BaseCommand *Base : Opt.Commands) - if (auto *Cmd = dyn_cast(Base)) - if (Cmd->Name == Name) - return Cmd->Filler; +OutputSectionCommand *LinkerScript::getCmd(OutputSection *Sec) const { + auto I = SecToCommand.find(Sec); + if (I == SecToCommand.end()) + return nullptr; + return I->second; +} + +Optional LinkerScript::getFiller(OutputSection *Sec) { + if (OutputSectionCommand *Cmd = getCmd(Sec)) + return Cmd->Filler; return None; } @@ -1042,26 +1057,16 @@ static void writeInt(uint8_t *Buf, uint6 } void LinkerScript::writeDataBytes(OutputSection *Sec, uint8_t *Buf) { - auto I = std::find_if(Opt.Commands.begin(), Opt.Commands.end(), - [=](BaseCommand *Base) { - if (auto *Cmd = dyn_cast(Base)) - if (Cmd->Sec == Sec) - return true; - return false; - }); - if (I == Opt.Commands.end()) - return; - auto *Cmd = cast(*I); - for (BaseCommand *Base : Cmd->Commands) - if (auto *Data = dyn_cast(Base)) - writeInt(Buf + Data->Offset, Data->Expression().getValue(), Data->Size); + if (OutputSectionCommand *Cmd = getCmd(Sec)) + for (BaseCommand *Base : Cmd->Commands) + if (auto *Data = dyn_cast(Base)) + writeInt(Buf + Data->Offset, Data->Expression().getValue(), Data->Size); } -bool LinkerScript::hasLMA(StringRef Name) { - for (BaseCommand *Base : Opt.Commands) - if (auto *Cmd = dyn_cast(Base)) - if (Cmd->LMAExpr && Cmd->Name == Name) - return true; +bool LinkerScript::hasLMA(OutputSection *Sec) { + if (OutputSectionCommand *Cmd = getCmd(Sec)) + if (Cmd->LMAExpr) + return true; return false; } @@ -1080,15 +1085,10 @@ ExprValue LinkerScript::getSymbolValue(c bool LinkerScript::isDefined(StringRef S) { return findSymbol(S) != nullptr; } -// Returns indices of ELF headers containing specific section, identified -// by Name. Each index is a zero based number of ELF header listed within -// PHDRS {} script block. -std::vector LinkerScript::getPhdrIndices(StringRef SectionName) { - for (BaseCommand *Base : Opt.Commands) { - auto *Cmd = dyn_cast(Base); - if (!Cmd || Cmd->Name != SectionName) - continue; - +// Returns indices of ELF headers containing specific section. Each index is a +// zero based number of ELF header listed within PHDRS {} script block. +std::vector LinkerScript::getPhdrIndices(OutputSection *Sec) { + if (OutputSectionCommand *Cmd = getCmd(Sec)) { std::vector Ret; for (StringRef PhdrName : Cmd->Phdrs) Ret.push_back(getPhdrIndex(Cmd->Location, PhdrName)); Modified: vendor/lld/dist/ELF/LinkerScript.h ============================================================================== --- vendor/lld/dist/ELF/LinkerScript.h Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/LinkerScript.h Tue May 16 19:47:41 2017 (r318376) @@ -211,8 +211,9 @@ struct ScriptConfiguration { std::vector ReferencedSymbols; }; -class LinkerScript { -protected: +class LinkerScript final { + llvm::DenseMap SecToCommand; + OutputSectionCommand *getCmd(OutputSection *Sec) const; void assignSymbol(SymbolAssignment *Cmd, bool InSec); void setDot(Expr E, const Twine &Loc, bool InSec); @@ -222,7 +223,7 @@ protected: std::vector createInputSectionList(OutputSectionCommand &Cmd); - std::vector getPhdrIndices(StringRef SectionName); + std::vector getPhdrIndices(OutputSection *Sec); size_t getPhdrIndex(const Twine &Loc, StringRef PhdrName); MemoryRegion *findMemoryRegion(OutputSectionCommand *Cmd); @@ -262,8 +263,8 @@ public: std::vector createPhdrs(); bool ignoreInterpSection(); - llvm::Optional getFiller(StringRef Name); - bool hasLMA(StringRef Name); + llvm::Optional getFiller(OutputSection *Sec); + bool hasLMA(OutputSection *Sec); bool shouldKeep(InputSectionBase *S); void assignOffsets(OutputSectionCommand *Cmd); void placeOrphanSections(); Modified: vendor/lld/dist/ELF/MapFile.cpp ============================================================================== --- vendor/lld/dist/ELF/MapFile.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/MapFile.cpp Tue May 16 19:47:41 2017 (r318376) @@ -84,7 +84,7 @@ template DenseMap getSymbolStrings(ArrayRef Syms) { std::vector Str(Syms.size()); - parallelFor(0, Syms.size(), [&](size_t I) { + parallelForEachN(0, Syms.size(), [&](size_t I) { raw_string_ostream OS(Str[I]); writeHeader(OS, Syms[I]->getVA(), Syms[I]->template getSize(), 0); Modified: vendor/lld/dist/ELF/OutputSections.cpp ============================================================================== --- vendor/lld/dist/ELF/OutputSections.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/OutputSections.cpp Tue May 16 19:47:41 2017 (r318376) @@ -133,7 +133,7 @@ template void OutputSection if (isa(First)) return; - this->Link = In::SymTab->OutSec->SectionIndex; + this->Link = InX::SymTab->OutSec->SectionIndex; // sh_info for SHT_REL[A] sections should contain the section header index of // the section to which the relocation applies. InputSectionBase *S = First->getRelocatedSection(); @@ -273,7 +273,7 @@ uint32_t OutputSection::getFiller() { // linker script. If nothing is specified and this is an executable section, // fall back to trap instructions to prevent bad diassembly and detect invalid // jumps to padding. - if (Optional Filler = Script->getFiller(Name)) + if (Optional Filler = Script->getFiller(this)) return *Filler; if (Flags & SHF_EXECINSTR) return Target->TrapInstr; @@ -297,7 +297,7 @@ template void OutputSection if (Filler) fill(Buf, Sections.empty() ? Size : Sections[0]->OutSecOff, Filler); - parallelFor(0, Sections.size(), [=](size_t I) { + parallelForEachN(0, Sections.size(), [=](size_t I) { InputSection *Sec = Sections[I]; Sec->writeTo(Buf); @@ -429,8 +429,11 @@ void OutputSectionFactory::addInputSec(I if (canMergeToProgbits(Sec->Type) && canMergeToProgbits(IS->Type)) Sec->Type = SHT_PROGBITS; else - error("Section has different type from others with the same name " + - toString(IS)); + error("section type mismatch for " + IS->Name + + "\n>>> " + toString(IS) + ": " + + getELFSectionTypeName(Config->EMachine, IS->Type) + + "\n>>> output section " + Sec->Name + ": " + + getELFSectionTypeName(Config->EMachine, Sec->Type)); } Sec->Flags |= Flags; } else { Modified: vendor/lld/dist/ELF/OutputSections.h ============================================================================== --- vendor/lld/dist/ELF/OutputSections.h Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/OutputSections.h Tue May 16 19:47:41 2017 (r318376) @@ -50,6 +50,7 @@ public: template void writeHeaderTo(typename ELFT::Shdr *SHdr); unsigned SectionIndex; + unsigned SortRank; uint32_t getPhdrFlags() const; Modified: vendor/lld/dist/ELF/Relocations.cpp ============================================================================== --- vendor/lld/dist/ELF/Relocations.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/Relocations.cpp Tue May 16 19:47:41 2017 (r318376) @@ -106,21 +106,21 @@ static unsigned handleMipsTlsRelocation( InputSectionBase &C, uint64_t Offset, int64_t Addend, RelExpr Expr) { if (Expr == R_MIPS_TLSLD) { - if (In::MipsGot->addTlsIndex() && Config->Pic) - In::RelaDyn->addReloc({Target->TlsModuleIndexRel, In::MipsGot, - In::MipsGot->getTlsIndexOff(), false, + if (InX::MipsGot->addTlsIndex() && Config->Pic) + In::RelaDyn->addReloc({Target->TlsModuleIndexRel, InX::MipsGot, + InX::MipsGot->getTlsIndexOff(), false, nullptr, 0}); C.Relocations.push_back({Expr, Type, Offset, Addend, &Body}); return 1; } if (Expr == R_MIPS_TLSGD) { - if (In::MipsGot->addDynTlsEntry(Body) && Body.isPreemptible()) { - uint64_t Off = In::MipsGot->getGlobalDynOffset(Body); + if (InX::MipsGot->addDynTlsEntry(Body) && Body.isPreemptible()) { + uint64_t Off = InX::MipsGot->getGlobalDynOffset(Body); In::RelaDyn->addReloc( - {Target->TlsModuleIndexRel, In::MipsGot, Off, false, &Body, 0}); + {Target->TlsModuleIndexRel, InX::MipsGot, Off, false, &Body, 0}); if (Body.isPreemptible()) - In::RelaDyn->addReloc({Target->TlsOffsetRel, In::MipsGot, + In::RelaDyn->addReloc({Target->TlsOffsetRel, InX::MipsGot, Off + Config->Wordsize, false, &Body, 0}); } C.Relocations.push_back({Expr, Type, Offset, Addend, &Body}); @@ -156,17 +156,17 @@ static unsigned handleARMTlsRelocation(u auto AddTlsReloc = [&](uint64_t Off, uint32_t Type, SymbolBody *Dest, bool Dyn) { if (Dyn) - In::RelaDyn->addReloc({Type, In::Got, Off, false, Dest, 0}); + In::RelaDyn->addReloc({Type, InX::Got, Off, false, Dest, 0}); else - In::Got->Relocations.push_back({R_ABS, Type, Off, 0, Dest}); + InX::Got->Relocations.push_back({R_ABS, Type, Off, 0, Dest}); }; // Local Dynamic is for access to module local TLS variables, while still // being suitable for being dynamically loaded via dlopen. // GOT[e0] is the module index, with a special value of 0 for the current // module. GOT[e1] is unused. There only needs to be one module index entry. - if (Expr == R_TLSLD_PC && In::Got->addTlsIndex()) { - AddTlsReloc(In::Got->getTlsIndexOff(), Target->TlsModuleIndexRel, + if (Expr == R_TLSLD_PC && InX::Got->addTlsIndex()) { + AddTlsReloc(InX::Got->getTlsIndexOff(), Target->TlsModuleIndexRel, NeedDynId ? nullptr : &Body, NeedDynId); C.Relocations.push_back({Expr, Type, Offset, Addend, &Body}); return 1; @@ -176,8 +176,8 @@ static unsigned handleARMTlsRelocation(u // the module index and offset of symbol in TLS block we can fill these in // using static GOT relocations. if (Expr == R_TLSGD_PC) { - if (In::Got->addDynTlsEntry(Body)) { - uint64_t Off = In::Got->getGlobalDynOffset(Body); + if (InX::Got->addDynTlsEntry(Body)) { + uint64_t Off = InX::Got->getGlobalDynOffset(Body); AddTlsReloc(Off, Target->TlsModuleIndexRel, &Body, NeedDynId); AddTlsReloc(Off + Config->Wordsize, Target->TlsOffsetRel, &Body, NeedDynOff); @@ -207,10 +207,10 @@ handleTlsRelocation(uint32_t Type, Symbo bool IsPreemptible = isPreemptible(Body, Type); if (isRelExprOneOf(Expr) && Config->Shared) { - if (In::Got->addDynTlsEntry(Body)) { - uint64_t Off = In::Got->getGlobalDynOffset(Body); - In::RelaDyn->addReloc({Target->TlsDescRel, In::Got, Off, - !IsPreemptible, &Body, 0}); + if (InX::Got->addDynTlsEntry(Body)) { + uint64_t Off = InX::Got->getGlobalDynOffset(Body); + In::RelaDyn->addReloc( + {Target->TlsDescRel, InX::Got, Off, !IsPreemptible, &Body, 0}); } if (Expr != R_TLSDESC_CALL) C.Relocations.push_back({Expr, Type, Offset, Addend, &Body}); @@ -224,10 +224,10 @@ handleTlsRelocation(uint32_t Type, Symbo {R_RELAX_TLS_LD_TO_LE, Type, Offset, Addend, &Body}); return 2; } - if (In::Got->addTlsIndex()) - In::RelaDyn->addReloc({Target->TlsModuleIndexRel, In::Got, - In::Got->getTlsIndexOff(), false, - nullptr, 0}); + if (InX::Got->addTlsIndex()) + In::RelaDyn->addReloc({Target->TlsModuleIndexRel, InX::Got, + InX::Got->getTlsIndexOff(), false, nullptr, + 0}); C.Relocations.push_back({Expr, Type, Offset, Addend, &Body}); return 1; } @@ -242,19 +242,19 @@ handleTlsRelocation(uint32_t Type, Symbo if (isRelExprOneOf(Expr)) { if (Config->Shared) { - if (In::Got->addDynTlsEntry(Body)) { - uint64_t Off = In::Got->getGlobalDynOffset(Body); + if (InX::Got->addDynTlsEntry(Body)) { + uint64_t Off = InX::Got->getGlobalDynOffset(Body); In::RelaDyn->addReloc( - {Target->TlsModuleIndexRel, In::Got, Off, false, &Body, 0}); + {Target->TlsModuleIndexRel, InX::Got, Off, false, &Body, 0}); // If the symbol is preemptible we need the dynamic linker to write // the offset too. uint64_t OffsetOff = Off + Config->Wordsize; if (IsPreemptible) - In::RelaDyn->addReloc({Target->TlsOffsetRel, In::Got, - OffsetOff, false, &Body, 0}); + In::RelaDyn->addReloc( + {Target->TlsOffsetRel, InX::Got, OffsetOff, false, &Body, 0}); else - In::Got->Relocations.push_back( + InX::Got->Relocations.push_back( {R_ABS, Target->TlsOffsetRel, OffsetOff, 0, &Body}); } C.Relocations.push_back({Expr, Type, Offset, Addend, &Body}); @@ -268,8 +268,8 @@ handleTlsRelocation(uint32_t Type, Symbo {Target->adjustRelaxExpr(Type, nullptr, R_RELAX_TLS_GD_TO_IE), Type, Offset, Addend, &Body}); if (!Body.isInGot()) { - In::Got->addEntry(Body); - In::RelaDyn->addReloc({Target->TlsGotRel, In::Got, + InX::Got->addEntry(Body); + In::RelaDyn->addReloc({Target->TlsGotRel, InX::Got, Body.getGotOffset(), false, &Body, 0}); } } else { @@ -518,7 +518,7 @@ template static void addCop // 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 @@ -774,7 +774,7 @@ static void addPltEntry(PltSection *Plt, template static void addGotEntry(SymbolBody &Sym, bool Preemptible) { - In::Got->addEntry(Sym); + InX::Got->addEntry(Sym); uint64_t Off = Sym.getGotOffset(); uint32_t DynType; @@ -792,10 +792,10 @@ static void addGotEntry(SymbolBody &Sym, bool Constant = !Preemptible && !(Config->Pic && !isAbsolute(Sym)); if (!Constant) In::RelaDyn->addReloc( - {DynType, In::Got, Off, !Preemptible, &Sym, 0}); + {DynType, InX::Got, Off, !Preemptible, &Sym, 0}); if (Constant || (!Config->IsRela && !Preemptible)) - In::Got->Relocations.push_back({Expr, DynType, Off, 0, &Sym}); + InX::Got->Relocations.push_back({Expr, DynType, Off, 0, &Sym}); } // The reason we have to do this early scan is as follows @@ -856,7 +856,7 @@ static void scanRelocs(InputSectionBase // needs it to be created. Here we request for that. if (isRelExprOneOf(Expr)) - In::Got->HasGotOffRel = true; + InX::Got->HasGotOffRel = true; // Read an addend. int64_t Addend = computeAddend(Rel, Sec.Data.data()); @@ -874,11 +874,11 @@ static void scanRelocs(InputSectionBase // 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, In::GotPlt, In::RelaPlt, - Target->PltRel, Body, !Preemptible); + addPltEntry(InX::Plt, InX::GotPlt, In::RelaPlt, Target->PltRel, + Body, !Preemptible); } // Create a GOT slot if a relocation needs GOT. @@ -891,9 +891,9 @@ static void scanRelocs(InputSectionBase // See "Global Offset Table" in Chapter 5 in the following document // for detailed description: // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf - In::MipsGot->addEntry(Body, Addend, Expr); + InX::MipsGot->addEntry(Body, Addend, Expr); if (Body.isTls() && Body.isPreemptible()) - In::RelaDyn->addReloc({Target->TlsGotRel, In::MipsGot, + In::RelaDyn->addReloc({Target->TlsGotRel, InX::MipsGot, Body.getGotOffset(), false, &Body, 0}); } else if (!Body.isInGot()) { addGotEntry(Body, Preemptible); @@ -927,7 +927,7 @@ static void scanRelocs(InputSectionBase // a dynamic relocation. // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf p.4-19 if (Config->EMachine == EM_MIPS) - In::MipsGot->addEntry(Body, Addend, Expr); + InX::MipsGot->addEntry(Body, Addend, Expr); continue; } Modified: vendor/lld/dist/ELF/ScriptParser.cpp ============================================================================== --- vendor/lld/dist/ELF/ScriptParser.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/ScriptParser.cpp Tue May 16 19:47:41 2017 (r318376) @@ -639,7 +639,7 @@ ScriptParser::readOutputSectionDescripti // We are compatible with ld.gold because it's easier to implement. uint32_t ScriptParser::parseFill(StringRef Tok) { uint32_t V = 0; - if (Tok.getAsInteger(0, V)) + if (!to_integer(Tok, V)) setError("invalid filler expression: " + Tok); uint32_t Buf; @@ -778,23 +778,23 @@ static Optional parseInt(Strin // Hexadecimal uint64_t Val; - if (Tok.startswith_lower("0x") && !Tok.substr(2).getAsInteger(16, Val)) + if (Tok.startswith_lower("0x") && to_integer(Tok.substr(2), Val, 16)) return Val; - if (Tok.endswith_lower("H") && !Tok.drop_back().getAsInteger(16, Val)) + if (Tok.endswith_lower("H") && to_integer(Tok.drop_back(), Val, 16)) return Val; // Decimal if (Tok.endswith_lower("K")) { - if (Tok.drop_back().getAsInteger(10, Val)) + if (!to_integer(Tok.drop_back(), Val, 10)) return None; return Val * 1024; } if (Tok.endswith_lower("M")) { - if (Tok.drop_back().getAsInteger(10, Val)) + if (!to_integer(Tok.drop_back(), Val, 10)) return None; return Val * 1024 * 1024; } - if (Tok.getAsInteger(10, Val)) + if (!to_integer(Tok, Val, 10)) return None; return Val; } @@ -900,10 +900,22 @@ Expr ScriptParser::readPrimary() { StringRef Name = readParenLiteral(); return [=] { return Script->isDefined(Name) ? 1 : 0; }; } + if (Tok == "LENGTH") { + StringRef Name = readParenLiteral(); + if (Script->Opt.MemoryRegions.count(Name) == 0) + setError("memory region not defined: " + Name); + return [=] { return Script->Opt.MemoryRegions[Name].Length; }; + } if (Tok == "LOADADDR") { StringRef Name = readParenLiteral(); return [=] { return Script->getOutputSection(Location, Name)->getLMA(); }; } + if (Tok == "ORIGIN") { + StringRef Name = readParenLiteral(); + if (Script->Opt.MemoryRegions.count(Name) == 0) + setError("memory region not defined: " + Name); + return [=] { return Script->Opt.MemoryRegions[Name].Origin; }; + } if (Tok == "SEGMENT_START") { expect("("); skip(); Modified: vendor/lld/dist/ELF/Strings.cpp ============================================================================== --- vendor/lld/dist/ELF/Strings.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/Strings.cpp Tue May 16 19:47:41 2017 (r318376) @@ -46,7 +46,7 @@ int elf::getPriority(StringRef S) { if (Pos == StringRef::npos) return 65536; int V; - if (S.substr(Pos + 1).getAsInteger(10, V)) + if (!to_integer(S.substr(Pos + 1), V, 10)) return 65536; return V; } @@ -68,7 +68,7 @@ std::vector elf::parseHex(Strin StringRef B = S.substr(0, 2); S = S.substr(2); uint8_t H; - if (B.getAsInteger(16, H)) { + if (!to_integer(B, H, 16)) { error("not a hexadecimal value: " + B); return {}; } Modified: vendor/lld/dist/ELF/Symbols.cpp ============================================================================== --- vendor/lld/dist/ELF/Symbols.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/Symbols.cpp Tue May 16 19:47:41 2017 (r318376) @@ -163,8 +163,8 @@ uint64_t SymbolBody::getVA(int64_t Adden return OutVA + Addend; } -template typename ELFT::uint SymbolBody::getGotVA() const { - return In::Got->getVA() + getGotOffset(); +uint64_t SymbolBody::getGotVA() const { + return InX::Got->getVA() + getGotOffset(); } uint64_t SymbolBody::getGotOffset() const { @@ -370,11 +370,6 @@ std::string lld::toString(const SymbolBo return B.getName(); } -template uint32_t SymbolBody::template getGotVA() const; -template uint32_t SymbolBody::template getGotVA() const; -template uint64_t SymbolBody::template getGotVA() const; -template uint64_t SymbolBody::template getGotVA() const; - template uint32_t SymbolBody::template getSize() const; template uint32_t SymbolBody::template getSize() const; template uint64_t SymbolBody::template getSize() const; Modified: vendor/lld/dist/ELF/Symbols.h ============================================================================== --- vendor/lld/dist/ELF/Symbols.h Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/Symbols.h Tue May 16 19:47:41 2017 (r318376) @@ -78,7 +78,7 @@ public: uint64_t getVA(int64_t Addend = 0) const; uint64_t getGotOffset() const; - template typename ELFT::uint getGotVA() const; + uint64_t getGotVA() const; uint64_t getGotPltOffset() const; uint64_t getGotPltVA() const; uint64_t getPltVA() const; Modified: vendor/lld/dist/ELF/SyntheticSections.cpp ============================================================================== --- vendor/lld/dist/ELF/SyntheticSections.cpp Tue May 16 19:47:39 2017 (r318375) +++ vendor/lld/dist/ELF/SyntheticSections.cpp Tue May 16 19:47:41 2017 (r318376) @@ -186,7 +186,7 @@ template void MipsOptionsSe Options->size = getSize(); if (!Config->Relocatable) - Reginfo.ri_gp_value = In::MipsGot->getGp(); + Reginfo.ri_gp_value = InX::MipsGot->getGp(); memcpy(Buf + sizeof(Elf_Mips_Options), &Reginfo, sizeof(Reginfo)); } @@ -244,7 +244,7 @@ MipsReginfoSection::MipsReginfoSec template void MipsReginfoSection::writeTo(uint8_t *Buf) { if (!Config->Relocatable) - Reginfo.ri_gp_value = In::MipsGot->getGp(); + Reginfo.ri_gp_value = InX::MipsGot->getGp(); memcpy(Buf, &Reginfo, sizeof(Reginfo)); } @@ -293,13 +293,12 @@ InputSection *elf::createInterpSection() return Sec; } -template SymbolBody *elf::addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value, uint64_t Size, InputSectionBase *Section) { auto *S = make(Name, /*IsLocal*/ true, STV_DEFAULT, Type, Value, Size, Section, nullptr); - if (In::SymTab) - In::SymTab->addSymbol(S); + if (InX::SymTab) + InX::SymTab->addSymbol(S); return S; } @@ -356,7 +355,7 @@ void BuildIdSection::computeHash( std::vector Hashes(Chunks.size() * HashSize); // Compute hash values. - parallelFor(0, Chunks.size(), [&](size_t I) { + parallelForEachN(0, Chunks.size(), [&](size_t I) { HashFn(Hashes.data() + I * HashSize, Chunks[I]); }); @@ -618,17 +617,16 @@ template void EhFrameSectio } } -template -GotSection::GotSection() +GotBaseSection::GotBaseSection() : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS, Target->GotEntrySize, ".got") {} -template void GotSection::addEntry(SymbolBody &Sym) { +void GotBaseSection::addEntry(SymbolBody &Sym) { Sym.GotIndex = NumEntries; ++NumEntries; } -template bool GotSection::addDynTlsEntry(SymbolBody &Sym) { +bool GotBaseSection::addDynTlsEntry(SymbolBody &Sym) { if (Sym.GlobalDynIndex != -1U) return false; Sym.GlobalDynIndex = NumEntries; @@ -639,7 +637,7 @@ template bool GotSection bool GotSection::addTlsIndex() { +bool GotBaseSection::addTlsIndex() { if (TlsIndexOff != uint32_t(-1)) return false; TlsIndexOff = NumEntries * Config->Wordsize; @@ -647,21 +645,19 @@ template bool GotSection -uint64_t GotSection::getGlobalDynAddr(const SymbolBody &B) const { +uint64_t GotBaseSection::getGlobalDynAddr(const SymbolBody &B) const { return this->getVA() + B.GlobalDynIndex * Config->Wordsize; } -template -uint64_t GotSection::getGlobalDynOffset(const SymbolBody &B) const { +uint64_t GotBaseSection::getGlobalDynOffset(const SymbolBody &B) const { return B.GlobalDynIndex * Config->Wordsize; } *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***