diff --git a/CMakeLists.txt b/CMakeLists.txt index c818da48..2bec58bd 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,6 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.4) + +cmake_policy(SET CMP0065 NEW) option(RPI4ARM64 "Set to ON if targeting an RaspberryPI4 device with multiarch arm64 and armhf" ${RPI4ARM64}) option(RK3326 "Set to ON if targeting an Rockchip RK3326 based device" ${RK3326}) @@ -36,7 +38,7 @@ project(box64 C ASM) enable_testing() -set(default_build_type "RelwithDebInfo") +set(default_build_type "RelWithDebInfo") if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to '${default_build_type}' as none was specified.") set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) @@ -101,6 +103,8 @@ if(USE_CCACHE) if(CCACHE_FOUND) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + else() + message(SEND_ERROR "ccache not found!") endif() endif() @@ -259,9 +263,9 @@ set(WRAPPER "${BOX64_ROOT}/src/wrapped/generated/wrapper.c" "${BOX64_ROOT}/src/w add_custom_command( OUTPUT "${BOX64_ROOT}/src/wrapped/generated/functions_list.txt" - COMMAND "${PYTHON_EXECUTABLE}" "${BOX64_ROOT}/rebuild_wrappers.py" - "${BOX64_ROOT}" - "PANDORA" "HAVE_LD80BITS" "NOALIGN" "HAVE_TRACE" "--" + COMMAND "${PYTHON_EXECUTABLE}" "${BOX64_ROOT}/rebuild_wrappers.py" + "${BOX64_ROOT}" + "PANDORA" "HAVE_LD80BITS" "NOALIGN" "HAVE_TRACE" "--" ${WRAPPEDS_HEAD} MAIN_DEPENDENCY "${BOX64_ROOT}/rebuild_wrappers.py" DEPENDS ${WRAPPEDS} ${WRAPPEDS_HEAD} @@ -338,9 +342,9 @@ if(ARM_DYNAREC) add_dependencies(arm64_pass2 WRAPPERS) add_dependencies(arm64_pass3 WRAPPERS) - add_library(dynarec STATIC - $ - $ + add_library(dynarec STATIC + $ + $ $ $ $ @@ -364,6 +368,7 @@ else() endif() add_executable(${BOX64} ${ELFLOADER_SRC} ${WRAPPEDS} "${BOX64_ROOT}/src/git_head.h") +set_target_properties(${BOX64} PROPERTIES ENABLE_EXPORTS ON) add_dependencies(${BOX64} WRAPPERS) #add_dependencies(${BOX64} PRINTER) target_link_libraries(${BOX64} m dl rt pthread) @@ -373,14 +378,12 @@ endif() if(${CMAKE_VERSION} VERSION_LESS "3.13") if(NOT NOLOADADDR) - set_target_properties(${BOX64} PROPERTIES LINK_FLAGS "-rdynamic -Wl,-Ttext-segment,${BOX64_ELF_ADDRESS}") - else() - set_target_properties(${BOX64} PROPERTIES LINK_FLAGS "-rdynamic") + set_target_properties(${BOX64} PROPERTIES LINK_FLAGS "-Wl,-Ttext-segment,${BOX64_ELF_ADDRESS}") endif() else() - target_link_options(${BOX64} PUBLIC -rdynamic) + # If symbols are missing, try this: target_link_options(${BOX64} PUBLIC -rdynamic) if(NOT NOLOADADDR) - target_link_options(${BOX64} PUBLIC -Wl,-Ttext-segment,${BOX64_ELF_ADDRESS}) + target_link_options(${BOX64} PUBLIC LINKER:-Ttext-segment,${BOX64_ELF_ADDRESS}) endif() endif() diff --git a/src/librarian/library.c b/src/librarian/library.c index cb2bb575..29ca0f3e 100755 --- a/src/librarian/library.c +++ b/src/librarian/library.c @@ -46,9 +46,9 @@ typedef struct bridged_s { KHASH_MAP_INIT_STR(bridgemap, bridged_t) -KHASH_MAP_IMPL_STR(datamap, uint32_t) KHASH_MAP_IMPL_STR(symbolmap, wrapper_t) KHASH_MAP_IMPL_STR(symbol2map, symbol2_t) +KHASH_MAP_IMPL_STR(datamap, uint64_t) char* Path2Name(const char* path) { @@ -129,7 +129,6 @@ int EmuLib_GetLocal(library_t* lib, const char* name, uintptr_t *offs, uintptr_t int NativeLib_GetLocal(library_t* lib, const char* name, uintptr_t *offs, uintptr_t *sz) { - // TODO (void)lib; (void)name; (void)offs; (void)sz; return 0; } @@ -537,7 +536,7 @@ int GetElfIndex(library_t* lib) return lib->priv.n.elf_index; } -int getSymbolInMaps(library_t*lib, const char* name, int noweak, uintptr_t *addr, uint32_t *size) +int getSymbolInMaps(library_t *lib, const char* name, int noweak, uintptr_t *addr, uintptr_t *size) { if(!lib->active) return 0; diff --git a/src/librarian/library_private.h b/src/librarian/library_private.h index 6169959e..e2d86ee7 100755 --- a/src/librarian/library_private.h +++ b/src/librarian/library_private.h @@ -23,7 +23,7 @@ typedef struct symbol2_s { KHASH_MAP_DECLARE_STR(symbolmap, wrapper_t) KHASH_MAP_DECLARE_STR(symbol2map, symbol2_t) -KHASH_MAP_DECLARE_STR(datamap, uint32_t) +KHASH_MAP_DECLARE_STR(datamap, uintptr_t) #ifndef MAX_PATH @@ -62,7 +62,7 @@ typedef struct library_s { union { wlib_t w; nlib_t n; - } priv; // private lib data + } priv; // private lib data box64context_t *context; // parent context kh_bridgemap_t *bridgemap; kh_symbolmap_t *symbolmap; @@ -93,10 +93,10 @@ typedef struct map_onesymbol2_s { } map_onesymbol2_t; typedef struct map_onedata_s { const char* name; - uint32_t sz; + uint32_t sz; // TODO: convert to size_t int weak; } map_onedata_t; -int getSymbolInMaps(library_t*lib, const char* name, int noweak, uintptr_t *addr, uint32_t *size); // Add bridges to functions +int getSymbolInMaps(library_t *lib, const char* name, int noweak, uintptr_t *addr, uintptr_t *size); // Add bridges to functions #endif //__LIBRARY_PRIVATE_H_ diff --git a/src/wrapped/wrappedlib_init.h b/src/wrapped/wrappedlib_init.h index cd59efe1..c9fe03a9 100755 --- a/src/wrapped/wrappedlib_init.h +++ b/src/wrapped/wrappedlib_init.h @@ -194,10 +194,10 @@ int FUNC(_fini)(library_t* lib) return 1; } -int FUNC(_get)(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz) +int FUNC(_get)(library_t* lib, const char* name, uintptr_t *offs, uintptr_t *sz) { uintptr_t addr = 0; - uint32_t size = 0; + uintptr_t size = 0; #ifdef CUSTOM_FAIL void* symbol = NULL; #endif @@ -217,10 +217,10 @@ int FUNC(_get)(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz) return 1; } -int FUNC(_getnoweak)(library_t* lib, const char* name, uintptr_t *offs, uint32_t *sz) +int FUNC(_getnoweak)(library_t* lib, const char* name, uintptr_t *offs, uintptr_t *sz) { uintptr_t addr = 0; - uint32_t size = 0; + uintptr_t size = 0; #ifdef CUSTOM_FAIL void* symbol = NULL; #endif