[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / linkerscript / subalign.s
bloba817a69933143b5579f43e424b447c9bed7ce612
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
4 # RUN: echo "SECTIONS { .aaa : { *(.aaa.*) } }" > %t1.script
5 # RUN: ld.lld -o %t1 --script %t1.script %t1.o
6 # RUN: llvm-objdump -s %t1 | FileCheck --check-prefix=NOALIGN %s
7 # NOALIGN: Contents of section .aaa:
8 # NOALIGN-NEXT: 01000000 00000000 00000000 00000000
9 # NOALIGN-NEXT: 00000000 00000000 00000000 00000000
10 # NOALIGN-NEXT: 02000000 00000000 00000000 00000000
11 # NOALIGN-NEXT: 00000000 00000000 00000000 00000000
12 # NOALIGN-NEXT: 03000000 00000000 00000000 00000000
13 # NOALIGN-NEXT: 00000000 00000000 00000000 00000000
14 # NOALIGN-NEXT: 00000000 00000000 00000000 00000000
15 # NOALIGN-NEXT: 00000000 00000000 00000000 00000000
16 # NOALIGN-NEXT: 04000000 00000000
18 # RUN: echo "SECTIONS { .aaa : SUBALIGN(1) { *(.aaa.*) } }" > %t2.script
19 # RUN: ld.lld -o %t2 --script %t2.script %t1.o
20 # RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SUBALIGN %s
21 # SUBALIGN: Contents of section .aaa:
22 # SUBALIGN: 01000000 00000000 02000000 00000000
23 # SUBALIGN: 03000000 00000000 04000000 00000000
25 ## Test we do not assert or crash when dot(.) is used inside SUBALIGN.
26 ## Value of dot is undefined. Some versions of ld.bfd do not allow to use dot
27 ## in such expressions.
28 # RUN: echo "SECTIONS { . = 0x32; .aaa : SUBALIGN(.) { *(.aaa*) } }" > %t3.script
29 # RUN: not ld.lld %t1.o --script %t3.script -o /dev/null 2>&1 | FileCheck --check-prefix=ERR1 %s
30 # ERR1: {{.*}}.script:1: unable to get location counter value
32 ## Test we are able to link with zero alignment, this is consistent with bfd 2.26.1.
33 # RUN: echo "SECTIONS { .aaa : SUBALIGN(0) { *(.aaa*) } }" > %t4.script
34 # RUN: ld.lld %t1.o --script %t4.script -o %t4
35 # RUN: llvm-objdump -s %t4 | FileCheck --check-prefix=SUBALIGN %s
37 ## Test we fail gracefully when alignment value is not a power of 2.
38 # RUN: echo "SECTIONS { .aaa : SUBALIGN(3) { *(.aaa*) } }" > %t5.script
39 # RUN: not ld.lld %t1.o --script %t5.script -o /dev/null 2>&1 | FileCheck --check-prefix=ERR2 %s
40 # ERR2: {{.*}}.script:1: alignment must be power of 2
42 .global _start
43 _start:
44 nop
46 .section .aaa.1, "a"
47 .align 16
48 .quad 1
50 .section .aaa.2, "a"
51 .align 32
52 .quad 2
54 .section .aaa.3, "a"
55 .align 64
56 .quad 3
58 .section .aaa.4, "a"
59 .align 128
60 .quad 4