Skip to content

Commit 3137465

Browse files
committed
s390x
1 parent d7952de commit 3137465

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* [x] loongarch64
2323
* [x] mips64
2424
* [x] ppc64 (Generated by chatgpt and requires verification)
25+
* [x] s390x (Generated by chatgpt and requires verification)
2526
* [x] alpha (Generated by chatgpt and requires verification)
2627
* [x] sparc (Generated by chatgpt and requires verification)
2728
* [x] sw_64 (Generated by chatgpt and requires verification)

README_zh.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* [x] loongarch64
2323
* [x] mips64
2424
* [x] ppc64 (由chatgpt 生成,需要验证)
25+
* [x] s390x (由chatgpt 生成,需要验证)
2526
* [x] alpha (由chatgpt 生成,需要验证)
2627
* [x] sparc (由chatgpt 生成,需要验证)
2728
* [x] sw_64 (由chatgpt 生成,需要验证n)

src/stub.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,18 @@
264264
((uint32_t*)fn)[2] = 0x6bfb0000;\
265265
CACHEFLUSH((char *)fn, CODESIZE);
266266
#define REPLACE_NEAR(t, fn, fn_stub) REPLACE_FAR(t, fn, fn_stub)
267+
#elif defined(__s390x__)
268+
#define CODESIZE 16U
269+
#define CODESIZE_MIN 16U
270+
#define CODESIZE_MAX CODESIZE
271+
// lgrl %r1, fn_stub
272+
// br %r1
273+
#define REPLACE_FAR(t, fn, fn_stub)\
274+
((uint32_t*)fn)[0] = 0xc0200000 | (1 << 20) | (0x0);\
275+
((uint32_t*)fn)[1] = 0x07f10000;\
276+
*(uint64_t *)(fn + 8) = (uint64_t)fn_stub;\
277+
CACHEFLUSH((char *)fn, CODESIZE);
278+
#define REPLACE_NEAR(t, fn, fn_stub) REPLACE_FAR(t, fn, fn_stub)
267279
#else //__i386__ _x86_64__ _M_IX86 _M_X64
268280
#define CODESIZE 13U
269281
#define CODESIZE_MIN 5U

0 commit comments

Comments
 (0)