]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/linkerscript/align.s
Vendor import of lld trunk r304222:
[FreeBSD/FreeBSD.git] / test / ELF / linkerscript / align.s
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
3
4 ## Check that ALIGN command workable using location counter
5 # RUN: echo "SECTIONS {      \
6 # RUN:  . = 0x10000;         \
7 # RUN:  .aaa : { *(.aaa) }   \
8 # RUN:  . = ALIGN(4096);     \
9 # RUN:  .bbb : { *(.bbb) }   \
10 # RUN:  . = ALIGN(4096 * 4); \
11 # RUN:  .ccc : { *(.ccc) }   \
12 # RUN: }" > %t.script
13 # RUN: ld.lld -o %t1 --script %t.script %t
14 # RUN: llvm-objdump -section-headers %t1 | FileCheck %s
15
16 ## Check that the two argument version of ALIGN command works
17 # RUN: echo "SECTIONS {             \
18 # RUN:  . = ALIGN(0x1234, 0x10000); \
19 # RUN:  .aaa : { *(.aaa) }          \
20 # RUN:  . = ALIGN(., 4096);         \
21 # RUN:  .bbb : { *(.bbb) }          \
22 # RUN:  . = ALIGN(., 4096 * 4);     \
23 # RUN:  .ccc : { *(.ccc) }          \
24 # RUN: }" > %t.script
25 # RUN: ld.lld -o %t1 --script %t.script %t
26 # RUN: llvm-objdump -section-headers %t1 | FileCheck %s
27
28 # CHECK:      Sections:
29 # CHECK-NEXT: Idx Name          Size      Address          Type
30 # CHECK-NEXT:   0               00000000 0000000000000000
31 # CHECK-NEXT:   1 .aaa          00000008 0000000000010000 DATA
32 # CHECK-NEXT:   2 .bbb          00000008 0000000000011000 DATA
33 # CHECK-NEXT:   3 .ccc          00000008 0000000000014000 DATA
34
35 ## Check output sections ALIGN modificator
36 # RUN: echo "SECTIONS {                    \
37 # RUN:  . = 0x10000;                       \
38 # RUN:  .aaa : { *(.aaa) }                 \
39 # RUN:  .bbb : ALIGN(4096) { *(.bbb) }     \
40 # RUN:  .ccc : ALIGN(4096 * 4) { *(.ccc) } \
41 # RUN: }" > %t2.script
42 # RUN: ld.lld -o %t2 --script %t2.script %t
43 # RUN: llvm-objdump -section-headers %t2 | FileCheck %s
44
45 ## Check use of variables in align expressions:
46 # RUN: echo "VAR = 0x1000;                                  \
47 # RUN: __code_base__ = 0x10000;                             \
48 # RUN: SECTIONS {                                           \
49 # RUN:  . = __code_base__;                                  \
50 # RUN:  .aaa : { *(.aaa) }                                  \
51 # RUN:  .bbb : ALIGN(VAR) { *(.bbb) }                       \
52 # RUN:  . = ALIGN(., VAR * 4);                              \
53 # RUN:  .ccc : { *(.ccc) }                                  \
54 # RUN:  __start_bbb = ADDR(.bbb);                           \
55 # RUN:  __end_bbb = ALIGN(__start_bbb + SIZEOF(.bbb), VAR); \
56 # RUN: }" > %t3.script
57 # RUN: ld.lld -o %t3 --script %t3.script %t
58 # RUN: llvm-objdump -section-headers %t3 | FileCheck %s
59 # RUN: llvm-objdump -t %t3 | FileCheck -check-prefix SYMBOLS %s
60
61 # SYMBOLS-LABEL: SYMBOL TABLE:
62 # SYMBOLS-NEXT: 0000000000000000         *UND*           00000000
63 # SYMBOLS-NEXT: 0000000000014008         .text           00000000 _start
64 # SYMBOLS-NEXT: 0000000000010000         *ABS*           00000000 __code_base__
65 # SYMBOLS-NEXT: 0000000000001000         *ABS*           00000000 VAR
66 # SYMBOLS-NEXT: 0000000000011000         .bbb            00000000 __start_bbb
67 # SYMBOLS-NEXT: 0000000000012000         .bbb            00000000 __end_bbb
68
69 .global _start
70 _start:
71  nop
72
73 .section .aaa, "a"
74 .quad 0
75
76 .section .bbb, "a"
77 .quad 0
78
79 .section .ccc, "a"
80 .quad 0