[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / relro-bss.s
blob8fc8167bb51b7dc6d093bd8747a1d3a99aa6be8e
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
3 # RUN: ld.lld %t.o -o %t
4 # RUN: llvm-readelf -l %t | FileCheck --check-prefix=SEG %s
5 # RUN: llvm-readelf -S %t | FileCheck %s
7 # We have 2 RW PT_LOAD segments. p_offset p_vaddr p_paddr p_filesz of the first
8 # should match PT_GNU_RELRO.
9 # Because .bss.rel.ro (nobits) doesn't take space, p_filesz < p_memsz.
11 # Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
12 # SEG: LOAD 0x0001c8 0x00000000002011c8 0x00000000002011c8 0x000001 0x000001 R E 0x1000
13 # SEG-NEXT: LOAD 0x0001c9 0x00000000002021c9 0x00000000002021c9 0x000001 0x002001 RW 0x1000
14 # SEG-NEXT: LOAD 0x0001ca 0x00000000002051ca 0x00000000002051ca 0x000001 0x000002 RW 0x1000
15 # SEG-NEXT: GNU_RELRO 0x0001c9 0x00000000002021c9 0x00000000002021c9 0x000001 0x002e37 R 0x1
16 # SEG-NEXT: GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x0
18 # SEG: .text
19 # SEG-NEXT: .data.rel.ro .bss.rel.ro
20 # SEG-NEXT: .data .bss
22 # And .data is placed in the next page (sh_offset = alignTo(0x2001, 4096) = 0x3000).
24 # [Nr] Name Type Address Off Size
25 # CHECK: .data.rel.ro PROGBITS 00000000002021c9 0001c9 000001
26 # CHECK-NEXT: .bss.rel.ro NOBITS 00000000002021ca 0001ca 002000
27 # CHECK-NEXT: .data PROGBITS 00000000002051ca 0001ca 000001
28 # CHECK-NEXT: .bss NOBITS 00000000002051cb 0001cb 000001
30 .globl _start
31 _start:
32 ret
34 .section .data.rel.ro, "aw"
35 .space 1
37 .section .bss.rel.ro, "aw", @nobits
38 .space 8192
40 .section .data, "aw"
41 .space 1
43 .section .bss, "aw"
44 .space 1