Fix some OSX incompatibilities on AARCH64
MODIFY
frida_mode/GNUmakefile
frida_mode/GNUmakefile
@@ -116,7 +116,7 @@ ifndef OS
$(error "Operating system unsupported")
endif
-GUM_DEVKIT_VERSION=15.1.27
+GUM_DEVKIT_VERSION=15.2.1
GUM_DEVKIT_FILENAME=frida-gumjs-devkit-$(GUM_DEVKIT_VERSION)-$(OS)-$(ARCH).tar.xz
GUM_DEVKIT_URL="https://github.com/frida/frida/releases/download/$(GUM_DEVKIT_VERSION)/$(GUM_DEVKIT_FILENAME)"

MODIFY
frida_mode/src/instrument/instrument.c
frida_mode/src/instrument/instrument.c
#include "stats.h"
#include "util.h"
+#define FRIDA_DEFAULT_MAP_SIZE (64UL << 10)
+
gboolean instrument_tracing = false;
gboolean instrument_optimize = false;
gboolean instrument_unique = false;
@@ -289,6 +291,7 @@ void instrument_config(void) {
}
void instrument_init(void) {
+ if (__afl_map_size == MAP_SIZE) __afl_map_size = FRIDA_DEFAULT_MAP_SIZE;
if (!instrument_is_coverage_optimize_supported()) instrument_optimize = false;

MODIFY
frida_mode/src/instrument/instrument_arm64.c
frida_mode/src/instrument/instrument_arm64.c
@@ -272,9 +272,10 @@ void instrument_coverage_optimize(const cs_insn *instr,
GumAddressSpec spec = {.near_address = cw->code,
.max_distance = 1ULL << 30};
+ guint page_size = gum_query_page_size();
instrument_previous_pc_addr = gum_memory_allocate_near(
- &spec, sizeof(guint64), 0x1000, GUM_PAGE_READ | GUM_PAGE_WRITE);
+ &spec, sizeof(guint64), page_size, GUM_PAGE_READ | GUM_PAGE_WRITE);
*instrument_previous_pc_addr = instrument_hash_zero;
FVERBOSE("instrument_previous_pc_addr: %p", instrument_previous_pc_addr);
FVERBOSE("code_addr: %p", cw->code);

MODIFY
frida_mode/src/instrument/instrument_x64.c
frida_mode/src/instrument/instrument_x64.c
@@ -335,17 +335,15 @@ static void instrument_coverage_write(GumAddress address,
void instrument_coverage_optimize(const cs_insn * instr,
GumStalkerOutput *output) {
-
GumX86Writer *cw = output->writer.x86;
- /* guint64 area_offset =
- * instrument_get_offset_hash(GUM_ADDRESS(instr->address)); */
if (instrument_previous_pc_addr == NULL) {
GumAddressSpec spec = {.near_address = cw->code,
.max_distance = 1ULL << 30};
+ guint page_size = gum_query_page_size();
instrument_previous_pc_addr = gum_memory_allocate_near(
- &spec, sizeof(guint64), 0x1000, GUM_PAGE_READ | GUM_PAGE_WRITE);
+ &spec, sizeof(guint64), page_size, GUM_PAGE_READ | GUM_PAGE_WRITE);
*instrument_previous_pc_addr = instrument_hash_zero;
FVERBOSE("instrument_previous_pc_addr: %p", instrument_previous_pc_addr);
FVERBOSE("code_addr: %p", cw->code);
@@ -361,7 +359,6 @@ void instrument_coverage_optimize(const cs_insn *instr,
}
instrument_coverage_write(GUM_ADDRESS(instr->address), output);
-
}
void instrument_coverage_optimize_insn(const cs_insn *instr,

MODIFY
frida_mode/src/instrument/instrument_x86.c
frida_mode/src/instrument/instrument_x86.c
@@ -162,9 +162,10 @@ void instrument_coverage_optimize(const cs_insn *instr,
GumAddressSpec spec = {.near_address = cw->code,
.max_distance = 1ULL << 30};
+ guint page_size = gum_query_page_size();
instrument_previous_pc_addr = gum_memory_allocate_near(
- &spec, sizeof(guint64), 0x1000, GUM_PAGE_READ | GUM_PAGE_WRITE);
+ &spec, sizeof(guint64), page_size, GUM_PAGE_READ | GUM_PAGE_WRITE);
*instrument_previous_pc_addr = instrument_hash_zero;
FVERBOSE("instrument_previous_pc_addr: %p", instrument_previous_pc_addr);
FVERBOSE("code_addr: %p", cw->code);

MODIFY
frida_mode/src/intercept.c
frida_mode/src/intercept.c
@@ -7,8 +7,8 @@ void intercept_hook(void *address, gpointer replacement, gpointer user_data) {
GumInterceptor *interceptor = gum_interceptor_obtain();
gum_interceptor_begin_transaction(interceptor);
- GumReplaceReturn ret =
- gum_interceptor_replace(interceptor, address, replacement, user_data);
+ GumReplaceReturn ret = gum_interceptor_replace(interceptor, address,
+ replacement, user_data, NULL);
if (ret != GUM_REPLACE_OK) { FFATAL("gum_interceptor_attach: %d", ret); }
gum_interceptor_end_transaction(interceptor);

Fix some OSX incompatibilities on AARCH64 (#1479)

Co-authored-by: Your Name <you@example.com>