89 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t3 4## Check that padding value works:5# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122 }" > %t.script6# RUN: ld.lld -o %t.out --script %t.script %t7# RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s8# YES: 66000011 22000011 22000011 220000119 10# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =(0x1100+0x22) }" > %t.script11# RUN: ld.lld -o %t.out --script %t.script %t12# RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES2 %s13# YES2: 66000011 22000011 22000011 2200001114 15## Confirming that address was correct:16# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x99887766 }" > %t.script17# RUN: ld.lld -o %t.out --script %t.script %t18# RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES3 %s19# YES3: 66998877 66998877 66998877 6699887720 21## Default padding value is 0x00:22# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } }" > %t.script23# RUN: ld.lld -o %t.out --script %t.script %t24# RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=NO %s25# NO: 66000000 00000000 00000000 0000000026 27## Decimal value.28# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =777 }" > %t.script29# RUN: ld.lld -o %t.out --script %t.script %t30# RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=DEC %s31# DEC: 66000003 09000003 09000003 0900000332 33## Invalid hex value:34# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x99XX }" > %t.script35# 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: 0x99XX38# ERR2-NEXT: >>> SECTIONS { .mysec : { *(.mysec*) } =0x99XX }39# ERR2-NEXT: >>> ^40# ERR2-EMPTY:41# ERR2-NEXT: error: {{.*}}.script:1: symbol not found: 0x99XX42 43## Check case with space between '=' and a value:44# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } = 0x1122 }" > %t.script45# RUN: ld.lld -o %t.out --script %t.script %t46# RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s47 48## Check case with optional comma following output section command:49# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x1122, .a : { *(.a*) } }" > %t.script50# RUN: ld.lld -o %t.out --script %t.script %t51# RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s52 53## Check we can use an artbitrary expression as a filler.54# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } = ((0x11<<8) | 0x22) }" > %t.script55# RUN: ld.lld -o %t.out --script %t.script %t56# RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s57 58## Check case with space between '=' and expression:59# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =((0x11 << 8) | 0x22) }" > %t.script60# RUN: ld.lld -o %t.out --script %t.script %t61# RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s62 63## Check we report an error if expression value is larger than 32-bits.64# RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =(0x11 << 32) }" > %t.script65# 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: 0x110000000067 68## Check we report an error if an expression use a symbol.69# RUN: echo "SECTIONS { foo = 0x11; .mysec : { *(.mysec*) } = foo }" > %t.script70# 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: foo72 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.script75# RUN: ld.lld -o %t.out --script %t.script %t76# RUN: llvm-objdump -s %t.out | FileCheck --check-prefix=YES %s77 78.section .mysec.1,"a"79.align 1680.byte 0x6681 82.section .mysec.2,"a"83.align 1684.byte 0x6685 86.globl _start87_start:88 nop89