[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / linkerscript / merge-output-sections.s
blobb15596f84cf66585ce810ec7168723186bddd453
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
4 ## SHF_MERGE sections within the same output section can be freely merged.
5 # RUN: echo 'SECTIONS { .rodata : { *(.rodata.*) }}' > %t.script
6 # RUN: ld.lld %t.o -T %t.script -o %t
7 # RUN: llvm-readelf -x .rodata %t | FileCheck --check-prefix=SAME %s --implicit-check-not=section
9 # SAME: section '.rodata':
10 # SAME-NEXT: 0x00000000 01000200 0300
12 ## SHF_MERGE sections with different output sections cannot be merged.
13 # RUN: echo 'SECTIONS { \
14 # RUN: .rodata.foo : { *(.rodata.foo) } \
15 # RUN: .rodata.bar : { *(.rodata.bar) } \
16 # RUN: }' > %t2.script
17 # RUN: ld.lld %t.o -T %t2.script -o %t2
18 # RUN: llvm-readelf -x .rodata.foo -x .rodata.bar %t2 | FileCheck --check-prefix=DIFF %s --implicit-check-not=section
20 # DIFF: section '.rodata.foo':
21 # DIFF-NEXT: 0x00000000 01000200 0300
22 # DIFF: section '.rodata.bar':
23 # DIFF-NEXT: 0x00000006 0100
25 .section .rodata.foo,"aM",@progbits,2,unique,0
26 .short 1
27 .short 2
28 .section .rodata.foo,"aM",@progbits,2,unique,1
29 .short 1
30 .short 3
32 .section .rodata.bar,"aM",@progbits,2,unique,0
33 .short 1
34 .section .rodata.bar,"aM",@progbits,2,unique,1
35 .short 1