2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
4 ## Check that padding value works:
5 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122 }" > %t.script
6 # RUN: ld.lld -o %t.out --script %t.script %t
7 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s
8 # YES: 66000011 22000011 22000011 22000011
10 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =(0x1100+0x22) }" > %t.script
11 # RUN: ld.lld -o %t.out --script %t.script %t
12 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES2 %s
13 # YES2: 66000011 22000011 22000011 22000011
15 ## Confirming that address was correct:
16 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x99887766 }" > %t.script
17 # RUN: ld.lld -o %t.out --script %t.script %t
18 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES3 %s
19 # YES3: 66998877 66998877 66998877 66998877
21 ## Default padding value is 0x00:
22 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } }" > %t.script
23 # RUN: ld.lld -o %t.out --script %t.script %t
24 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=NO %s
25 # NO: 66000000 00000000 00000000 00000000
28 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =777 }" > %t.script
29 # RUN: ld.lld -o %t.out --script %t.script %t
30 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=DEC %s
31 # DEC: 66000003 09000003 09000003 09000003
34 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x99XX }" > %t.script
35 # RUN: not ld.lld -o /dev/null --script %t.script %t 2>&1 \
36 # RUN: | FileCheck --check-prefix=ERR2 %s
37 # ERR2: malformed number: 0x99XX
39 ## Check case with space between '=' and a value:
40 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } = 0x1122 }" > %t.script
41 # RUN: ld.lld -o %t.out --script %t.script %t
42 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s
44 ## Check case with optional comma following output section command:
45 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122, .a : { *(.a*) } }" > %t.script
46 # RUN: ld.lld -o %t.out --script %t.script %t
47 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s
49 ## Check we can use an artbitrary expression as a filler.
50 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } = ((0x11<<8) | 0x22) }" > %t.script
51 # RUN: ld.lld -o %t.out --script %t.script %t
52 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s
54 ## Check case with space between '=' and expression:
55 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =((0x11 << 8) | 0x22) }" > %t.script
56 # RUN: ld.lld -o %t.out --script %t.script %t
57 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s
59 ## Check we report an error if expression value is larger than 32-bits.
60 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =(0x11 << 32) }" > %t.script
61 # RUN: not ld.lld -o /dev/null --script %t.script %t 2>&1 | FileCheck --check-prefix=ERR3 %s
62 # ERR3: filler expression result does not fit 32-bit: 0x1100000000
64 ## Check we report an error if an expression use a symbol.
65 # RUN: echo "SECTIONS { foo = 0x11; .mysec : { *(.mysec*) } = foo }" > %t.script
66 # RUN: not ld.lld -o /dev/null %t --script %t.script 2>&1 | FileCheck --check-prefix=ERR4 %s
67 # ERR4: symbol not found: foo
69 ## Check we are able to parse scripts where "/DISCARD/" follows a section fill expression.
70 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122 /DISCARD/ : { *(.text) } }" > %t.script
71 # RUN: ld.lld -o %t.out --script %t.script %t
72 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s