1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t 3 4## Check simple RAM-only memory region. 5 6# RUN: echo "MEMORY { ram (rwx) : ORIGIN = 0x8000, LENGTH = 256K } \ 7# RUN: SECTIONS { \ 8# RUN: .text : { *(.text) } > ram \ 9# RUN: .data : { *(.data) } > ram \ 10# RUN: }" > %t.script 11# RUN: ld.lld -o %t1 --script %t.script %t 12# RUN: llvm-readelf -S %t1 | FileCheck --check-prefix=RAM %s 13 14# RAM: [ 1] .text PROGBITS 0000000000008000 001000 000001 15# RAM-NEXT: [ 2] .data PROGBITS 0000000000008001 001001 001000 16 17## Check RAM and ROM memory regions. 18 19# RUN: echo "MEMORY { \ 20# RUN: ram (rwx) : ORIGIN = 0, LENGTH = 1024M \ 21# RUN: rom (rx) : org = (0x80 * 0x1000 * 0x1000), len = 64M \ 22# RUN: } \ 23# RUN: SECTIONS { \ 24# RUN: .text : { *(.text) } >rom \ 25# RUN: .data : { *(.data) } >ram \ 26# RUN: }" > %t.script 27# RUN: ld.lld -o %t1 --script %t.script %t 28# RUN: llvm-readelf -S %t1 | FileCheck --check-prefix=RAMROM %s 29 30# RAMROM: [ 1] .text PROGBITS 0000000080000000 001000 000001 31# RAMROM-NEXT: [ 2] .data PROGBITS 0000000000000000 002000 001000 32 33## Check memory region placement by attributes. 34 35# RUN: echo "MEMORY { \ 36# RUN: ram (!rx) : ORIGIN = 0, LENGTH = 1024M \ 37# RUN: rom (rx) : o = 0x80000000, l = 64M \ 38# RUN: } \ 39# RUN: SECTIONS { \ 40# RUN: .text : { *(.text) } \ 41# RUN: .data : { *(.data) } > ram \ 42# RUN: }" > %t.script 43# RUN: ld.lld -o %t1 --script %t.script %t 44# RUN: llvm-readelf -S %t1 | FileCheck --check-prefix=ATTRS %s 45 46# ATTRS: [ 1] .text PROGBITS 0000000080000000 001000 000001 47# ATTRS-NEXT: [ 2] .data PROGBITS 0000000000000000 002000 001000 48 49## ORIGIN/LENGTH support expressions with symbol assignments. 50# RUN: echo 'MEMORY { ram : ORIGIN = symbol, LENGTH = 4097 } \ 51# RUN: SECTIONS { \ 52# RUN: .text : { *(.text) } > ram \ 53# RUN: .data : { *(.data) } > ram \ 54# RUN: }' > %t.script 55# RUN: ld.lld -T %t.script %t --defsym symbol=0x5000 -o %t.relro 56# RUN: llvm-readelf -S %t.relro | FileCheck --check-prefix=RELRO %s 57# RUN: echo 'symbol = 0x5000;' > %t1.script 58# RUN: ld.lld -T %t.script -T %t1.script %t -o %t.relro2 59# RUN: llvm-readelf -S %t.relro2 | FileCheck --check-prefix=RELRO %s 60 61# RELRO: [ 1] .text PROGBITS 0000000000005000 001000 000001 62# RELRO-NEXT: [ 2] .data PROGBITS 0000000000005001 001001 001000 63 64# RUN: echo 'MEMORY { ram : ORIGIN = CONSTANT(COMMONPAGESIZE), LENGTH = CONSTANT(COMMONPAGESIZE)+1 } \ 65# RUN: SECTIONS { \ 66# RUN: .text : { *(.text) } > ram \ 67# RUN: .data : { *(.data) } > ram \ 68# RUN: }' > %t.script 69# RUN: ld.lld -T %t.script %t -o %t.pagesize 70# RUN: llvm-readelf -S %t.pagesize | FileCheck --check-prefix=PAGESIZE %s 71 72# PAGESIZE: [ 1] .text PROGBITS 0000000000001000 001000 000001 73# PAGESIZE-NEXT: [ 2] .data PROGBITS 0000000000001001 001001 001000 74 75.text 76.global _start 77_start: 78 nop 79 80.data 81b: 82 .long 1 83 .zero 4092 84