Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / riscv-gp.s
blob29411d19b01929166fc53e181dde191632aaba69
1 # REQUIRES: riscv
2 # RUN: llvm-mc -filetype=obj -triple=riscv32 %s -o %t.32.o
3 # RUN: ld.lld -pie %t.32.o -o %t.32
4 # RUN: llvm-readelf -S -s %t.32 | FileCheck --check-prefix=SEC32 %s
5 # RUN: not ld.lld -shared %t.32.o -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s
7 # RUN: llvm-mc -filetype=obj -triple=riscv64 %s -o %t.64.o
8 # RUN: ld.lld -pie %t.64.o -o %t.64
9 # RUN: llvm-readelf -S -s %t.64 | FileCheck --check-prefix=SEC64 %s
10 # RUN: not ld.lld -shared %t.64.o -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s
12 ## __global_pointer$ = .sdata+0x800 = 0x39c0
13 # SEC32: [ [[#SDATA:]]] .sdata PROGBITS {{0*}}000031c0
14 # SEC32: {{0*}}000039c0 0 NOTYPE GLOBAL DEFAULT [[#SDATA]] __global_pointer$
16 # SEC64: [ [[#SDATA:]]] .sdata PROGBITS {{0*}}000032e0
17 # SEC64: {{0*}}00003ae0 0 NOTYPE GLOBAL DEFAULT [[#SDATA]] __global_pointer$
19 ## __global_pointer$ - 0x1000 = 4096*3-2048
20 # DIS: 1000: auipc gp, 3
21 # DIS-NEXT: addi gp, gp, -2048
23 # ERR: error: relocation R_RISCV_PCREL_HI20 cannot be used against symbol '__global_pointer$'; recompile with -fPIC
25 ## -r mode does not define __global_pointer$.
26 # RUN: ld.lld -r %t.64.o -o %t.64.ro
27 # RUN: llvm-readelf -s %t.64.ro | FileCheck --check-prefix=RELOCATABLE %s
29 # RELOCATABLE: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND __global_pointer$
31 lla gp, __global_pointer$
33 .section .sdata,"aw"