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 --implicit-check-not=error:
37 # ERR2: error: {{.*}}.script:1: malformed number: 0x99XX
38 # ERR2-NEXT: >>> SECTIONS { .mysec : { *(.mysec*) } =0x99XX }
41 # ERR2-NEXT: error: {{.*}}.script:1: symbol not found: 0x99XX
43 ## Check case with space between '=' and a value:
44 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } = 0x1122 }" > %t.script
45 # RUN: ld.lld -o %t.out --script %t.script %t
46 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s
48 ## Check case with optional comma following output section command:
49 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122, .a : { *(.a*) } }" > %t.script
50 # RUN: ld.lld -o %t.out --script %t.script %t
51 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s
53 ## Check we can use an artbitrary expression as a filler.
54 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } = ((0x11<<8) | 0x22) }" > %t.script
55 # RUN: ld.lld -o %t.out --script %t.script %t
56 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s
58 ## Check case with space between '=' and expression:
59 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =((0x11 << 8) | 0x22) }" > %t.script
60 # RUN: ld.lld -o %t.out --script %t.script %t
61 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s
63 ## Check we report an error if expression value is larger than 32-bits.
64 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =(0x11 << 32) }" > %t.script
65 # RUN: not ld.lld -o /dev/null --script %t.script %t 2>&1 | FileCheck --check-prefix=ERR3 %s --implicit-check-not=error:
66 # ERR3: error: {{.*}}.script:1: filler expression result does not fit 32-bit: 0x1100000000
68 ## Check we report an error if an expression use a symbol.
69 # RUN: echo "SECTIONS { foo = 0x11; .mysec : { *(.mysec*) } = foo }" > %t.script
70 # RUN: not ld.lld -o /dev/null %t --script %t.script 2>&1 | FileCheck --check-prefix=ERR4 %s --implicit-check-not=error:
71 # ERR4: error: {{.*}}.script:1: symbol not found: foo
73 ## Check we are able to parse scripts where "/DISCARD/" follows a section fill expression.
74 # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122 /DISCARD/ : { *(.text) } }" > %t.script
75 # RUN: ld.lld -o %t.out --script %t.script %t
76 # RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s