From 9bd4566dac26dfac9a913d8e80666b6a06f81142 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 10 Mar 2017 00:47:33 +0000 Subject: [PATCH] Use SectionBase for linker script expressions. This is a small step for fixing pr32031, which needs expressions that point to input sections. llvm-svn: 297431 --- lld/ELF/LinkerScript.cpp | 4 ++-- lld/ELF/LinkerScript.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index b4f6f1fe0eb6..67661c81b8de 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -63,7 +63,7 @@ template static SymbolBody *addRegular(SymbolAssignment *Cmd) { 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(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(); }; diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index 829592e50a28..b9dd3f7bb81f 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -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 Section; + std::function Section; uint64_t operator()(uint64_t Dot) const { return Val(Dot); } operator bool() const { return (bool)Val; } Expr(std::function Val, std::function IsAbsolute, - std::function Section) + std::function Section) : Val(Val), IsAbsolute(IsAbsolute), Section(Section) {} template Expr(T V) : Expr(V, [] { return true; }, [] { return nullptr; }) {}