[lld] r297431 - Use SectionBase for linker script expressions.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 9 16:47:34 PST 2017


Author: rafael
Date: Thu Mar  9 18:47:33 2017
New Revision: 297431

URL: http://llvm.org/viewvc/llvm-project?rev=297431&view=rev
Log:
Use SectionBase for linker script expressions.

This is a small step for fixing pr32031, which needs expressions that
point to input sections.

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

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=297431&r1=297430&r2=297431&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Mar  9 18:47:33 2017
@@ -63,7 +63,7 @@ template <class ELFT> static SymbolBody
       Cmd->Name, /*Type*/ 0, Visibility, /*CanOmitFromDynSym*/ false,
       /*File*/ nullptr);
   Sym->Binding = STB_GLOBAL;
-  OutputSection *Sec =
+  SectionBase *Sec =
       Cmd->Expression.IsAbsolute() ? nullptr : Cmd->Expression.Section();
   replaceBody<DefinedRegular>(Sym, Cmd->Name, /*IsLocal=*/false, Visibility,
                               STT_NOTYPE, 0, 0, Sec, nullptr);
@@ -1617,7 +1617,7 @@ Expr ScriptParser::readExpr() {
 static Expr combine(StringRef Op, Expr L, Expr R) {
   auto IsAbs = [=] { return L.IsAbsolute() && R.IsAbsolute(); };
   auto GetOutSec = [=] {
-    OutputSection *S = L.Section();
+    SectionBase *S = L.Section();
     return S ? S : R.Section();
   };
 

Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=297431&r1=297430&r2=297431&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Thu Mar  9 18:47:33 2017
@@ -36,6 +36,7 @@ class InputSection;
 class OutputSection;
 class OutputSectionFactory;
 class InputSectionBase;
+class SectionBase;
 
 // This represents an expression in the linker script.
 // ScriptParser::readExpr reads an expression and returns an Expr.
@@ -47,13 +48,13 @@ struct Expr {
 
   // If expression is section-relative the function below is used
   // to get the output section pointer.
-  std::function<OutputSection *()> Section;
+  std::function<SectionBase *()> Section;
 
   uint64_t operator()(uint64_t Dot) const { return Val(Dot); }
   operator bool() const { return (bool)Val; }
 
   Expr(std::function<uint64_t(uint64_t)> Val, std::function<bool()> IsAbsolute,
-       std::function<OutputSection *()> Section)
+       std::function<SectionBase *()> Section)
       : Val(Val), IsAbsolute(IsAbsolute), Section(Section) {}
   template <typename T>
   Expr(T V) : Expr(V, [] { return true; }, [] { return nullptr; }) {}




More information about the llvm-commits mailing list