Changes to support variations in the mapsize
MODIFY
frida_mode/GNUmakefile
frida_mode/GNUmakefile
@@ -259,7 +259,7 @@ endif
############################## AFL #############################################
-$(AFL_COMPILER_RT_OBJ): $(AFL_COMPILER_RT_SRC)
+$(AFL_COMPILER_RT_OBJ): $(AFL_COMPILER_RT_SRC) $(ROOT)include/config.h
$(TARGET_CC) \
$(CFLAGS) \
$(AFL_CFLAGS) \

MODIFY
frida_mode/src/instrument/instrument.c
frida_mode/src/instrument/instrument.c
@@ -318,12 +318,6 @@ void instrument_init(void) {
if (instrument_unique) { instrument_tracing = TRUE; }
- if (__afl_map_size != 0x10000) {
-
- FATAL("Bad map size: 0x%08x", __afl_map_size);
-
- }
-
transformer = gum_stalker_transformer_make_from_callback(
instrument_basic_block, NULL, NULL);

MODIFY
frida_mode/src/instrument/instrument_x64.c
frida_mode/src/instrument/instrument_x64.c
@@ -216,6 +216,8 @@ static gboolean instrument_coverage_find_low(const GumRangeDetails *details,
static GumAddress last_limit = (64ULL << 10);
gpointer * address = (gpointer *)user_data;
+ last_limit = GUM_ALIGN_SIZE (last_limit, __afl_map_size);
+
if ((details->range->base_address - last_limit) > __afl_map_size) {
*address = GSIZE_TO_POINTER(last_limit);
@@ -235,7 +237,7 @@ static gboolean instrument_coverage_find_low(const GumRangeDetails *details,
* current block ID.
*/
last_limit = GUM_ALIGN_SIZE(
- details->range->base_address + details->range->size, (64ULL << 10));
+ details->range->base_address + details->range->size, __afl_map_size);
return TRUE;
}
@@ -326,7 +328,7 @@ void instrument_coverage_optimize_init(void) {
FVERBOSE("Low address: %p", low_address);
if (low_address == 0 ||
- GPOINTER_TO_SIZE(low_address) > ((2UL << 20) - __afl_map_size)) {
+ GPOINTER_TO_SIZE(low_address) > ((2UL << 30) - __afl_map_size)) {
FATAL("Invalid low_address: %p", low_address);

Changes to support variations in the mapsize