Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 May 2017 19:47:42 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
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
Message-ID:  <201705161947.v4GJlg3g097308@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <algorithm>
 #include <memory>
 

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 <algorithm>
 #include <atomic>
@@ -192,7 +192,7 @@ void ICF::forEachClass(std::function<voi
   // Split sections into 256 shards and call Fn in parallel.
   size_t NumShards = 256;
   size_t Step = Chunks.size() / NumShards;
-  parallel_for(size_t(0), NumShards, [&](size_t I) {
+  for_each_n(parallel::par, size_t(0), NumShards, [&](size_t I) {
     forEachClassRange(I * Step, (I + 1) * Step, Fn);
   });
   forEachClassRange(Step * NumShards, Chunks.size(), Fn);

Modified: vendor/lld/dist/COFF/MapFile.cpp
==============================================================================
--- vendor/lld/dist/COFF/MapFile.cpp	Tue May 16 19:47:39 2017	(r318375)
+++ vendor/lld/dist/COFF/MapFile.cpp	Tue May 16 19:47:41 2017	(r318376)
@@ -25,7 +25,7 @@
 #include "Symbols.h"
 #include "Writer.h"
 
-#include "lld/Core/Parallel.h"
+#include "llvm/Support/Parallel.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
@@ -76,7 +76,7 @@ static SymbolMapTy getSectionSyms(ArrayR
 static DenseMap<DefinedRegular *, std::string>
 getSymbolStrings(ArrayRef<DefinedRegular *> Syms) {
   std::vector<std::string> 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 <algorithm>
@@ -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<uint64_t> 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<ELFT>::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<ELFT>::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<ELFT>::ARMAttributes == nullptr) {
-      In<ELFT>::ARMAttributes = make<InputSection>(this, &Sec, Name);
-      return In<ELFT>::ARMAttributes;
+    if (InX::ARMAttributes == nullptr) {
+      InX::ARMAttributes = make<InputSection>(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<ELFT>::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<ELFT>() + A;
+    return Body.getGotVA() + A;
   case R_GOTONLY_PC:
-    return In<ELFT>::Got->getVA() + A - P;
+    return InX::Got->getVA() + A - P;
   case R_GOTONLY_PC_FROM_END:
-    return In<ELFT>::Got->getVA() + A - P + In<ELFT>::Got->getSize();
+    return InX::Got->getVA() + A - P + InX::Got->getSize();
   case R_GOTREL:
-    return Body.getVA(A) - In<ELFT>::Got->getVA();
+    return Body.getVA(A) - InX::Got->getVA();
   case R_GOTREL_FROM_END:
-    return Body.getVA(A) - In<ELFT>::Got->getVA() - In<ELFT>::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<ELFT>::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<ELFT>() + A) - getAArch64Page(P);
+    return getAArch64Page(Body.getGotVA() + A) - getAArch64Page(P);
   case R_GOT_PC:
   case R_RELAX_TLS_GD_TO_IE:
-    return Body.getGotVA<ELFT>() + 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<ELFT>::MipsGot->getGp();
+    return Body.getVA(A) - InX::MipsGot->getGp();
   case R_MIPS_GOT_GP:
-    return In<ELFT>::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<ELFT>::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<ELFT>::MipsGot->getVA() +
-           In<ELFT>::MipsGot->getPageEntryOffset(Body, A) -
-           In<ELFT>::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<ELFT>::MipsGot->getVA() +
-           In<ELFT>::MipsGot->getBodyEntryOffset(Body, A) -
-           In<ELFT>::MipsGot->getGp();
+    return InX::MipsGot->getVA() + InX::MipsGot->getBodyEntryOffset(Body, A) -
+           InX::MipsGot->getGp();
   case R_MIPS_TLSGD:
-    return In<ELFT>::MipsGot->getVA() + In<ELFT>::MipsGot->getTlsOffset() +
-           In<ELFT>::MipsGot->getGlobalDynOffset(Body) -
-           In<ELFT>::MipsGot->getGp();
+    return InX::MipsGot->getVA() + InX::MipsGot->getTlsOffset() +
+           InX::MipsGot->getGlobalDynOffset(Body) - InX::MipsGot->getGp();
   case R_MIPS_TLSLD:
-    return In<ELFT>::MipsGot->getVA() + In<ELFT>::MipsGot->getTlsOffset() +
-           In<ELFT>::MipsGot->getTlsIndexOff() - In<ELFT>::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<ELFT>() + A;
   case R_TLSDESC:
-    return In<ELFT>::Got->getGlobalDynAddr(Body) + A;
+    return InX::Got->getGlobalDynAddr(Body) + A;
   case R_TLSDESC_PAGE:
-    return getAArch64Page(In<ELFT>::Got->getGlobalDynAddr(Body) + A) -
+    return getAArch64Page(InX::Got->getGlobalDynAddr(Body) + A) -
            getAArch64Page(P);
   case R_TLSGD:
-    return In<ELFT>::Got->getGlobalDynOffset(Body) + A -
-           In<ELFT>::Got->getSize();
+    return InX::Got->getGlobalDynOffset(Body) + A - InX::Got->getSize();
   case R_TLSGD_PC:
-    return In<ELFT>::Got->getGlobalDynAddr(Body) + A - P;
+    return InX::Got->getGlobalDynAddr(Body) + A - P;
   case R_TLSLD:
-    return In<ELFT>::Got->getTlsIndexOff() + A - In<ELFT>::Got->getSize();
+    return InX::Got->getTlsIndexOff() + A - InX::Got->getSize();
   case R_TLSLD_PC:
-    return In<ELFT>::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<OutputSectionCommand>(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<OutputSectionCommand>(*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<OutputSectionCommand>(Base);
-      return Cmd && Cmd->Name == Name;
-    });
-    if (Pos == E) {
-      auto *Cmd = make<OutputSectionCommand>(Name);
+    OutputSectionCommand *Cmd = getCmd(Sec);
+    if (!Cmd) {
+      Cmd = make<OutputSectionCommand>(Name);
       Opt.Commands.insert(CmdIter, Cmd);
       ++CmdIndex;
 
       Cmd->Sec = Sec;
+      SecToCommand[Sec] = Cmd;
       auto *ISD = make<InputSectionDescription>("");
       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<PhdrEntry> 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<uint32_t> LinkerScript::getFiller(StringRef Name) {
-  for (BaseCommand *Base : Opt.Commands)
-    if (auto *Cmd = dyn_cast<OutputSectionCommand>(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<uint32_t> 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<OutputSectionCommand>(Base))
-                            if (Cmd->Sec == Sec)
-                              return true;
-                          return false;
-                        });
-  if (I == Opt.Commands.end())
-    return;
-  auto *Cmd = cast<OutputSectionCommand>(*I);
-  for (BaseCommand *Base : Cmd->Commands)
-    if (auto *Data = dyn_cast<BytesDataCommand>(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<BytesDataCommand>(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<OutputSectionCommand>(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<size_t> LinkerScript::getPhdrIndices(StringRef SectionName) {
-  for (BaseCommand *Base : Opt.Commands) {
-    auto *Cmd = dyn_cast<OutputSectionCommand>(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<size_t> LinkerScript::getPhdrIndices(OutputSection *Sec) {
+  if (OutputSectionCommand *Cmd = getCmd(Sec)) {
     std::vector<size_t> 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<llvm::StringRef> ReferencedSymbols;
 };
 
-class LinkerScript {
-protected:
+class LinkerScript final {
+  llvm::DenseMap<OutputSection *, OutputSectionCommand *> 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<InputSectionBase *>
   createInputSectionList(OutputSectionCommand &Cmd);
 
-  std::vector<size_t> getPhdrIndices(StringRef SectionName);
+  std::vector<size_t> getPhdrIndices(OutputSection *Sec);
   size_t getPhdrIndex(const Twine &Loc, StringRef PhdrName);
 
   MemoryRegion *findMemoryRegion(OutputSectionCommand *Cmd);
@@ -262,8 +263,8 @@ public:
   std::vector<PhdrEntry> createPhdrs();
   bool ignoreInterpSection();
 
-  llvm::Optional<uint32_t> getFiller(StringRef Name);
-  bool hasLMA(StringRef Name);
+  llvm::Optional<uint32_t> 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 <class ELFT>
 DenseMap<DefinedRegular *, std::string>
 getSymbolStrings(ArrayRef<DefinedRegular *> Syms) {
   std::vector<std::string> Str(Syms.size());
-  parallelFor(0, Syms.size(), [&](size_t I) {
+  parallelForEachN(0, Syms.size(), [&](size_t I) {
     raw_string_ostream OS(Str[I]);
     writeHeader<ELFT>(OS, Syms[I]->getVA(), Syms[I]->template getSize<ELFT>(),
                       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 <class ELFT> void OutputSection
   if (isa<SyntheticSection>(First))
     return;
 
-  this->Link = In<ELFT>::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<uint32_t> Filler = Script->getFiller(Name))
+  if (Optional<uint32_t> Filler = Script->getFiller(this))
     return *Filler;
   if (Flags & SHF_EXECINSTR)
     return Target->TrapInstr;
@@ -297,7 +297,7 @@ template <class ELFT> 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<ELFT>(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 <typename ELFT> 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<ELFT>::MipsGot->addTlsIndex() && Config->Pic)
-      In<ELFT>::RelaDyn->addReloc({Target->TlsModuleIndexRel, In<ELFT>::MipsGot,
-                                   In<ELFT>::MipsGot->getTlsIndexOff(), false,
+    if (InX::MipsGot->addTlsIndex() && Config->Pic)
+      In<ELFT>::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<ELFT>::MipsGot->addDynTlsEntry(Body) && Body.isPreemptible()) {
-      uint64_t Off = In<ELFT>::MipsGot->getGlobalDynOffset(Body);
+    if (InX::MipsGot->addDynTlsEntry(Body) && Body.isPreemptible()) {
+      uint64_t Off = InX::MipsGot->getGlobalDynOffset(Body);
       In<ELFT>::RelaDyn->addReloc(
-          {Target->TlsModuleIndexRel, In<ELFT>::MipsGot, Off, false, &Body, 0});
+          {Target->TlsModuleIndexRel, InX::MipsGot, Off, false, &Body, 0});
       if (Body.isPreemptible())
-        In<ELFT>::RelaDyn->addReloc({Target->TlsOffsetRel, In<ELFT>::MipsGot,
+        In<ELFT>::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<ELFT>::RelaDyn->addReloc({Type, In<ELFT>::Got, Off, false, Dest, 0});
+      In<ELFT>::RelaDyn->addReloc({Type, InX::Got, Off, false, Dest, 0});
     else
-      In<ELFT>::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<ELFT>::Got->addTlsIndex()) {
-    AddTlsReloc(In<ELFT>::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<ELFT>::Got->addDynTlsEntry(Body)) {
-      uint64_t Off = In<ELFT>::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<R_TLSDESC, R_TLSDESC_PAGE, R_TLSDESC_CALL>(Expr) &&
       Config->Shared) {
-    if (In<ELFT>::Got->addDynTlsEntry(Body)) {
-      uint64_t Off = In<ELFT>::Got->getGlobalDynOffset(Body);
-      In<ELFT>::RelaDyn->addReloc({Target->TlsDescRel, In<ELFT>::Got, Off,
-                                   !IsPreemptible, &Body, 0});
+    if (InX::Got->addDynTlsEntry(Body)) {
+      uint64_t Off = InX::Got->getGlobalDynOffset(Body);
+      In<ELFT>::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<ELFT>::Got->addTlsIndex())
-      In<ELFT>::RelaDyn->addReloc({Target->TlsModuleIndexRel, In<ELFT>::Got,
-                                   In<ELFT>::Got->getTlsIndexOff(), false,
-                                   nullptr, 0});
+    if (InX::Got->addTlsIndex())
+      In<ELFT>::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<R_TLSDESC, R_TLSDESC_PAGE, R_TLSDESC_CALL, R_TLSGD,
                      R_TLSGD_PC>(Expr)) {
     if (Config->Shared) {
-      if (In<ELFT>::Got->addDynTlsEntry(Body)) {
-        uint64_t Off = In<ELFT>::Got->getGlobalDynOffset(Body);
+      if (InX::Got->addDynTlsEntry(Body)) {
+        uint64_t Off = InX::Got->getGlobalDynOffset(Body);
         In<ELFT>::RelaDyn->addReloc(
-            {Target->TlsModuleIndexRel, In<ELFT>::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<ELFT>::RelaDyn->addReloc({Target->TlsOffsetRel, In<ELFT>::Got,
-                                       OffsetOff, false, &Body, 0});
+          In<ELFT>::RelaDyn->addReloc(
+              {Target->TlsOffsetRel, InX::Got, OffsetOff, false, &Body, 0});
         else
-          In<ELFT>::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<ELFT>::Got->addEntry(Body);
-        In<ELFT>::RelaDyn->addReloc({Target->TlsGotRel, In<ELFT>::Got,
+        InX::Got->addEntry(Body);
+        In<ELFT>::RelaDyn->addReloc({Target->TlsGotRel, InX::Got,
                                      Body.getGotOffset(), false, &Body, 0});
       }
     } else {
@@ -518,7 +518,7 @@ template <class ELFT> 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<ELFT>(SS);
-  BssSection *Sec = IsReadOnly ? In<ELFT>::BssRelRo : In<ELFT>::Bss;
+  BssSection *Sec = IsReadOnly ? InX::BssRelRo : InX::Bss;
   uint64_t Off = Sec->reserveSpace(SymSize, SS->getAlignment<ELFT>());
 
   // Look through the DSO's dynamic symbol table for aliases and create a
@@ -774,7 +774,7 @@ static void addPltEntry(PltSection *Plt,
 
 template <class ELFT>
 static void addGotEntry(SymbolBody &Sym, bool Preemptible) {
-  In<ELFT>::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<ELFT>::RelaDyn->addReloc(
-        {DynType, In<ELFT>::Got, Off, !Preemptible, &Sym, 0});
+        {DynType, InX::Got, Off, !Preemptible, &Sym, 0});
 
   if (Constant || (!Config->IsRela && !Preemptible))
-    In<ELFT>::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<R_GOTONLY_PC, R_GOTONLY_PC_FROM_END, R_GOTREL,
                        R_GOTREL_FROM_END, R_PPC_TOC>(Expr))
-      In<ELFT>::Got->HasGotOffRel = true;
+      InX::Got->HasGotOffRel = true;
 
     // Read an addend.
     int64_t Addend = computeAddend<ELFT>(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<ELFT>::IgotPlt, In<ELFT>::RelaIplt,
+        addPltEntry(InX::Iplt, InX::IgotPlt, In<ELFT>::RelaIplt,
                     Target->IRelativeRel, Body, true);
       else
-        addPltEntry(InX::Plt, In<ELFT>::GotPlt, In<ELFT>::RelaPlt,
-                    Target->PltRel, Body, !Preemptible);
+        addPltEntry(InX::Plt, InX::GotPlt, In<ELFT>::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<ELFT>::MipsGot->addEntry(Body, Addend, Expr);
+        InX::MipsGot->addEntry(Body, Addend, Expr);
         if (Body.isTls() && Body.isPreemptible())
-          In<ELFT>::RelaDyn->addReloc({Target->TlsGotRel, In<ELFT>::MipsGot,
+          In<ELFT>::RelaDyn->addReloc({Target->TlsGotRel, InX::MipsGot,
                                        Body.getGotOffset(), false, &Body, 0});
       } else if (!Body.isInGot()) {
         addGotEntry<ELFT>(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<ELFT>::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<uint64_t> 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<uint8_t> 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 <class ELFT> typename ELFT::uint SymbolBody::getGotVA() const {
-  return In<ELFT>::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<ELF32LE>() const;
-template uint32_t SymbolBody::template getGotVA<ELF32BE>() const;
-template uint64_t SymbolBody::template getGotVA<ELF64LE>() const;
-template uint64_t SymbolBody::template getGotVA<ELF64BE>() const;
-
 template uint32_t SymbolBody::template getSize<ELF32LE>() const;
 template uint32_t SymbolBody::template getSize<ELF32BE>() const;
 template uint64_t SymbolBody::template getSize<ELF64LE>() 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 <class ELFT> 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 <class ELFT> void MipsOptionsSe
   Options->size = getSize();
 
   if (!Config->Relocatable)
-    Reginfo.ri_gp_value = In<ELFT>::MipsGot->getGp();
+    Reginfo.ri_gp_value = InX::MipsGot->getGp();
   memcpy(Buf + sizeof(Elf_Mips_Options), &Reginfo, sizeof(Reginfo));
 }
 
@@ -244,7 +244,7 @@ MipsReginfoSection<ELFT>::MipsReginfoSec
 
 template <class ELFT> void MipsReginfoSection<ELFT>::writeTo(uint8_t *Buf) {
   if (!Config->Relocatable)
-    Reginfo.ri_gp_value = In<ELFT>::MipsGot->getGp();
+    Reginfo.ri_gp_value = InX::MipsGot->getGp();
   memcpy(Buf, &Reginfo, sizeof(Reginfo));
 }
 
@@ -293,13 +293,12 @@ InputSection *elf::createInterpSection()
   return Sec;
 }
 
-template <class ELFT>
 SymbolBody *elf::addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value,
                                    uint64_t Size, InputSectionBase *Section) {
   auto *S = make<DefinedRegular>(Name, /*IsLocal*/ true, STV_DEFAULT, Type,
                                  Value, Size, Section, nullptr);
-  if (In<ELFT>::SymTab)
-    In<ELFT>::SymTab->addSymbol(S);
+  if (InX::SymTab)
+    InX::SymTab->addSymbol(S);
   return S;
 }
 
@@ -356,7 +355,7 @@ void BuildIdSection::computeHash(
   std::vector<uint8_t> 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 <class ELFT> void EhFrameSectio
   }
 }
 
-template <class ELFT>
-GotSection<ELFT>::GotSection()
+GotBaseSection::GotBaseSection()
     : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
                        Target->GotEntrySize, ".got") {}
 
-template <class ELFT> void GotSection<ELFT>::addEntry(SymbolBody &Sym) {
+void GotBaseSection::addEntry(SymbolBody &Sym) {
   Sym.GotIndex = NumEntries;
   ++NumEntries;
 }
 
-template <class ELFT> bool GotSection<ELFT>::addDynTlsEntry(SymbolBody &Sym) {
+bool GotBaseSection::addDynTlsEntry(SymbolBody &Sym) {
   if (Sym.GlobalDynIndex != -1U)
     return false;
   Sym.GlobalDynIndex = NumEntries;
@@ -639,7 +637,7 @@ template <class ELFT> bool GotSection<EL
 
 // Reserves TLS entries for a TLS module ID and a TLS block offset.
 // In total it takes two GOT slots.
-template <class ELFT> bool GotSection<ELFT>::addTlsIndex() {
+bool GotBaseSection::addTlsIndex() {
   if (TlsIndexOff != uint32_t(-1))
     return false;
   TlsIndexOff = NumEntries * Config->Wordsize;
@@ -647,21 +645,19 @@ template <class ELFT> bool GotSection<EL
   return true;
 }
 
-template <class ELFT>
-uint64_t GotSection<ELFT>::getGlobalDynAddr(const SymbolBody &B) const {
+uint64_t GotBaseSection::getGlobalDynAddr(const SymbolBody &B) const {
   return this->getVA() + B.GlobalDynIndex * Config->Wordsize;
 }
 
-template <class ELFT>
-uint64_t GotSection<ELFT>::getGlobalDynOffset(const SymbolBody &B) const {
+uint64_t GotBaseSection::getGlobalDynOffset(const SymbolBody &B) const {
   return B.GlobalDynIndex * Config->Wordsize;
 }
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705161947.v4GJlg3g097308>