[lld] r281831 - [ELF] - SEGMENT_START's default argument can be an expression
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 17 11:14:56 PDT 2016
Author: grimar
Date: Sat Sep 17 13:14:56 2016
New Revision: 281831
URL: http://llvm.org/viewvc/llvm-project?rev=281831&view=rev
Log:
[ELF] - SEGMENT_START's default argument can be an expression
Our implementation supported integer value previously.
ld can use expression,
for example, it is OK to write
. = SEGMENT_START("foobar", .);
Patch implements that.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/Inputs/segment-start.script
lld/trunk/test/ELF/linkerscript/segment-start.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=281831&r1=281830&r2=281831&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Sat Sep 17 13:14:56 2016
@@ -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("(");
Modified: lld/trunk/test/ELF/linkerscript/Inputs/segment-start.script
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/Inputs/segment-start.script?rev=281831&r1=281830&r2=281831&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/Inputs/segment-start.script (original)
+++ lld/trunk/test/ELF/linkerscript/Inputs/segment-start.script Sat Sep 17 13:14:56 2016
@@ -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));
}
Modified: lld/trunk/test/ELF/linkerscript/segment-start.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/segment-start.s?rev=281831&r1=281830&r2=281831&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/segment-start.s (original)
+++ lld/trunk/test/ELF/linkerscript/segment-start.s Sat Sep 17 13:14:56 2016
@@ -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
More information about the llvm-commits
mailing list