14
14
// aligned to 2 bytes boundaries. Despite unfamiliarty, I found that it
15
15
// just feels like a 64-bit i386 in a parallel universe.
16
16
//
17
- // Its psABI reserves %r0 and %r1 as scratch registers so we can use them
18
- // in our PLT. %r2-%r6 are used for parameter passing. %r2 is also used to
19
- // return a value. In position independent code, %r12 usually contains the
20
- // address of GOT. %r14 usually contains a return address. %r15 is a stack
21
- // pointer. Access registers %a0 and %a1 contain the upper 32 bits and
22
- // the lower 32 bits of the thread pointer, respectively.
17
+ // Here is the register usage in this ABI:
23
18
//
24
- // https://uclibc.org/docs/psABI-s390x.pdf
19
+ // r0-r1: reserved as scratch registers so we can use them in our PLT
20
+ // r2: parameter passing and return values
21
+ // r3-r6: parameter passing
22
+ // r12: address of GOT if position-independent code
23
+ // r14: return address
24
+ // r15: stack pointer
25
+ // a1: upper 32 bits of TP (thread pointer)
26
+ // a2: lower 32 bits of TP (thread pointer)
27
+ //
28
+ // TLS is supported on s390x in the same way as it is on other targets
29
+ // with one exeption. On other targets, __tls_get_addr is used to get an
30
+ // address of a thread-local variable. On s390x, __tls_get_offset is used
31
+ // instead. The difference is __tls_get_offset returns an address of a
32
+ // thread-local variable as an offset from TP. So we need to add TP to a
33
+ // return value before use. I don't know why it is different, but that is
34
+ // the way it is.
35
+ //
36
+ // https://github.com/IBM/s390x-abi/releases/download/v1.6/lzsabi_s390x.pdf
25
37
26
38
#include " mold.h"
27
39
@@ -33,7 +45,7 @@ template <>
33
45
void write_plt_header (Context<E> &ctx, u8 *buf) {
34
46
static u8 insn[] = {
35
47
0xe3 , 0x00 , 0xf0 , 0x38 , 0x00 , 0x24 , // stg %r0, 56(%r15)
36
- 0xc0 , 0x10 , 0 , 0 , 0 , 0 , // larl %r1, GOT_OFFSET
48
+ 0xc0 , 0x10 , 0 , 0 , 0 , 0 , // larl %r1, GOTPLT_OFFSET
37
49
0xd2 , 0x07 , 0xf0 , 0x30 , 0x10 , 0x08 , // mvc 48(8, %r15), 8(%r1)
38
50
0xe3 , 0x10 , 0x10 , 0x10 , 0x00 , 0x04 , // lg %r1, 16(%r1)
39
51
0x07 , 0xf1 , // br %r1
0 commit comments