[PATCH] D19364: [ELF] - Implemented linkerscript ALIGN command

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 22 04:46:49 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL267145: [ELF] - Implemented linkerscript ALIGN command (authored by grimar).

Changed prior to commit:
  http://reviews.llvm.org/D19364?vs=54496&id=54633#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19364

Files:
  lld/trunk/ELF/LinkerScript.cpp
  lld/trunk/test/ELF/linkerscript-align.s

Index: lld/trunk/test/ELF/linkerscript-align.s
===================================================================
--- lld/trunk/test/ELF/linkerscript-align.s
+++ lld/trunk/test/ELF/linkerscript-align.s
@@ -0,0 +1,41 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+
+# RUN: echo "SECTIONS { \
+# RUN:  . = 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
+# CHECK-NEXT:   1 .aaa          00000008 0000000000010000 DATA
+# CHECK-NEXT:   2 .bbb          00000008 0000000000011000 DATA
+# CHECK-NEXT:   3 .ccc          00000008 0000000000014000 DATA
+
+.global _start
+_start:
+ nop
+
+.section .aaa, "a"
+.quad 0
+
+.section .bbb, "a"
+.quad 0
+
+.section .ccc, "a"
+.quad 0
Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -94,6 +94,14 @@
       return 0;
     return V;
   }
+  if (Tok == "ALIGN") {
+    if (!expect(Tokens, "("))
+      return 0;
+    uint64_t V = parseExpr(Tokens);
+    if (!expect(Tokens, ")"))
+      return 0;
+    return alignTo(Dot, V);
+  }
   return getInteger(Tok);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19364.54633.patch
Type: text/x-patch
Size: 1657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160422/88c0239b/attachment.bin>


More information about the llvm-commits mailing list