[lld] r277599 - Revert 277594, it caused PR28827

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 3 07:37:58 PDT 2016


Author: nico
Date: Wed Aug  3 09:37:57 2016
New Revision: 277599

URL: http://llvm.org/viewvc/llvm-project?rev=277599&view=rev
Log:
Revert 277594, it caused PR28827

Modified:
    lld/trunk/COFF/InputFiles.cpp
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/LinkerScript.h
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=277599&r1=277598&r2=277599&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Wed Aug  3 09:37:57 2016
@@ -64,7 +64,7 @@ std::string InputFile::getShortName() {
 
 void ArchiveFile::parse() {
   // Parse a MemoryBufferRef as an archive file.
-  File = check(Archive::create(MB), "failed to parse static library");
+  File = check(Archive::create(MB), getShortName());
 
   // Allocate a buffer for Lazy objects.
   size_t NumSyms = File->getNumberOfSymbols();
@@ -81,7 +81,7 @@ void ArchiveFile::parse() {
   for (auto &Child : File->children(Err))
     Seen[Child.getChildOffset()].clear();
   if (Err)
-    fatal(Err, "failed to parse static library");
+    fatal(Err, getShortName());
 }
 
 // Returns a buffer pointing to a member file containing a given symbol.
@@ -109,13 +109,13 @@ MemoryBufferRef ArchiveFile::getMember(c
 void ObjectFile::parse() {
   // Parse a memory buffer as a COFF file.
   std::unique_ptr<Binary> Bin =
-      check(createBinary(MB), "failed to parse object file");
+      check(createBinary(MB), getShortName());
 
   if (auto *Obj = dyn_cast<COFFObjectFile>(Bin.get())) {
     Bin.release();
     COFFObj.reset(Obj);
   } else {
-    fatal(getName() + " is not a COFF file");
+    fatal(getShortName() + " is not a COFF file");
   }
 
   // Read section and symbol tables.
@@ -169,7 +169,7 @@ void ObjectFile::initializeSymbols() {
   for (uint32_t I = 0; I < NumSymbols; ++I) {
     // Get a COFFSymbolRef object.
     COFFSymbolRef Sym =
-        check(COFFObj->getSymbol(I), "broken object file: " + getName());
+        check(COFFObj->getSymbol(I), "broken object file: " + getShortName());
 
     const void *AuxP = nullptr;
     if (Sym.getNumberOfAuxSymbols())
@@ -231,12 +231,12 @@ Defined *ObjectFile::createDefined(COFFS
 
   // Reserved sections numbers don't have contents.
   if (llvm::COFF::isReservedSectionNumber(SectionNumber))
-    fatal("broken object file: " + getName());
+    fatal("broken object file: " + getShortName());
 
   // This symbol references a section which is not present in the section
   // header.
   if ((uint32_t)SectionNumber >= SparseChunks.size())
-    fatal("broken object file: " + getName());
+    fatal("broken object file: " + getShortName());
 
   // Nothing else to do without a section chunk.
   auto *SC = cast_or_null<SectionChunk>(SparseChunks[SectionNumber]);

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=277599&r1=277598&r2=277599&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed Aug  3 09:37:57 2016
@@ -218,8 +218,9 @@ template <class ELFT> void LinkerScript<
   }
 }
 
-template <class ELFT> void LinkerScript<ELFT>::assignAddresses() {
-  ArrayRef<OutputSectionBase<ELFT> *> Sections = *OutputSections;
+template <class ELFT>
+void LinkerScript<ELFT>::assignAddresses(
+    ArrayRef<OutputSectionBase<ELFT> *> Sections) {
   // Orphan sections are sections present in the input files which
   // are not explicitly placed into the output file by the linker script.
   // We place orphan sections at end of file.
@@ -288,8 +289,8 @@ template <class ELFT> void LinkerScript<
 }
 
 template <class ELFT>
-std::vector<PhdrEntry<ELFT>> LinkerScript<ELFT>::createPhdrs() {
-  ArrayRef<OutputSectionBase<ELFT> *> Sections = *OutputSections;
+std::vector<PhdrEntry<ELFT>>
+LinkerScript<ELFT>::createPhdrs(ArrayRef<OutputSectionBase<ELFT> *> Sections) {
   std::vector<PhdrEntry<ELFT>> Ret;
 
   for (const PhdrsCommand &Cmd : Opt.PhdrsCommands) {

Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=277599&r1=277598&r2=277599&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Wed Aug  3 09:37:57 2016
@@ -133,11 +133,12 @@ public:
   void createSections(std::vector<OutputSectionBase<ELFT> *> *Out,
                       OutputSectionFactory<ELFT> &Factory);
 
-  std::vector<PhdrEntry<ELFT>> createPhdrs();
+  std::vector<PhdrEntry<ELFT>>
+  createPhdrs(ArrayRef<OutputSectionBase<ELFT> *> S);
 
   ArrayRef<uint8_t> getFiller(StringRef Name);
   bool shouldKeep(InputSectionBase<ELFT> *S);
-  void assignAddresses();
+  void assignAddresses(ArrayRef<OutputSectionBase<ELFT> *> S);
   int compareSections(StringRef A, StringRef B);
   void addScriptedSymbols();
   bool hasPhdrsCommands();

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=277599&r1=277598&r2=277599&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Aug  3 09:37:57 2016
@@ -245,11 +245,12 @@ template <class ELFT> void Writer<ELFT>:
   if (Config->Relocatable) {
     assignFileOffsets();
   } else {
-    Phdrs = Script<ELFT>::X->hasPhdrsCommands() ? Script<ELFT>::X->createPhdrs()
-                                                : createPhdrs();
+    Phdrs = Script<ELFT>::X->hasPhdrsCommands()
+                ? Script<ELFT>::X->createPhdrs(OutputSections)
+                : createPhdrs();
     fixHeaders();
     if (ScriptConfig->HasContents) {
-      Script<ELFT>::X->assignAddresses();
+      Script<ELFT>::X->assignAddresses(OutputSections);
     } else {
       fixSectionAlignments();
       assignAddresses();




More information about the llvm-commits mailing list