[lld] r289968 - [ELF] - Linkerscript: Implement two argument version of ALIGN()
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 16 10:19:35 PST 2016
Author: ruiu
Date: Fri Dec 16 12:19:35 2016
New Revision: 289968
URL: http://llvm.org/viewvc/llvm-project?rev=289968&view=rev
Log:
[ELF] - Linkerscript: Implement two argument version of ALIGN()
Fixes http://llvm.org/PR31129
Patch by Alexander Richardson!
Differential Revision: https://reviews.llvm.org/D27848
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/align.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=289968&r1=289967&r2=289968&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Fri Dec 16 12:19:35 2016
@@ -1736,7 +1736,14 @@ Expr ScriptParser::readPrimary() {
if (Tok == "ASSERT")
return readAssert();
if (Tok == "ALIGN") {
- Expr E = readParenExpr();
+ expect("(");
+ Expr E = readExpr();
+ if (consume(",")) {
+ Expr E2 = readExpr();
+ expect(")");
+ return [=](uint64_t Dot) { return alignTo(E(Dot), E2(Dot)); };
+ }
+ expect(")");
return [=](uint64_t Dot) { return alignTo(Dot, E(Dot)); };
}
if (Tok == "CONSTANT") {
Modified: lld/trunk/test/ELF/linkerscript/align.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/align.s?rev=289968&r1=289967&r2=289968&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/align.s (original)
+++ lld/trunk/test/ELF/linkerscript/align.s Fri Dec 16 12:19:35 2016
@@ -21,6 +21,28 @@
# RUN: }" > %t.script
# RUN: ld.lld -o %t1 --script %t.script %t
# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
+
+## Check that the two argument version of ALIGN command works
+# RUN: echo "SECTIONS { \
+# RUN: . = ALIGN(0x1234, 0x10000); \
+# RUN: .aaa : \
+# RUN: { \
+# RUN: *(.aaa) \
+# RUN: } \
+# RUN: . = ALIGN(., 4096); \
+# RUN: .bbb : \
+# RUN: { \
+# RUN: *(.bbb) \
+# RUN: } \
+# RUN: . = ALIGN(., 4096 * 4); \
+# RUN: .ccc : \
+# RUN: { \
+# RUN: *(.ccc) \
+# RUN: } \
+# RUN: }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
+
# CHECK: Sections:
# CHECK-NEXT: Idx Name Size Address Type
# CHECK-NEXT: 0 00000000 0000000000000000
More information about the llvm-commits
mailing list