diff options
35 files changed, 1023 insertions, 344 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index dc0bc8c6..5a9f5022 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,6 +236,14 @@ endif() if(SAVE_MEM) add_definitions(-DSAVE_MEM) endif() +if(STATICBUILD) + #-fno-pic -mcmodel=large + add_definitions(-DSTATICBUILD) + add_definitions(-Wno-deprecated-declarations) #by-design, deprecated function can be used + set(BUILD_SHARED_LIBS OFF) + set(CMAKE_EXE_LINKER_FLAGS "-static") + set(HAVE_TRACE OFF) +endif() if(PAGE8K) add_definitions(-DPAGE8K) endif() @@ -320,8 +328,6 @@ set(ELFLOADER_SRC "${BOX64_ROOT}/src/box64context.c" "${BOX64_ROOT}/src/build_info.c" "${BOX64_ROOT}/src/custommem.c" - "${BOX64_ROOT}/src/mallochook.c" - "${BOX64_ROOT}/src/steam.c" "${BOX64_ROOT}/src/dynarec/dynarec.c" "${BOX64_ROOT}/src/elfs/elfloader.c" "${BOX64_ROOT}/src/elfs/elfparser.c" @@ -342,12 +348,9 @@ set(ELFLOADER_SRC "${BOX64_ROOT}/src/librarian/librarian.c" "${BOX64_ROOT}/src/librarian/library.c" "${BOX64_ROOT}/src/librarian/dictionnary.c" - "${BOX64_ROOT}/src/librarian/globalsymbols.c" "${BOX64_ROOT}/src/librarian/symbols.c" "${BOX64_ROOT}/src/libtools/auxval.c" "${BOX64_ROOT}/src/libtools/myalign.c" - "${BOX64_ROOT}/src/libtools/sdl1rwops.c" - "${BOX64_ROOT}/src/libtools/sdl2rwops.c" "${BOX64_ROOT}/src/libtools/signals.c" "${BOX64_ROOT}/src/libtools/threads.c" "${BOX64_ROOT}/src/tools/bitutils.c" @@ -356,13 +359,22 @@ set(ELFLOADER_SRC "${BOX64_ROOT}/src/tools/callback.c" "${BOX64_ROOT}/src/tools/my_cpuid.c" "${BOX64_ROOT}/src/tools/fileutils.c" - "${BOX64_ROOT}/src/tools/gtkclass.c" "${BOX64_ROOT}/src/tools/pathcoll.c" "${BOX64_ROOT}/src/tools/rbtree.c" "${BOX64_ROOT}/src/tools/rcfile.c" "${BOX64_ROOT}/src/tools/wine_tools.c" "${BOX64_ROOT}/src/wrapped/generated/wrapper.c" ) +if(NOT STATICBUILD) + list(APPEND ELFLOADER_SRC + "${BOX64_ROOT}/src/mallochook.c" + "${BOX64_ROOT}/src/steam.c" + "${BOX64_ROOT}/src/libtools/sdl1rwops.c" + "${BOX64_ROOT}/src/libtools/sdl2rwops.c" + "${BOX64_ROOT}/src/tools/gtkclass.c" + "${BOX64_ROOT}/src/librarian/globalsymbols.c" + ) +endif() if(NOT ANDROID) list(APPEND ELFLOADER_SRC "${BOX64_ROOT}/src/libtools/obstack.c" @@ -400,6 +412,20 @@ set(INTERPRETER "${BOX64_ROOT}/src/emu/x64runf30f.c" ) +if(STATICBUILD) +set(WRAPPEDS + "${BOX64_ROOT}/src/wrapped/wrappedldlinux.c" + "${BOX64_ROOT}/src/wrapped/wrappedlibbsd.c" + "${BOX64_ROOT}/src/wrapped/wrappedlibc.c" + "${BOX64_ROOT}/src/wrapped/wrappedlibcmusl.c" + "${BOX64_ROOT}/src/wrapped/wrappedlibdl.c" + "${BOX64_ROOT}/src/wrapped/wrappedlibm.c" + "${BOX64_ROOT}/src/wrapped/wrappedutil.c" + "${BOX64_ROOT}/src/wrapped/wrappedlibresolv.c" + "${BOX64_ROOT}/src/wrapped/wrappedlibrt.c" + "${BOX64_ROOT}/src/wrapped/wrappedlibpthread.c" +) +else() set(WRAPPEDS "${BOX64_ROOT}/src/wrapped/wrappedalure.c" "${BOX64_ROOT}/src/wrapped/wrappedalut.c" @@ -623,6 +649,7 @@ set(WRAPPEDS "${BOX64_ROOT}/src/wrapped/wrappedidn2.c" "${BOX64_ROOT}/src/wrapped/wrappedanl.c" ) +endif() if(ANDROID) list(APPEND WRAPPEDS "${BOX64_ROOT}/src/wrapped/wrappedandroidshmem.c" @@ -654,7 +681,7 @@ if(NOT CI) 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" "ANDROID" "TERMUX" "--" + "PANDORA" "HAVE_LD80BITS" "NOALIGN" "HAVE_TRACE" "ANDROID" "TERMUX" "STATICBUILD" "--" ${WRAPPEDS_HEAD} MAIN_DEPENDENCY "${BOX64_ROOT}/rebuild_wrappers.py" DEPENDS ${WRAPPEDS} ${WRAPPEDS_HEAD} @@ -837,7 +864,8 @@ add_dependencies(${BOX64} WRAPPERS) #add_dependencies(${BOX64} PRINTER) #target_link_libraries(${BOX64} c m dl rt pthread resolv) if(STATICBUILD) - set_target_properties(${BOX64} PROPERTIES LINK_FLAGS "-static -Wl,--no-as-needed -Wl,--whole-archive -Wl,--allow-multiple-definition -lm -ldl -lrt -lpthread -lresolv -lc -lutil -Wl,-defsym,_DYNAMIC=0 -pthread") + #set_target_properties(${BOX64} PROPERTIES LINK_FLAGS "-fuse-ld=gold -static -Wl,--no-relax -Wl,--allow-multiple-definition -ldl -lrt -lpthread -lresolv -lc -lutil -lm -Wl,-defsym,_DYNAMIC=0 -pthread") + target_link_libraries(${BOX64} c m dl pthread resolv util bsd c) else() if(ANDROID) if(TERMUX) diff --git a/docs/COMPILE.md b/docs/COMPILE.md index df4ed71d..b669dc1e 100644 --- a/docs/COMPILE.md +++ b/docs/COMPILE.md @@ -250,6 +250,11 @@ If you are not building from a git clone (for example, downloading a release sou You need to add `-DWITH_MOLD=1` if GNU ld is extremely slow. Then run `mold -run make -j4` to build (make sure [Mold](https://github.com/rui314/mold) is installed). +#### Build a statically linked box64 + +You can now build box64 staticaly linked, with `-DSTATICBUILD`. This is to use inside an x86_64 chroot. Note that this version of box64 will have just the minimum of wrapped libs. So only libc, libm and libpthread basically are wrapped. Other libs (like libGL or libvulkan, SDL2, etc...) will not be wrapped and x86_64 version will be used. It's designed to be used in docker image, or in headless server. +Also, the Static Build is highly experimental, but feedback are always welcomed. + ---- Testing diff --git a/src/box64context.c b/src/box64context.c index 208a9fa2..33a0d10b 100644 --- a/src/box64context.c +++ b/src/box64context.c @@ -230,7 +230,9 @@ box64context_t *NewBox64Context(int argc) // create exit bridge context->exit_bridge = AddBridge(context->system, NULL, NULL, 0, NULL); // get handle to box64 itself + #ifndef STATICBUILD context->box64lib = dlopen(NULL, RTLD_NOW|RTLD_GLOBAL); + #endif context->dlprivate = NewDLPrivate(); context->argc = argc; @@ -341,8 +343,10 @@ void FreeBox64Context(box64context_t** context) FreeBridge(&ctx->system); + #ifndef STATICBUILD freeGLProcWrapper(ctx); freeALProcWrapper(ctx); + #endif if(ctx->stack_clone) box_free(ctx->stack_clone); diff --git a/src/elfs/elfloader.c b/src/elfs/elfloader.c index 88b204c5..d6f0dc02 100644 --- a/src/elfs/elfloader.c +++ b/src/elfs/elfloader.c @@ -471,7 +471,7 @@ struct tlsdesc }; uintptr_t tlsdescUndefweak = 0; uintptr_t GetSegmentBaseEmu(x64emu_t* emu, int seg); -EXPORT uintptr_t _dl_tlsdesc_undefweak(x64emu_t* emu) +EXPORT uintptr_t my__dl_tlsdesc_undefweak(x64emu_t* emu) { struct tlsdesc *td = (struct tlsdesc *)R_RAX; return td->arg; @@ -763,7 +763,7 @@ int RelocateElfRELA(lib_t *maplib, lib_t *local_maplib, int bindnow, int deepbin printf_dump(LOG_NEVER, "Apply %s R_X86_64_TLSDESC @%p with addend=%zu\n", BindSym(bind), p, rela[i].r_addend); struct tlsdesc volatile *td = (struct tlsdesc volatile *)p; if(!tlsdescUndefweak) - tlsdescUndefweak = AddBridge(my_context->system, pFE, _dl_tlsdesc_undefweak, 0, "_dl_tlsdesc_undefweak"); + tlsdescUndefweak = AddBridge(my_context->system, pFE, my__dl_tlsdesc_undefweak, 0, "_dl_tlsdesc_undefweak"); td->entry = tlsdescUndefweak; td->arg = (uintptr_t)(head->tlsbase + rela[i].r_addend); } else { @@ -916,7 +916,9 @@ void AddSymbols(lib_t *maplib, elfheader_t* h) if(box64_dump && h->DynSym) DumpDynSym(h); if(h==my_context->elfs[0]) GrabX64CopyMainElfReloc(h); + #ifndef STATICBUILD checkHookedSymbols(h); + #endif } /* @@ -1058,7 +1060,11 @@ void MarkElfInitDone(elfheader_t* h) if(h) h->init_done = 1; } +#ifndef STATICBUILD void startMallocHook(); +#else +void startMallocHook() {} +#endif void RunElfInit(elfheader_t* h, x64emu_t *emu) { if(!h || h->init_done) diff --git a/src/emu/x64trace.c b/src/emu/x64trace.c index ac655040..415a268c 100644 --- a/src/emu/x64trace.c +++ b/src/emu/x64trace.c @@ -39,6 +39,9 @@ typedef struct zydis_dec_s { int InitX64Trace(box64context_t *context) { + #ifndef HAVE_TRACE + return 1; + #else if(context->zydis) return 0; context->zydis = (zydis_t*)box_calloc(1, sizeof(zydis_t)); @@ -62,20 +65,26 @@ int InitX64Trace(box64context_t *context) context->dec32 = InitX86TraceDecoder(context); return 0; + #endif } void DeleteX64Trace(box64context_t *context) { + #ifdef HAVE_TRACE if(!context->zydis) return; if(context->zydis->lib) dlclose(context->zydis->lib); box_free(context->zydis); context->zydis = NULL; + #endif } zydis_dec_t* InitX86TraceDecoder(box64context_t *context) { + #ifndef HAVE_TRACE + return NULL; + #else if(!context->zydis) return NULL; zydis_dec_t *dec = (zydis_dec_t*)box_calloc(1, sizeof(zydis_dec_t)); @@ -85,15 +94,21 @@ zydis_dec_t* InitX86TraceDecoder(box64context_t *context) context->zydis->ZydisFormatterInit(&dec->formatter, ZYDIS_FORMATTER_STYLE_INTEL); return dec; + #endif } void DeleteX86TraceDecoder(zydis_dec_t **dec) { + #ifdef HAVE_TRACE box_free(*dec); *dec = NULL; + #endif } zydis_dec_t* InitX64TraceDecoder(box64context_t *context) { + #ifndef HAVE_TRACE + return NULL; + #else if(!context->zydis) return NULL; zydis_dec_t *dec = (zydis_dec_t*)box_calloc(1, sizeof(zydis_dec_t)); @@ -103,15 +118,21 @@ zydis_dec_t* InitX64TraceDecoder(box64context_t *context) context->zydis->ZydisFormatterInit(&dec->formatter, ZYDIS_FORMATTER_STYLE_INTEL); return dec; + #endif } void DeleteX64TraceDecoder(zydis_dec_t **dec) { + #ifdef HAVE_TRACE box_free(*dec); *dec = NULL; + #endif } const char* DecodeX64Trace(zydis_dec_t *dec, uintptr_t p) { + #ifndef HAVE_TRACE + return "???"; + #else static char buff[512]; if(ZYAN_SUCCESS(dec->ZydisDecoderDecodeBuffer(&dec->decoder, (char*)p, 15, &dec->instruction))) { @@ -133,4 +154,5 @@ const char* DecodeX64Trace(zydis_dec_t *dec, uintptr_t p) sprintf(buff, "Decoder failed @%p", (void*)p); } return buff; + #endif } diff --git a/src/include/debug.h b/src/include/debug.h index 59568021..0f0526f7 100644 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -127,8 +127,10 @@ void printf_ftrace(const char* fmt, ...); #define EXPORTDYN #endif +#ifndef STATICBUILD void init_malloc_hook(void); -#ifdef ANDROID +#endif +#if defined(ANDROID) || defined(STATICBUILD) #define box_malloc malloc #define box_realloc realloc #define box_calloc calloc diff --git a/src/librarian/librarian.c b/src/librarian/librarian.c index 9250a165..9b5e82ac 100644 --- a/src/librarian/librarian.c +++ b/src/librarian/librarian.c @@ -476,8 +476,10 @@ static int GetGlobalSymbolStartEnd_internal(lib_t *maplib, const char* name, uin // nope, not found return weak; } +#ifndef STATICBUILD void** my_GetGTKDisplay(); void** my_GetGthreadsGotInitialized(); +#endif int GetGlobalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, uintptr_t* end, elfheader_t* self, int version, const char* vername, int veropt, void** elfsym) { if(GetGlobalSymbolStartEnd_internal(maplib, name, start, end, self, &version, &vername, &veropt, elfsym)) { @@ -494,6 +496,7 @@ int GetGlobalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, u } return 1; } + #ifndef STATICBUILD // some special case symbol, defined inside box64 itself if(!strcmp(name, "gdk_display")) { *start = (uintptr_t)my_GetGTKDisplay(); @@ -507,6 +510,7 @@ int GetGlobalSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* start, u printf_log(LOG_INFO, "Using global g_threads_got_initialized for gthread2 (%p:%p)\n", start, *(void**)start); return 1; } + #endif // not found... return 0; } @@ -565,6 +569,7 @@ int GetGlobalWeakSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* star } return 1; } + #ifndef STATICBUILD // some special case symbol, defined inside box64 itself if(!strcmp(name, "gdk_display")) { *start = (uintptr_t)my_GetGTKDisplay(); @@ -580,6 +585,7 @@ int GetGlobalWeakSymbolStartEnd(lib_t *maplib, const char* name, uintptr_t* star printf_log(LOG_INFO, "Using global g_threads_got_initialized for gthread2 (%p:%p)\n", start, *(void**)start); return 1; } + #endif // not found... return 0; } diff --git a/src/librarian/library.c b/src/librarian/library.c index 6d888fdc..99d884cd 100644 --- a/src/librarian/library.c +++ b/src/librarian/library.c @@ -33,19 +33,31 @@ #define GO(P, N) int wrapped##N##_init(library_t* lib, box64context_t *box64); \ void wrapped##N##_fini(library_t* lib); +#ifdef STATICBUILD +#include "library_list_static.h" +#else #include "library_list.h" +#endif #undef GO #define GO(P, N) {P, wrapped##N##_init, wrapped##N##_fini}, wrappedlib_t wrappedlibs[] = { +#ifdef STATICBUILD +#include "library_list_static.h" +#else #include "library_list.h" +#endif }; #undef GO KHASH_MAP_IMPL_STR(symbolmap, symbol1_t) KHASH_MAP_IMPL_STR(symbol2map, symbol2_t) +#ifdef STATICBUILD +KHASH_MAP_IMPL_STR(datamap, datamap_t) +#else KHASH_MAP_IMPL_STR(datamap, uint64_t) +#endif char* Path2Name(const char* path) { @@ -715,11 +727,19 @@ static int getSymbolInDataMaps(library_t*lib, const char* name, int noweak, uint void* symbol; khint_t k = kh_get(datamap, lib->w.datamap, name); if (k!=kh_end(lib->w.datamap)) { + #ifdef STATICBUILD + symbol = (void*)(kh_value(lib->w.datamap, k).addr); + #else symbol = dlsym(lib->w.lib, kh_key(lib->w.datamap, k)); + #endif if(symbol) { // found! *addr = (uintptr_t)symbol; + #ifdef STATICBUILD + *size = kh_value(lib->w.datamap, k).size; + #else *size = kh_value(lib->w.datamap, k); + #endif *weak = 0; return 1; } @@ -727,11 +747,19 @@ static int getSymbolInDataMaps(library_t*lib, const char* name, int noweak, uint if(!noweak) { k = kh_get(datamap, lib->w.wdatamap, name); if (k!=kh_end(lib->w.wdatamap)) { + #ifdef STATICBUILD + symbol = (void*)(kh_value(lib->w.wdatamap, k).addr); + #else symbol = dlsym(lib->w.lib, kh_key(lib->w.wdatamap, k)); + #endif if(symbol) { // found! *addr = (uintptr_t)symbol; + #ifdef STATICBUILD + *size = kh_value(lib->w.wdatamap, k).size; + #else *size = kh_value(lib->w.wdatamap, k); + #endif *weak = 1; return 1; } @@ -746,13 +774,21 @@ static int getSymbolInDataMaps(library_t*lib, const char* name, int noweak, uint else strcpy(buff, "my_"); strcat(buff, name); + #ifdef STATICBUILD + symbol = kh_value(lib->w.mydatamap, k).addr; + #else symbol = dlsym(my_context->box64lib, buff); + #endif if(!symbol) printf_log(LOG_NONE, "Warning, data %s not found\n", buff); if(symbol) { // found! *addr = (uintptr_t)symbol; + #ifdef STATICBUILD + *size = kh_value(lib->w.mydatamap, k).size; + #else *size = kh_value(lib->w.mydatamap, k); + #endif *weak = 0; return 1; } @@ -773,7 +809,11 @@ static int getSymbolInSymbolMaps(library_t*lib, const char* name, int noweak, ui else strcpy(buff, "my_"); strcat(buff, name); + #ifdef STATICBUILD + symbol = (void*)s->addr; + #else symbol = dlsym(my_context->box64lib, buff); + #endif if(!symbol) { printf_log(LOG_NONE, "Warning, function %s not found\n", buff); return 0; @@ -797,7 +837,11 @@ static int getSymbolInSymbolMaps(library_t*lib, const char* name, int noweak, ui else strcpy(buff, "my_"); strcat(buff, name); + #ifdef STATICBUILD + symbol = (void*)s->addr; + #else symbol = dlsym(my_context->box64lib, buff); + #endif if(!symbol) { printf_log(LOG_NONE, "Warning, function %s not found\n", buff); return 0; @@ -815,6 +859,9 @@ static int getSymbolInSymbolMaps(library_t*lib, const char* name, int noweak, ui if (k!=kh_end(lib->w.symbolmap)) { symbol1_t *s = &kh_value(lib->w.symbolmap, k); if(!s->resolved) { + #ifdef STATICBUILD + symbol = (void*)s->addr; + #else symbol = dlsym(lib->w.lib, name); if(!symbol && lib->w.altprefix) { char newname[200]; @@ -830,6 +877,7 @@ static int getSymbolInSymbolMaps(library_t*lib, const char* name, int noweak, ui strcat(newname, name); symbol = GetNativeSymbolUnversioned(lib->w.lib, newname); } + #endif if(!symbol) { printf_dump(LOG_INFO, "Warning, function %s not found in lib %s\n", name, lib->name); return 0; @@ -854,7 +902,11 @@ static int getSymbolInSymbolMaps(library_t*lib, const char* name, int noweak, ui else strcpy(buff, "my_"); strcat(buff, name); + #ifdef STATICBUILD + symbol = (void*)s->addr; + #else symbol = dlsym(my_context->box64lib, buff); + #endif if(!symbol) { printf_log(LOG_NONE, "Warning, function %s not found\n", buff); return 0; @@ -871,6 +923,9 @@ static int getSymbolInSymbolMaps(library_t*lib, const char* name, int noweak, ui if (k!=kh_end(lib->w.wsymbolmap)) { symbol1_t *s = &kh_value(lib->w.wsymbolmap, k); if(!s->resolved) { + #ifdef STATICBUILD + symbol = (void*)s->addr; + #else symbol = dlsym(lib->w.lib, name); if(!symbol && lib->w.altprefix) { char newname[200]; @@ -886,6 +941,7 @@ static int getSymbolInSymbolMaps(library_t*lib, const char* name, int noweak, ui strcat(newname, name); symbol = GetNativeSymbolUnversioned(lib->w.lib, newname); } + #endif if(!symbol) { printf_dump(LOG_INFO, "Warning, function %s not found in lib %s\n", name, lib->name); return 0; @@ -906,11 +962,15 @@ static int getSymbolInSymbolMaps(library_t*lib, const char* name, int noweak, ui if(!noweak || !s->weak) { if(!s->resolved) { + #ifdef STATICBUILD + symbol = (void*)s->addr; + #else symbol = dlsym(lib->w.lib, kh_value(lib->w.symbol2map, k).name); if(!symbol) symbol = dlsym(RTLD_DEFAULT, kh_value(lib->w.symbol2map, k).name); // search globaly maybe if(!symbol) symbol = GetNativeSymbolUnversioned(lib->w.lib, kh_value(lib->w.symbol2map, k).name); + #endif if(!symbol) { printf_dump(LOG_INFO, "Warning, function %s not found in lib %s\n", kh_value(lib->w.symbol2map, k).name, lib->name); return 0; diff --git a/src/librarian/library_private.h b/src/librarian/library_private.h index 1da4c264..a13df4a0 100644 --- a/src/librarian/library_private.h +++ b/src/librarian/library_private.h @@ -30,9 +30,20 @@ typedef struct symbol2_s { uintptr_t addr; } symbol2_t; +#ifdef STATICBUILD +typedef struct datamap_s { + uint64_t size; + uintptr_t addr; +} datamap_t; +#endif + KHASH_MAP_DECLARE_STR(symbolmap, symbol1_t) KHASH_MAP_DECLARE_STR(symbol2map, symbol2_t) +#ifdef STATICBUILD +KHASH_MAP_DECLARE_STR(datamap, datamap_t) +#else KHASH_MAP_DECLARE_STR(datamap, uint64_t) +#endif #ifndef MAX_PATH @@ -88,17 +99,26 @@ typedef struct map_onesymbol_s { const char* name; wrapper_t w; int weak; +#ifdef STATICBUILD + void* addr; +#endif } map_onesymbol_t; typedef struct map_onesymbol2_s { const char* name; wrapper_t w; int weak; const char* name2; +#ifdef STATICBUILD + void* addr; +#endif } map_onesymbol2_t; typedef struct map_onedata_s { const char* name; uint32_t sz; // TODO: convert to size_t int weak; +#ifdef STATICBUILD + void* addr; +#endif } map_onedata_t; int getSymbolInMaps(library_t *lib, const char* name, int noweak, uintptr_t *addr, uintptr_t *size, int *weak, int version, const char* vername, int local, int veropt); // Add bridges to functions diff --git a/src/library_list_static.h b/src/library_list_static.h new file mode 100644 index 00000000..dfb21112 --- /dev/null +++ b/src/library_list_static.h @@ -0,0 +1,24 @@ +#ifndef GO +#error Nope +#endif + +GO("libc.musl-x86_64.so.1", libcmusl) +#ifdef ANDROID +GO("libpthread.so", libpthread) +GO("librt.so", librt) +GO("libbsd.so", libbsd) +GO("libc.so", libc) +GO("libm.so", libm) +GO("libdl.so", libdl) +GO("libresolv.so", libresolv) +#else +GO("libpthread.so.0", libpthread) +GO("librt.so.1", librt) +GO("libbsd.so.0", libbsd) +GO("libc.so.6", libc) +GO("libm.so.6", libm) +GO("libdl.so.2", libdl) +GO("libresolv.so.2", libresolv) +#endif +GO("libutil.so.1", util) +GO("ld-linux-x86-64.so.2", ldlinux) diff --git a/src/libtools/static_libc.h b/src/libtools/static_libc.h new file mode 100644 index 00000000..c5dd8a59 --- /dev/null +++ b/src/libtools/static_libc.h @@ -0,0 +1,319 @@ +#include <inttypes.h> +#include <locale.h> +#include <netinet/in.h> +#include <aliases.h> +#include <arpa/inet.h> +#include <envz.h> +#include <fmtmsg.h> +#include <fnmatch.h> +#include <fstab.h> +#include <grp.h> +#include <gnu/libc-version.h> +#include <iconv.h> +#include <ifaddrs.h> +#include <langinfo.h> +#include <libgen.h> +#include <libintl.h> +#include <mntent.h> +#include <mcheck.h> +#include <netdb.h> +#include <net/if.h> +#include <printf.h> +#include <pwd.h> +#include <regex.h> +#include <semaphore.h> +#include <sys/eventfd.h> +#include <sys/fanotify.h> +#include <sys/file.h> +#include <sys/fsuid.h> +#include <sys/klog.h> +#include <sys/random.h> +#include <sys/inotify.h> +#include <sys/mount.h> +#include <sys/msg.h> +#include <sys/personality.h> +#include <sys/quota.h> +#include <sys/reboot.h> +#include <sys/shm.h> +#include <sys/sendfile.h> +#include <sys/signalfd.h> +#include <sys/statvfs.h> +#include <sys/sysinfo.h> +#include <sys/timeb.h> +#include <sys/times.h> +#include <sys/timex.h> +#include <sys/timerfd.h> +#include <sys/uio.h> +#include <sys/wait.h> +#include <sys/xattr.h> +#include <shadow.h> +#include <termios.h> +#include <ttyent.h> +#include <uchar.h> +#include <utime.h> +#include <utmp.h> +#include <utmpx.h> +#include <wctype.h> +#include <wordexp.h> +#include <math.h> + +#include "myalign.h" +#include "libtools/static_threads.h" + +//extern void* sys_errlist; +//extern void* _sys_errlist; +extern void* __progname_full; +extern void* __progname; +extern void* _IO_list_all; +extern void* _IO_file_jumps; +extern FILE* _IO_2_1_stdout_; +extern FILE* _IO_2_1_stdin_; +extern FILE* _IO_2_1_stderr_; +//extern const unsigned short int *__ctype_b; +extern void* __check_rhosts_file; +typedef struct x64_stack_s x64_stack_t; +extern sighandler_t my_sigset(x64emu_t* emu, int signum, sighandler_t handler); +extern int my_sigaltstack(x64emu_t* emu, const x64_stack_t* ss, x64_stack_t* oss); +int my_obstack_vprintf(x64emu_t* emu, struct obstack* obstack, void* fmt, x64_va_list_t V); +void my__obstack_newchunk(x64emu_t* emu, struct obstack* obstack, int s); +void my_obstack_free(struct obstack * obstack, void* block); +void my__obstack_free(struct obstack * obstack, void* block); +int my__obstack_begin(struct obstack * obstack, size_t size, size_t alignment, void* chunkfun, void* freefun); +extern int __adjtimex(void*); +extern void __assert(void*, void*, int); +extern void __assert_fail(void*, void*, uint32_t, void*); +extern void __assert_perror_fail(int, void*, uint32_t, void*); +extern void __bzero(void*, size_t); +extern int capget(void*, void*); +extern int capset(void*, void*); +void cfree(void* p) {free(p);} +//extern void clnt_pcreateerror(void*); +//extern void clnt_perrno(uint32_t); +//extern void* clnt_spcreateerror(void*); +//extern char* clnt_sperrno(enum clnt_stat); +extern int __close(int); +extern int __connect(int, void*, uint32_t); +extern double copysign(double, double); +extern float copysignf(float, float); +extern long double copysignl(long double, long double); +extern int __dup2(int, int); +extern void* __duplocale(void*); +extern int __endmntent(void*); +extern void __explicit_bzero_chk(void*, size_t, size_t); +extern size_t __fbufsize(void*); +extern size_t __fdelt_chk(size_t); +extern void* __fgets_chk(void*, size_t, int, void*); +extern int __finite(double); +extern int finite(double); +extern int __finitef(float); +extern int finitef(float); +extern int __finitel(long double); +extern int finitel(long double); +extern int __flbf(void*); +extern void _flushlbf(); +extern size_t __fpending(void*); +extern void __fpurge(void*); +extern int __freadable(void*); +extern size_t __fread_chk(void*, size_t, size_t, size_t, void*); +extern int __freading(void*); +extern size_t __fread_unlocked_chk(void*, size_t, size_t, size_t, void*); +extern void __freelocale(void*); +extern int __fseeko64(void*, ssize_t, int); +extern int __fsetlocking(void*, int); +extern ssize_t __ftello64(void*); +extern int __fwritable(void*); +extern int __fwriting(void*); +extern void* __getcwd_chk(void*, size_t, size_t); +extern int __getgroups_chk(int, void*, size_t); +extern void* __getmntent_r(void*, void*, void*, int); +//extern int getnetname(char *); +extern int __getpid(void); +//extern int getpublickey (const char *, char *); +extern int __getrlimit(int, void*); +//extern int getrpcport(char *, int, int, int); +//extern int getsecretkey (char *, char *, char *); +extern int __gettimeofday(void*, void*); +extern void* __gmtime_r(void*, void*); +extern uint32_t gnu_dev_major(size_t); +extern size_t gnu_dev_makedev(uint32_t, uint32_t); +extern uint32_t gnu_dev_minor(size_t); +//extern int host2netname(char *, const char *, const char *); +extern int iconvctl(long, int, void*); +extern int _IO_default_doallocate(void*); +extern void _IO_default_finish(void*, int); +extern int _IO_default_pbackfail(void*, int); +extern int _IO_default_uflow(void*); +extern size_t _IO_default_xsgetn(void*, void*, size_t); +extern size_t _IO_default_xsputn(void*, void*, size_t); +extern void _IO_doallocbuf(void*); +extern int _IO_do_write(void*, void*, size_t); +extern void* _IO_file_attach(void*, int); +extern int _IO_file_close(void*); +extern int _IO_file_close_it(void*); +extern int _IO_file_doallocate(void*); +extern void* _IO_file_fopen(void*, void*, void*, int); +extern void _IO_file_init(void*); +extern void* _IO_file_open(void*, void*, int, int, int, int); +extern int _IO_file_overflow(void*, int); +extern ssize_t _IO_file_read(void*, void*, ssize_t); +extern int64_t _IO_file_seek(void*, int64_t, int); +extern int64_t _IO_file_seekoff(void*, int64_t, int, int); +extern void* _IO_file_setbuf(void*, void*, ssize_t); +extern int _IO_file_sync(void*); +extern int _IO_file_underflow(void*); +extern ssize_t _IO_file_write(void*, void*, ssize_t); +extern size_t _IO_file_xsputn(void*, void*, size_t); +extern void _IO_flockfile(void*); +extern int _IO_flush_all(); +extern void _IO_flush_all_linebuffered(); +extern void _IO_free_backup_area(void*); +extern void _IO_funlockfile(void*); +extern int _IO_getc(void*); +extern size_t _IO_getline_info(void*, void*, size_t, int, int, void*); +extern void _IO_init(void*, void*); +extern void _IO_init_marker(void*, void*); +extern void _IO_link_in(void*); +//extern int ioperm(size_t, size_t, int); +extern int _IO_putc(int, void*); +extern int __iswctype_l(uint32_t, size_t, size_t); +//extern int key_secretkey_is_set(void); +//extern int key_setsecret(const char *); +extern void* __libc_calloc(size_t, size_t); +extern void __libc_free(void*); +extern void* __libc_malloc(size_t); +extern void* __libc_memalign(size_t, size_t); +extern void* __libc_pvalloc(size_t); +extern void* __libc_realloc(void*, size_t); +extern void* __libc_valloc(size_t); +extern int64_t __lseek(int, int64_t, int); +extern int __madvise(void*, size_t, int); +extern size_t __mbrtowc(void*, void*, size_t, void*); +extern size_t __mbsnrtowcs_chk(void*, void*, size_t, size_t, void*, size_t); +extern size_t __mbsrtowcs_chk(void*, void*, size_t, void*, size_t); +extern size_t __mbstowcs_chk(void*, void*, size_t, size_t); +extern void _mcount(void*, void*); +extern void* __memcpy_chk(void*, void*, uint32_t, size_t); +extern void* __memmove_chk(void*, void*, size_t, size_t); +extern void* __mempcpy_chk(void*, void*, size_t, size_t); +extern void* __memset_chk(void*, int, size_t, size_t); +extern void* __mktemp(void*); +extern int __nanosleep(void*, void*); +//extern int netname2host(char *, char *, const int); +//extern int netname2user(char *, uid_t *, gid_t *, int *, gid_t *); +extern void* __newlocale(int, void*, void*); +extern void __nl_langinfo_l(uint32_t, void*); +extern int __open_2(void*, int); +extern int __open64_2(void*, int); +extern int __openat_2(int, void*, int); +extern int __openat64_2(int, void*, int); +extern int __pipe(void*); +//extern int pmap_set(size_t, size_t, int, int); +//extern int pmap_unset(size_t, size_t); +extern int __poll(void*, size_t, int); +extern int __poll_chk(void*, uint32_t, int, size_t); +extern int __ppoll_chk(void*, uint32_t, void*, void*, size_t); +extern ssize_t __pread64(int, void*, size_t, int64_t); +extern ssize_t __pread_chk(int, void*, size_t, ssize_t, size_t); +//extern void __sF(int, void*); +//extern void __assert2(int, void*); +//extern void pthread_kill_other_threads_np(); +extern void* __rawmemchr(void*, int); +extern ssize_t __read(int, void*, size_t); +extern ssize_t __read_chk(int, void*, size_t, size_t); +extern ssize_t __recv(int, void*, size_t, int); +extern ssize_t __recv_chk(int, void*, size_t, size_t, int); +extern void __res_iclose(void*, int); +extern int __res_init(); +extern void __res_nclose(void*); +extern int __res_ninit(void*); +extern void* __res_state(); +//extern int _rpc_dtablesize(); +//extern void* __rpc_thread_svc_max_pollfd(); +//extern void* __rpc_thread_svc_pollfd(); +extern void* __sbrk(long); +extern double scalbn(double, int); +extern float scalbnf(float, int); +extern long double scalbnl(long double, int); +extern int __sched_getparam(int, void*); +extern int __sched_get_priority_max(int); +extern int __sched_get_priority_min(int); +extern int __sched_yield(); +extern int __select(int, void*, void*, void*, void*); +extern ssize_t __send(int, void*, size_t, int); +extern int __sendmmsg(int, void*, uint32_t, int); +extern void* __setmntent(void*, void*); +extern int __setpgid(void*, void*); +int __sigaddset(void* a, int b) {return sigaddset(a, b);} +extern int __signbit(double); +extern int __signbitf(float); +extern int __signbitl(long double); +extern int __sigsuspend(void*); +extern int __sigtimedwait(void*, void*, void*); +extern int __socket(int, int, int); +extern void* __stpcpy_chk(void*, void*, size_t); +extern void* __stpncpy_chk(void*, void*, size_t, size_t); +extern int __strcasecmp(void*, void*); +extern void* __strcasestr(void*, void*); +extern void* __strcat_chk(void*, void*, size_t); +extern int __strcoll_l(void*, void*, void*); +extern void* __strcpy_chk(void*, void*, size_t); +extern void* __strdup(void*); +extern void* __strerror_r(int, void*, size_t); +extern long strfmon_l(void*, size_t, void*, void*, ...); +extern size_t __strftime_l(void*, size_t, void*, void*, size_t); +extern void* __strncat_chk(void*, void*, size_t, size_t); +extern void* __strncpy_chk(void*, void*, size_t, size_t); +extern void* __strndup(void*, size_t); +extern double __strtod_internal(void*, void*, int); +extern double __strtod_l(void*, void*, void*); +extern float __strtof_internal(void*, void*, int); +extern float __strtof_l(void*, void*, size_t); +extern long double __strtold_internal(void*, void*, int); +extern long double __strtold_l(void*, void*, void*); +extern long __strtol_internal(void*, void*, int, int); +extern long __strtol_l(void*, void*, int); +extern int64_t __strtoll_internal(void*, void*, int, int); +extern int64_t __strtoll_l(void*, void*, int, void*); +extern size_t __strtoul_internal(void*, void*, int, int); +extern uint64_t __strtoull_internal(void*, void*, int, int); +extern size_t __strtoull_l(void*, void*, int, void*); +extern size_t __strxfrm_l(void*, void*, size_t, size_t); +//extern void svc_exit(void); +//extern void svc_getreq(int); +//extern void svc_getreq_common(int); +//extern void svc_getreq_poll(struct pollfd *, int); +//extern void svc_run(void); +//extern void svc_unregister(u_long, u_long); +//extern int __sysctl(void*, int, void*, void*, void*, size_t); +//extern int sysctl(void*, int, void*, void*, void*, size_t); +extern void thrd_exit(void*); +extern int __towlower_l(int, void*); +extern int __towupper_l(int, void*); +extern int __underflow(void*); +extern void* __uselocale(void*); +extern int user2netname(char *, const uid_t, const char *); +extern int __wait(void*); +extern int __waitpid(int, void*, int); +extern int __wcscasecmp_l(void*, void*, void*); +extern void* __wcscat_chk(void*, void*, size_t); +extern int __wcscoll_l(void*, void*, void*); +extern void* __wcscpy_chk(void*, void*, size_t); +extern size_t __wcsftime_l(void*, size_t, void*, void*, void*); +extern void* __wcsncat_chk(void*, void*, size_t, size_t); +extern void* __wcsncpy_chk(void*, void*, size_t, size_t); +extern size_t __wcsxfrm_l(void*, void*, size_t, size_t); +extern int __wctomb_chk(void* uint32_t, size_t); +extern size_t __wctype_l(void*, void*); +extern void* __wmemcpy_chk(void*, void*, size_t, size_t); +extern void* __wmemmove_chk(void*, void*, size_t, size_t); +extern void* __wmemset_chk(void* uint32_t, size_t, size_t); +extern ssize_t __write(int, void*, size_t); +extern int __xpg_strerror_r(int __errnum, char *__buf, size_t __buflen); +extern int __xpg_sigpause(int __sig); +extern char *__xpg_basename(char *__path); +//extern int __xmknodat(int, int, void*, uint32_t, void*); +//extern int __xmknod(int, void*, uint32_t, void*); +//extern int xdr_void(); +void* dummy_pFLp(size_t a, void* b) {} +void* dummy_pFpLLp(void* a, size_t b, size_t c, void* d) {} +void* dummy__ZnwmSt11align_val_tRKSt9nothrow_t(size_t a, size_t b, void* c) {} \ No newline at end of file diff --git a/src/libtools/static_threads.h b/src/libtools/static_threads.h new file mode 100644 index 00000000..62240fbf --- /dev/null +++ b/src/libtools/static_threads.h @@ -0,0 +1,86 @@ +#include <pthread.h> + +typedef struct x64emu_s x64emu_t; +typedef struct x64_unwind_buff_s x64_unwind_buff_t; +typedef union my_mutexattr_s my_mutexattr_t; +typedef union my_barrierattr_s my_barrierattr_t; +typedef union my_condattr_s my_condattr_t; +int my_pthread_atfork(x64emu_t *emu, void* prepare, void* parent, void* child); +int my_pthread_attr_destroy(x64emu_t* emu, void* attr); +int my_pthread_attr_getstack(x64emu_t* emu, void* attr, void** stackaddr, size_t* stacksize); +int my_pthread_attr_setstack(x64emu_t* emu, void* attr, void* stackaddr, size_t stacksize); +int my_pthread_attr_setstacksize(x64emu_t* emu, void* attr, size_t stacksize); +int my_pthread_attr_getdetachstate(x64emu_t* emu, pthread_attr_t* attr, int *state); +int my_pthread_attr_getguardsize(x64emu_t* emu, pthread_attr_t* attr, size_t* size); +int my_pthread_attr_getinheritsched(x64emu_t* emu, pthread_attr_t* attr, int* sched); +int my_pthread_attr_getschedparam(x64emu_t* emu, pthread_attr_t* attr, void* param); +int my_pthread_attr_getschedpolicy(x64emu_t* emu, pthread_attr_t* attr, int* policy); +int my_pthread_attr_getscope(x64emu_t* emu, pthread_attr_t* attr, int* scope); +int my_pthread_attr_getstackaddr(x64emu_t* emu, pthread_attr_t* attr, void* addr); +int my_pthread_attr_getstacksize(x64emu_t* emu, pthread_attr_t* attr, size_t* size); +int my_pthread_attr_init(x64emu_t* emu, pthread_attr_t* attr); +int my_pthread_attr_setaffinity_np(x64emu_t* emu, pthread_attr_t* attr, size_t cpusize, void* cpuset); +int my_pthread_attr_setdetachstate(x64emu_t* emu, pthread_attr_t* attr, int state); +int my_pthread_attr_setguardsize(x64emu_t* emu, pthread_attr_t* attr, size_t size); +int my_pthread_attr_setinheritsched(x64emu_t* emu, pthread_attr_t* attr, int sched); +int my_pthread_attr_setschedparam(x64emu_t* emu, pthread_attr_t* attr, void* param); +int my_pthread_attr_setschedpolicy(x64emu_t* emu, pthread_attr_t* attr, int policy); +int my_pthread_attr_setscope(x64emu_t* emu, pthread_attr_t* attr, int scope); +int my_pthread_attr_setstackaddr(x64emu_t* emu, pthread_attr_t* attr, void* addr); +int my_pthread_getattr_np(x64emu_t* emu, pthread_t thread_id, pthread_attr_t* attr); +int my_pthread_getattr_default_np(x64emu_t* emu, pthread_attr_t* attr); +int my_pthread_setattr_default_np(x64emu_t* emu, pthread_attr_t* attr); +int my_pthread_create(x64emu_t *emu, void* t, void* attr, void* start_routine, void* arg); +int my_pthread_once(x64emu_t* emu, int* once, void* cb); +int my___pthread_once(x64emu_t* emu, void* once, void* cb); +int my_pthread_key_create(x64emu_t* emu, pthread_key_t* key, void* dtor); +int my___pthread_key_create(x64emu_t* emu, pthread_key_t* key, void* dtor); +int my_pthread_key_delete(x64emu_t* emu, pthread_key_t key); +int my_pthread_barrierattr_destroy(x64emu_t* emu, my_barrierattr_t* b); +int my_pthread_barrierattr_getpshared(x64emu_t* emu, my_barrierattr_t* b, void* p); +int my_pthread_barrierattr_init(x64emu_t* emu, my_barrierattr_t* b); +int my_pthread_barrierattr_setpshared(x64emu_t* emu, my_barrierattr_t* b, int p); +int my_pthread_cond_timedwait(x64emu_t* emu, pthread_cond_t* cond, void* mutex, void* abstime); +int my_pthread_cond_wait(x64emu_t* emu, pthread_cond_t* cond, void* mutex); +int my_pthread_cond_clockwait(x64emu_t *emu, pthread_cond_t* cond, void* mutex, clockid_t __clock_id, const struct timespec* __abstime); +int my_pthread_getaffinity_np(x64emu_t* emu, pthread_t thread, size_t cpusetsize, void* cpuset); +int my_pthread_setaffinity_np(x64emu_t* emu, pthread_t thread, size_t cpusetsize, void* cpuset); +int my_pthread_kill(x64emu_t* emu, void* thread, int sig); +int my_pthread_kill_old(x64emu_t* emu, void* thread, int sig); +int my_pthread_mutexattr_destroy(x64emu_t* emu, my_mutexattr_t *attr); +int my___pthread_mutexattr_destroy(x64emu_t* emu, my_mutexattr_t *attr); +int my_pthread_mutexattr_getkind_np(x64emu_t* emu, my_mutexattr_t *attr, void* p); +int my_pthread_mutexattr_getprotocol(x64emu_t* emu, my_mutexattr_t *attr, void* p); +int my_pthread_mutexattr_gettype(x64emu_t* emu, my_mutexattr_t *attr, void* p); +int my_pthread_mutexattr_getrobust(x64emu_t* emu, my_mutexattr_t *attr, void* p); +int my_pthread_mutexattr_init(x64emu_t* emu, my_mutexattr_t *attr); +int my___pthread_mutexattr_init(x64emu_t* emu, my_mutexattr_t *attr); +int my_pthread_mutexattr_setkind_np(x64emu_t* emu, my_mutexattr_t *attr, int k); +int my_pthread_mutexattr_setprotocol(x64emu_t* emu, my_mutexattr_t *attr, int p); +int my_pthread_mutexattr_setpshared(x64emu_t* emu, my_mutexattr_t *attr, int p); +int my_pthread_mutexattr_settype(x64emu_t* emu, my_mutexattr_t *attr, int t); +int my___pthread_mutexattr_settype(x64emu_t* emu, my_mutexattr_t *attr, int t); +int my_pthread_mutexattr_setrobust(x64emu_t* emu, my_mutexattr_t *attr, int t); +int my_pthread_mutex_init(pthread_mutex_t *m, my_mutexattr_t *att); +int my___pthread_mutex_init(pthread_mutex_t *m, my_mutexattr_t *att); +int my_pthread_condattr_destroy(x64emu_t* emu, my_condattr_t* c); +int my_pthread_condattr_getclock(x64emu_t* emu, my_condattr_t* c, void* cl); +int my_pthread_condattr_getpshared(x64emu_t* emu, my_condattr_t* c, void* p); +int my_pthread_condattr_init(x64emu_t* emu, my_condattr_t* c); +int my_pthread_condattr_setclock(x64emu_t* emu, my_condattr_t* c, int cl); +int my_pthread_condattr_setpshared(x64emu_t* emu, my_condattr_t* c, int p); +int my_pthread_cond_init(x64emu_t* emu, pthread_cond_t *pc, my_condattr_t* c); +int my_pthread_cond_destroy(x64emu_t* emu, pthread_cond_t *pc); +int my_pthread_cond_broadcast(x64emu_t* emu, pthread_cond_t *pc); +int my_pthread_barrierattr_destroy(x64emu_t* emu, my_barrierattr_t* b); +int my_pthread_barrierattr_getpshared(x64emu_t* emu, my_barrierattr_t* b, void* p); +int my_pthread_barrierattr_init(x64emu_t* emu, my_barrierattr_t* b); +int my_pthread_barrierattr_setpshared(x64emu_t* emu, my_barrierattr_t* b, int p); +int my_pthread_barrier_init(x64emu_t* emu, pthread_barrier_t* bar, my_barrierattr_t* b, uint32_t count); +void my___pthread_register_cancel(x64emu_t* emu, x64_unwind_buff_t* buff); +void my___pthread_unregister_cancel(x64emu_t* emu, x64_unwind_buff_t* buff); +void my___pthread_unwind_next(x64emu_t* emu, x64_unwind_buff_t* buff); +void my__pthread_cleanup_push_defer(x64emu_t* emu, void* buffer, void* routine, void* arg); +void my__pthread_cleanup_push(x64emu_t* emu, void* buffer, void* routine, void* arg); +void my__pthread_cleanup_pop_restore(x64emu_t* emu, void* buffer, int exec); +void my__pthread_cleanup_pop(x64emu_t* emu, void* buffer, int exec); \ No newline at end of file diff --git a/src/main.c b/src/main.c index cddfbc44..8cecf8ac 100644 --- a/src/main.c +++ b/src/main.c @@ -1451,7 +1451,9 @@ void setupTrace() } #endif } +#ifndef STATICBUILD void endMallocHook(); +#endif void endBox64() { @@ -1461,7 +1463,9 @@ void endBox64() // then call all the fini dynarec_log(LOG_DEBUG, "endBox64() called\n"); box64_quit = 1; + #ifndef STATICBUILD endMallocHook(); + #endif x64emu_t* emu = thread_get_emu(); void startTimedExit(); startTimedExit(); @@ -1570,10 +1574,14 @@ static void load_rcfiles() } } +#ifndef STATICBUILD void pressure_vessel(int argc, const char** argv, int nextarg, const char* prog); +#endif extern char** environ; int main(int argc, const char **argv, char **env) { + #ifndef STATICBUILD init_malloc_hook(); + #endif init_auxval(argc, argv, environ?environ:env); // analogue to QEMU_VERSION in qemu-user-mode emulation if(getenv("BOX64_VERSION")) { @@ -1657,7 +1665,7 @@ int main(int argc, const char **argv, char **env) { //wine_preloaded = 1; } } - #if 1 + #ifndef STATICBUILD // pre-check for pressure-vessel-wrap if(strstr(prog, "pressure-vessel-wrap")==(prog+strlen(prog)-strlen("pressure-vessel-wrap"))) { printf_log(LOG_INFO, "BOX64: pressure-vessel-wrap detected\n"); diff --git a/src/tools/my_cpuid.c b/src/tools/my_cpuid.c index e4de411a..a7f9ae3e 100644 --- a/src/tools/my_cpuid.c +++ b/src/tools/my_cpuid.c @@ -39,7 +39,7 @@ int get_cpuMhz() else cpucore = -1; } - + #ifndef STATICBUILD if(!MHz) { // try with lscpu, grabbing the max frequency FILE* f = popen("lscpu | grep \"CPU max MHz:\" | sed -r 's/CPU max MHz:\\s{1,}//g'", "r"); @@ -68,6 +68,7 @@ int get_cpuMhz() } } } + #endif if(!MHz) MHz = 1000; // default to 1Ghz... sprintf(cpumhz, "%d", MHz); @@ -132,6 +133,7 @@ const char* getCpuName() return name; } setenv("BOX64_CPUNAME", name, 1); // temporary set + #ifndef STATICBUILD FILE* f = popen("lscpu | grep \"Model name:\" | sed -r 's/Model name:\\s{1,}//g'", "r"); if(f) { char tmp[200] = ""; @@ -171,6 +173,7 @@ const char* getCpuName() return name; } } + #endif // Nope, bye return name; } diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index 4999044b..514b18eb 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -502,9 +502,7 @@ #() iFupL #() iFupp #() iFfff -#() iFlip #() iFLip -#() iFLLi #() iFLpp #() iFpwp #() iFpii @@ -936,7 +934,6 @@ #() iFEpLi #() iFEpLp #() iFEppi -#() iFEppu #() iFEppd #() iFEppL #() iFEppp @@ -965,7 +962,6 @@ #() iFipWp #() iFipui #() iFipuL -#() iFipup #() iFipLi #() iFipLu #() iFipLp @@ -984,7 +980,6 @@ #() iFuppi #() iFuppu #() iFuppp -#() iFLLiW #() iFLppp #() iFpwww #() iFpwpp @@ -1504,7 +1499,6 @@ #() iFiiipu #() iFiiipp #() iFiiupp -#() iFiipup #() iFiuuuu #() iFiuuup #() iFiuLip @@ -1989,7 +1983,6 @@ #() iFpipLpp #() iFpippip #() iFpippup -#() iFpipppL #() iFpipppp #() iFpCiipp #() iFpCpipu @@ -3040,9 +3033,16 @@ #!defined(HAVE_LD80BITS) lFKK #!defined(HAVE_LD80BITS) KFKKK #defined(NOALIGN) iFipiip +#!defined(NOALIGN) iFEppu #!defined(NOALIGN) iFEiiip #!defined(NOALIGN) iFEipii #!defined(NOALIGN) iFEipiip +#!defined(STATICBUILD) iFlip +#!defined(STATICBUILD) iFLLi +#!defined(STATICBUILD) iFipup +#!defined(STATICBUILD) iFLLiW +#!defined(STATICBUILD) iFiipup +#!defined(STATICBUILD) iFpipppL #() vFEv -> vFE #() iFEv -> iFE #() lFEv -> lFE @@ -4035,18 +4035,6 @@ wrappedlibc: - _setjmp - atexit - getcontext - - pthread_attr_destroy - - pthread_attr_init - - pthread_barrierattr_destroy - - pthread_barrierattr_init - - pthread_cond_broadcast - - pthread_cond_destroy - - pthread_condattr_destroy - - pthread_condattr_init - - pthread_getattr_default_np - - pthread_mutexattr_destroy - - pthread_mutexattr_init - - pthread_setattr_default_np - register_printf_type - setcontext - setjmp @@ -4085,30 +4073,12 @@ wrappedlibc: - fstat64 - iFup: - setrlimit -- iFLp: - - pthread_getattr_np - iFpi: - __sigsetjmp - backtrace - - pthread_attr_setdetachstate - - pthread_attr_setinheritsched - - pthread_attr_setschedpolicy - - pthread_attr_setscope - - pthread_barrierattr_setpshared - - pthread_condattr_setclock - - pthread_condattr_setpshared - - pthread_kill - - pthread_kill@GLIBC_2.2.5 - - pthread_mutexattr_setkind_np - - pthread_mutexattr_setprotocol - - pthread_mutexattr_setpshared - - pthread_mutexattr_setrobust - - pthread_mutexattr_settype - sigsetjmp - iFpL: - munmap - - pthread_attr_setguardsize - - pthread_attr_setstacksize - iFpp: - __vprintf_chk - dl_iterate_phdr @@ -4116,28 +4086,6 @@ wrappedlibc: - execvp - lstat - lstat64 - - pthread_attr_getdetachstate - - pthread_attr_getguardsize - - pthread_attr_getinheritsched - - pthread_attr_getschedparam - - pthread_attr_getschedpolicy - - pthread_attr_getscope - - pthread_attr_getstackaddr - - pthread_attr_getstacksize - - pthread_attr_setschedparam - - pthread_attr_setstackaddr - - pthread_barrierattr_getpshared - - pthread_cond_init - - pthread_cond_wait - - pthread_condattr_getclock - - pthread_condattr_getpshared - - pthread_key_create - - pthread_mutex_init - - pthread_mutexattr_getkind_np - - pthread_mutexattr_getprotocol - - pthread_mutexattr_getrobust - - pthread_mutexattr_gettype - - pthread_once - sigaltstack - stat - stat64 @@ -4200,26 +4148,15 @@ wrappedlibc: - vdprintf - iFpLi: - mprotect -- iFpLp: - - pthread_attr_setaffinity_np - - pthread_getaffinity_np - - pthread_setaffinity_np - iFppi: - ftw - ftw64 -- iFppu: - - pthread_barrier_init -- iFppL: - - pthread_attr_setstack - iFppp: - __cxa_atexit - __cxa_thread_atexit_impl - __vfprintf_chk - __vsscanf - execve - - pthread_atfork - - pthread_attr_getstack - - pthread_cond_timedwait - iFppV: - __asprintf - __isoc23_fscanf @@ -4309,14 +4246,11 @@ wrappedlibc: - vswprintf - iFppii: - nftw64 -- iFppip: - - pthread_cond_clockwait - iFppiV: - makecontext - iFpppp: - __register_atfork - __vsprintf_chk - - pthread_create - scandir - scandir64 - lFuipp: @@ -4539,6 +4473,7 @@ wrappedlibm: - __sinhf_finite - __sqrtf_finite - nearbyintf + - pow10f - rintf - dFd: - __acos_finite @@ -4553,7 +4488,12 @@ wrappedlibm: - __sinh_finite - __sqrt_finite - nearbyint + - pow10 - rint +- DFD: + - pow10l +- KFK: + - pow10l - fFff: - __atan2f_finite - __fmodf_finite diff --git a/src/wrapped/generated/wrappedlibctypes.h b/src/wrapped/generated/wrappedlibctypes.h index efe6d40d..6e38ef3d 100644 --- a/src/wrapped/generated/wrappedlibctypes.h +++ b/src/wrapped/generated/wrappedlibctypes.h @@ -28,7 +28,6 @@ typedef void (*vFpp_t)(void*, void*); typedef void (*vFpV_t)(void*, ...); typedef int32_t (*iFip_t)(int32_t, void*); typedef int32_t (*iFup_t)(uint32_t, void*); -typedef int32_t (*iFLp_t)(uintptr_t, void*); typedef int32_t (*iFpi_t)(void*, int32_t); typedef int32_t (*iFpL_t)(void*, uintptr_t); typedef int32_t (*iFpp_t)(void*, void*); @@ -48,10 +47,7 @@ typedef int32_t (*iFipp_t)(int32_t, void*, void*); typedef int32_t (*iFipV_t)(int32_t, void*, ...); typedef int32_t (*iFipA_t)(int32_t, void*, va_list); typedef int32_t (*iFpLi_t)(void*, uintptr_t, int32_t); -typedef int32_t (*iFpLp_t)(void*, uintptr_t, void*); typedef int32_t (*iFppi_t)(void*, void*, int32_t); -typedef int32_t (*iFppu_t)(void*, void*, uint32_t); -typedef int32_t (*iFppL_t)(void*, void*, uintptr_t); typedef int32_t (*iFppp_t)(void*, void*, void*); typedef int32_t (*iFppV_t)(void*, void*, ...); typedef int32_t (*iFppA_t)(void*, void*, va_list); @@ -79,7 +75,6 @@ typedef int32_t (*iFpipA_t)(void*, int32_t, void*, va_list); typedef int32_t (*iFpLpV_t)(void*, uintptr_t, void*, ...); typedef int32_t (*iFpLpA_t)(void*, uintptr_t, void*, va_list); typedef int32_t (*iFppii_t)(void*, void*, int32_t, int32_t); -typedef int32_t (*iFppip_t)(void*, void*, int32_t, void*); typedef int32_t (*iFppiV_t)(void*, void*, int32_t, ...); typedef int32_t (*iFpppp_t)(void*, void*, void*, void*); typedef intptr_t (*lFuipp_t)(uint32_t, int32_t, void*, void*); @@ -115,18 +110,6 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void* GO(_setjmp, iFp_t) \ GO(atexit, iFp_t) \ GO(getcontext, iFp_t) \ - GO(pthread_attr_destroy, iFp_t) \ - GO(pthread_attr_init, iFp_t) \ - GO(pthread_barrierattr_destroy, iFp_t) \ - GO(pthread_barrierattr_init, iFp_t) \ - GO(pthread_cond_broadcast, iFp_t) \ - GO(pthread_cond_destroy, iFp_t) \ - GO(pthread_condattr_destroy, iFp_t) \ - GO(pthread_condattr_init, iFp_t) \ - GO(pthread_getattr_default_np, iFp_t) \ - GO(pthread_mutexattr_destroy, iFp_t) \ - GO(pthread_mutexattr_init, iFp_t) \ - GO(pthread_setattr_default_np, iFp_t) \ GO(register_printf_type, iFp_t) \ GO(setcontext, iFp_t) \ GO(setjmp, iFp_t) \ @@ -154,55 +137,16 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void* GO(fstat, iFip_t) \ GO(fstat64, iFip_t) \ GO(setrlimit, iFup_t) \ - GO(pthread_getattr_np, iFLp_t) \ GO(__sigsetjmp, iFpi_t) \ GO(backtrace, iFpi_t) \ - GO(pthread_attr_setdetachstate, iFpi_t) \ - GO(pthread_attr_setinheritsched, iFpi_t) \ - GO(pthread_attr_setschedpolicy, iFpi_t) \ - GO(pthread_attr_setscope, iFpi_t) \ - GO(pthread_barrierattr_setpshared, iFpi_t) \ - GO(pthread_condattr_setclock, iFpi_t) \ - GO(pthread_condattr_setpshared, iFpi_t) \ - GO(pthread_kill, iFpi_t) \ - GO(pthread_kill@GLIBC_2.2.5, iFpi_t) \ - GO(pthread_mutexattr_setkind_np, iFpi_t) \ - GO(pthread_mutexattr_setprotocol, iFpi_t) \ - GO(pthread_mutexattr_setpshared, iFpi_t) \ - GO(pthread_mutexattr_setrobust, iFpi_t) \ - GO(pthread_mutexattr_settype, iFpi_t) \ GO(sigsetjmp, iFpi_t) \ GO(munmap, iFpL_t) \ - GO(pthread_attr_setguardsize, iFpL_t) \ - GO(pthread_attr_setstacksize, iFpL_t) \ GO(__vprintf_chk, iFpp_t) \ GO(dl_iterate_phdr, iFpp_t) \ GO(execv, iFpp_t) \ GO(execvp, iFpp_t) \ GO(lstat, iFpp_t) \ GO(lstat64, iFpp_t) \ - GO(pthread_attr_getdetachstate, iFpp_t) \ - GO(pthread_attr_getguardsize, iFpp_t) \ - GO(pthread_attr_getinheritsched, iFpp_t) \ - GO(pthread_attr_getschedparam, iFpp_t) \ - GO(pthread_attr_getschedpolicy, iFpp_t) \ - GO(pthread_attr_getscope, iFpp_t) \ - GO(pthread_attr_getstackaddr, iFpp_t) \ - GO(pthread_attr_getstacksize, iFpp_t) \ - GO(pthread_attr_setschedparam, iFpp_t) \ - GO(pthread_attr_setstackaddr, iFpp_t) \ - GO(pthread_barrierattr_getpshared, iFpp_t) \ - GO(pthread_cond_init, iFpp_t) \ - GO(pthread_cond_wait, iFpp_t) \ - GO(pthread_condattr_getclock, iFpp_t) \ - GO(pthread_condattr_getpshared, iFpp_t) \ - GO(pthread_key_create, iFpp_t) \ - GO(pthread_mutex_init, iFpp_t) \ - GO(pthread_mutexattr_getkind_np, iFpp_t) \ - GO(pthread_mutexattr_getprotocol, iFpp_t) \ - GO(pthread_mutexattr_getrobust, iFpp_t) \ - GO(pthread_mutexattr_gettype, iFpp_t) \ - GO(pthread_once, iFpp_t) \ GO(sigaltstack, iFpp_t) \ GO(stat, iFpp_t) \ GO(stat64, iFpp_t) \ @@ -249,21 +193,13 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void* GO(dprintf, iFipV_t) \ GO(vdprintf, iFipA_t) \ GO(mprotect, iFpLi_t) \ - GO(pthread_attr_setaffinity_np, iFpLp_t) \ - GO(pthread_getaffinity_np, iFpLp_t) \ - GO(pthread_setaffinity_np, iFpLp_t) \ GO(ftw, iFppi_t) \ GO(ftw64, iFppi_t) \ - GO(pthread_barrier_init, iFppu_t) \ - GO(pthread_attr_setstack, iFppL_t) \ GO(__cxa_atexit, iFppp_t) \ GO(__cxa_thread_atexit_impl, iFppp_t) \ GO(__vfprintf_chk, iFppp_t) \ GO(__vsscanf, iFppp_t) \ GO(execve, iFppp_t) \ - GO(pthread_atfork, iFppp_t) \ - GO(pthread_attr_getstack, iFppp_t) \ - GO(pthread_cond_timedwait, iFppp_t) \ GO(__asprintf, iFppV_t) \ GO(__isoc23_fscanf, iFppV_t) \ GO(__isoc23_sscanf, iFppV_t) \ @@ -327,11 +263,9 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void* GO(vsnprintf, iFpLpA_t) \ GO(vswprintf, iFpLpA_t) \ GO(nftw64, iFppii_t) \ - GO(pthread_cond_clockwait, iFppip_t) \ GO(makecontext, iFppiV_t) \ GO(__register_atfork, iFpppp_t) \ GO(__vsprintf_chk, iFpppp_t) \ - GO(pthread_create, iFpppp_t) \ GO(scandir, iFpppp_t) \ GO(scandir64, iFpppp_t) \ GO(ptrace, lFuipp_t) \ diff --git a/src/wrapped/generated/wrappedlibmtypes.h b/src/wrapped/generated/wrappedlibmtypes.h index f5ab45f4..b31e0cbc 100644 --- a/src/wrapped/generated/wrappedlibmtypes.h +++ b/src/wrapped/generated/wrappedlibmtypes.h @@ -21,6 +21,8 @@ typedef int64_t (*IFD_t)(long double); typedef int64_t (*IFK_t)(double); typedef float (*fFf_t)(float); typedef double (*dFd_t)(double); +typedef long double (*DFD_t)(long double); +typedef double (*KFK_t)(double); typedef float (*fFff_t)(float, float); typedef double (*dFdd_t)(double, double); @@ -45,6 +47,7 @@ typedef double (*dFdd_t)(double, double); GO(__sinhf_finite, fFf_t) \ GO(__sqrtf_finite, fFf_t) \ GO(nearbyintf, fFf_t) \ + GO(pow10f, fFf_t) \ GO(rintf, fFf_t) \ GO(__acos_finite, dFd_t) \ GO(__acosh_finite, dFd_t) \ @@ -58,7 +61,10 @@ typedef double (*dFdd_t)(double, double); GO(__sinh_finite, dFd_t) \ GO(__sqrt_finite, dFd_t) \ GO(nearbyint, dFd_t) \ + GO(pow10, dFd_t) \ GO(rint, dFd_t) \ + GO(pow10l, DFD_t) \ + GO(pow10l, KFK_t) \ GO(__atan2f_finite, fFff_t) \ GO(__fmodf_finite, fFff_t) \ GO(__hypotf_finite, fFff_t) \ diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index 6da52f0f..78ec76b8 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -540,9 +540,7 @@ typedef int32_t (*iFupu_t)(uint32_t, void*, uint32_t); typedef int32_t (*iFupL_t)(uint32_t, void*, uintptr_t); typedef int32_t (*iFupp_t)(uint32_t, void*, void*); typedef int32_t (*iFfff_t)(float, float, float); -typedef int32_t (*iFlip_t)(intptr_t, int32_t, void*); typedef int32_t (*iFLip_t)(uintptr_t, int32_t, void*); -typedef int32_t (*iFLLi_t)(uintptr_t, uintptr_t, int32_t); typedef int32_t (*iFLpp_t)(uintptr_t, void*, void*); typedef int32_t (*iFpwp_t)(void*, int16_t, void*); typedef int32_t (*iFpii_t)(void*, int32_t, int32_t); @@ -974,7 +972,6 @@ typedef int32_t (*iFEpUp_t)(x64emu_t*, void*, uint64_t, void*); typedef int32_t (*iFEpLi_t)(x64emu_t*, void*, uintptr_t, int32_t); typedef int32_t (*iFEpLp_t)(x64emu_t*, void*, uintptr_t, void*); typedef int32_t (*iFEppi_t)(x64emu_t*, void*, void*, int32_t); -typedef int32_t (*iFEppu_t)(x64emu_t*, void*, void*, uint32_t); typedef int32_t (*iFEppd_t)(x64emu_t*, void*, void*, double); typedef int32_t (*iFEppL_t)(x64emu_t*, void*, void*, uintptr_t); typedef int32_t (*iFEppp_t)(x64emu_t*, void*, void*, void*); @@ -1003,7 +1000,6 @@ typedef int32_t (*iFipip_t)(int32_t, void*, int32_t, void*); typedef int32_t (*iFipWp_t)(int32_t, void*, uint16_t, void*); typedef int32_t (*iFipui_t)(int32_t, void*, uint32_t, int32_t); typedef int32_t (*iFipuL_t)(int32_t, void*, uint32_t, uintptr_t); -typedef int32_t (*iFipup_t)(int32_t, void*, uint32_t, void*); typedef int32_t (*iFipLi_t)(int32_t, void*, uintptr_t, int32_t); typedef int32_t (*iFipLu_t)(int32_t, void*, uintptr_t, uint32_t); typedef int32_t (*iFipLp_t)(int32_t, void*, uintptr_t, void*); @@ -1022,7 +1018,6 @@ typedef int32_t (*iFupLp_t)(uint32_t, void*, uintptr_t, void*); typedef int32_t (*iFuppi_t)(uint32_t, void*, void*, int32_t); typedef int32_t (*iFuppu_t)(uint32_t, void*, void*, uint32_t); typedef int32_t (*iFuppp_t)(uint32_t, void*, void*, void*); -typedef int32_t (*iFLLiW_t)(uintptr_t, uintptr_t, int32_t, uint16_t); typedef int32_t (*iFLppp_t)(uintptr_t, void*, void*, void*); typedef int32_t (*iFpwww_t)(void*, int16_t, int16_t, int16_t); typedef int32_t (*iFpwpp_t)(void*, int16_t, void*, void*); @@ -1542,7 +1537,6 @@ typedef int32_t (*iFEpppA_t)(x64emu_t*, void*, void*, void*, void*); typedef int32_t (*iFiiipu_t)(int32_t, int32_t, int32_t, void*, uint32_t); typedef int32_t (*iFiiipp_t)(int32_t, int32_t, int32_t, void*, void*); typedef int32_t (*iFiiupp_t)(int32_t, int32_t, uint32_t, void*, void*); -typedef int32_t (*iFiipup_t)(int32_t, int32_t, void*, uint32_t, void*); typedef int32_t (*iFiuuuu_t)(int32_t, uint32_t, uint32_t, uint32_t, uint32_t); typedef int32_t (*iFiuuup_t)(int32_t, uint32_t, uint32_t, uint32_t, void*); typedef int32_t (*iFiuLip_t)(int32_t, uint32_t, uintptr_t, int32_t, void*); @@ -2027,7 +2021,6 @@ typedef int32_t (*iFpipupp_t)(void*, int32_t, void*, uint32_t, void*, void*); typedef int32_t (*iFpipLpp_t)(void*, int32_t, void*, uintptr_t, void*, void*); typedef int32_t (*iFpippip_t)(void*, int32_t, void*, void*, int32_t, void*); typedef int32_t (*iFpippup_t)(void*, int32_t, void*, void*, uint32_t, void*); -typedef int32_t (*iFpipppL_t)(void*, int32_t, void*, void*, void*, uintptr_t); typedef int32_t (*iFpipppp_t)(void*, int32_t, void*, void*, void*, void*); typedef int32_t (*iFpCiipp_t)(void*, uint8_t, int32_t, int32_t, void*, void*); typedef int32_t (*iFpCpipu_t)(void*, uint8_t, void*, int32_t, void*, uint32_t); @@ -3089,11 +3082,21 @@ typedef int32_t (*iFipiip_t)(int32_t, void*, int32_t, int32_t, void*); #endif #if !defined(NOALIGN) +typedef int32_t (*iFEppu_t)(x64emu_t*, void*, void*, uint32_t); typedef int32_t (*iFEiiip_t)(x64emu_t*, int32_t, int32_t, int32_t, void*); typedef int32_t (*iFEipii_t)(x64emu_t*, int32_t, void*, int32_t, int32_t); typedef int32_t (*iFEipiip_t)(x64emu_t*, int32_t, void*, int32_t, int32_t, void*); #endif +#if !defined(STATICBUILD) +typedef int32_t (*iFlip_t)(intptr_t, int32_t, void*); +typedef int32_t (*iFLLi_t)(uintptr_t, uintptr_t, int32_t); +typedef int32_t (*iFipup_t)(int32_t, void*, uint32_t, void*); +typedef int32_t (*iFLLiW_t)(uintptr_t, uintptr_t, int32_t, uint16_t); +typedef int32_t (*iFiipup_t)(int32_t, int32_t, void*, uint32_t, void*); +typedef int32_t (*iFpipppL_t)(void*, int32_t, void*, void*, void*, uintptr_t); +#endif + void vFE(x64emu_t *emu, uintptr_t fcn) { vFE_t fn = (vFE_t)fcn; fn(emu); } void vFv(x64emu_t *emu, uintptr_t fcn) { vFv_t fn = (vFv_t)fcn; fn(); (void)emu; } void vFc(x64emu_t *emu, uintptr_t fcn) { vFc_t fn = (vFc_t)fcn; fn((int8_t)R_RDI); } @@ -3598,9 +3601,7 @@ void iFupu(x64emu_t *emu, uintptr_t fcn) { iFupu_t fn = (iFupu_t)fcn; R_RAX=(int void iFupL(x64emu_t *emu, uintptr_t fcn) { iFupL_t fn = (iFupL_t)fcn; R_RAX=(int32_t)fn((uint32_t)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX); } void iFupp(x64emu_t *emu, uintptr_t fcn) { iFupp_t fn = (iFupp_t)fcn; R_RAX=(int32_t)fn((uint32_t)R_RDI, (void*)R_RSI, (void*)R_RDX); } void iFfff(x64emu_t *emu, uintptr_t fcn) { iFfff_t fn = (iFfff_t)fcn; R_RAX=(int32_t)fn(emu->xmm[0].f[0], emu->xmm[1].f[0], emu->xmm[2].f[0]); } -void iFlip(x64emu_t *emu, uintptr_t fcn) { iFlip_t fn = (iFlip_t)fcn; R_RAX=(int32_t)fn((intptr_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX); } void iFLip(x64emu_t *emu, uintptr_t fcn) { iFLip_t fn = (iFLip_t)fcn; R_RAX=(int32_t)fn((uintptr_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX); } -void iFLLi(x64emu_t *emu, uintptr_t fcn) { iFLLi_t fn = (iFLLi_t)fcn; R_RAX=(int32_t)fn((uintptr_t)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX); } void iFLpp(x64emu_t *emu, uintptr_t fcn) { iFLpp_t fn = (iFLpp_t)fcn; R_RAX=(int32_t)fn((uintptr_t)R_RDI, (void*)R_RSI, (void*)R_RDX); } void iFpwp(x64emu_t *emu, uintptr_t fcn) { iFpwp_t fn = (iFpwp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int16_t)R_RSI, (void*)R_RDX); } void iFpii(x64emu_t *emu, uintptr_t fcn) { iFpii_t fn = (iFpii_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX); } @@ -4032,7 +4033,6 @@ void iFEpUp(x64emu_t *emu, uintptr_t fcn) { iFEpUp_t fn = (iFEpUp_t)fcn; R_RAX=( void iFEpLi(x64emu_t *emu, uintptr_t fcn) { iFEpLi_t fn = (iFEpLi_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX); } void iFEpLp(x64emu_t *emu, uintptr_t fcn) { iFEpLp_t fn = (iFEpLp_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (void*)R_RDX); } void iFEppi(x64emu_t *emu, uintptr_t fcn) { iFEppi_t fn = (iFEppi_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX); } -void iFEppu(x64emu_t *emu, uintptr_t fcn) { iFEppu_t fn = (iFEppu_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uint32_t)R_RDX); } void iFEppd(x64emu_t *emu, uintptr_t fcn) { iFEppd_t fn = (iFEppd_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, emu->xmm[0].d[0]); } void iFEppL(x64emu_t *emu, uintptr_t fcn) { iFEppL_t fn = (iFEppL_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX); } void iFEppp(x64emu_t *emu, uintptr_t fcn) { iFEppp_t fn = (iFEppp_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX); } @@ -4061,7 +4061,6 @@ void iFipip(x64emu_t *emu, uintptr_t fcn) { iFipip_t fn = (iFipip_t)fcn; R_RAX=( void iFipWp(x64emu_t *emu, uintptr_t fcn) { iFipWp_t fn = (iFipWp_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (void*)R_RSI, (uint16_t)R_RDX, (void*)R_RCX); } void iFipui(x64emu_t *emu, uintptr_t fcn) { iFipui_t fn = (iFipui_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (void*)R_RSI, (uint32_t)R_RDX, (int32_t)R_RCX); } void iFipuL(x64emu_t *emu, uintptr_t fcn) { iFipuL_t fn = (iFipuL_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (void*)R_RSI, (uint32_t)R_RDX, (uintptr_t)R_RCX); } -void iFipup(x64emu_t *emu, uintptr_t fcn) { iFipup_t fn = (iFipup_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (void*)R_RSI, (uint32_t)R_RDX, (void*)R_RCX); } void iFipLi(x64emu_t *emu, uintptr_t fcn) { iFipLi_t fn = (iFipLi_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (int32_t)R_RCX); } void iFipLu(x64emu_t *emu, uintptr_t fcn) { iFipLu_t fn = (iFipLu_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (uint32_t)R_RCX); } void iFipLp(x64emu_t *emu, uintptr_t fcn) { iFipLp_t fn = (iFipLp_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (void*)R_RCX); } @@ -4080,7 +4079,6 @@ void iFupLp(x64emu_t *emu, uintptr_t fcn) { iFupLp_t fn = (iFupLp_t)fcn; R_RAX=( void iFuppi(x64emu_t *emu, uintptr_t fcn) { iFuppi_t fn = (iFuppi_t)fcn; R_RAX=(int32_t)fn((uint32_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (int32_t)R_RCX); } void iFuppu(x64emu_t *emu, uintptr_t fcn) { iFuppu_t fn = (iFuppu_t)fcn; R_RAX=(int32_t)fn((uint32_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (uint32_t)R_RCX); } void iFuppp(x64emu_t *emu, uintptr_t fcn) { iFuppp_t fn = (iFuppp_t)fcn; R_RAX=(int32_t)fn((uint32_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX); } -void iFLLiW(x64emu_t *emu, uintptr_t fcn) { iFLLiW_t fn = (iFLLiW_t)fcn; R_RAX=(int32_t)fn((uintptr_t)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX, (uint16_t)R_RCX); } void iFLppp(x64emu_t *emu, uintptr_t fcn) { iFLppp_t fn = (iFLppp_t)fcn; R_RAX=(int32_t)fn((uintptr_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX); } void iFpwww(x64emu_t *emu, uintptr_t fcn) { iFpwww_t fn = (iFpwww_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int16_t)R_RSI, (int16_t)R_RDX, (int16_t)R_RCX); } void iFpwpp(x64emu_t *emu, uintptr_t fcn) { iFpwpp_t fn = (iFpwpp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int16_t)R_RSI, (void*)R_RDX, (void*)R_RCX); } @@ -4600,7 +4598,6 @@ void iFEpppA(x64emu_t *emu, uintptr_t fcn) { iFEpppA_t fn = (iFEpppA_t)fcn; R_RA void iFiiipu(x64emu_t *emu, uintptr_t fcn) { iFiiipu_t fn = (iFiiipu_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (uint32_t)R_R8); } void iFiiipp(x64emu_t *emu, uintptr_t fcn) { iFiiipp_t fn = (iFiiipp_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)R_R8); } void iFiiupp(x64emu_t *emu, uintptr_t fcn) { iFiiupp_t fn = (iFiiupp_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (int32_t)R_RSI, (uint32_t)R_RDX, (void*)R_RCX, (void*)R_R8); } -void iFiipup(x64emu_t *emu, uintptr_t fcn) { iFiipup_t fn = (iFiipup_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (uint32_t)R_RCX, (void*)R_R8); } void iFiuuuu(x64emu_t *emu, uintptr_t fcn) { iFiuuuu_t fn = (iFiuuuu_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX, (uint32_t)R_RCX, (uint32_t)R_R8); } void iFiuuup(x64emu_t *emu, uintptr_t fcn) { iFiuuup_t fn = (iFiuuup_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX, (uint32_t)R_RCX, (void*)R_R8); } void iFiuLip(x64emu_t *emu, uintptr_t fcn) { iFiuLip_t fn = (iFiuLip_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (uint32_t)R_RSI, (uintptr_t)R_RDX, (int32_t)R_RCX, (void*)R_R8); } @@ -5085,7 +5082,6 @@ void iFpipupp(x64emu_t *emu, uintptr_t fcn) { iFpipupp_t fn = (iFpipupp_t)fcn; R void iFpipLpp(x64emu_t *emu, uintptr_t fcn) { iFpipLpp_t fn = (iFpipLpp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX, (void*)R_R8, (void*)R_R9); } void iFpippip(x64emu_t *emu, uintptr_t fcn) { iFpippip_t fn = (iFpippip_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (int32_t)R_R8, (void*)R_R9); } void iFpippup(x64emu_t *emu, uintptr_t fcn) { iFpippup_t fn = (iFpippup_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (uint32_t)R_R8, (void*)R_R9); } -void iFpipppL(x64emu_t *emu, uintptr_t fcn) { iFpipppL_t fn = (iFpipppL_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (uintptr_t)R_R9); } void iFpipppp(x64emu_t *emu, uintptr_t fcn) { iFpipppp_t fn = (iFpipppp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9); } void iFpCiipp(x64emu_t *emu, uintptr_t fcn) { iFpCiipp_t fn = (iFpCiipp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (uint8_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (void*)R_R8, (void*)R_R9); } void iFpCpipu(x64emu_t *emu, uintptr_t fcn) { iFpCpipu_t fn = (iFpCpipu_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (uint8_t)R_RSI, (void*)R_RDX, (int32_t)R_RCX, (void*)R_R8, (uint32_t)R_R9); } @@ -6147,11 +6143,21 @@ void iFipiip(x64emu_t *emu, uintptr_t fcn) { iFipiip_t fn = (iFipiip_t)fcn; R_RA #endif #if !defined(NOALIGN) +void iFEppu(x64emu_t *emu, uintptr_t fcn) { iFEppu_t fn = (iFEppu_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uint32_t)R_RDX); } void iFEiiip(x64emu_t *emu, uintptr_t fcn) { iFEiiip_t fn = (iFEiiip_t)fcn; R_RAX=(int32_t)fn(emu, (int32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX); } void iFEipii(x64emu_t *emu, uintptr_t fcn) { iFEipii_t fn = (iFEipii_t)fcn; R_RAX=(int32_t)fn(emu, (int32_t)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX); } void iFEipiip(x64emu_t *emu, uintptr_t fcn) { iFEipiip_t fn = (iFEipiip_t)fcn; R_RAX=(int32_t)fn(emu, (int32_t)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (void*)R_R8); } #endif +#if !defined(STATICBUILD) +void iFlip(x64emu_t *emu, uintptr_t fcn) { iFlip_t fn = (iFlip_t)fcn; R_RAX=(int32_t)fn((intptr_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX); } +void iFLLi(x64emu_t *emu, uintptr_t fcn) { iFLLi_t fn = (iFLLi_t)fcn; R_RAX=(int32_t)fn((uintptr_t)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX); } +void iFipup(x64emu_t *emu, uintptr_t fcn) { iFipup_t fn = (iFipup_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (void*)R_RSI, (uint32_t)R_RDX, (void*)R_RCX); } +void iFLLiW(x64emu_t *emu, uintptr_t fcn) { iFLLiW_t fn = (iFLLiW_t)fcn; R_RAX=(int32_t)fn((uintptr_t)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX, (uint16_t)R_RCX); } +void iFiipup(x64emu_t *emu, uintptr_t fcn) { iFiipup_t fn = (iFiipup_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (uint32_t)R_RCX, (void*)R_R8); } +void iFpipppL(x64emu_t *emu, uintptr_t fcn) { iFpipppL_t fn = (iFpipppL_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (uintptr_t)R_R9); } +#endif + void vFEv(x64emu_t *emu, uintptr_t fcn) { vFE_t fn = (vFE_t)fcn; fn(emu); } void iFEv(x64emu_t *emu, uintptr_t fcn) { iFE_t fn = (iFE_t)fcn; R_RAX=(int32_t)fn(emu); } void lFEv(x64emu_t *emu, uintptr_t fcn) { lFE_t fn = (lFE_t)fcn; R_RAX=(intptr_t)fn(emu); } @@ -6568,9 +6574,7 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &iFupL) return 1; if (fun == &iFupp) return 1; if (fun == &iFfff) return 4; - if (fun == &iFlip) return 1; if (fun == &iFLip) return 1; - if (fun == &iFLLi) return 1; if (fun == &iFLpp) return 1; if (fun == &iFpwp) return 1; if (fun == &iFpii) return 1; @@ -6937,7 +6941,6 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &iFipWp) return 1; if (fun == &iFipui) return 1; if (fun == &iFipuL) return 1; - if (fun == &iFipup) return 1; if (fun == &iFipLi) return 1; if (fun == &iFipLu) return 1; if (fun == &iFipLp) return 1; @@ -6955,7 +6958,6 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &iFuppi) return 1; if (fun == &iFuppu) return 1; if (fun == &iFuppp) return 1; - if (fun == &iFLLiW) return 1; if (fun == &iFLppp) return 1; if (fun == &iFpwww) return 1; if (fun == &iFpwpp) return 1; @@ -7369,7 +7371,6 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &iFiiipu) return 1; if (fun == &iFiiipp) return 1; if (fun == &iFiiupp) return 1; - if (fun == &iFiipup) return 1; if (fun == &iFiuuuu) return 1; if (fun == &iFiuuup) return 1; if (fun == &iFiuLip) return 1; @@ -7779,7 +7780,6 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &iFpipLpp) return 1; if (fun == &iFpippip) return 1; if (fun == &iFpippup) return 1; - if (fun == &iFpipppL) return 1; if (fun == &iFpipppp) return 1; if (fun == &iFpCiipp) return 1; if (fun == &iFpCpipu) return 1; @@ -7983,6 +7983,14 @@ int isSimpleWrapper(wrapper_t fun) { #if defined(NOALIGN) if (fun == &iFipiip) return 1; #endif +#if !defined(STATICBUILD) + if (fun == &iFlip) return 1; + if (fun == &iFLLi) return 1; + if (fun == &iFipup) return 1; + if (fun == &iFLLiW) return 1; + if (fun == &iFiipup) return 1; + if (fun == &iFpipppL) return 1; +#endif return 0; } #elif defined(RV64) diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index e6cc6738..a6464e60 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -540,9 +540,7 @@ void iFupu(x64emu_t *emu, uintptr_t fnc); void iFupL(x64emu_t *emu, uintptr_t fnc); void iFupp(x64emu_t *emu, uintptr_t fnc); void iFfff(x64emu_t *emu, uintptr_t fnc); -void iFlip(x64emu_t *emu, uintptr_t fnc); void iFLip(x64emu_t *emu, uintptr_t fnc); -void iFLLi(x64emu_t *emu, uintptr_t fnc); void iFLpp(x64emu_t *emu, uintptr_t fnc); void iFpwp(x64emu_t *emu, uintptr_t fnc); void iFpii(x64emu_t *emu, uintptr_t fnc); @@ -974,7 +972,6 @@ void iFEpUp(x64emu_t *emu, uintptr_t fnc); void iFEpLi(x64emu_t *emu, uintptr_t fnc); void iFEpLp(x64emu_t *emu, uintptr_t fnc); void iFEppi(x64emu_t *emu, uintptr_t fnc); -void iFEppu(x64emu_t *emu, uintptr_t fnc); void iFEppd(x64emu_t *emu, uintptr_t fnc); void iFEppL(x64emu_t *emu, uintptr_t fnc); void iFEppp(x64emu_t *emu, uintptr_t fnc); @@ -1003,7 +1000,6 @@ void iFipip(x64emu_t *emu, uintptr_t fnc); void iFipWp(x64emu_t *emu, uintptr_t fnc); void iFipui(x64emu_t *emu, uintptr_t fnc); void iFipuL(x64emu_t *emu, uintptr_t fnc); -void iFipup(x64emu_t *emu, uintptr_t fnc); void iFipLi(x64emu_t *emu, uintptr_t fnc); void iFipLu(x64emu_t *emu, uintptr_t fnc); void iFipLp(x64emu_t *emu, uintptr_t fnc); @@ -1022,7 +1018,6 @@ void iFupLp(x64emu_t *emu, uintptr_t fnc); void iFuppi(x64emu_t *emu, uintptr_t fnc); void iFuppu(x64emu_t *emu, uintptr_t fnc); void iFuppp(x64emu_t *emu, uintptr_t fnc); -void iFLLiW(x64emu_t *emu, uintptr_t fnc); void iFLppp(x64emu_t *emu, uintptr_t fnc); void iFpwww(x64emu_t *emu, uintptr_t fnc); void iFpwpp(x64emu_t *emu, uintptr_t fnc); @@ -1542,7 +1537,6 @@ void iFEpppA(x64emu_t *emu, uintptr_t fnc); void iFiiipu(x64emu_t *emu, uintptr_t fnc); void iFiiipp(x64emu_t *emu, uintptr_t fnc); void iFiiupp(x64emu_t *emu, uintptr_t fnc); -void iFiipup(x64emu_t *emu, uintptr_t fnc); void iFiuuuu(x64emu_t *emu, uintptr_t fnc); void iFiuuup(x64emu_t *emu, uintptr_t fnc); void iFiuLip(x64emu_t *emu, uintptr_t fnc); @@ -2027,7 +2021,6 @@ void iFpipupp(x64emu_t *emu, uintptr_t fnc); void iFpipLpp(x64emu_t *emu, uintptr_t fnc); void iFpippip(x64emu_t *emu, uintptr_t fnc); void iFpippup(x64emu_t *emu, uintptr_t fnc); -void iFpipppL(x64emu_t *emu, uintptr_t fnc); void iFpipppp(x64emu_t *emu, uintptr_t fnc); void iFpCiipp(x64emu_t *emu, uintptr_t fnc); void iFpCpipu(x64emu_t *emu, uintptr_t fnc); @@ -3089,11 +3082,21 @@ void iFipiip(x64emu_t *emu, uintptr_t fnc); #endif #if !defined(NOALIGN) +void iFEppu(x64emu_t *emu, uintptr_t fnc); void iFEiiip(x64emu_t *emu, uintptr_t fnc); void iFEipii(x64emu_t *emu, uintptr_t fnc); void iFEipiip(x64emu_t *emu, uintptr_t fnc); #endif +#if !defined(STATICBUILD) +void iFlip(x64emu_t *emu, uintptr_t fnc); +void iFLLi(x64emu_t *emu, uintptr_t fnc); +void iFipup(x64emu_t *emu, uintptr_t fnc); +void iFLLiW(x64emu_t *emu, uintptr_t fnc); +void iFiipup(x64emu_t *emu, uintptr_t fnc); +void iFpipppL(x64emu_t *emu, uintptr_t fnc); +#endif + void vFEv(x64emu_t *emu, uintptr_t fnc); void iFEv(x64emu_t *emu, uintptr_t fnc); void lFEv(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped/wrappedldlinux.c b/src/wrapped/wrappedldlinux.c index 83245e93..90ec1b23 100644 --- a/src/wrapped/wrappedldlinux.c +++ b/src/wrapped/wrappedldlinux.c @@ -34,14 +34,25 @@ void stSetup(box64context_t* context) my___libc_stack_end = context->stack; // is this the end, or should I add stasz? } +#ifdef STATICBUILD +#include <link.h> +extern void* __libc_enable_secure; +extern void* __stack_chk_guard; +//extern void* __pointer_chk_guard; +//extern void* _rtld_global; +//extern void* _rtld_global_ro; +#endif + // don't try to load the actual ld-linux (because name is variable), just use box64 itself, as it's linked to ld-linux const char* ldlinuxName = "ld-linux.so.2"; #define LIBNAME ldlinux +#ifndef STATICBUILD #define PRE_INIT\ if(1) \ lib->w.lib = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL); \ else +#endif #define CUSTOM_INIT \ stSetup(box64); \ diff --git a/src/wrapped/wrappedldlinux_private.h b/src/wrapped/wrappedldlinux_private.h index 9bdcccb1..4bde24e1 100644 --- a/src/wrapped/wrappedldlinux_private.h +++ b/src/wrapped/wrappedldlinux_private.h @@ -15,9 +15,15 @@ // _dl_tls_setup DATA(__libc_enable_secure, sizeof(void*)) DATAM(__libc_stack_end, sizeof(void*)) -DATA(__pointer_chk_guard, sizeof(void*)) DATAB(_r_debug, 40) +#ifdef STATICBUILD +//DATA(__pointer_chk_guard, sizeof(void*)) +//DATA(_rtld_global, sizeof(void*)) +//DATA(_rtld_global_ro, sizeof(void*)) +#else +DATA(__pointer_chk_guard, sizeof(void*)) DATA(_rtld_global, sizeof(void*)) DATA(_rtld_global_ro, sizeof(void*)) +#endif DATA(__stack_chk_guard, sizeof(void*)) GOM(__tls_get_addr, pFp) //%NoE diff --git a/src/wrapped/wrappedlib_init.h b/src/wrapped/wrappedlib_init.h index 44af7c90..3505efd3 100644 --- a/src/wrapped/wrappedlib_init.h +++ b/src/wrapped/wrappedlib_init.h @@ -43,36 +43,54 @@ // #define the 4 maps first #undef GO -#define GO(N, W) {#N, W, 0}, #undef GOW +#ifdef STATICBUILD +#define GO(N, W) {#N, W, 0, &N}, +#define GOW(N, W) {#N, W, 1, &N}, +#else +#define GO(N, W) {#N, W, 0}, #define GOW(N, W) {#N, W, 1}, +#endif static const map_onesymbol_t MAPNAME(symbolmap)[] = { #include PRIVATE(LIBNAME) }; #undef GO -#define GO(N, W) #undef GOW -#define GOW(N, W) #undef GOM -#define GOM(N, W) {#N, W, 0}, #undef GOWM +#define GO(N, W) +#define GOW(N, W) +#ifdef STATICBUILD +#define GOM(N, W) {#N, W, 0, &my_##N}, +#define GOWM(N, W) {#N, W, 1, &my_##N}, +#else +#define GOM(N, W) {#N, W, 0}, #define GOWM(N, W) {#N, W, 1}, +#endif static const map_onesymbol_t MAPNAME(mysymbolmap)[] = { #include PRIVATE(LIBNAME) }; #undef GOM -#define GOM(N, W) #undef GOWM -#define GOWM(N, W) #undef GOS +#define GOM(N, W) +#define GOWM(N, W) +#ifdef STATICBUILD +#define GOS(N, W) {#N, W, 0, &my_##N}, +#else #define GOS(N, W) {#N, W, 0}, +#endif static const map_onesymbol_t MAPNAME(stsymbolmap)[] = { #include PRIVATE(LIBNAME) }; #undef GOS -#define GOS(N, W) #undef GO2 +#define GOS(N, W) +#ifdef STATICBUILD +#define GO2(N, W, O) {#N, W, 0, #O, &O}, +#else #define GO2(N, W, O) {#N, W, 0, #O}, +#endif static const map_onesymbol2_t MAPNAME(symbol2map)[] = { #include PRIVATE(LIBNAME) }; @@ -81,9 +99,15 @@ static const map_onesymbol2_t MAPNAME(symbol2map)[] = { #undef DATA #undef DATAV #undef DATAB +#ifdef STATICBUILD +#define DATA(N, S) {#N, S, 0, (void*)&N}, +#define DATAV(N, S) {#N, S, 1, (void*)&N}, +#define DATAB(N, S) {#N, S, 0, (void*)&N}, +#else #define DATA(N, S) {#N, S, 0}, #define DATAV(N, S) {#N, S, 1}, #define DATAB(N, S) {#N, S, 0}, +#endif static const map_onedata_t MAPNAME(datamap)[] = { #include PRIVATE(LIBNAME) }; @@ -94,7 +118,11 @@ static const map_onedata_t MAPNAME(datamap)[] = { #define DATAV(N, S) #define DATAB(N, S) #undef DATAM +#ifdef STATICBUILD +#define DATAM(N, S) {#N, S, 0, &my_##N}, +#else #define DATAM(N, S) {#N, S, 0}, +#endif static const map_onedata_t MAPNAME(mydatamap)[] = { #include PRIVATE(LIBNAME) }; @@ -136,6 +164,7 @@ int FUNC(_init)(library_t* lib, box64context_t* box64) PRE_INIT #endif { +#ifndef STATICBUILD lib->w.lib = dlopen(MAPNAME(Name), RTLD_LAZY | RTLD_GLOBAL); if(!lib->w.lib) { #ifdef ALTNAME @@ -154,6 +183,9 @@ int FUNC(_init)(library_t* lib, box64context_t* box64) } else lib->path = box_strdup(ALTNAME); #endif } else lib->path = box_strdup(MAPNAME(Name)); +#else + lib->path = box_strdup(MAPNAME(Name)); +#endif } WrappedLib_CommonInit(lib); @@ -162,6 +194,25 @@ int FUNC(_init)(library_t* lib, box64context_t* box64) int cnt; // populates maps... +#ifdef STATICBUILD +#define DOIT(mapname) \ + cnt = sizeof(MAPNAME(mapname))/sizeof(map_onesymbol_t); \ + for (int i = 0; i < cnt; ++i) { \ + if (MAPNAME(mapname)[i].weak) { \ + k = kh_put(symbolmap, lib->w.w##mapname, MAPNAME(mapname)[i].name, &ret); \ + kh_value(lib->w.w##mapname, k).w = MAPNAME(mapname)[i].w; \ + kh_value(lib->w.w##mapname, k).resolved = 0; \ + kh_value(lib->w.w##mapname, k).addr = (uintptr_t)MAPNAME(mapname)[i].addr; \ + } else { \ + k = kh_put(symbolmap, lib->w.mapname, MAPNAME(mapname)[i].name, &ret); \ + kh_value(lib->w.mapname, k).w = MAPNAME(mapname)[i].w; \ + kh_value(lib->w.mapname, k).resolved = 0; \ + kh_value(lib->w.mapname, k).addr = (uintptr_t)MAPNAME(mapname)[i].addr; \ + } \ + if (strchr(MAPNAME(mapname)[i].name, '@')) \ + AddDictionnary(box64->versym, MAPNAME(mapname)[i].name); \ + } +#else #define DOIT(mapname) \ cnt = sizeof(MAPNAME(mapname))/sizeof(map_onesymbol_t); \ for (int i = 0; i < cnt; ++i) { \ @@ -177,6 +228,7 @@ int FUNC(_init)(library_t* lib, box64context_t* box64) if (strchr(MAPNAME(mapname)[i].name, '@')) \ AddDictionnary(box64->versym, MAPNAME(mapname)[i].name); \ } +#endif DOIT(symbolmap) DOIT(mysymbolmap) #undef DOIT @@ -184,7 +236,12 @@ int FUNC(_init)(library_t* lib, box64context_t* box64) for (int i=0; i<cnt; ++i) { k = kh_put(symbolmap, lib->w.stsymbolmap, MAPNAME(stsymbolmap)[i].name, &ret); kh_value(lib->w.stsymbolmap, k).w = MAPNAME(stsymbolmap)[i].w; + #ifdef STATICBUILD + kh_value(lib->w.stsymbolmap, k).resolved = 1; + kh_value(lib->w.stsymbolmap, k).addr = (uintptr_t)MAPNAME(stsymbolmap)[i].addr; + #else kh_value(lib->w.stsymbolmap, k).resolved = 0; + #endif if(strchr(MAPNAME(stsymbolmap)[i].name, '@')) AddDictionnary(box64->versym, MAPNAME(stsymbolmap)[i].name); } @@ -194,7 +251,12 @@ int FUNC(_init)(library_t* lib, box64context_t* box64) kh_value(lib->w.symbol2map, k).name = MAPNAME(symbol2map)[i].name2; kh_value(lib->w.symbol2map, k).w = MAPNAME(symbol2map)[i].w; kh_value(lib->w.symbol2map, k).weak = MAPNAME(symbol2map)[i].weak; + #ifdef STATICBUILD + kh_value(lib->w.symbol2map, k).resolved = 1; + kh_value(lib->w.symbol2map, k).addr = (uintptr_t)MAPNAME(symbol2map)[i].addr; + #else kh_value(lib->w.symbol2map, k).resolved = 0; + #endif if(strchr(MAPNAME(symbol2map)[i].name, '@')) AddDictionnary(box64->versym, MAPNAME(symbol2map)[i].name); } @@ -202,16 +264,31 @@ int FUNC(_init)(library_t* lib, box64context_t* box64) for (int i=0; i<cnt; ++i) { if(MAPNAME(datamap)[i].weak) { k = kh_put(datamap, lib->w.wdatamap, MAPNAME(datamap)[i].name, &ret); + #ifdef STATICBUILD + kh_value(lib->w.wdatamap, k).size = MAPNAME(datamap)[i].sz; + kh_value(lib->w.wdatamap, k).addr = (uintptr_t)MAPNAME(datamap)[i].addr; + #else kh_value(lib->w.wdatamap, k) = MAPNAME(datamap)[i].sz; + #endif } else { k = kh_put(datamap, lib->w.datamap, MAPNAME(datamap)[i].name, &ret); + #ifdef STATICBUILD + kh_value(lib->w.datamap, k).size = MAPNAME(datamap)[i].sz; + kh_value(lib->w.datamap, k).addr = (uintptr_t)MAPNAME(datamap)[i].addr; + #else kh_value(lib->w.datamap, k) = MAPNAME(datamap)[i].sz; + #endif } } cnt = sizeof(MAPNAME(mydatamap))/sizeof(map_onedata_t); for (int i=0; i<cnt; ++i) { k = kh_put(datamap, lib->w.mydatamap, MAPNAME(mydatamap)[i].name, &ret); + #ifdef STATICBUILD + kh_value(lib->w.mydatamap, k).size = MAPNAME(mydatamap)[i].sz; + kh_value(lib->w.mydatamap, k).addr = (uintptr_t)MAPNAME(mydatamap)[i].addr; + #else kh_value(lib->w.mydatamap, k) = MAPNAME(mydatamap)[i].sz; + #endif } #ifdef ALTMY SETALT(ALTMY); diff --git a/src/wrapped/wrappedlibbsd.c b/src/wrapped/wrappedlibbsd.c index 8937ed9d..231e74ce 100644 --- a/src/wrapped/wrappedlibbsd.c +++ b/src/wrapped/wrappedlibbsd.c @@ -24,10 +24,19 @@ const char* libbsdName = "libbsd.so.0"; #endif #define LIBNAME libbsd +#ifdef STATICBUILD +void arc4random_addrandom(unsigned char *dat, int datlen); +void arc4random_stir(void); +const char *getprogname(void); +void setprogname(const char *); +#endif + +#ifndef STATICBUILD #define PRE_INIT\ if(1) \ lib->w.lib = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL); \ else +#endif // define all standard library functions #include "wrappedlib_init.h" diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 6629585f..889ae59b 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -911,7 +911,7 @@ EXPORT int my_vsscanf(x64emu_t* emu, void* stream, void* fmt, x64_va_list_t b) return vsscanf(stream, fmt, VARARGS); } -EXPORT int my__vsscanf(x64emu_t* emu, void* stream, void* fmt, void* b) __attribute__((alias("my_vsscanf"))); +EXPORT int my___vsscanf(x64emu_t* emu, void* stream, void* fmt, void* b) __attribute__((alias("my_vsscanf"))); EXPORT int my_vswscanf(x64emu_t* emu, void* stream, void* fmt, x64_va_list_t b) { @@ -2818,6 +2818,11 @@ EXPORT void* my_mallinfo(x64emu_t* emu, void* p) return p; } +#ifdef STATICBUILD +void my_updateGlobalOpt() {} +void my_checkGlobalOpt() {} +#endif + EXPORT int my_getopt(int argc, char* const argv[], const char *optstring) { my_updateGlobalOpt(); @@ -3475,10 +3480,16 @@ EXPORT char* my_program_invocation_short_name = NULL; // ignoring this for now EXPORT char my___libc_single_threaded = 0; +#ifdef STATICBUILD +#include "libtools/static_libc.h" +#endif + +#ifndef STATICBUILD #define PRE_INIT\ if(1) \ lib->w.lib = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL); \ else +#endif #ifdef ANDROID #define NEEDED_LIBS_DEF 1,\ diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index c0ebefd1..c38718cc 100644 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -124,6 +124,21 @@ GO(chroot, iFp) GOW(clearenv, iFv) GO(clearerr, vFp) GO(clearerr_unlocked, vFp) +#ifdef STATICBUILD +//GO(clnt_broadcast, +//GO(clnt_create, !FpLLp) +//GO(clnt_pcreateerror, vFp) +//GO(clnt_perrno, vFu) +//GO(clnt_perror, vF!p) +//GO(clntraw_create, !FLL) +//GO(clnt_spcreateerror, pFp) +//GO(clnt_sperrno, pFu) +//GO(clnt_sperror, pF!p) +//GO(clnttcp_create, !F!LLpuu) +//GO(clntudp_bufcreate, !F!LL?puu) +//GO(clntudp_create, !F!LL?p) +//GO(clntunix_create, !F!LLpuu) +#else //GO(clnt_broadcast, //GO(clnt_create, !FpLLp) GO(clnt_pcreateerror, vFp) @@ -137,6 +152,7 @@ GO(clnt_sperrno, pFu) //GO(clntudp_bufcreate, !F!LL?puu) //GO(clntudp_create, !F!LL?p) //GO(clntunix_create, !F!LLpuu) +#endif GO(clock, lFv) GO(clock_adjtime, iFip) //GO(__clock_getcpuclockid, @@ -176,7 +192,11 @@ GO(ctime_r, pFpp) //DATA(__ctype32_b, //DATA(__ctype32_tolower, //DATA(__ctype32_toupper, +#ifdef STATICBUILD +//DATA(__ctype_b, sizeof(void*)) +#else DATA(__ctype_b, sizeof(void*)) +#endif GO(__ctype_b_loc, pFv) GO(__ctype_get_mb_cur_max, LFv) //GO(__ctype_init, @@ -565,7 +585,11 @@ GO(getnameinfo, iFpupupui) //GO(getnetent_r, iF!pL!p) GO(getnetgrent, iFppp) GOW(getnetgrent_r, iFppppL) +#ifdef STATICBUILD +//GO(getnetname, iFp) +#else GO(getnetname, iFp) +#endif GOW(get_nprocs, iFv) GOW(get_nprocs_conf, iFv) GOM(getopt, iFipp) @@ -579,7 +603,7 @@ GO(__getpgid, iFi) GOW(getpgid, iFi) GO(getpgrp, iFv) GOW(get_phys_pages, lFv) -GO(__getpid, uFv) +GO(__getpid, iFv) GO(getpid, iFv) //GO(getpmsg, // Deprecated GOW(getppid, iFv) @@ -591,7 +615,11 @@ GO(getprotobynumber_r, iFippLp) GO(getprotoent, pFv) GO(getprotoent_r, iFppLp) GOW(getpt, iFv) +#ifdef STATICBUILD +//GO(getpublickey, iFpp) +#else GO(getpublickey, iFpp) +#endif GOW(getpw, iFup) GO(getpwent, pFv) GO(getpwent_r, iFppLp) @@ -611,11 +639,19 @@ GO(getrpcbynumber, pFi) GO(getrpcbynumber_r, iFippLp) GO(getrpcent, pFv) GO(getrpcent_r, iFppLp) +#ifdef STATICBUILD +//GO(getrpcport, +#else GO(getrpcport, iFpLLu) +#endif GOW(getrusage, iFip) //GOW(gets, // Deprecated //GO(__gets_chk, +#ifdef STATICBUILD +//GO(getsecretkey, +#else GO(getsecretkey, iFppp) +#endif GO(getservbyname, pFpp) GO(getservbyname_r, iFppppLp) GO(getservbyport, pFip) @@ -688,7 +724,11 @@ GOW(hdestroy, vFv) //DATAB(__h_errno, GO(__h_errno_location, pFv) GO(herror, vFp) +#ifdef STATICBUILD +//GO(host2netname, +#else GO(host2netname, iFppp) +#endif //GO(hsearch, pF?u) //GOW(hsearch_r, iF?up!) GO(hstrerror, pFi) @@ -832,7 +872,11 @@ DATA(_IO_list_all, sizeof(void*)) //GO(_IO_marker_difference, //GO(_IO_padn, //GO(_IO_peekc_locked, +#ifdef STATICBUILD +//GO(ioperm, +#else GO(ioperm, iFLLi) +#endif GOM(iopl, iFEi) //Not always present //GO(_IO_popen, //GO(_IO_printf, @@ -1013,9 +1057,15 @@ GOW(jrand48_r, iFppp) //GO(key_gendes, iF!) //DATAB(__key_gendes_LOCAL, //GO(key_get_conv, iFp!) +#ifdef STATICBUILD +//GO(key_secretkey_is_set, +//GO(key_setnet, +//GO(key_setsecret, +#else GO(key_secretkey_is_set, iFv) //GO(key_setnet, GO(key_setsecret, iFp) +#endif GOW(kill, iFii) GO(killpg, iFii) GO(klogctl, iFipi) @@ -1233,8 +1283,13 @@ GO(__nanosleep, iFpp) GOW(nanosleep, iFpp) //GO(__nanosleep_nocancel, //GO(__netlink_assert_response, +#ifdef STATICBUILD +//GO(netname2host, iFppi) +//GO(netname2user, iFppppp) +#else GO(netname2host, iFppi) GO(netname2user, iFppppp) +#endif GO(__newlocale, pFipp) GOW(newlocale, pFipp) //GO(nfsservctl, // Deprecated @@ -1333,8 +1388,13 @@ GO(pkey_set, iFiu) //GO(pmap_getmaps, pF!) //GO(pmap_getport, WF!LLu) //GO(pmap_rmtcall, uF!LLL@p@p?p) +#ifdef STATICBUILD +//GO(pmap_set, iFLLiW) +//GO(pmap_unset, iFLL) +#else GO(pmap_set, iFLLiW) GO(pmap_unset, iFLL) +#endif GO(__poll, iFpLi) GO(poll, iFpLi) GO(__poll_chk, iFpuiL) @@ -1398,131 +1458,13 @@ DATA(__progname_full, sizeof(void)) GOW(pselect, iFippppp) GO(psiginfo, vFpp) GO(psignal, vFip) +#ifdef STATICBUILD +//GO(__sF, vFip) +//GO(__assert2, vFip) +#else GO(__sF, vFip) GO(__assert2, vFip) - -GOM(pthread_atfork, iFEppp) -GOM(pthread_attr_destroy, iFEp) -GOM(pthread_attr_getdetachstate, iFEpp) -GOM(pthread_attr_getguardsize, iFEpp) -GOM(pthread_attr_getinheritsched, iFEpp) -GOM(pthread_attr_getschedparam, iFEpp) -GOM(pthread_attr_getschedpolicy, iFEpp) -GOM(pthread_attr_getscope, iFEpp) -GOM(pthread_attr_getstack, iFEppp) -GOM(pthread_attr_getstackaddr, iFEpp) -GOM(pthread_attr_getstacksize, iFEpp) -GOM(pthread_attr_init, iFEp) -GOM(pthread_attr_setaffinity_np, iFEpLp) -GOM(pthread_attr_setdetachstate, iFEpi) -GOM(pthread_attr_setguardsize, iFEpL) -GOM(pthread_attr_setinheritsched, iFEpi) -GOM(pthread_attr_setschedparam, iFEpp) -GOM(pthread_attr_setschedpolicy, iFEpi) -GOM(pthread_attr_setscope, iFEpi) -GOM(pthread_attr_setstackaddr, iFEpp) -GOM(pthread_attr_setstack, iFEppL) -GOM(pthread_attr_setstacksize, iFEpL) -GOM(pthread_barrierattr_destroy, iFEp) -GOM(pthread_barrierattr_getpshared, iFEpp) -GOM(pthread_barrierattr_init, iFEp) -GOM(pthread_barrierattr_setpshared, iFEpi) -GO(pthread_barrier_destroy, iFp) -GOM(pthread_barrier_init, iFEppu) -GO(pthread_barrier_wait, iFp) -GO(pthread_cancel, iFL) -GOM(pthread_condattr_destroy, iFEp) -GOM(pthread_condattr_getclock, iFEpp) -GOM(pthread_condattr_getpshared, iFEpp) -GOM(pthread_condattr_init, iFEp) -GOM(pthread_condattr_setclock, iFEpi) -GOM(pthread_condattr_setpshared, iFEpi) -GOM(pthread_cond_broadcast, iFEp) -GOM(pthread_cond_destroy, iFEp) -GOM(pthread_cond_init, iFEpp) -GO(pthread_cond_signal, iFp) -GOM(pthread_cond_timedwait, iFEppp) -GOM(pthread_cond_wait, iFEpp) -GOM(pthread_create, iFEpppp) -GOM(pthread_cond_clockwait, iFEppip) -GO(pthread_detach, iFL) -GO(pthread_equal, iFLL) -GO(pthread_exit, vFp) -GOM(pthread_getaffinity_np, iFEpLp) -GOM(pthread_getattr_np, iFELp) -GOM(pthread_getattr_default_np, iFEp) -GOM(pthread_setattr_default_np, iFEp) -GO(pthread_getcpuclockid, iFLp) -GO(pthread_getschedparam, iFLpp) -GO(pthread_getspecific, pFL) -GO(pthread_getname_np, iFppL) -GO(pthread_join, iFLp) -GOM(pthread_key_create, iFEpp) -GO(pthread_key_delete, iFL) -GO2(pthread_kill@GLIBC_2.2.5, iFEpi, my_pthread_kill_old) -GOM(pthread_kill, iFEpi) -GO(pthread_kill_other_threads_np, vFv) -GOM(pthread_mutexattr_destroy, iFEp) -GOM(pthread_mutexattr_getkind_np, iFEpp) -GOM(pthread_mutexattr_getprotocol, iFEpp) -GOM(pthread_mutexattr_getrobust, iFEpp) -GOM(pthread_mutexattr_gettype, iFEpp) -GOM(pthread_mutexattr_init, iFEp) -GOM(pthread_mutexattr_setkind_np, iFEpi) -GOM(pthread_mutexattr_setprotocol, iFEpi) -GOM(pthread_mutexattr_setpshared, iFEpi) -GOM(pthread_mutexattr_setrobust, iFEpi) -GOM(pthread_mutexattr_settype, iFEpi) -GO(pthread_mutex_consistent, iFp) -GO(pthread_mutex_destroy, iFp) -// phtread_mutex_t is 40 bytes on x86_64, but 48bytes on ARM64 -GOM(pthread_mutex_init, iFpp) -GO(pthread_mutex_lock, iFp) -GO(pthread_mutex_timedlock, iFpp) -GO(pthread_mutex_trylock, iFp) -GO(pthread_mutex_unlock, iFp) -GOM(pthread_once, iFEpp) -GO(pthread_rwlockattr_destroy, vFp) -GO(pthread_rwlockattr_getkind_np, iFpp) -GO(pthread_rwlockattr_init, iFp) -GO(pthread_rwlockattr_setkind_np, iFpi) -GO(pthread_rwlock_destroy, iFp) -GO(pthread_rwlock_init, iFpp) -GO(pthread_rwlock_rdlock, iFp) -GO(pthread_rwlock_tryrdlock, iFp) -GO(pthread_rwlock_trywrlock, iFp) -GO(pthread_rwlock_unlock, iFp) -GO(pthread_rwlock_wrlock, iFp) -GO(pthread_self, LFv) -GOM(pthread_setaffinity_np, iFEpLp) -GO(pthread_setcancelstate, iFip) -GO(pthread_setcanceltype, iFip) -GO(pthread_setconcurrency, iFi) -GO(pthread_setname_np, iFpp) -GO(pthread_setschedparam, iFLip) -GO(pthread_setschedprio, iFpi) -GO(pthread_setspecific, iFLp) -GO(pthread_sigmask, iFipp) -GO(pthread_spin_destroy, iFp) -GO(pthread_spin_init, iFpi) -GO(pthread_spin_lock, iFp) -GO(pthread_spin_trylock, iFp) -GO(pthread_spin_unlock, iFp) -GO(pthread_testcancel, vFv) -GO(pthread_timedjoin_np, iFppp) -GO(pthread_tryjoin_np, iFpp) -GO(pthread_yield, iFv) -GO(sem_close, iFp) -GO(sem_clockwait, iFppp) -GO(sem_destroy, iFp) -GO(sem_getvalue, iFpp) -GO(sem_init, iFpiu) -GO(sem_open, pFpOM) -GO(sem_post, iFp) -GO(sem_timedwait, iFpp) -GO(sem_trywait, iFp) -GO(sem_unlink, iFp) -GO(sem_wait, iFp) +#endif GOM(ptrace, lFEuipp) GO(ptsname, pFi) @@ -1651,12 +1593,21 @@ GO(rexec_af, iFpippppW) //DATAB(rexecoptions, GO(rindex, pFpi) GOW(rmdir, iFp) +#ifdef STATICBUILD +//DATAB(rpc_createerr, +//GO(_rpc_dtablesize, iFv) +//GO(__rpc_thread_createerr, !Fv) +//GO(__rpc_thread_svc_fdset, !Fv) +//GO(__rpc_thread_svc_max_pollfd, pFv) +//GO(__rpc_thread_svc_pollfd, pFv) +#else //DATAB(rpc_createerr, GO(_rpc_dtablesize, iFv) //GO(__rpc_thread_createerr, !Fv) //GO(__rpc_thread_svc_fdset, !Fv) GO(__rpc_thread_svc_max_pollfd, pFv) GO(__rpc_thread_svc_pollfd, pFv) +#endif GO(rpmatch, iFp) GO(rresvport, iFp) GO(rresvport_af, iFpW) @@ -1995,6 +1946,36 @@ GO(strxfrm, LFppL) GO(__strxfrm_l, LFppLL) GO(strxfrm_l, LFppLp) //GO(stty, // Deprecated +#ifdef STATICBUILD +//DATAB(svcauthdes_stats, +//GO(svcerr_auth, vF!u) +//GO(svcerr_decode, vF!) +//GO(svcerr_noproc, vF!) +//GO(svcerr_noprog, vF!) +//GO(svcerr_progvers, vF!LL) +//GO(svcerr_systemerr, vF!) +//GO(svcerr_weakauth, vF!) +//GO(svc_exit, vFv) +//GO(svcfd_create, !Fiuu) +//DATAB(svc_fdset, +//GO(svc_getreq, vFi) +//GO(svc_getreq_common, vFi) +//GO(svc_getreq_poll, vFpi) +//GO(svc_getreqset, vF!) +//DATAB(svc_max_pollfd, +//DATAB(svc_pollfd, +//GO(svcraw_create, !Fv) +//GO(svc_register, iF!LL@L) +//GO(svc_run, vFv) +//GO(svc_sendreply, iF!@p) +//GO(svctcp_create, !Fiuu) +//GO(svcudp_bufcreate, !Fiuu) +//GO(svcudp_create, !Fi) +//GO(svcudp_enablecache, +//GO(svcunix_create, !Fiuup) +//GO(svcunixfd_create, +//GO(svc_unregister, vFLL) +#else //DATAB(svcauthdes_stats, //GO(svcerr_auth, vF!u) //GO(svcerr_decode, vF!) @@ -2023,6 +2004,7 @@ GO(svc_run, vFv) //GO(svcunix_create, !Fiuup) //GO(svcunixfd_create, GO(svc_unregister, vFLL) +#endif GO(swab, vFppl) GOWM(swapcontext, iFEpp) //GOW(swapoff, @@ -2038,10 +2020,20 @@ GO(syncfs, iFi) GOM(syscall, lFEv) GOM(__sysconf, lFEi) GOM(sysconf, IFEi) +#ifdef STATICBUILD +//GO(__sysctl, +//GO(sysctl, +#else GO(__sysctl, iFpipppL) GOW(sysctl, iFpipppL) // Deprecated +#endif +#ifdef STATICBUILD +//DATA(_sys_errlist, sizeof(void*)) +//DATA(sys_errlist, sizeof(void*)) +#else DATA(_sys_errlist, sizeof(void*)) DATA(sys_errlist, sizeof(void*)) +#endif GOW(sysinfo, iFp) GOM(syslog, vFEipV) GOM(__syslog_chk, vFEiipV) @@ -2145,7 +2137,11 @@ GO(updwtmpx, vFpp) //GO(uselib, // Deprecated GO(__uselocale, pFp) GOW(uselocale, pFp) +#ifdef STATICBUILD +//GO(user2netname, +#else GO(user2netname, iFpup) +#endif GO(usleep, iFu) //GO(ustat, // Deprecated GO(utime, iFpp) @@ -2397,11 +2393,21 @@ GOW(writev, lFipi) //GO(xdr_u_quad_t, iF!p) //GO(xdr_u_short, iF!p) //GO(xdr_vector, iF!puu@) +#ifdef STATICBUILD +//GO(xdr_void, +//GO(xdr_wrapstring, iF!p) +#else GO(xdr_void, iFv) //GO(xdr_wrapstring, iF!p) +#endif //GO(xencrypt, +#ifdef STATICBUILD +//GO(__xmknod, iFipup) +//GO(__xmknodat, iFiipup) +#else GO(__xmknod, iFipup) GO(__xmknodat, iFiipup) +#endif GO(__xpg_basename, pFp) GOW(__xpg_sigpause, iFi) GO(__xpg_strerror_r, pFipL) @@ -2429,7 +2435,11 @@ DATAM(program_invocation_short_name, sizeof(void*)) DATAM(__libc_single_threaded, 1) +#ifdef STATICBUILD +//GO(iconvctl, +#else GO(iconvctl, iFlip) +#endif GO(dummy__ZnwmSt11align_val_tRKSt9nothrow_t, pFLLp) // for mallochook.c #ifdef ANDROID @@ -2440,3 +2450,11 @@ GO(__errno, pFv) //GOM(__libc_init, //GO(__errno, #endif +#ifdef STATICBUILD +GO(dummy_pFLp, pFLp) +GO(dummy_pFpLLp, pFpLLp) +#else +// not needed in no-static build +//GO(dummy_pFLp, pFLp) +//GO(dummy_pFpLLp, pFpLLp) +#endif diff --git a/src/wrapped/wrappedlibcmusl.c b/src/wrapped/wrappedlibcmusl.c index 213fecd1..8294b7ce 100644 --- a/src/wrapped/wrappedlibcmusl.c +++ b/src/wrapped/wrappedlibcmusl.c @@ -21,10 +21,12 @@ const char* libcmuslName = "libc.musl-x86_64.so.1"; #define LIBNAME libcmusl +#ifndef STATICBUILD #define PRE_INIT\ if(1) \ lib->w.lib = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL); \ else +#endif #define CUSTOM_INIT \ box64_musl = 1; diff --git a/src/wrapped/wrappedlibdl.c b/src/wrapped/wrappedlibdl.c index b781b9cb..98d81034 100644 --- a/src/wrapped/wrappedlibdl.c +++ b/src/wrapped/wrappedlibdl.c @@ -611,6 +611,10 @@ void closeAllDLOpenned() } } +#ifdef STATICBUILD +//extern void* _dlfcn_hook; +#endif + #define CUSTOM_FINI \ closeAllDLOpenned(); diff --git a/src/wrapped/wrappedlibdl_private.h b/src/wrapped/wrappedlibdl_private.h index f547ffb9..c2106250 100644 --- a/src/wrapped/wrappedlibdl_private.h +++ b/src/wrapped/wrappedlibdl_private.h @@ -4,7 +4,11 @@ GOM(dladdr, iFEpp) GOM(dladdr1, iFEpppi) GOM(dlclose, iFEp) GOM(dlerror, pFEv) -DATAB(_dlfcn_hook, 8) +#ifdef STATICBUILD +//DATAB(_dlfcn_hook, sizeof(void*)) +#else +DATAB(_dlfcn_hook, sizeof(void*)) +#endif GOM(dlinfo, iFEpip) GOM(dlmopen, pFEppi) GOM(dlopen, pFEpi) diff --git a/src/wrapped/wrappedlibm.c b/src/wrapped/wrappedlibm.c index 670ce370..797d8bd3 100644 --- a/src/wrapped/wrappedlibm.c +++ b/src/wrapped/wrappedlibm.c @@ -1,7 +1,7 @@ +#define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> -#define _GNU_SOURCE /* See feature_test_macros(7) */ #include <dlfcn.h> #include <complex.h> #include <math.h> @@ -193,6 +193,14 @@ EXPORT double my_llrintl(x64emu_t* emu, double val) } #endif +double my_pow10(double a) { return exp10(a);} +float my_pow10f(float a) { return exp10f(a);} +long double my_pow10l(long double a) { return exp10l(a);} + +#ifdef STATICBUILD +//extern void* _LIB_VERSION; +#endif + #undef FROUND #undef TO_NATIVE diff --git a/src/wrapped/wrappedlibm_private.h b/src/wrapped/wrappedlibm_private.h index 7e2a55df..64e9a7ec 100644 --- a/src/wrapped/wrappedlibm_private.h +++ b/src/wrapped/wrappedlibm_private.h @@ -350,7 +350,11 @@ GO2(lgammal_r, KFKp, lgamma_r) #endif GOW(lgamma_r, dFdp) // __lgamma_r_finite +#ifdef STATICBUILD +//DATAV(_LIB_VERSION, 8) +#else DATAV(_LIB_VERSION, 8) +#endif GOWM(llrint, IFEd) GOWM(llrintf, IFEf) #ifdef HAVE_LD80BITS @@ -417,12 +421,12 @@ GOW(nexttoward, dFdD) GOW(nexttowardf, fFfD) // nexttowardl // Weak GOW(pow, dFdd) -GOW(pow10, dFd) -GOW(pow10f, fFf) +GOWM(pow10, dFd) +GOWM(pow10f, fFf) #ifdef HAVE_LD80BITS -GOW(pow10l, DFD) +GOWM(pow10l, DFD) #else -GOW(pow10l, KFK) +GOWM(pow10l, KFK) #endif GOW(powf, fFff) GOM(__powf_finite, fFff) diff --git a/src/wrapped/wrappedlibpthread.c b/src/wrapped/wrappedlibpthread.c index d29218ed..9b0184c6 100644 --- a/src/wrapped/wrappedlibpthread.c +++ b/src/wrapped/wrappedlibpthread.c @@ -1,3 +1,4 @@ +#define __USE_UNIX98 #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> @@ -20,30 +21,6 @@ const char* libpthreadName = "libpthread.so.0"; #define LIBNAME libpthread - -//int my_pthread_create(x64emu_t *emu, void* t, void* attr, void* start_routine, void* arg); //implemented in thread.c -//int my_pthread_key_create(x64emu_t* emu, void* key, void* dtor); -//int my___pthread_key_create(x64emu_t* emu, void* key, void* dtor); -//int my_pthread_once(x64emu_t* emu, void* once, void* cb); -//int my___pthread_once(x64emu_t* emu, void* once, void* cb); -//int my_pthread_cond_broadcast(x64emu_t* emu, void* cond); -//int my_pthread_cond_destroy(x64emu_t* emu, void* cond); -//int my_pthread_cond_init(x64emu_t* emu, void* cond, void* attr); -//int my_pthread_cond_signal(x64emu_t* emu, void* cond); -//int my_pthread_cond_timedwait(x64emu_t* emu, void* cond, void* mutex, void* abstime); -//int my_pthread_cond_wait(x64emu_t* emu, void* cond, void* mutex); -//int my_pthread_mutexattr_setkind_np(x64emu_t* emu, void* t, int kind); -//int my_pthread_attr_setscope(x64emu_t* emu, void* attr, int scope); -//void my__pthread_cleanup_push_defer(x64emu_t* emu, void* buffer, void* routine, void* arg); -//void my__pthread_cleanup_push(x64emu_t* emu, void* buffer, void* routine, void* arg); -//void my__pthread_cleanup_pop(x64emu_t* emu, void* buffer, int exec); -//void my__pthread_cleanup_pop_restore(x64emu_t* emu, void* buffer, int exec); -//int my_pthread_kill(x64emu_t* emu, void* thread, int sig); -//int my_pthread_getaffinity_np(x64emu_t* emu, pthread_t thread, int cpusetsize, void* cpuset); -//int my_pthread_setaffinity_np(x64emu_t* emu, pthread_t thread, int cpusetsize, void* cpuset); -//int my_pthread_attr_setaffinity_np(x64emu_t* emu, void* attr, uint32_t cpusetsize, void* cpuset); - - //EXPORT int my_pthread_attr_setschedparam(x64emu_t* emu, void* attr, void* param) //{ // int policy; @@ -82,4 +59,21 @@ EXPORT void my___pthread_initialize() // nothing, the lib initialize itself now } +#ifdef STATICBUILD +#include <semaphore.h> +#include "libtools/static_threads.h" + +extern void* __pthread_getspecific(size_t); +extern int __pthread_mutex_destroy(void*); +extern int __pthread_mutex_lock(void*); +extern int __pthread_mutex_trylock(void*); +extern int __pthread_mutex_unlock(void*); +extern int __pthread_rwlock_init(void*, void*); +extern int __pthread_rwlock_rdlock(void*); +extern int __pthread_rwlock_unlock(void*); +extern int __pthread_rwlock_wrlock(void*); +extern int __pthread_setspecific(size_t, void*); +extern int pthread_sigmask(int, void*, void*); +#endif + #include "wrappedlib_init.h" diff --git a/src/wrapped/wrappedlibpthread_private.h b/src/wrapped/wrappedlibpthread_private.h index ca356e39..878d9f8f 100644 --- a/src/wrapped/wrappedlibpthread_private.h +++ b/src/wrapped/wrappedlibpthread_private.h @@ -138,7 +138,11 @@ GOM(pthread_key_create, iFEpp) GOM(pthread_key_delete, iFEL) GO2(pthread_kill@GLIBC_2.2.5, iFEpi, my_pthread_kill_old) GOM(pthread_kill, iFEpi) +#ifndef STATICBUILD GO(pthread_kill_other_threads_np, vFv) +#else +//GO(pthread_kill_other_threads_np, vFv) +#endif #ifdef NOALIGN GO(__pthread_mutexattr_destroy, iFp) GO(pthread_mutexattr_destroy, iFp) diff --git a/src/wrapped/wrappedlibresolv.c b/src/wrapped/wrappedlibresolv.c index 36af9fbc..f36326d2 100644 --- a/src/wrapped/wrappedlibresolv.c +++ b/src/wrapped/wrappedlibresolv.c @@ -20,4 +20,32 @@ const char* libresolvName = "libresolv.so.2"; #define LIBNAME libresolv +#ifdef STATICBUILD +#include <arpa/inet.h> +#include <resolv.h> + +#undef __dn_comp +#undef __dn_expand +#undef __dn_skipname + +int __dn_comp(void* a, void* b, int c, void* d, void* e ) {return dn_comp(a, b, c, d, e);} +int __dn_expand(void* a, void* b, void* c, void* d, int e) {return dn_expand(a, b, c, d, e);} +int __dn_skipname(void* a, void* b) {return dn_skipname(a, b);} +uint32_t __ns_get16(void* a); +size_t __ns_get32(void* a); +extern int __ns_name_ntop(void* a, void* b, size_t c) {return ns_name_ntop(a, b, c);} +extern int __ns_name_unpack(void* a, void* b, void* c, void* d, size_t e) {return ns_name_unpack(a, b, c, d, e);} +extern int __res_dnok(void* a) {return res_dnok(a);} +extern int __res_hnok(void* a) {return res_hnok(a);} +extern int __res_mailok(void* a) {return res_mailok(a);} +extern int __res_mkquery(int a, void* b, int c, int d, void* e, int f, void* g, void* h, int i) {return res_mkquery(a, b, c, d, e, f, g, h, i);} +extern int __res_nquery(int a, void* b, int c, int d, void* e, int f) {return res_nquery(a, b, c, d, e, f);} +extern int __res_nsearch(void* a, void* b, int c, int d, void* e, int f) {return res_nsearch(a, b, c, d, e, f);} +extern int __res_ownok(void* a) {return res_ownok(a);} +extern int __res_query(void* a, int b, int c, void* d, int e) {return res_query(a, b, c, d, e);} +extern int __res_querydomain(void* a, void* b, int c, int d, void* e, int f) {return res_querydomain(a, b, c, d, e, f);} +extern int __res_search(void* a, int b, int c, void* d, int e) {return res_search(a, b, c, d, e);} +extern int __res_send(void* a, int b, void* c, int d) {return res_send(a, b, c, d);} +#endif + #include "wrappedlib_init.h" diff --git a/src/wrapped/wrappedlibrt.c b/src/wrapped/wrappedlibrt.c index 3b90c84a..36ea8829 100644 --- a/src/wrapped/wrappedlibrt.c +++ b/src/wrapped/wrappedlibrt.c @@ -112,7 +112,7 @@ EXPORT int my_aio_write64(x64emu_t emu, struct aiocb* aiocbp) aiocbp->aio_sigevent.sigev_notify_function = findsigev_notifyFct(aiocbp->aio_sigevent.sigev_notify_function); return my->aio_write64(aiocbp); } -EXPORT int mylio_listio(x64emu_t* emu, int mode, struct aiocb* list[], int nent, struct sigevent* sig) +EXPORT int my_lio_listio(x64emu_t* emu, int mode, struct aiocb* list[], int nent, struct sigevent* sig) { struct sigevent sevent; if(sig) { @@ -148,11 +148,18 @@ EXPORT int my_aio_write64(x64emu_t emu, void* aiocbp) errno = ENOSYS; return -1; } -EXPORT int mylio_listio(x64emu_t* emu, int mode, void* list[], int nent, struct sigevent* sig) +EXPORT int my_lio_listio(x64emu_t* emu, int mode, void* list[], int nent, struct sigevent* sig) { errno = ENOSYS; return -1; } #endif +#ifdef STATICBUILD +#include <mqueue.h> +#include <sys/mman.h> + +extern int __mq_open_2(void*, int); +#endif + #include "wrappedlib_init.h" diff --git a/src/wrapped/wrappedutil.c b/src/wrapped/wrappedutil.c index 3d4911aa..91503f78 100644 --- a/src/wrapped/wrappedutil.c +++ b/src/wrapped/wrappedutil.c @@ -37,10 +37,18 @@ EXPORT pid_t my_forkpty(x64emu_t* emu, void* amaster, void* name, void* termp, v return 0; } +#ifdef STATICBUILD +#include <pty.h> +#include <utmp.h> +#endif + +#ifdef STATICBUILD +#else #define PRE_INIT\ if(1) \ lib->w.lib = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL); \ else +#endif #include "wrappedlib_init.h" |