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 -s %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 -s %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 -s %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 -s %t.64s | FileCheck %s
19 # NOSDATA-NEXT: .tdata
21 # NOSDATA-NEXT: .dynamic
23 # NOSDATA-NEXT: .relro_padding
24 # NOSDATA-NEXT: .data PROGBITS [[#%x,DATA:]]
25 # NOSDATA-NEXT: .bss NOBITS [[#%x,BSS:]]
27 ## If there is an undefined reference to __global_pointer$ but .sdata doesn't
28 ## exist, define __global_pointer$ and set its st_shndx arbitrarily to 1.
29 ## The symbol value should not be used by the program.
31 # NOSDATA-DAG: [[#]]: {{0*}}[[#BSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] _edata
32 # NOSDATA-DAG: [[#]]: {{0*}}[[#BSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] __bss_start
33 # NOSDATA-DAG: [[#]]: {{0*}}800 0 NOTYPE GLOBAL DEFAULT 1 __global_pointer$
38 # CHECK-NEXT: .dynamic
40 # CHECK-NEXT: .relro_padding
42 # CHECK-NEXT: .sdata PROGBITS [[#%x,SDATA:]]
43 # CHECK-NEXT: .sbss NOBITS [[#%x,SBSS:]]
46 # CHECK-DAG: [[#]]: {{0*}}[[#SBSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] _edata
47 # CHECK-DAG: [[#]]: {{0*}}[[#SBSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] __bss_start
48 # CHECK-DAG: [[#]]: {{0*}}[[#SDATA+0x800]] 0 NOTYPE GLOBAL DEFAULT [[#]] __global_pointer$
50 .globl _edata, __bss_start
51 lla gp
, __global_pointer$
53 .section .data,"aw",@progbits; .long _GLOBAL_OFFSET_TABLE_ - .
54 .section .bss,"aw",@nobits; .space 1
55 .section .tdata,"awT",@progbits; .space 1
56 .section .tbss,"awT",@nobits; .space 1
58 .section .sdata,"aw",@progbits; .space 1
59 .section .sbss,"aw",@nobits; .space 1