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.
4
5# RUN: split-file %s %t
6# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/asm -o %t.o
7
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
10
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
15
16# EXE:      [Nr] Name  Type      Address
17# EXE-NEXT: [ 0]
18# EXE-NEXT: [ 1] .text PROGBITS  0000000000000000
19# EXE-NEXT: [ 2] .bss  NOBITS    000000000000000a
20
21# EXE:      R_X86_64_64 {{.*}} .bss + 1
22
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
29
30# RO:       [Nr] Name  Type      Address
31# RO-NEXT:  [ 0]
32# RO-NEXT:  [ 1] .bss  NOBITS    0000000000000000
33
34# RO:       R_X86_64_64 {{.*}} .bss + 1
35
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
41
42#--- asm
43movabsq .bss, %rax
44
45.bss
46.byte 0
47
48#--- lds
49SECTIONS {
50  .bss : { BYTE(0) *(.bss) }
51}
52