diff options
author | Fangrui Song <i@maskray.me> | 2024-11-14 22:17:10 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2024-11-14 22:17:10 -0800 |
commit | e24457a330923dbc43a0e056deddb2d42c682e6c (patch) | |
tree | 23600b14b4da27fbb774ceb3218294408f0d97f9 /lld/ELF/ScriptParser.cpp | |
parent | b4adce0056bac9f650ec883a1dc5e082aa649b5c (diff) | |
download | llvm-e24457a330923dbc43a0e056deddb2d42c682e6c.zip llvm-e24457a330923dbc43a0e056deddb2d42c682e6c.tar.gz llvm-e24457a330923dbc43a0e056deddb2d42c682e6c.tar.bz2 |
[ELF] Migrate away from global ctx
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index d8adc56..aa89d8c 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -972,8 +972,8 @@ void ScriptParser::readSectionAddressType(OutputSection *cmd) { } } -static Expr checkAlignment(Expr e, std::string &loc) { - return [=] { +static Expr checkAlignment(Ctx &ctx, Expr e, std::string &loc) { + return [=, &ctx] { uint64_t alignment = std::max((uint64_t)1, e().getValue()); if (!isPowerOf2_64(alignment)) { ErrAlways(ctx) << loc << ": alignment must be power of 2"; @@ -1023,9 +1023,9 @@ OutputDesc *ScriptParser::readOutputSectionDescription(StringRef outSec) { if (consume("AT")) osec->lmaExpr = readParenExpr(); if (consume("ALIGN")) - osec->alignExpr = checkAlignment(readParenExpr(), location); + osec->alignExpr = checkAlignment(ctx, readParenExpr(), location); if (consume("SUBALIGN")) - osec->subalignExpr = checkAlignment(readParenExpr(), location); + osec->subalignExpr = checkAlignment(ctx, readParenExpr(), location); // Parse constraints. if (consume("ONLY_IF_RO")) @@ -1516,13 +1516,13 @@ Expr ScriptParser::readPrimary() { expect("("); Expr e = readExpr(); if (consume(")")) { - e = checkAlignment(e, location); + e = checkAlignment(ctx, e, location); return [=, s = ctx.script] { return alignToPowerOf2(s->getDot(), e().getValue()); }; } expect(","); - Expr e2 = checkAlignment(readExpr(), location); + Expr e2 = checkAlignment(ctx, readExpr(), location); expect(")"); return [=] { ExprValue v = e(); |