diff options
author | Yifan Lu | 2016-11-03 23:10:30 -0700 |
---|---|---|
committer | Yifan Lu | 2016-11-03 23:10:30 -0700 |
commit | 89377379e8486b1220384c969bb2897a02e3283b (patch) | |
tree | 1464f14a94111008ef6ca8d34096b3ddacc1eb5e /lib/arm/assemble.h | |
parent | Made ARM patch alignment 0x4 so copy from kernel to user works (diff) | |
download | substitute-89377379e8486b1220384c969bb2897a02e3283b.tar.gz |
Implemented call rewrite support, fixes #3
Diffstat (limited to '')
-rw-r--r-- | lib/arm/assemble.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/arm/assemble.h b/lib/arm/assemble.h index 625f464..e6a72d0 100644 --- a/lib/arm/assemble.h +++ b/lib/arm/assemble.h @@ -111,3 +111,10 @@ static inline void LDR_PC(struct assemble_ctx ctx, uint32_t dpc) { if (ctx.pc & 2) // for alignment op16(ctx.codep, 0xbf00); } + +static inline void ADD_PC(struct assemble_ctx ctx, uint32_t Rd, uint32_t imm12) { + if (ctx.thumb) + op32(ctx.codep, 0x0000f20f | ((imm12 >> 11) << 10) | (((imm12 & 0x700) >> 8) << 28) | Rd << 24 | (imm12 & 0xff) << 16); + else + op32(ctx.codep, 0x028f0000 | Rd << 12 | imm12 << 0 | ctx.cond << 28); +} |