2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
4 ## Check simple RAM-only memory region.
6 # RUN: echo "MEMORY { ram (rwx) : ORIGIN = 0x8000, LENGTH = 256K } \
8 # RUN: .text : { *(.text) } > ram \
9 # RUN: .data : { *(.data) } > ram \
11 # RUN: ld.lld -o %t1 --script %t.script %t
12 # RUN: llvm-readelf -S %t1 | FileCheck --check-prefix=RAM %s
14 # RAM: [ 1] .text PROGBITS 0000000000008000 001000 000001
15 # RAM-NEXT: [ 2] .data PROGBITS 0000000000008001 001001 001000
17 ## Check RAM and ROM memory regions.
19 # RUN: echo "MEMORY { \
20 # RUN: ram (rwx) : ORIGIN = 0, LENGTH = 1024M \
21 # RUN: rom (rx) : org = (0x80 * 0x1000 * 0x1000), len = 64M \
24 # RUN: .text : { *(.text) } >rom \
25 # RUN: .data : { *(.data) } >ram \
27 # RUN: ld.lld -o %t1 --script %t.script %t
28 # RUN: llvm-readelf -S %t1 | FileCheck --check-prefix=RAMROM %s
30 # RAMROM: [ 1] .text PROGBITS 0000000080000000 001000 000001
31 # RAMROM-NEXT: [ 2] .data PROGBITS 0000000000000000 002000 001000
33 ## Check memory region placement by attributes.
35 # RUN: echo "MEMORY { \
36 # RUN: ram (!rx) : ORIGIN = 0, LENGTH = 1024M \
37 # RUN: rom (rx) : o = 0x80000000, l = 64M \
40 # RUN: .text : { *(.text) } \
41 # RUN: .data : { *(.data) } > ram \
43 # RUN: ld.lld -o %t1 --script %t.script %t
44 # RUN: llvm-readelf -S %t1 | FileCheck --check-prefix=ATTRS %s
46 # ATTRS: [ 1] .text PROGBITS 0000000080000000 001000 000001
47 # ATTRS-NEXT: [ 2] .data PROGBITS 0000000000000000 002000 001000
49 ## ORIGIN/LENGTH support expressions with symbol assignments.
50 # RUN: echo 'MEMORY { ram : ORIGIN = symbol, LENGTH = 4097 } \
52 # RUN: .text : { *(.text) } > ram \
53 # RUN: .data : { *(.data) } > ram \
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
61 # RELRO: [ 1] .text PROGBITS 0000000000005000 001000 000001
62 # RELRO-NEXT: [ 2] .data PROGBITS 0000000000005001 001001 001000
64 # RUN: echo 'MEMORY { ram : ORIGIN = CONSTANT(COMMONPAGESIZE), LENGTH = CONSTANT(COMMONPAGESIZE)+1 } \
66 # RUN: .text : { *(.text) } > ram \
67 # RUN: .data : { *(.data) } > ram \
69 # RUN: ld.lld -T %t.script %t -o %t.pagesize
70 # RUN: llvm-readelf -S %t.pagesize | FileCheck --check-prefix=PAGESIZE %s
72 # PAGESIZE: [ 1] .text PROGBITS 0000000000001000 001000 000001
73 # PAGESIZE-NEXT: [ 2] .data PROGBITS 0000000000001001 001001 001000