2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
3 # RUN: echo "MEMORY { \
4 # RUN: ROM (rwx): ORIGIN = 0x1000, LENGTH = 0x100 \
5 # RUN: RAM (rwx): ORIGIN = 0x2000, LENGTH = 0x100 \
7 # RUN: INCLUDE \"%t.script.inc\" \
9 # RUN: .text : { *(.text*) } > ALIAS_TEXT \
10 # RUN: .data : { *(.data*) } > ALIAS_DATA \
13 ## .text to ROM, .data to RAM.
14 # RUN: echo "REGION_ALIAS (\"ALIAS_TEXT\", ROM);" > %t.script.inc
15 # RUN: echo "REGION_ALIAS (\"ALIAS_DATA\", RAM);" >> %t.script.inc
16 # RUN: ld.lld %t --script %t.script -o %t2
17 # RUN: llvm-objdump --section-headers %t2 | FileCheck %s
18 # CHECK: .text 00000001 0000000000001000 TEXT
19 # CHECK: .data 00000008 0000000000002000 DATA
22 # RUN: echo "REGION_ALIAS (\"ALIAS_TEXT\", ROM);" > %t.script.inc
23 # RUN: echo "REGION_ALIAS (\"ALIAS_DATA\", ROM);" >> %t.script.inc
24 # RUN: ld.lld %t --script %t.script -o %t2
25 # RUN: llvm-objdump --section-headers %t2 | FileCheck %s --check-prefix=RAM
26 # RAM: .text 00000001 0000000000001000 TEXT
27 # RAM: .data 00000008 0000000000001001 DATA
29 ## Redefinition of region.
30 # RUN: echo "REGION_ALIAS (\"ROM\", ROM);" > %t.script.inc
31 # RUN: not ld.lld %t --script %t.script -o /dev/null 2>&1 | \
32 # RUN: FileCheck %s --check-prefix=ERR1
33 # ERR1: {{.*}}script.inc:1: redefinition of memory region 'ROM'
35 ## Redefinition of alias.
36 # RUN: echo "REGION_ALIAS (\"ALIAS_TEXT\", ROM);" > %t.script.inc
37 # RUN: echo "REGION_ALIAS (\"ALIAS_TEXT\", ROM);" >> %t.script.inc
38 # RUN: not ld.lld %t --script %t.script -o /dev/null 2>&1 | \
39 # RUN: FileCheck %s --check-prefix=ERR2
40 # ERR2: {{.*}}script.inc:2: redefinition of memory region 'ALIAS_TEXT'
42 ## Attemp to create an alias for undefined region.
43 # RUN: echo "REGION_ALIAS (\"ALIAS_TEXT\", FOO);" > %t.script.inc
44 # RUN: not ld.lld %t --script %t.script -o /dev/null 2>&1 | \
45 # RUN: FileCheck %s --check-prefix=ERR3
46 # ERR3: {{.*}}script.inc:1: memory region 'FOO' is not defined