1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t 3 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 9 10## Confirming that address was correct: 11# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x99887766 }" > %t.script 12# RUN: ld.lld -o %t.out --script %t.script %t 13# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=YES2 %s 14# YES2: 66998877 66998877 66998877 66998877 15 16## Default padding value is 0x00: 17# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } }" > %t.script 18# RUN: ld.lld -o %t.out --script %t.script %t 19# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=NO %s 20# NO: 66000000 00000000 00000000 00000000 21 22## Decimal value. 23# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =777 }" > %t.script 24# RUN: ld.lld -o %t.out --script %t.script %t 25# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=DEC %s 26# DEC: 66000003 09000003 09000003 09000003 27 28## Invalid hex value: 29# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x99XX }" > %t.script 30# RUN: not ld.lld -o %t.out --script %t.script %t 2>&1 \ 31# RUN: | FileCheck --check-prefix=ERR2 %s 32# ERR2: malformed number: 0x99XX 33 34## Check case with space between '=' and a value: 35# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } = 0x1122 }" > %t.script 36# RUN: ld.lld -o %t.out --script %t.script %t 37# RUN: llvm-objdump -s %t.out | FileCheck -check-prefix=YES %s 38 39## Check case with optional comma following output section command: 40# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122, .a : { *(.a*) } }" > %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 43 44## Check we can use an artbitrary expression as a filler. 45# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } = ((0x11<<8) | 0x22) }" > %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 48 49## Check case with space between '=' and expression: 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 53 54## Check we report an error if expression value is larger that 32-bits. 55# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =(0x11 << 32) }" > %t.script 56# RUN: not ld.lld -o %t.out --script %t.script %t 2>&1 | FileCheck --check-prefix=ERR3 %s 57# ERR3: filler expression result does not fit 32-bit: 0x1100000000 58 59## Check we report an error if an expression use a symbol. 60# RUN: echo "SECTIONS { foo = 0x11; .mysec : { *(.mysec*) } = foo }" > %t.script 61# RUN: not ld.lld -o %t.out %t --script %t.script 2>&1 | FileCheck --check-prefix=ERR4 %s 62# ERR4: symbol not found: foo 63 64.section .mysec.1,"a" 65.align 16 66.byte 0x66 67 68.section .mysec.2,"a" 69.align 16 70.byte 0x66 71 72.globl _start 73_start: 74 nop 75