2 ## Test RISC-V specific section layout. See also section-layout.s and riscv-gp.s.
4 # RUN: llvm-mc -filetype=obj -triple=riscv32 %s -o %t.32.o
5 # RUN: ld.lld -pie %t.32.o -o %t.32
6 # RUN: llvm-readelf -S -sX %t.32 | FileCheck %s --check-prefix=NOSDATA
7 # RUN: llvm-mc -filetype=obj -triple=riscv32 --defsym=SDATA=1 %s -o %t.32s.o
8 # RUN: ld.lld -pie %t.32s.o -o %t.32s
9 # RUN: llvm-readelf -S -sX %t.32s | FileCheck %s
11 # RUN: llvm-mc -filetype=obj -triple=riscv64 %s -o %t.64.o
12 # RUN: ld.lld -pie %t.64.o -o %t.64
13 # RUN: llvm-readelf -S -sX %t.64 | FileCheck %s --check-prefix=NOSDATA
14 # RUN: llvm-mc -filetype=obj -triple=riscv64 --defsym=SDATA=1 %s -o %t.64s.o
15 # RUN: ld.lld -pie %t.64s.o -o %t.64s
16 # RUN: llvm-readelf -S -sX %t.64s | FileCheck %s
18 # NOSDATA: .rodata PROGBITS
19 # NOSDATA-NEXT: .text PROGBITS
20 # NOSDATA-NEXT: .tdata PROGBITS [[#%x,TDATA:]]
21 # NOSDATA-NEXT: .tbss NOBITS
22 # NOSDATA-NEXT: .dynamic DYNAMIC
23 # NOSDATA-NEXT: .got PROGBITS
24 # NOSDATA-NEXT: .relro_padding NOBITS
25 # NOSDATA-NEXT: .data PROGBITS [[#%x,DATA:]]
26 # NOSDATA-NEXT: .bss NOBITS [[#%x,BSS:]]
28 ## If there is an undefined reference to __global_pointer$ but .sdata doesn't
29 ## exist, define __global_pointer$ and set its st_shndx arbitrarily to 1.
30 ## The symbol value should not be used by the program.
32 # NOSDATA-DAG: [[#]]: {{.*}} 0 NOTYPE GLOBAL DEFAULT [[#]] (.text) _etext
33 # NOSDATA-DAG: [[#]]: {{0*}}[[#BSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] (.data) _edata
34 # NOSDATA-DAG: [[#]]: {{0*}}[[#BSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] (.bss) __bss_start
35 # NOSDATA-DAG: [[#]]: {{0*}}800 0 NOTYPE GLOBAL DEFAULT 1 (.dynsym) __global_pointer$
37 # CHECK: .rodata PROGBITS
38 # CHECK-NEXT: .srodata PROGBITS
39 # CHECK-NEXT: .text PROGBITS
40 # CHECK-NEXT: .tdata PROGBITS
41 # CHECK-NEXT: .tbss NOBITS
42 # CHECK-NEXT: .dynamic DYNAMIC
43 # CHECK-NEXT: .got PROGBITS
44 # CHECK-NEXT: .relro_padding NOBITS
45 # CHECK-NEXT: .data PROGBITS
46 # CHECK-NEXT: .sdata PROGBITS [[#%x,SDATA:]]
47 # CHECK-NEXT: .sbss NOBITS [[#%x,SBSS:]]
48 # CHECK-NEXT: .bss NOBITS
50 # CHECK-DAG: [[#]]: {{0*}}[[#SBSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] (.sdata) _edata
51 # CHECK-DAG: [[#]]: {{0*}}[[#SBSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] (.sbss) __bss_start
52 # CHECK-DAG: [[#]]: {{0*}}[[#SDATA+0x800]] 0 NOTYPE GLOBAL DEFAULT [[#]] (.sdata) __global_pointer$
54 .globl _etext, _edata, __bss_start
55 lla gp
, __global_pointer$
57 .section .rodata,"a",@progbits; .space 1
58 .section .data,"aw",@progbits; .long _GLOBAL_OFFSET_TABLE_ - .
59 .section .bss,"aw",@nobits; .space 1
60 .section .tdata,"awT",@progbits; .space 1
61 .section .tbss,"awT",@nobits; .space 1
63 .section .sdata,"aw",@progbits; .space 1
64 .section .sdata.suffix,"aw",@progbits; .space 1
65 .section .sbss,"aw",@nobits; .space 1
66 .section .sbss.suffix,"aw",@nobits; .space 1
67 .section .srodata,"a",@progbits; .space 1
68 .section .srodata.suffix,"a",@progbits; .space 1