diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index d6f406e5c287..597d3bad3691 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -1427,11 +1427,9 @@ Expr ScriptParser::readPrimary() { expect("("); next(); expect(","); - uint64_t Val; - if (next().getAsInteger(0, Val)) - setError("integer expected"); + Expr E = readExpr(); expect(")"); - return [=](uint64_t Dot) { return Val; }; + return [=](uint64_t Dot) { return E(Dot); }; } if (Tok == "DATA_SEGMENT_ALIGN") { expect("("); diff --git a/lld/test/ELF/linkerscript/Inputs/segment-start.script b/lld/test/ELF/linkerscript/Inputs/segment-start.script index 95933a290d5d..9f1a59360105 100644 --- a/lld/test/ELF/linkerscript/Inputs/segment-start.script +++ b/lld/test/ELF/linkerscript/Inputs/segment-start.script @@ -2,6 +2,6 @@ SECTIONS { PROVIDE (foobar1 = SEGMENT_START("text-segment", 0x8001)); PROVIDE (foobar2 = SEGMENT_START("data-segment", 0x8002)); - PROVIDE (foobar3 = SEGMENT_START("bss-segment", 0x8003)); + PROVIDE (foobar3 = SEGMENT_START("bss-segment", 0x8000 + (4 - 1))); PROVIDE (foobar4 = SEGMENT_START("abc-segment", 0x8004)); } diff --git a/lld/test/ELF/linkerscript/segment-start.s b/lld/test/ELF/linkerscript/segment-start.s index fb00ef13a2ce..00245e42e967 100644 --- a/lld/test/ELF/linkerscript/segment-start.s +++ b/lld/test/ELF/linkerscript/segment-start.s @@ -12,7 +12,7 @@ // CHECK: Name: foobar3 // CHECK-NEXT: Value: 0x8003 -// CHECK: Name: foobar +// CHECK: Name: foobar4 // CHECK-NEXT: Value: 0x8004 .data @@ -24,4 +24,4 @@ // RUN: echo "SECTIONS { . = SEGMENT_START(\"foobar\", foo); }" > %t.script // RUN: not ld.lld %t.o %t.script -shared -o %t2.so 2>&1 \ // RUN: | FileCheck --check-prefix=ERR %s -// ERR: integer expected +// ERR: symbol not found: foo