[lld] r294460 - Revert "Simplify symbol computation for non alloc sections."

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 8 07:19:04 PST 2017


Author: rafael
Date: Wed Feb  8 09:19:03 2017
New Revision: 294460

URL: http://llvm.org/viewvc/llvm-project?rev=294460&view=rev
Log:
Revert "Simplify symbol computation for non alloc sections."

This reverts commit r294346. Looks like it regressed the build of
magenta.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/OutputSections.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=294460&r1=294459&r2=294460&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed Feb  8 09:19:03 2017
@@ -101,8 +101,12 @@ static void assignSymbol(SymbolAssignmen
 
   if (auto *Body = dyn_cast<DefinedSynthetic>(Cmd->Sym)) {
     Body->Section = Cmd->Expression.Section();
-    if (Body->Section)
-      Body->Value = Cmd->Expression(Dot) - Body->Section->Addr;
+    if (Body->Section) {
+      uint64_t VA = 0;
+      if (Body->Section->Flags & SHF_ALLOC)
+        VA = Body->Section->Addr;
+      Body->Value = Cmd->Expression(Dot) - VA;
+    }
     return;
   }
 
@@ -802,9 +806,12 @@ void LinkerScript<ELFT>::assignAddresses
   }
 
   uintX_t MinVA = std::numeric_limits<uintX_t>::max();
-  for (OutputSectionBase *Sec : *OutputSections)
+  for (OutputSectionBase *Sec : *OutputSections) {
     if (Sec->Flags & SHF_ALLOC)
       MinVA = std::min<uint64_t>(MinVA, Sec->Addr);
+    else
+      Sec->Addr = 0;
+  }
 
   allocateHeaders<ELFT>(Phdrs, *OutputSections, MinVA);
 }

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=294460&r1=294459&r2=294460&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Feb  8 09:19:03 2017
@@ -57,7 +57,7 @@ void OutputSectionBase::writeHeaderTo(ty
   Shdr->sh_flags = Flags;
   Shdr->sh_info = Info;
   Shdr->sh_link = Link;
-  Shdr->sh_addr = (Flags & SHF_ALLOC) ? Addr : 0;
+  Shdr->sh_addr = Addr;
   Shdr->sh_size = Size;
   Shdr->sh_name = ShName;
 }




More information about the llvm-commits mailing list