[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / linkerscript / sections-constraint.s
blobb0dc51c9f711d427a938c60abe4fc7f5f8178fdf
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
3 # RUN: echo "SECTIONS { \
4 # RUN: .writable : ONLY_IF_RW { *(.writable) } \
5 # RUN: .readable : ONLY_IF_RO { *(.readable) }}" > %t.script
6 # RUN: ld.lld -o %t1 --script %t.script %t
7 # RUN: llvm-objdump --section-headers %t1 | \
8 # RUN: FileCheck -check-prefix=BASE %s
9 # BASE: Sections:
10 # BASE-NEXT: Idx Name Size
11 # BASE-NEXT: 0 00000000
12 # BASE: .writable 00000004
13 # BASE: .readable 00000004
15 # RUN: echo "SECTIONS { \
16 # RUN: .foo : ONLY_IF_RO { *(.foo.*) } \
17 # RUN: .writable : ONLY_IF_RW { *(.writable) } \
18 # RUN: .readable : ONLY_IF_RO { *(.readable) }}" > %t2.script
19 # RUN: ld.lld -o %t2 --script %t2.script %t
20 # RUN: llvm-objdump --section-headers %t2 | \
21 # RUN: FileCheck -check-prefix=NO1 %s
22 # NO1: Sections:
23 # NO1-NEXT: Idx Name Size
24 # NO1-NEXT: 0 00000000
25 # NO1: .writable 00000004
26 # NO1: .foo.2 00000004
27 # NO1: .readable 00000004
28 # NO1: .foo.1 00000004
30 .global _start
31 _start:
32 nop
34 .section .writable, "aw"
35 writable:
36 .long 1
38 .section .readable, "a"
39 readable:
40 .long 2
42 .section .foo.1, "awx"
43 .long 0
45 .section .foo.2, "aw"
46 .long 0