diff options
author | George Rimar <grimar@accesssoftek.com> | 2016-04-22 11:40:53 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2016-04-22 11:40:53 +0000 |
commit | dffc1410c55f62efbff8f14f8a761a3c3371b6f2 (patch) | |
tree | 9b8b7740a76ae5da11491b8c036bb5e53ef6714f | |
parent | b1bfd5039eeadefd3ad071ca46729d5d996586eb (diff) | |
download | bcm5719-llvm-dffc1410c55f62efbff8f14f8a761a3c3371b6f2.tar.gz bcm5719-llvm-dffc1410c55f62efbff8f14f8a761a3c3371b6f2.zip |
[ELF] - Implemented linkerscript ALIGN command
ALIGN(exp)
Return the location counter (.) aligned to the next exp boundary. (https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/expressions.html)
Patch implements this command.
This fixes PR27406.
Differential revision: http://reviews.llvm.org/D19364
llvm-svn: 267145
-rw-r--r-- | lld/ELF/LinkerScript.cpp | 8 | ||||
-rw-r--r-- | lld/test/ELF/linkerscript-align.s | 41 |
2 files changed, 49 insertions, 0 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 77ba023b049..1cfe358c857 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -94,6 +94,14 @@ uint64_t LinkerScript<ELFT>::parsePrimary(ArrayRef<StringRef> &Tokens) { 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); } diff --git a/lld/test/ELF/linkerscript-align.s b/lld/test/ELF/linkerscript-align.s new file mode 100644 index 00000000000..5f6e6f77076 --- /dev/null +++ b/lld/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 |