xref: /llvm-project/lld/test/ELF/systemz-reloc-pc32.s (revision fe3406e349884e4ef61480dd0607f1e237102c74)
1# REQUIRES: systemz
2# RUN: rm -rf %t && split-file %s %t
3
4## Check recompile with -fPIC error message
5# RUN: llvm-mc -filetype=obj -triple=s390x-unknown-linux %t/shared.s -o %t/shared.o
6# RUN: not ld.lld -shared %t/shared.o -o /dev/null 2>&1 | FileCheck %s
7
8# CHECK: error: relocation R_390_PC32 cannot be used against symbol '_shared'; recompile with -fPIC
9# CHECK: >>> defined in {{.*}}
10# CHECK: >>> referenced by {{.*}}:(.data+0x1)
11
12## Check patching of negative addends
13
14# RUN: llvm-mc -filetype=obj -triple=s390x -defsym ADDEND=1 %t/addend.s -o %t/1.o
15# RUN: llvm-mc -filetype=obj -triple=s390x -defsym ADDEND=2147483648 %t/addend.s -o %t/2.o
16# RUN: llvm-mc -filetype=obj -triple=s390x -defsym ADDEND=2147483649 %t/addend.s -o %t/3.o
17
18# RUN: ld.lld --section-start=.text=0x0 %t/1.o -o %t/1out
19# RUN: ld.lld --section-start=.text=0x0 %t/2.o -o %t/2out
20# RUN: not ld.lld --section-start=.text=0x0 %t/3.o -o /dev/null 2>&1 | FileCheck %s -DFILE=%t/3.o --check-prefix RANGE
21
22# RANGE: error: [[FILE]]:(.text+0x0): relocation R_390_PC32 out of range
23
24# RUN: llvm-readelf --hex-dump=.text %t/1out | FileCheck %s -DADDEND=ffffffff --check-prefix DUMP
25# RUN: llvm-readelf --hex-dump=.text %t/2out | FileCheck %s -DADDEND=80000000 --check-prefix DUMP
26
27# DUMP:  0x00000000 [[ADDEND]]
28
29#--- shared.s
30.data
31 .byte 0xe8
32 .long _shared - .
33
34#--- addend.s
35.text
36.globl _start
37_start:
38    .reloc ., R_390_PC32, .text-ADDEND
39    .space 4
40