Skip to content

Commit

Permalink
tests: Improve reliability of import slot test
Browse files Browse the repository at this point in the history
We were doing gum_module_find_export_by_name(NULL, "malloc"), which on
UNIX does dlsym(RTLD_DEFAULT, "malloc"). Turns out this may give us the
address of gum-tests' import stub, instead of the actual implementation
in libc.
  • Loading branch information
oleavr committed Feb 16, 2024
1 parent bc2fc64 commit a5b73ed
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tests/core/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,9 @@ TESTCASE (module_import_slot_should_contain_correct_value)
return;
}

actual_value =
gum_strip_code_address (GPOINTER_TO_SIZE (*slot));
expected_value =
gum_strip_code_address (gum_module_find_export_by_name (NULL, "malloc"));
actual_value = gum_strip_code_address (GPOINTER_TO_SIZE (*slot));
expected_value = gum_strip_code_address (gum_module_find_export_by_name (
gum_process_query_libc_name (), "malloc"));

g_assert_cmphex (actual_value, ==, expected_value);
}
Expand Down

0 comments on commit a5b73ed

Please sign in to comment.