summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-12-16 18:19:35 +0000
committerRui Ueyama <ruiu@google.com>2016-12-16 18:19:35 +0000
commit5d804dc8f765cca28a6738cdc3efdfc7f71a5b4a (patch)
treed6a6c4d494470e75c8c563a285d692738259bfaf
parent55e7d65b12a5afffab1fd70c0cdf75d19867daed (diff)
downloadbcm5719-llvm-5d804dc8f765cca28a6738cdc3efdfc7f71a5b4a.tar.gz
bcm5719-llvm-5d804dc8f765cca28a6738cdc3efdfc7f71a5b4a.zip
[ELF] - Linkerscript: Implement two argument version of ALIGN()
Fixes http://llvm.org/PR31129 Patch by Alexander Richardson! Differential Revision: https://reviews.llvm.org/D27848 llvm-svn: 289968
-rw-r--r--lld/ELF/LinkerScript.cpp9
-rw-r--r--lld/test/ELF/linkerscript/align.s22
2 files changed, 30 insertions, 1 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 81498b26dbe..7387c9c2590 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -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") {
diff --git a/lld/test/ELF/linkerscript/align.s b/lld/test/ELF/linkerscript/align.s
index ac2908a9a7e..1e50fed3fa8 100644
--- a/lld/test/ELF/linkerscript/align.s
+++ b/lld/test/ELF/linkerscript/align.s
@@ -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
OpenPOWER on IntegriCloud