blob: f0f149f1a9772d233aca78fe008bd1320f183800 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#pragma once
#include "arm64/assemble.h"
#define MAX_JUMP_PATCH_SIZE 12
#define MAX_REWRITTEN_SIZE (7 * 2 * 4) /* also conservative */
static inline int jump_patch_size(uintptr_t pc, uintptr_t dpc,
struct arch_dis_ctx arch) {
intptr_t diff = (dpc & ~0xfff) - (pc & ~0xfff);
if (!(diff >= -0x100000000 && diff < 0x100000000))
return -1;
else if (pc & 0xfff)
return 8;
else
return 12;
}
static inline void make_jump_patch(void **codep, uintptr_t pc, uintptr_t dpc,
struct arch_dis_ctx arch) {
ADRP_ADD(codep, 12 /* XXX */, pc, dpc);
}
|