Add support for SEGMENT_START.
This is a bit of an odd feature. It is normally used in
. = SEGMENT_START(seg, val);
In bfd it evaluates to val or to the value of the corresponding
-T<seg>-segment. Note that the -T<seg>-segment in bfd doesn't actually
change the segment address, just the value this evaluates too,
including in the default linker script.
In gold the -T<seg>-segment options do change the segment address and
seeing this expressions in linker scripts disables the options.
For new this just always evaluates the expression to val.
llvm-svn: 277014
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 50a7b75..395f126 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -872,6 +872,15 @@
expect(")");
return [=](uint64_t Dot) { return getConstant(Tok); };
}
+ if (Tok == "SEGMENT_START") {
+ expect("(");
+ next();
+ expect(",");
+ uint64_t Val;
+ next().getAsInteger(0, Val);
+ expect(")");
+ return [=](uint64_t Dot) { return Val; };
+ }
if (Tok == "DATA_SEGMENT_ALIGN") {
expect("(");
Expr E = readExpr();