[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / section-symbol-gap.s
blob75a207d6d6f75ad99f0270d2ebcfa1a57d8ad939
1 # REQUIRES: x86
2 ## Test st_value of the STT_SECTION symbol equals the output section address,
3 ## instead of the first input section address.
5 # RUN: split-file %s %t
6 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/asm -o %t.o
8 # RUN: ld.lld --emit-relocs -T %t/lds %t.o -o %t.out
9 # RUN: llvm-readelf -S -r -s %t.out | FileCheck %s --check-prefix=EXE
11 ## In -r mode, section addresses are zeros, hence the st_value fields of
12 ## STT_SECTION are zeros.
13 # RUN: ld.lld -r -T %t/lds %t.o -o %t.ro
14 # RUN: llvm-readelf -S -r -s %t.ro | FileCheck %s --check-prefix=RO
16 # EXE: [Nr] Name Type Address
17 # EXE-NEXT: [ 0]
18 # EXE-NEXT: [ 1] .text PROGBITS 0000000000000000
19 # EXE-NEXT: [ 2] .bss NOBITS 000000000000000a
21 # EXE: R_X86_64_64 {{.*}} .bss + 1
23 # EXE: Symbol table '.symtab' contains 4 entries:
24 # EXE-NEXT: Num: Value Size Type Bind Vis Ndx Name
25 # EXE-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
26 # EXE-NEXT: 1: 000000000000000a 0 SECTION LOCAL DEFAULT 2 .bss
27 # EXE-NEXT: 2: 0000000000000000 0 SECTION LOCAL DEFAULT 1 .text
28 # EXE-NEXT: 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 .comment
30 # RO: [Nr] Name Type Address
31 # RO-NEXT: [ 0]
32 # RO-NEXT: [ 1] .bss NOBITS 0000000000000000
34 # RO: R_X86_64_64 {{.*}} .bss + 1
36 # RO: Symbol table '.symtab' contains 3 entries:
37 # RO-NEXT: Num: Value Size Type Bind Vis Ndx Name
38 # RO-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
39 # RO-NEXT: 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 .bss
40 # RO-NEXT: 2: 0000000000000000 0 SECTION LOCAL DEFAULT 2 .text
42 #--- asm
43 movabsq .bss, %rax
45 .bss
46 .byte 0
48 #--- lds
49 SECTIONS {
50 .bss : { BYTE(0) *(.bss) }