Skip to content

Commit

Permalink
android: Bug fix for mmap, thanks xie muxi.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhkl0228 committed Aug 28, 2024
1 parent 4e75367 commit 505b926
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1316,15 +1316,16 @@ private int mprotect(Backend backend, Emulator<?> emulator) {
return emulator.getMemory().mprotect(alignedAddress, (int) alignedLength, prot);
}

private static final int MMAP2_SHIFT = 12;

private long mmap(Backend backend, Emulator<?> emulator) {
long start = backend.reg_read(Arm64Const.UC_ARM64_REG_X0).longValue();
int length = backend.reg_read(Arm64Const.UC_ARM64_REG_X1).intValue();
int prot = backend.reg_read(Arm64Const.UC_ARM64_REG_X2).intValue();
int flags = backend.reg_read(Arm64Const.UC_ARM64_REG_X3).intValue();
int fd = backend.reg_read(Arm64Const.UC_ARM64_REG_X4).intValue();
int offset = backend.reg_read(Arm64Const.UC_ARM64_REG_X5).intValue() << MMAP2_SHIFT;
int offset = backend.reg_read(Arm64Const.UC_ARM64_REG_X5).intValue();
if (offset % emulator.getPageAlign() != 0) {
throw new IllegalArgumentException("offset=0x" + Long.toHexString(offset));
}

boolean warning = length > 0x10000000;
if (log.isDebugEnabled() || warning) {
Expand Down

0 comments on commit 505b926

Please sign in to comment.