From a5b73ed201c6609c48e0faf270439d0104b126c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Fri, 16 Feb 2024 09:27:19 +0000 Subject: [PATCH] tests: Improve reliability of import slot test 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. --- tests/core/process.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/core/process.c b/tests/core/process.c index 5d8cea2d8..16893ff52 100644 --- a/tests/core/process.c +++ b/tests/core/process.c @@ -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); }