Skip to content

Commit

Permalink
fix thumb bit removal and add test that repl_test_calculate_returns_even
Browse files Browse the repository at this point in the history
  • Loading branch information
YSaxon committed Apr 15, 2024
1 parent 0352198 commit d775431
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,19 @@ ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_SHARED_LIBRARY_PREFIX}cliffi_test${CMA
)
set_tests_properties(repl_test_address_addition PROPERTIES PASS_REGULAR_EXPRESSION "Function returned: \"?Hallo,_wyrld:")

if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
add_test(NAME repl_test_calculate_returns_even
COMMAND cliffi --repltest
calculate_offset testlib_offset ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_SHARED_LIBRARY_PREFIX}cliffi_test${CMAKE_SHARED_LIBRARY_SUFFIX} add 0x10000 \n
calculate_offset testlib_offset2 ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_SHARED_LIBRARY_PREFIX}cliffi_test${CMAKE_SHARED_LIBRARY_SUFFIX} add 0x10001 \n

testlib_offset \n
testlib_offset2 \n
)
set_tests_properties(repl_test_calculate_returns_even PROPERTIES PASS_REGULAR_EXPRESSION "testlib_offset = [0-9a-fA-FxX]+[02468ace]")
set_tests_properties(repl_test_calculate_returns_even PROPERTIES PASS_REGULAR_EXPRESSION "testlib_offset2 = [0-9a-fA-FxX]+[02468ace]")
endif()



endif()
Expand Down
4 changes: 2 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#endif

const char* NAME = "cliffi";
const char* VERSION = "v1.6.8";
const char* VERSION = "v1.6.9";
const char* BASIC_USAGE_STRING = "<library> <return_typeflag> <function_name> [[-typeflag] <arg>.. [ ... <varargs>..] ]\n";

sigjmp_buf jmpBuffer;
Expand Down Expand Up @@ -543,7 +543,7 @@ void parseCalculateOffset(char* calculateCommand) {
void* lib_handle = getOrLoadLibrary(libraryName);
void* symbol_handle = loadFunctionHandle(lib_handle, symbolName);
uintptr_t symbol_address = (uintptr_t)symbol_handle;
#if defined(__TARGET_FEATURE_THUMB)
#if defined(__arm__)
address = (void*)((uintptr_t) address & ~1); // clear the thumb bit
symbol_address &= ~1; // clear the thumb bit
#endif
Expand Down

0 comments on commit d775431

Please sign in to comment.