forked from OSchip/llvm-project
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
This commit is contained in:
parent
0666a76aac
commit
9bd4566dac
|
@ -63,7 +63,7 @@ template <class ELFT> 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<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();
|
||||
};
|
||||
|
||||
|
|
|
@ -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; }) {}
|
||||
|
|
Loading…
Reference in New Issue