|
1 | 1 | # REQUIRES: x86
|
2 |
| -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t |
| 2 | +# RUN: rm -rf %t && split-file %s %t && cd %t |
| 3 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o |
3 | 4 |
|
4 |
| -# Empty SECTIONS command. |
5 |
| -# RUN: echo "SECTIONS {}" > %t.script |
6 |
| -# RUN: ld.lld -o %t1 --script %t.script %t |
7 |
| -# RUN: llvm-objdump --section-headers %t1 | \ |
| 5 | +#--- empty.lds |
| 6 | +SECTIONS {} |
| 7 | + |
| 8 | +# RUN: ld.lld -o empty -T empty.lds a.o |
| 9 | +# RUN: llvm-objdump --section-headers empty | \ |
8 | 10 | # RUN: FileCheck -check-prefix=SEC-DEFAULT %s
|
9 | 11 |
|
| 12 | +#--- 1.lds |
10 | 13 | # SECTIONS command with the same order as default.
|
11 |
| -# RUN: echo "SECTIONS { \ |
12 |
| -# RUN: .text : { *(.text) } \ |
13 |
| -# RUN: .data : { *(.data) } }" > %t.script |
14 |
| -# RUN: ld.lld -o %t2 --script %t.script %t |
15 |
| -# RUN: llvm-objdump --section-headers %t2 | \ |
| 14 | +SECTIONS { |
| 15 | + .text : { *(.text) } |
| 16 | + .data : { *(.data) } } |
| 17 | + |
| 18 | +# RUN: ld.lld -o 1 -T 1.lds a.o |
| 19 | +# RUN: llvm-objdump --section-headers 1 | \ |
16 | 20 | # RUN: FileCheck -check-prefix=SEC-DEFAULT %s
|
17 | 21 |
|
18 | 22 | # Idx Name Size
|
|
28 | 32 | # .text and .data have swapped names but proper sizes and types.
|
29 | 33 | # RUN: echo "SECTIONS { \
|
30 | 34 | # RUN: .data : { *(.text) } \
|
31 |
| -# RUN: .text : { *(.data) } }" > %t.script |
32 |
| -# RUN: ld.lld -o %t4 --script %t.script %t |
| 35 | +# RUN: .text : { *(.data) } }" > t.lds |
| 36 | +# RUN: ld.lld -o %t4 --script t.lds a.o |
33 | 37 | # RUN: llvm-objdump --section-headers %t4 | \
|
34 | 38 | # RUN: FileCheck -check-prefix=SEC-SWAP-NAMES %s
|
35 | 39 |
|
|
50 | 54 | # RUN: .text : { *(.text) } \
|
51 | 55 | # RUN: .data : { *(.data) } } \
|
52 | 56 | # RUN: SECTIONS { \
|
53 |
| -# RUN: .data : { *(other) } }" > %t.script |
54 |
| -# RUN: ld.lld -o %t6 --script %t.script %t |
| 57 | +# RUN: .data : { *(other) } }" > t.lds |
| 58 | +# RUN: ld.lld -o %t6 --script t.lds a.o |
55 | 59 | # RUN: llvm-objdump --section-headers %t6 | \
|
56 | 60 | # RUN: FileCheck -check-prefix=SEC-MULTI %s
|
57 | 61 |
|
|
72 | 76 | # RUN: .data : { *(.data) } \
|
73 | 77 | # RUN: .comment : { *(.comment) } \
|
74 | 78 | # RUN: other : { *(other) } }' > %t5.lds
|
75 |
| -# RUN: ld.lld -o %t5 -T %t5.lds %t |
| 79 | +# RUN: ld.lld -o %t5 -T %t5.lds a.o |
76 | 80 | # RUN: llvm-readelf -S -l %t5 | FileCheck --check-prefix=SEP-BY-NONALLOC %s
|
77 | 81 |
|
78 | 82 | # SEP-BY-NONALLOC: [Nr] Name Type Address Off Size ES Flg
|
|
87 | 91 | # SEP-BY-NONALLOC-NEXT: LOAD 0x00100e 0x000000000000000e 0x000000000000000e 0x000023 0x000025 RW 0x1000
|
88 | 92 | # SEP-BY-NONALLOC-NEXT: GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0
|
89 | 93 |
|
| 94 | +#--- semi.lds |
90 | 95 | # Input section pattern contains additional semicolon.
|
91 | 96 | # Case found in linux kernel script. Check we are able to parse it.
|
92 |
| -# RUN: echo "SECTIONS { .text : { ;;*(.text);;S = 0;; } }" > %t.script |
93 |
| -# RUN: ld.lld -o /dev/null --script %t.script %t |
| 97 | +SECTIONS { .text : { ;;*(.text);;S = 0;; } } |
| 98 | + |
| 99 | +# RUN: ld.lld -T semi.lds a.o |
| 100 | + |
| 101 | +#--- unclosed.lds |
| 102 | +SECTIONS { |
| 103 | + .text : { *(.text) } |
| 104 | + |
| 105 | +# RUN: not ld.lld -T unclosed.lds a.o 2>&1 | FileCheck --check-prefix=UNCLOSED %s |
| 106 | +# UNCLOSED: error: unclosed.lds:1: malformed number: |
| 107 | + |
| 108 | +#--- unclosed-out.lds |
| 109 | +SECTIONS { |
| 110 | + .text : { *(.text) |
94 | 111 |
|
| 112 | +#--- a.s |
95 | 113 | .globl _start
|
96 | 114 | _start:
|
97 | 115 | mov $60, %rax
|
|
0 commit comments