From de31ea3f0be79775103b70d90da96da355e5586f Mon Sep 17 00:00:00 2001 From: Hanlu Li Date: Thu, 13 Aug 2026 19:14:21 +0800 Subject: [PATCH 1/3] LATX, fix: Harden loader wrapper semantics Correct native link-map handling, preserve dlvsym and dlinfo semantics, bound dlopen path expansion, and make dlerror state thread-local. Serialize TB bridge registration, keep generated dlfcn mappings aligned, and scope guest CPU-state forwarding to the paths that require it. Signed-off-by: Hanlu Li --- target/i386/latx/context/library.c | 15 +- target/i386/latx/context/meson.build | 1 - target/i386/latx/context/wrappedlibc.c | 437 ++++++++++++------ target/i386/latx/context/wrappedlibdl.c | 395 ++++++++++++---- target/i386/latx/context/wrapper.c | 6 +- target/i386/latx/context/wrappertbbridge.c | 32 +- target/i386/latx/include/box64context.h | 3 +- .../latx/include/generated/wrappedlibctypes.h | 13 +- .../include/generated/wrappedlibdltypes.h | 13 +- 9 files changed, 653 insertions(+), 262 deletions(-) diff --git a/target/i386/latx/context/library.c b/target/i386/latx/context/library.c index af2ae878fea..47eb03326ee 100755 --- a/target/i386/latx/context/library.c +++ b/target/i386/latx/context/library.c @@ -240,19 +240,20 @@ static void initNativeLib(library_t *lib, box64context_t* context) { return; } + struct link_map *real_lm = NULL; + if(dlinfo(lib->priv.w.lib, RTLD_DI_LINKMAP, &real_lm) || !real_lm) { + printf_log(LOG_INFO, "Failed to dlinfo lib %s\n", lib->name); + break; + } linkmap_t *lm = addLinkMapLib(lib); if(!lm) { // Crashed already printf_log(LOG_INFO, "Failure to add lib %s linkmap\n", lib->name); break; } - struct link_map real_lm; - if(dlinfo(lib->priv.w.lib, RTLD_DI_LINKMAP, &real_lm)) { - printf_log(LOG_INFO, "Failed to dlinfo lib %s\n", lib->name); - } - lm->l_addr = real_lm.l_addr; - lm->l_name = real_lm.l_name; - lm->l_ld = real_lm.l_ld; + lm->l_addr = real_lm->l_addr; + lm->l_name = real_lm->l_name; + lm->l_ld = real_lm->l_ld; kzt_groups_log_library(lib->name, true); break; } diff --git a/target/i386/latx/context/meson.build b/target/i386/latx/context/meson.build index b7c8ac9a0cb..2fc5d4d73cd 100644 --- a/target/i386/latx/context/meson.build +++ b/target/i386/latx/context/meson.build @@ -49,7 +49,6 @@ my_file = files( 'wrappedlibglx.c', 'wrappedlibxxf86vm.c', 'wrappedlibxau.c', - 'wrappedlibxi.c', 'wrappedlibxdmcp.c', 'wrappedxshmfence.c', 'wrappedlibxfixes.c', diff --git a/target/i386/latx/context/wrappedlibc.c b/target/i386/latx/context/wrappedlibc.c index c6bced3cbd0..4cfcf652826 100644 --- a/target/i386/latx/context/wrappedlibc.c +++ b/target/i386/latx/context/wrappedlibc.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -3508,7 +3509,6 @@ dlprivate_t *NewDLPrivate(void) { return dl; } void FreeDLPrivate(dlprivate_t **lib) { - box_free((*lib)->last_error); box_free(*lib); } @@ -3523,7 +3523,96 @@ void* my_dlvsym(void *handle, void *symbol, const char *vername) EXPORT; int my_dlinfo(void* handle, int request, void* info) EXPORT; -#define CLEARERR if(dl->last_error) box_free(dl->last_error); dl->last_error = NULL; +static __thread char dl_error_buffer[512]; +static __thread int dl_error_pending; + +static void clear_dl_error(dlprivate_t *dl) +{ + if (dl && dl->x86dlerror) + (void)RunFunctionWithState((uintptr_t)dl->x86dlerror, 0); + dl_error_pending = 0; +} + +static void set_dl_error(dlprivate_t *dl, const char *message) +{ + (void)dl; + snprintf(dl_error_buffer, sizeof(dl_error_buffer), "%s", message); + dl_error_pending = 1; +} + +static void set_dl_errorf(dlprivate_t *dl, const char *format, ...) +{ + char message[512]; + va_list args; + + va_start(args, format); + vsnprintf(message, sizeof(message), format, args); + va_end(args); + set_dl_error(dl, message); +} + +#define CLEARERR clear_dl_error(dl); + +static int replace_path_token(char **path, const char *token, + const char *replacement) +{ + const size_t token_len = strlen(token); + const size_t replacement_len = strlen(replacement); + size_t search_from = 0; + char *match; + + while ((match = strstr(*path + search_from, token))) { + const size_t prefix_len = (size_t)(match - *path); + const size_t suffix_len = strlen(match + token_len); + size_t expanded_len; + char *expanded; + + if (suffix_len == SIZE_MAX || + prefix_len > SIZE_MAX - replacement_len || + prefix_len + replacement_len > SIZE_MAX - suffix_len - 1) + return -1; + expanded_len = prefix_len + replacement_len + suffix_len + 1; + expanded = box_malloc(expanded_len); + if (!expanded) + return -1; + memcpy(expanded, *path, prefix_len); + memcpy(expanded + prefix_len, replacement, replacement_len); + memcpy(expanded + prefix_len + replacement_len, + match + token_len, suffix_len + 1); + box_free(*path); + *path = expanded; + search_from = prefix_len + replacement_len; + } + return 0; +} + +static char *expand_dlopen_path(const char *filename) +{ + char *path = box_strdup(filename); + char *origin; + char *slash; + + if (!path) + return NULL; + origin = box_strdup(my_context->fullpath ? my_context->fullpath : ""); + if (!origin) { + box_free(path); + return NULL; + } + slash = strrchr(origin, '/'); + + if (slash) + *slash = '\0'; + else + origin[0] = '\0'; + if (replace_path_token(&path, "${ORIGIN}", origin) || + replace_path_token(&path, "${PLATFORM}", "x86_64")) { + box_free(path); + path = NULL; + } + box_free(origin); + return path; +} //#define R_RSP cpu->regs[R_ESP] static void Push64(CPUX86State *cpu, uint64_t v) { @@ -3536,29 +3625,28 @@ int init_x86dlfun(void); int init_x86dlfun(void) { elfheader_t* h = NULL; -#ifdef CONFIG_LOONGARCH_NEW_WORLD - char buf[PATH_MAX] = {0}; - snprintf(buf, PATH_MAX, "%s%s", interp_prefix, - "/usr/lib/glibc-hwcaps/x86-64-v2" /* AOSC OS (Core 12.2.2), glibc 2.40 (EmuKit 20250909~pre20250911T080911Z) */); - PrependList(&my_context->box64_ld_lib, buf, 1); -#endif h = loadElfFromFile("libc.so.6"); lsassert(h); - const char* syms[] = {"dlopen", "dlsym", "dlclose", "dladdr", "dladdr1", "dlinfo"}; - void *rsyms[6] = {0}; + const char* syms[] = { + "dlopen", "dlsym", "dlclose", "dladdr", + "dladdr1", "dlinfo", "dlvsym", "dlerror", + }; + void *rsyms[8] = {0}; int rrsyms = 0; - ResetSpecialCaseElf(h, syms, 6, rsyms, &rrsyms); - if (rrsyms != 6) { + ResetSpecialCaseElf(h, syms, 8, rsyms, &rrsyms); + if (rrsyms != 8) { h = loadElfFromFile("libdl.so.2"); - ResetSpecialCaseElf(h, syms, 6, rsyms, &rrsyms); + ResetSpecialCaseElf(h, syms, 8, rsyms, &rrsyms); } - lsassert(rrsyms == 6); + lsassert(rrsyms == 8); my_context->dlprivate->x86dlopen = rsyms[0]; my_context->dlprivate->x86dlsym = rsyms[1]; my_context->dlprivate->x86dlclose = rsyms[2]; my_context->dlprivate->x86dladdr = rsyms[3]; my_context->dlprivate->x86dladdr1 = rsyms[4]; my_context->dlprivate->x86dlinfo = rsyms[5]; + my_context->dlprivate->x86dlvsym = rsyms[6]; + my_context->dlprivate->x86dlerror = rsyms[7]; kzt_wine_init_x86(); return 0; } @@ -3605,39 +3693,31 @@ void* my_dlopen(void *filename, int flag){ lsassert(dl->x86dlopen); } if(filename) { - char* rfilename = (char*)alloca(MAX_PATH); - strcpy(rfilename, (char*)filename); - printf_dlsym(LOG_DEBUG, "Call to dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag); - while(strstr(rfilename, "${ORIGIN}")) { - char* origin = box_strdup(my_context->fullpath); - char* p = strrchr(origin, '/'); - if(p) *p = '\0'; // remove file name to have only full path, without last '/' - char* tmp = (char*)box_calloc(1, strlen(rfilename)-strlen("${ORIGIN}")+strlen(origin)+1); - p = strstr(rfilename, "${ORIGIN}"); - memcpy(tmp, rfilename, p-rfilename); - strcat(tmp, origin); - strcat(tmp, p+strlen("${ORIGIN}")); - strcpy(rfilename, tmp); - box_free(tmp); - box_free(origin); - } - while(strstr(rfilename, "${PLATFORM}")) { - char* platform = box_strdup("x86_64"); - char* p = strrchr(platform, '/'); - if(p) *p = '\0'; // remove file name to have only full path, without last '/' - char* tmp = (char*)box_calloc(1, strlen(rfilename)-strlen("${PLATFORM}")+strlen(platform)+1); - p = strstr(rfilename, "${PLATFORM}"); - memcpy(tmp, rfilename, p-rfilename); - strcat(tmp, platform); - strcat(tmp, p+strlen("${PLATFORM}")); - strcpy(rfilename, tmp); - box_free(tmp); - box_free(platform); + char* rfilename = expand_dlopen_path((char*)filename); + if (!rfilename) { + set_dl_error(dl, "Cannot expand dlopen path"); + return NULL; } + printf_dlsym(LOG_DEBUG, "Call to dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag); if (rfilename[0] == '/' && !FileExist(rfilename, IS_FILE)) { - char filetmp[PATH_MAX] = {0}; - snprintf(filetmp , PATH_MAX, "%s%s", interp_prefix, rfilename); - strcpy(rfilename, filetmp); + const size_t interp_len = strlen(interp_prefix); + const size_t filename_len = strlen(rfilename); + if (filename_len == SIZE_MAX || + interp_len > SIZE_MAX - filename_len - 1) { + box_free(rfilename); + set_dl_error(dl, "Cannot prefix dlopen path"); + return NULL; + } + char *prefixed = box_malloc(interp_len + filename_len + 1); + if (!prefixed) { + box_free(rfilename); + set_dl_error(dl, "Cannot prefix dlopen path"); + return NULL; + } + strcpy(prefixed, interp_prefix); + strcat(prefixed, rfilename); + box_free(rfilename); + rfilename = prefixed; printf_dlsym(LOG_DEBUG, "dlopen filename change to \"%s\"\n", rfilename); } // check if alread dlopenned... @@ -3660,11 +3740,17 @@ void* my_dlopen(void *filename, int flag){ if(!(flag&0x4)) dl->count[i] = dl->count[i]+1; printf_dlsym(LOG_DEBUG, "dlopen: Recycling %s/%p count=%ld (dlopened=%ld, elf_index=%d)\n", rfilename, (void*)(i+1), dl->count[i], dl->dlopened[i], GetElfIndex(dl->libs[i])); + box_free(rfilename); return (void*)(i+1); } } if(strstr(rfilename, "libGL.so")){ - strcpy(rfilename, "libGL.so.1"); + box_free(rfilename); + rfilename = box_strdup("libGL.so.1"); + if (!rfilename) { + set_dl_error(dl, "Cannot rewrite dlopen path"); + return NULL; + } } dlopened = (GetLibInternal(rfilename)==NULL); // Then open the lib @@ -3683,24 +3769,27 @@ void* my_dlopen(void *filename, int flag){ printf_dlsym(LOG_DEBUG, "warning call call x86dlopen filename %s %x ret=0x%lx\n", (char *)filename, flag, ret); //lsassert(0); if (ret) { + box_free(rfilename); return (void *)ret; } - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "filename \"%s\" flag=%x\n", (char *)filename, flag); - printf_dlsym(LOG_NEVER, "%p return %p\n", dl->last_error, (void*)NULL); + set_dl_errorf(dl, "filename \"%s\" flag=%x\n", + (char *)filename, flag); + box_free(rfilename); return NULL; #endif } if(AddNeededLib(NULL, NULL, NULL, is_local, bindnow, libs, 1, my_context)) { printf_dlsym(strchr(rfilename,'/')?LOG_DEBUG:LOG_INFO, "Warning: Cannot dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag); - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Cannot dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag); + set_dl_errorf(dl, "Cannot dlopen(\"%s\"/%p, %X)\n", + rfilename, filename, flag); + box_free(rfilename); return NULL; } lib = GetLibInternal(rfilename); - if (!lib) return NULL; + if (!lib) { + box_free(rfilename); + return NULL; + } lib->x86dlopenflag = flag; if (lib && lib->type == LIB_EMULATED) { // if dlopened = 0 ---> lib added but not loaded @@ -3713,6 +3802,7 @@ void* my_dlopen(void *filename, int flag){ } } //TODO:RunDeferedElfInit; + box_free(rfilename); } else { // check if already dlopenned... for (size_t i=0; ilib_sz; ++i) { @@ -3750,10 +3840,18 @@ void* my_dlopen(void *filename, int flag){ void* my_dlmopen(void* lmid, void *filename, int flag) { - if(lmid) { - printf_dlsym(LOG_INFO, "Warning, dlmopen(%p, %p(\"%s\"), 0x%x) called with lmid not LMID_ID_BASE (unsupported)\n", lmid, filename, filename?(char*)filename:"self", flag); + dlprivate_t *dl = my_context->dlprivate; + + if ((Lmid_t)lmid != LM_ID_BASE) { + char error[160]; + snprintf(error, sizeof(error), + "dlmopen namespace %p is unsupported", lmid); + set_dl_error(dl, error); + printf_dlsym(LOG_INFO, + "Warning, dlmopen(%p, %p(\"%s\"), 0x%x) rejected: unsupported namespace\n", + lmid, filename, filename ? (char*)filename : "self", flag); + return NULL; } - // lmid is ignored for now... return my_dlopen(filename, flag); } @@ -3792,6 +3890,23 @@ static int my_dlsym_lib(library_t* lib, const char* rsymbol, uintptr_t *start, u return ret; } +static int find_dl_library_index(dlprivate_t *dl, void *handle, size_t *index) +{ + const size_t raw_handle = (size_t)handle; + + if (raw_handle > 0 && raw_handle <= dl->lib_sz) { + *index = raw_handle - 1; + return 1; + } + for (size_t i = 0; i < dl->lib_sz; ++i) { + if (dl->libs[i] && dl->libs[i]->x86linkmap == handle) { + *index = i; + return 1; + } + } + return 0; +} + void* my_dlsym(void *handle, void *symbol){ dlprivate_t *dl = my_context->dlprivate; uintptr_t start = 0, end = 0; @@ -3802,6 +3917,17 @@ void* my_dlsym(void *handle, void *symbol){ lsassert(dl->x86dlsym); } printf_dlsym(LOG_DEBUG, "Call to dlsym(%p, \"%s\")%s\n", handle, rsymbol, dlsym_error?"":"\n"); + if (handle && handle != (void*)~0LL) { + size_t known_index; + if (!find_dl_library_index(dl, handle, &known_index)) { + uint64_t ret = RunFunctionWithState( + (uintptr_t)dl->x86dlsym, 2, handle, symbol); + if (!ret) + set_dl_errorf(dl, "Symbol \"%s\" not found in %p\n", + rsymbol, handle); + return (void*)ret; + } + } //lsassert(!strstr(rsymbol, "XcursorGetDefaultSize")); if(handle==NULL) { // special case, look globably @@ -3830,10 +3956,8 @@ void* my_dlsym(void *handle, void *symbol){ } printf_dlsym(LOG_NEVER, "debug my %d\n", __LINE__); } - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Symbol \"%s\" not found in %p)\n", rsymbol, handle); - printf_dlsym(LOG_NEVER, "%p return %p\n", dl->last_error, (void*)NULL); + set_dl_errorf(dl, "Symbol \"%s\" not found in %p)\n", rsymbol, + handle); return NULL; #endif } @@ -3895,30 +4019,27 @@ void* my_dlsym(void *handle, void *symbol){ } } #endif - __MY_CPU; #if FORWORDBACK + __MY_CPU; lsassert(dl->x86dlsym); Push64(cpu, (uint64_t)dl->x86dlsym); printf_dlsym(LOG_DEBUG, "warning call x86dlsym filename is %s 0x%lx %s\n", strlen(lmfile)?lmfile:"NULL", cpu->regs[R_EDI], (char*)symbol); return NULL; #else - uint64_t ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dlsym, 2, cpu->regs[R_EDI], symbol); - printf_dlsym(LOG_DEBUG, "warning call call x86dlsym filename is %s handle 0x%lx ret=0x%lx\n", strlen(lmfile)?lmfile:"NULL", cpu->regs[R_EDI], ret); + uint64_t ret = RunFunctionWithState( + (uintptr_t)my_context->dlprivate->x86dlsym, 2, handle, + symbol); + printf_dlsym(LOG_DEBUG, "warning call call x86dlsym filename is %s handle %p ret=0x%lx\n", strlen(lmfile)?lmfile:"NULL", handle, ret); if (ret) { return (void *)ret; } - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Symbol \"%s\" not found in %p)\n", rsymbol, handle); - printf_dlsym(LOG_NEVER, "%p return %p\n", dl->last_error, (void*)NULL); + set_dl_errorf(dl, "Symbol \"%s\" not found in %p)\n", rsymbol, + handle); return NULL; #endif } if(dl->count[nlib]==0) { - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Bad handle %p (already closed))\n", handle); - printf_dlsym(LOG_NEVER, "%p return %p\n", dl->last_error, (void*)NULL); + set_dl_errorf(dl, "Bad handle %p (already closed))\n", handle); return NULL; } if(dl->libs[nlib]) { @@ -3935,9 +4056,11 @@ void* my_dlsym(void *handle, void *symbol){ } lsassert(ret); dl->libs[nlib]->x86linkmap = (void *)ret; - ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dlsym, 2, dl->libs[nlib]->x86linkmap , cpu->regs[R_ESI]); + ret = RunFunctionWithState( + (uintptr_t)my_context->dlprivate->x86dlsym, 2, + dl->libs[nlib]->x86linkmap, symbol); printf_dlsym(LOG_DEBUG, "call x86dlsym filename %s is wrapped but not find symbol, dlsym(%p, %s) ret=0x%lx\n", - dl->libs[nlib]->name, dl->libs[nlib]->x86linkmap, (char *)cpu->regs[R_ESI], ret); + dl->libs[nlib]->name, dl->libs[nlib]->x86linkmap, (char *)symbol, ret); return (void *)ret; } #endif @@ -3950,15 +4073,15 @@ void* my_dlsym(void *handle, void *symbol){ printf_dlsym(LOG_DEBUG, "warning call x86dlsym filename is %s %lx\n", dl->libs[nlib]->x86linkmap->l_name, cpu->regs[R_EDI]); return NULL; #else - uint64_t ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dlsym, 2, cpu->regs[R_EDI], cpu->regs[R_ESI]); - printf_dlsym(LOG_DEBUG, "call x86dlsym filename is %s %s ret=0x%lx\n", dl->libs[nlib]->x86linkmap->l_name, (char *)cpu->regs[R_ESI], ret); + uint64_t ret = RunFunctionWithState( + (uintptr_t)my_context->dlprivate->x86dlsym, 2, + dl->libs[nlib]->x86linkmap, symbol); + printf_dlsym(LOG_DEBUG, "call x86dlsym filename is %s %s ret=0x%lx\n", dl->libs[nlib]->x86linkmap->l_name, (char *)symbol, ret); if (ret) { return (void *)ret; } - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Symbol \"%s\" not found in %p)\n", rsymbol, handle); - printf_dlsym(LOG_NEVER, "%p return %p\n", dl->last_error, (void*)NULL); + set_dl_errorf(dl, "Symbol \"%s\" not found in %p)\n", rsymbol, + handle); return NULL; #endif } @@ -3971,11 +4094,9 @@ void* my_dlsym(void *handle, void *symbol){ return (void*)start; } #endif - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Symbol \"%s\" not found in %p)\n", rsymbol, handle); + set_dl_errorf(dl, "Symbol \"%s\" not found in %p)\n", rsymbol, + handle); printf_dlsym(LOG_NEVER, "%p\n", NULL); - lsassertm(0,"%s",dl->last_error); return NULL; } printf_dlsym(LOG_NEVER, "%p\n", (void*)start); @@ -4009,18 +4130,11 @@ int my_dlclose(void *handle) Push64(cpu, (uint64_t)dl->x86dlclose); return 0; } - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Bad handle %p, ret = %d)\n", handle, ret); - printf_dlsym(LOG_DEBUG, "dlclose: %s\n", dl->last_error); - lsassertm(0,"%s",dl->last_error); + set_dl_errorf(dl, "Bad handle %p, ret = %d)\n", handle, ret); return -1; } if(dl->count[nlib]==0) { - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Bad handle %p (already closed))\n", handle); - printf_dlsym(LOG_DEBUG, "dlclose: %s\n", dl->last_error); + set_dl_errorf(dl, "Bad handle %p (already closed))\n", handle); return -1; } dl->count[nlib] = dl->count[nlib]-1; @@ -4045,7 +4159,19 @@ int my_dlclose(void *handle) char* my_dlerror(void) { dlprivate_t *dl = my_context->dlprivate; - return dl->last_error; + + if (!dl->x86dlerror) + init_x86dlfun(); + if (dl_error_pending) { + if (dl->x86dlerror) + (void)RunFunctionWithState((uintptr_t)dl->x86dlerror, 0); + dl_error_pending = 0; + return dl_error_buffer; + } + if (!dl->x86dlerror) + return NULL; + return (char*)(uintptr_t)RunFunctionWithState( + (uintptr_t)dl->x86dlerror, 0); } int my_dladdr1(void *addr, void *i, void** extra_info, int flags) @@ -4107,7 +4233,50 @@ int my_dladdr(void *addr, void *i) void* my_dlvsym(void *handle, void *symbol, const char *vername) { printf_dlsym(LOG_DEBUG, "Call to dlvsym(%p, \"%s\", %s)", handle, (char *)symbol, vername?vername:"(nil)"); - return my_dlsym(handle, symbol); + dlprivate_t *dl = my_context->dlprivate; + size_t nlib; + void *guest_handle = handle; + + clear_dl_error(dl); + if (!dl->x86dlvsym) + init_x86dlfun(); + if (!dl->x86dlvsym) { + set_dl_error(dl, "dlvsym is unavailable in the guest loader"); + return NULL; + } + if (handle == (void*)~0LL) { + __MY_CPU; + Push64(cpu, (uint64_t)dl->x86dlvsym); + return NULL; + } + if (!handle) + return (void*)(uintptr_t)RunFunctionWithState( + (uintptr_t)dl->x86dlvsym, 3, guest_handle, symbol, vername); + if (find_dl_library_index(dl, handle, &nlib)) { + if (!dl->count[nlib]) { + set_dl_errorf(dl, "Bad handle %p (already closed)\n", handle); + return NULL; + } + if (!dl->libs[nlib]) { + return (void*)(uintptr_t)RunFunctionWithState( + (uintptr_t)dl->x86dlvsym, 3, NULL, symbol, vername); + } + guest_handle = dl->libs[nlib]->x86linkmap; + if (!guest_handle) { + guest_handle = (void*)(uintptr_t)RunFunctionWithState( + (uintptr_t)dl->x86dlopen, 2, dl->libs[nlib]->name, + dl->libs[nlib]->x86dlopenflag); + dl->libs[nlib]->x86linkmap = guest_handle; + if (!guest_handle) { + set_dl_errorf(dl, "Missing guest link_map for handle %p\n", + handle); + return NULL; + } + } + } + uintptr_t ret = RunFunctionWithState( + (uintptr_t)dl->x86dlvsym, 3, guest_handle, symbol, vername); + return (void*)ret; } int my_dlinfo(void* handle, int request, void* info) @@ -4115,52 +4284,48 @@ int my_dlinfo(void* handle, int request, void* info) printf_dlsym(LOG_DEBUG, "Call to dlinfo(%p, %d, %p)\n", handle, request, info); dlprivate_t *dl = my_context->dlprivate; CLEARERR - lsassert(0);//latx not support yet. - if (!dl->x86dlopen) { + if (!dl->x86dlinfo) { init_x86dlfun(); - lsassert(dl->x86dlopen); + lsassert(dl->x86dlinfo); } - size_t nlib = (size_t)handle; - if(nlib > dl->lib_sz) { - for (int i = 0; i < dl->lib_sz; i++) { - if (dl->libs[i] && dl->libs[i]->active && dl->libs[i]->type == LIB_EMULATED && ((size_t)dl->libs[i]->x86linkmap) == nlib) { - nlib = i + 1; - break; - } + size_t nlib; + void *guest_handle = handle; + if (find_dl_library_index(dl, handle, &nlib)) { + if (!dl->count[nlib]) { + set_dl_errorf(dl, "Bad handle %p (already closed)\n", handle); + return -1; } - } - --nlib; - // size_t is unsigned - if(nlib>=dl->lib_sz) { - if(!dl->last_error) - dl->last_error = box_calloc(1, 129); - snprintf(dl->last_error, 129, "Bad handle %p)\n", handle); - printf_dlsym(LOG_DEBUG, "dlinfo: %s\n", dl->last_error); - return -1; - } - #if 0 - if(!dl->dllibs[nlib].count || !dl->dllibs[nlib].full) { - if(!dl->last_error) - dl->last_error = box_calloc(1, 129); - snprintf(dl->last_error, 129, "Bad handle %p (already closed))\n", handle); - printf_dlsym(LOG_DEBUG, "dlinfo: %s\n", dl->last_error); - return -1; - } - #endif - library_t *lib = dl->libs[nlib]; - switch(request) { - case 2: // RTLD_DI_LINKMAP - { - *(linkmap_t**)info = getLinkMapLib(lib); + if (!dl->libs[nlib]) { + guest_handle = NULL; + } else { + guest_handle = dl->libs[nlib]->x86linkmap; + if (!guest_handle) { + guest_handle = (void*)(uintptr_t)RunFunctionWithState( + (uintptr_t)dl->x86dlopen, 2, dl->libs[nlib]->name, + dl->libs[nlib]->x86dlopenflag); + dl->libs[nlib]->x86linkmap = guest_handle; + if (!guest_handle) { + set_dl_errorf(dl, + "Cannot open guest library for handle %p\n", + handle); + return -1; + } } - return 0; - default: - printf_dlsym(LOG_NONE, "Warning, unsupported call to dlinfo(%p, %d, %p)\n", handle, request, info); - if(!dl->last_error) - dl->last_error = box_calloc(1, 129); - snprintf(dl->last_error, 129, "unsupported call to dlinfo request:%d\n", request); + if (request == RTLD_DI_LINKMAP) { + if (!info) { + set_dl_errorf(dl, + "Invalid dlinfo result for handle %p\n", + handle); + return -1; + } + *(struct link_map**)info = guest_handle; + return 0; + } + } } - return -1; + uint64_t ret = RunFunctionWithState( + (uintptr_t)dl->x86dlinfo, 3, guest_handle, request, info); + return ret; } #endif diff --git a/target/i386/latx/context/wrappedlibdl.c b/target/i386/latx/context/wrappedlibdl.c index 1f7c3ce8626..3043da61cdf 100644 --- a/target/i386/latx/context/wrappedlibdl.c +++ b/target/i386/latx/context/wrappedlibdl.c @@ -8,7 +8,9 @@ #include #include +#include #include +#include #include #include "elf.h" #include @@ -34,7 +36,6 @@ dlprivate_t *NewDLPrivate(void) { return dl; } void FreeDLPrivate(dlprivate_t **lib) { - box_free((*lib)->last_error); box_free(*lib); } @@ -51,7 +52,96 @@ int my_dlinfo(void* handle, int request, void* info) EXPORT; #define LIBNAME libdl const char* libdlName = "libdl.so.2"; -#define CLEARERR if(dl->last_error) box_free(dl->last_error); dl->last_error = NULL; +static __thread char dl_error_buffer[512]; +static __thread int dl_error_pending; + +static void clear_dl_error(dlprivate_t *dl) +{ + if (dl && dl->x86dlerror) + (void)RunFunctionWithState((uintptr_t)dl->x86dlerror, 0); + dl_error_pending = 0; +} + +static void set_dl_error(dlprivate_t *dl, const char *message) +{ + (void)dl; + snprintf(dl_error_buffer, sizeof(dl_error_buffer), "%s", message); + dl_error_pending = 1; +} + +static void set_dl_errorf(dlprivate_t *dl, const char *format, ...) +{ + char message[512]; + va_list args; + + va_start(args, format); + vsnprintf(message, sizeof(message), format, args); + va_end(args); + set_dl_error(dl, message); +} + +#define CLEARERR clear_dl_error(dl); + +static int replace_path_token(char **path, const char *token, + const char *replacement) +{ + const size_t token_len = strlen(token); + const size_t replacement_len = strlen(replacement); + size_t search_from = 0; + char *match; + + while ((match = strstr(*path + search_from, token))) { + const size_t prefix_len = (size_t)(match - *path); + const size_t suffix_len = strlen(match + token_len); + size_t expanded_len; + char *expanded; + + if (suffix_len == SIZE_MAX || + prefix_len > SIZE_MAX - replacement_len || + prefix_len + replacement_len > SIZE_MAX - suffix_len - 1) + return -1; + expanded_len = prefix_len + replacement_len + suffix_len + 1; + expanded = box_malloc(expanded_len); + if (!expanded) + return -1; + memcpy(expanded, *path, prefix_len); + memcpy(expanded + prefix_len, replacement, replacement_len); + memcpy(expanded + prefix_len + replacement_len, + match + token_len, suffix_len + 1); + box_free(*path); + *path = expanded; + search_from = prefix_len + replacement_len; + } + return 0; +} + +static char *expand_dlopen_path(const char *filename) +{ + char *path = box_strdup(filename); + char *origin; + char *slash; + + if (!path) + return NULL; + origin = box_strdup(my_context->fullpath ? my_context->fullpath : ""); + if (!origin) { + box_free(path); + return NULL; + } + slash = strrchr(origin, '/'); + + if (slash) + *slash = '\0'; + else + origin[0] = '\0'; + if (replace_path_token(&path, "${ORIGIN}", origin) || + replace_path_token(&path, "${PLATFORM}", "x86_64")) { + box_free(path); + path = NULL; + } + box_free(origin); + return path; +} //#define R_RSP cpu->regs[R_ESP] static void Push64(CPUX86State *cpu, uint64_t v) { @@ -64,21 +154,26 @@ int init_x86dlfun(void) { elfheader_t* h = loadElfFromFile("libdl.so.2"); lsassert(h); - const char* syms[] = {"dlopen", "dlsym", "dlclose", "dladdr", "dladdr1", "dlinfo"}; - void *rsyms[6] = {0}; + const char* syms[] = { + "dlopen", "dlsym", "dlclose", "dladdr", + "dladdr1", "dlinfo", "dlvsym", "dlerror", + }; + void *rsyms[8] = {0}; int rrsyms = 0; - ResetSpecialCaseElf(h, syms, 6, rsyms, &rrsyms); - if (rrsyms != 6) { + ResetSpecialCaseElf(h, syms, 8, rsyms, &rrsyms); + if (rrsyms != 8) { h = loadElfFromFile("libc.so.6"); - ResetSpecialCaseElf(h, syms, 6, rsyms, &rrsyms); + ResetSpecialCaseElf(h, syms, 8, rsyms, &rrsyms); } - lsassert(rrsyms == 6); + lsassert(rrsyms == 8); my_context->dlprivate->x86dlopen = rsyms[0]; my_context->dlprivate->x86dlsym = rsyms[1]; my_context->dlprivate->x86dlclose = rsyms[2]; my_context->dlprivate->x86dladdr = rsyms[3]; my_context->dlprivate->x86dladdr1 = rsyms[4]; my_context->dlprivate->x86dlinfo = rsyms[5]; + my_context->dlprivate->x86dlvsym = rsyms[6]; + my_context->dlprivate->x86dlerror = rsyms[7]; return 0; } static int callx86dlopen(void *filename, int flag, elfheader_t * h, int is_local) { @@ -124,39 +219,31 @@ void* my_dlopen(void *filename, int flag){ lsassert(dl->x86dlopen); } if(filename) { - char* rfilename = (char*)alloca(MAX_PATH); - strcpy(rfilename, (char*)filename); - printf_dlsym(LOG_DEBUG, "Call to dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag); - while(strstr(rfilename, "${ORIGIN}")) { - char* origin = box_strdup(my_context->fullpath); - char* p = strrchr(origin, '/'); - if(p) *p = '\0'; // remove file name to have only full path, without last '/' - char* tmp = (char*)box_calloc(1, strlen(rfilename)-strlen("${ORIGIN}")+strlen(origin)+1); - p = strstr(rfilename, "${ORIGIN}"); - memcpy(tmp, rfilename, p-rfilename); - strcat(tmp, origin); - strcat(tmp, p+strlen("${ORIGIN}")); - strcpy(rfilename, tmp); - box_free(tmp); - box_free(origin); - } - while(strstr(rfilename, "${PLATFORM}")) { - char* platform = box_strdup("x86_64"); - char* p = strrchr(platform, '/'); - if(p) *p = '\0'; // remove file name to have only full path, without last '/' - char* tmp = (char*)box_calloc(1, strlen(rfilename)-strlen("${PLATFORM}")+strlen(platform)+1); - p = strstr(rfilename, "${PLATFORM}"); - memcpy(tmp, rfilename, p-rfilename); - strcat(tmp, platform); - strcat(tmp, p+strlen("${PLATFORM}")); - strcpy(rfilename, tmp); - box_free(tmp); - box_free(platform); + char* rfilename = expand_dlopen_path((char*)filename); + if (!rfilename) { + set_dl_error(dl, "Cannot expand dlopen path"); + return NULL; } + printf_dlsym(LOG_DEBUG, "Call to dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag); if (rfilename[0] == '/' && !FileExist(rfilename, IS_FILE)) { - char filetmp[PATH_MAX] = {0}; - snprintf(filetmp , PATH_MAX, "%s%s", interp_prefix, rfilename); - strcpy(rfilename, filetmp); + const size_t interp_len = strlen(interp_prefix); + const size_t filename_len = strlen(rfilename); + if (filename_len == SIZE_MAX || + interp_len > SIZE_MAX - filename_len - 1) { + box_free(rfilename); + set_dl_error(dl, "Cannot prefix dlopen path"); + return NULL; + } + char *prefixed = box_malloc(interp_len + filename_len + 1); + if (!prefixed) { + box_free(rfilename); + set_dl_error(dl, "Cannot prefix dlopen path"); + return NULL; + } + strcpy(prefixed, interp_prefix); + strcat(prefixed, rfilename); + box_free(rfilename); + rfilename = prefixed; printf_dlsym(LOG_DEBUG, "dlopen filename change to \"%s\"\n", rfilename); } // check if alread dlopenned... @@ -179,11 +266,17 @@ void* my_dlopen(void *filename, int flag){ if(!(flag&0x4)) dl->count[i] = dl->count[i]+1; printf_dlsym(LOG_DEBUG, "dlopen: Recycling %s/%p count=%ld (dlopened=%ld, elf_index=%d)\n", rfilename, (void*)(i+1), dl->count[i], dl->dlopened[i], GetElfIndex(dl->libs[i])); + box_free(rfilename); return (void*)(i+1); } } if(strstr(rfilename, "libGL.so")){ - strcpy(rfilename, "libGL.so.1"); + box_free(rfilename); + rfilename = box_strdup("libGL.so.1"); + if (!rfilename) { + set_dl_error(dl, "Cannot rewrite dlopen path"); + return NULL; + } } dlopened = (GetLibInternal(rfilename)==NULL); // Then open the lib @@ -202,24 +295,27 @@ void* my_dlopen(void *filename, int flag){ printf_dlsym(LOG_DEBUG, "warning call call x86dlopen filename %s %x ret=0x%lx\n", (char *)filename, flag, ret); //lsassert(0); if (ret) { + box_free(rfilename); return (void *)ret; } - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "filename \"%s\" flag=%x\n", (char *)filename, flag); - printf_dlsym(LOG_NEVER, "%p return %p\n", dl->last_error, (void*)NULL); + set_dl_errorf(dl, "filename \"%s\" flag=%x\n", + (char *)filename, flag); + box_free(rfilename); return NULL; #endif } if(AddNeededLib(NULL, NULL, NULL, is_local, bindnow, libs, 1, my_context)) { printf_dlsym(strchr(rfilename,'/')?LOG_DEBUG:LOG_INFO, "Warning: Cannot dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag); - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Cannot dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag); + set_dl_errorf(dl, "Cannot dlopen(\"%s\"/%p, %X)\n", + rfilename, filename, flag); + box_free(rfilename); return NULL; } lib = GetLibInternal(rfilename); - if (!lib) return NULL; + if (!lib) { + box_free(rfilename); + return NULL; + } lib->x86dlopenflag = flag; if (lib && lib->type == LIB_EMULATED) { // if dlopened = 0 ---> lib added but not loaded @@ -232,6 +328,7 @@ void* my_dlopen(void *filename, int flag){ } } //TODO:RunDeferedElfInit; + box_free(rfilename); } else { // check if already dlopenned... for (size_t i=0; ilib_sz; ++i) { @@ -269,10 +366,18 @@ void* my_dlopen(void *filename, int flag){ void* my_dlmopen(void* lmid, void *filename, int flag) { - if(lmid) { - printf_dlsym(LOG_INFO, "Warning, dlmopen(%p, %p(\"%s\"), 0x%x) called with lmid not LMID_ID_BASE (unsupported)\n", lmid, filename, filename?(char*)filename:"self", flag); + dlprivate_t *dl = my_context->dlprivate; + + if ((Lmid_t)lmid != LM_ID_BASE) { + char error[160]; + snprintf(error, sizeof(error), + "dlmopen namespace %p is unsupported", lmid); + set_dl_error(dl, error); + printf_dlsym(LOG_INFO, + "Warning, dlmopen(%p, %p(\"%s\"), 0x%x) rejected: unsupported namespace\n", + lmid, filename, filename ? (char*)filename : "self", flag); + return NULL; } - // lmid is ignored for now... return my_dlopen(filename, flag); } @@ -311,6 +416,23 @@ static int my_dlsym_lib(library_t* lib, const char* rsymbol, uintptr_t *start, u return ret; } +static int find_dl_library_index(dlprivate_t *dl, void *handle, size_t *index) +{ + const size_t raw_handle = (size_t)handle; + + if (raw_handle > 0 && raw_handle <= dl->lib_sz) { + *index = raw_handle - 1; + return 1; + } + for (size_t i = 0; i < dl->lib_sz; ++i) { + if (dl->libs[i] && dl->libs[i]->x86linkmap == handle) { + *index = i; + return 1; + } + } + return 0; +} + void* my_dlsym(void *handle, void *symbol){ dlprivate_t *dl = my_context->dlprivate; uintptr_t start = 0, end = 0; @@ -321,6 +443,17 @@ void* my_dlsym(void *handle, void *symbol){ lsassert(dl->x86dlsym); } printf_dlsym(LOG_DEBUG, "Call to dlsym(%p, \"%s\")%s\n", handle, rsymbol, dlsym_error?"":"\n"); + if (handle && handle != (void*)~0LL) { + size_t known_index; + if (!find_dl_library_index(dl, handle, &known_index)) { + uint64_t ret = RunFunctionWithState( + (uintptr_t)dl->x86dlsym, 2, handle, symbol); + if (!ret) + set_dl_errorf(dl, "Symbol \"%s\" not found in %p\n", + rsymbol, handle); + return (void*)ret; + } + } //lsassert(!strstr(rsymbol, "XcursorGetDefaultSize")); if(handle==NULL) { // special case, look globably @@ -348,10 +481,8 @@ void* my_dlsym(void *handle, void *symbol){ } printf_dlsym(LOG_NEVER, "debug my %d\n", __LINE__); } - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Symbol \"%s\" not found in %p)\n", rsymbol, handle); - printf_dlsym(LOG_NEVER, "%p return %p\n", dl->last_error, (void*)NULL); + set_dl_errorf(dl, "Symbol \"%s\" not found in %p)\n", rsymbol, + handle); return NULL; #endif } @@ -413,30 +544,27 @@ void* my_dlsym(void *handle, void *symbol){ } } #endif - __MY_CPU; #if FORWORDBACK + __MY_CPU; lsassert(dl->x86dlsym); Push64(cpu, (uint64_t)dl->x86dlsym); printf_dlsym(LOG_DEBUG, "warning call x86dlsym filename is %s 0x%lx %s\n", strlen(lmfile)?lmfile:"NULL", cpu->regs[R_EDI], (char*)symbol); return NULL; #else - uint64_t ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dlsym, 2, cpu->regs[R_EDI], symbol); - printf_dlsym(LOG_DEBUG, "warning call call x86dlsym filename is %s handle 0x%lx ret=0x%lx\n", strlen(lmfile)?lmfile:"NULL", cpu->regs[R_EDI], ret); + uint64_t ret = RunFunctionWithState( + (uintptr_t)my_context->dlprivate->x86dlsym, 2, handle, + symbol); + printf_dlsym(LOG_DEBUG, "warning call call x86dlsym filename is %s handle %p ret=0x%lx\n", strlen(lmfile)?lmfile:"NULL", handle, ret); if (ret) { return (void *)ret; } - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Symbol \"%s\" not found in %p)\n", rsymbol, handle); - printf_dlsym(LOG_NEVER, "%p return %p\n", dl->last_error, (void*)NULL); + set_dl_errorf(dl, "Symbol \"%s\" not found in %p)\n", rsymbol, + handle); return NULL; #endif } if(dl->count[nlib]==0) { - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Bad handle %p (already closed))\n", handle); - printf_dlsym(LOG_NEVER, "%p return %p\n", dl->last_error, (void*)NULL); + set_dl_errorf(dl, "Bad handle %p (already closed))\n", handle); return NULL; } if(dl->libs[nlib]) { @@ -453,9 +581,11 @@ void* my_dlsym(void *handle, void *symbol){ } lsassert(ret); dl->libs[nlib]->x86linkmap = (void *)ret; - ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dlsym, 2, dl->libs[nlib]->x86linkmap , cpu->regs[R_ESI]); + ret = RunFunctionWithState( + (uintptr_t)my_context->dlprivate->x86dlsym, 2, + dl->libs[nlib]->x86linkmap, symbol); printf_dlsym(LOG_DEBUG, "call x86dlsym filename %s is wrapped but not find symbol, dlsym(%p, %s) ret=0x%lx\n", - dl->libs[nlib]->name, dl->libs[nlib]->x86linkmap, (char *)cpu->regs[R_ESI], ret); + dl->libs[nlib]->name, dl->libs[nlib]->x86linkmap, (char *)symbol, ret); return (void *)ret; } #endif @@ -468,15 +598,15 @@ void* my_dlsym(void *handle, void *symbol){ printf_dlsym(LOG_DEBUG, "warning call x86dlsym filename is %s %lx\n", dl->libs[nlib]->x86linkmap->l_name, cpu->regs[R_EDI]); return NULL; #else - uint64_t ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dlsym, 2, cpu->regs[R_EDI], cpu->regs[R_ESI]); - printf_dlsym(LOG_DEBUG, "call x86dlsym filename is %s %s ret=0x%lx\n", dl->libs[nlib]->x86linkmap->l_name, (char *)cpu->regs[R_ESI], ret); + uint64_t ret = RunFunctionWithState( + (uintptr_t)my_context->dlprivate->x86dlsym, 2, + dl->libs[nlib]->x86linkmap, symbol); + printf_dlsym(LOG_DEBUG, "call x86dlsym filename is %s %s ret=0x%lx\n", dl->libs[nlib]->x86linkmap->l_name, (char *)symbol, ret); if (ret) { return (void *)ret; } - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Symbol \"%s\" not found in %p)\n", rsymbol, handle); - printf_dlsym(LOG_NEVER, "%p return %p\n", dl->last_error, (void*)NULL); + set_dl_errorf(dl, "Symbol \"%s\" not found in %p)\n", rsymbol, + handle); return NULL; #endif } @@ -489,11 +619,9 @@ void* my_dlsym(void *handle, void *symbol){ return (void*)start; } #endif - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Symbol \"%s\" not found in %p)\n", rsymbol, handle); + set_dl_errorf(dl, "Symbol \"%s\" not found in %p)\n", rsymbol, + handle); printf_dlsym(LOG_NEVER, "%p\n", NULL); - lsassertm(0,"%s",dl->last_error); return NULL; } printf_dlsym(LOG_NEVER, "%p\n", (void*)start); @@ -527,18 +655,11 @@ int my_dlclose(void *handle) Push64(cpu, (uint64_t)dl->x86dlclose); return 0; } - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Bad handle %p, ret = %d)\n", handle, ret); - printf_dlsym(LOG_DEBUG, "dlclose: %s\n", dl->last_error); - lsassertm(0,"%s",dl->last_error); + set_dl_errorf(dl, "Bad handle %p, ret = %d)\n", handle, ret); return -1; } if(dl->count[nlib]==0) { - if(!dl->last_error) - dl->last_error = box_malloc(129); - snprintf(dl->last_error, 129, "Bad handle %p (already closed))\n", handle); - printf_dlsym(LOG_DEBUG, "dlclose: %s\n", dl->last_error); + set_dl_errorf(dl, "Bad handle %p (already closed))\n", handle); return -1; } dl->count[nlib] = dl->count[nlib]-1; @@ -563,7 +684,19 @@ int my_dlclose(void *handle) char* my_dlerror(void) { dlprivate_t *dl = my_context->dlprivate; - return dl->last_error; + + if (!dl->x86dlerror) + init_x86dlfun(); + if (dl_error_pending) { + if (dl->x86dlerror) + (void)RunFunctionWithState((uintptr_t)dl->x86dlerror, 0); + dl_error_pending = 0; + return dl_error_buffer; + } + if (!dl->x86dlerror) + return NULL; + return (char*)(uintptr_t)RunFunctionWithState( + (uintptr_t)dl->x86dlerror, 0); } int my_dladdr1(void *addr, void *i, void** extra_info, int flags) @@ -625,7 +758,50 @@ int my_dladdr(void *addr, void *i) void* my_dlvsym(void *handle, void *symbol, const char *vername) { printf_dlsym(LOG_DEBUG, "Call to dlvsym(%p, \"%s\", %s)", handle, (char *)symbol, vername?vername:"(nil)"); - return my_dlsym(handle, symbol); + dlprivate_t *dl = my_context->dlprivate; + size_t nlib; + void *guest_handle = handle; + + clear_dl_error(dl); + if (!dl->x86dlvsym) + init_x86dlfun(); + if (!dl->x86dlvsym) { + set_dl_error(dl, "dlvsym is unavailable in the guest loader"); + return NULL; + } + if (handle == (void*)~0LL) { + __MY_CPU; + Push64(cpu, (uint64_t)dl->x86dlvsym); + return NULL; + } + if (!handle) + return (void*)(uintptr_t)RunFunctionWithState( + (uintptr_t)dl->x86dlvsym, 3, guest_handle, symbol, vername); + if (find_dl_library_index(dl, handle, &nlib)) { + if (!dl->count[nlib]) { + set_dl_errorf(dl, "Bad handle %p (already closed)\n", handle); + return NULL; + } + if (!dl->libs[nlib]) { + return (void*)(uintptr_t)RunFunctionWithState( + (uintptr_t)dl->x86dlvsym, 3, NULL, symbol, vername); + } + guest_handle = dl->libs[nlib]->x86linkmap; + if (!guest_handle) { + guest_handle = (void*)(uintptr_t)RunFunctionWithState( + (uintptr_t)dl->x86dlopen, 2, dl->libs[nlib]->name, + dl->libs[nlib]->x86dlopenflag); + dl->libs[nlib]->x86linkmap = guest_handle; + if (!guest_handle) { + set_dl_errorf(dl, "Missing guest link_map for handle %p\n", + handle); + return NULL; + } + } + } + uintptr_t ret = RunFunctionWithState( + (uintptr_t)dl->x86dlvsym, 3, guest_handle, symbol, vername); + return (void*)ret; } int my_dlinfo(void* handle, int request, void* info) @@ -637,10 +813,45 @@ int my_dlinfo(void* handle, int request, void* info) init_x86dlfun(); lsassert(dl->x86dlinfo); } - __MY_CPU; - uint64_t ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dlinfo, 3, cpu->regs[R_EDI], cpu->regs[R_ESI], cpu->regs[R_EDX]); + size_t nlib; + void *guest_handle = handle; + if (find_dl_library_index(dl, handle, &nlib)) { + if (!dl->count[nlib]) { + set_dl_errorf(dl, "Bad handle %p (already closed)\n", handle); + return -1; + } + if (!dl->libs[nlib]) { + guest_handle = NULL; + } else { + guest_handle = dl->libs[nlib]->x86linkmap; + if (!guest_handle) { + guest_handle = (void*)(uintptr_t)RunFunctionWithState( + (uintptr_t)dl->x86dlopen, 2, dl->libs[nlib]->name, + dl->libs[nlib]->x86dlopenflag); + dl->libs[nlib]->x86linkmap = guest_handle; + if (!guest_handle) { + set_dl_errorf(dl, + "Cannot open guest library for handle %p\n", + handle); + return -1; + } + } + if (request == RTLD_DI_LINKMAP) { + if (!info) { + set_dl_errorf(dl, + "Invalid dlinfo result for handle %p\n", + handle); + return -1; + } + *(struct link_map**)info = guest_handle; + return 0; + } + } + } + uint64_t ret = RunFunctionWithState( + (uintptr_t)my_context->dlprivate->x86dlinfo, 3, + guest_handle, request, info); return ret; } #include "wrappedlib_init.h" - diff --git a/target/i386/latx/context/wrapper.c b/target/i386/latx/context/wrapper.c index 10669c71535..05a27892353 100644 --- a/target/i386/latx/context/wrapper.c +++ b/target/i386/latx/context/wrapper.c @@ -44,11 +44,11 @@ extern void* my__IO_2_1_stderr_; if (kzt_call_log) { \ Dl_info dl_info; \ int ret = dladdr((const void *)fcn, &dl_info); \ - if (ret != -1) { \ + if (ret != 0) { \ printf_kzt_call(LOG_INFO, "pid %d %llx call %s(%p,%p,%p,%p,%p,%p,%p,%p,%p,%p,%p,%p) = 0x%lx from %s\n", \ getpid(), \ (unsigned long long)pthread_self(), \ - dl_info.dli_sname, \ + dl_info.dli_sname ? dl_info.dli_sname : "", \ (void *)R_RDI, \ (void *)R_RSI, \ (void*)R_RDX, \ @@ -62,7 +62,7 @@ extern void* my__IO_2_1_stderr_; *(void**)(R_RSP + 40), \ *(void**)(R_RSP + 48), \ R_RAX, \ - dl_info.dli_fname); \ + dl_info.dli_fname ? dl_info.dli_fname : ""); \ } else { \ fprintf(stderr, "call dladdr err 0x%lx ret =%d \n", fcn, ret); \ } \ diff --git a/target/i386/latx/context/wrappertbbridge.c b/target/i386/latx/context/wrappertbbridge.c index 0693474f1c9..2305058a419 100644 --- a/target/i386/latx/context/wrappertbbridge.c +++ b/target/i386/latx/context/wrappertbbridge.c @@ -8,12 +8,15 @@ #include "wrappertbbridge.h" -static GTree * tree; -static gint pc_cmp(gconstpointer ap, gconstpointer bp) +static GTree *tree; +static GMutex tree_lock; +static gint pc_cmp(gconstpointer ap, gconstpointer bp, gpointer user_data) { const struct kzt_tbbridge *a = ap; const struct kzt_tbbridge *b = bp; + (void)user_data; + if (a->pc > b->pc) { return 1; } else if (a->pc < b->pc){ @@ -24,7 +27,11 @@ static gint pc_cmp(gconstpointer ap, gconstpointer bp) } void* kzt_tbbridge_init(void) { - tree = g_tree_new(pc_cmp); + g_mutex_lock(&tree_lock); + if (!tree) { + tree = g_tree_new_full(pc_cmp, NULL, free, NULL); + } + g_mutex_unlock(&tree_lock); lsassert(tree); return tree; } @@ -32,19 +39,32 @@ struct kzt_tbbridge* kzt_tbbridge_lookup(target_ulong pc) { lsassert(tree&&pc); struct kzt_tbbridge key = {.pc = pc}; - return (struct kzt_tbbridge *)g_tree_lookup(tree, &key); + g_mutex_lock(&tree_lock); + struct kzt_tbbridge *bridge = + (struct kzt_tbbridge *)g_tree_lookup(tree, &key); + g_mutex_unlock(&tree_lock); + return bridge; } int kzt_tbbridge_insert(target_ulong pc, ADDR func, void * wrapper) { lsassert(tree&&pc&&wrapper); - if (kzt_tbbridge_lookup(pc)) { - return 1; + struct kzt_tbbridge key = {.pc = pc}; + + g_mutex_lock(&tree_lock); + struct kzt_tbbridge *bridge = + (struct kzt_tbbridge *)g_tree_lookup(tree, &key); + if (bridge) { + int ret = (bridge->func == func && bridge->wrapper == wrapper) ? 1 : -1; + g_mutex_unlock(&tree_lock); + return ret; } struct kzt_tbbridge* new_tbbridge = malloc(sizeof(struct kzt_tbbridge)); + lsassert(new_tbbridge); new_tbbridge->pc = pc; new_tbbridge->func = func; new_tbbridge->wrapper = wrapper; g_tree_insert(tree, new_tbbridge, new_tbbridge); + g_mutex_unlock(&tree_lock); return 0; } diff --git a/target/i386/latx/include/box64context.h b/target/i386/latx/include/box64context.h index 489d1b79ad4..9cb2cae6032 100755 --- a/target/i386/latx/include/box64context.h +++ b/target/i386/latx/include/box64context.h @@ -47,13 +47,14 @@ typedef struct dlprivate_s { struct link_map *dlx86handle; size_t lib_sz; size_t lib_cap; - char* last_error; void * x86dlopen; void * x86dlclose; void * x86dlsym; void * x86dladdr1; void * x86dladdr; void * x86dlinfo; + void * x86dlvsym; + void * x86dlerror; } dlprivate_t; struct latx_kzt_debug { char *name; diff --git a/target/i386/latx/include/generated/wrappedlibctypes.h b/target/i386/latx/include/generated/wrappedlibctypes.h index 92258aa8e1c..6e6731ee6ac 100644 --- a/target/i386/latx/include/generated/wrappedlibctypes.h +++ b/target/i386/latx/include/generated/wrappedlibctypes.h @@ -100,6 +100,10 @@ typedef int32_t (*iFpppppp_t)(void*, void*, void*, void*, void*, void*); typedef void* (*pFpLiiil_t)(void*, uintptr_t, int32_t, int32_t, int32_t, intptr_t); typedef int32_t (*iFpippppp_t)(void*, int32_t, void*, void*, void*, void*, void*); typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void*); +typedef void* (*pFv_t)(void); +typedef int32_t (*iFpip_t)(void*, int32_t, void*); +typedef void* (*pFppi_t)(void*, void*, int32_t); +typedef int32_t (*iFpppi_t)(void*, void*, void*, int32_t); #ifndef CONFIG_LOONGARCH_NEW_WORLD #define SUPER() ADDED_FUNCTIONS() \ GO(_Jv_RegisterClasses, vFv_t) \ @@ -358,15 +362,6 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void* GO(__libc_start_main, iFpippppp_t) \ GO(clone, iFppipppp_t) #else -typedef int64_t (*iFp_t)(void*); -typedef void* (*pFv_t)(void); -typedef int64_t (*iFpp_t)(void*, void*); -typedef void* (*pFpi_t)(void*, int64_t); -typedef void* (*pFpp_t)(void*, void*); -typedef int64_t (*iFpip_t)(void*, int64_t, void*); -typedef void* (*pFppi_t)(void*, void*, int64_t); -typedef void* (*pFppp_t)(void*, void*, void*); -typedef int64_t (*iFpppi_t)(void*, void*, void*, int64_t); #define SUPER() ADDED_FUNCTIONS() \ GO(_Jv_RegisterClasses, vFv_t) \ GO(__cxa_pure_virtual, vFv_t) \ diff --git a/target/i386/latx/include/generated/wrappedlibdltypes.h b/target/i386/latx/include/generated/wrappedlibdltypes.h index ed802d2c3ee..2261bb8c355 100644 --- a/target/i386/latx/include/generated/wrappedlibdltypes.h +++ b/target/i386/latx/include/generated/wrappedlibdltypes.h @@ -8,15 +8,15 @@ #define ADDED_FUNCTIONS() #endif -typedef int64_t (*iFp_t)(void*); +typedef int32_t (*iFp_t)(void*); typedef void* (*pFv_t)(void); -typedef int64_t (*iFpp_t)(void*, void*); -typedef void* (*pFpi_t)(void*, int64_t); +typedef int32_t (*iFpp_t)(void*, void*); +typedef void* (*pFpi_t)(void*, int32_t); typedef void* (*pFpp_t)(void*, void*); -typedef int64_t (*iFpip_t)(void*, int64_t, void*); -typedef void* (*pFppi_t)(void*, void*, int64_t); +typedef int32_t (*iFpip_t)(void*, int32_t, void*); +typedef void* (*pFppi_t)(void*, void*, int32_t); typedef void* (*pFppp_t)(void*, void*, void*); -typedef int64_t (*iFpppi_t)(void*, void*, void*, int64_t); +typedef int32_t (*iFpppi_t)(void*, void*, void*, int32_t); #define SUPER() ADDED_FUNCTIONS() \ GO(dlclose, iFp_t) \ @@ -30,4 +30,3 @@ typedef int64_t (*iFpppi_t)(void*, void*, void*, int64_t); GO(dladdr1, iFpppi_t) #endif // __wrappedlibdlTYPES_H_ - From 1dea76eca139b7de4899aca1f9b12a77abca5a7a Mon Sep 17 00:00:00 2001 From: Hanlu Li Date: Thu, 13 Aug 2026 19:14:21 +0800 Subject: [PATCH 2/3] LATX, fix: Correct native wrapper ABIs Align X11, XCB, Xt, GL, GLX, EGL, and Vulkan signatures with their native prototypes. Preserve wide scalar and aggregate arguments, bridge custom callbacks and proc-address results, and keep generated tables and shared dispatchers consistent. Signed-off-by: Hanlu Li --- target/i386/latx/context/wrappedlibegl.c | 66 +++-- target/i386/latx/context/wrappedlibgl.c | 221 ++++++++++------ target/i386/latx/context/wrappedlibglx.c | 128 +++++---- target/i386/latx/context/wrappedlibx11.c | 12 +- target/i386/latx/context/wrappedlibxcb.c | 8 + target/i386/latx/context/wrappedlibxt.c | 15 +- target/i386/latx/context/wrappedvulkan.c | 77 ++++-- target/i386/latx/context/wrapper.c | 89 ++++++- .../include/generated/wrappedlibgltypes.h | 4 +- .../include/generated/wrappedlibglxtypes.h | 13 +- .../include/generated/wrappedlibxcbtypes.h | 3 +- .../include/generated/wrappedlibxttypes.h | 5 +- .../include/generated/wrappedvulkantypes.h | 4 +- .../i386/latx/include/wrappedlibgl_private.h | 243 +++++++++--------- .../i386/latx/include/wrappedlibglx_private.h | 37 ++- .../i386/latx/include/wrappedlibx11_private.h | 10 +- .../i386/latx/include/wrappedlibxcb_private.h | 22 +- .../latx/include/wrappedlibxcbrandr_private.h | 8 +- .../include/wrappedlibxcbrenderutil_private.h | 3 +- .../latx/include/wrappedlibxcbshm_private.h | 2 +- .../include/wrappedlibxcbxfixes_private.h | 2 +- .../include/wrappedlibxcbxinput_private.h | 8 +- .../i386/latx/include/wrappedlibxi_private.h | 4 +- .../latx/include/wrappedlibxrandr_private.h | 4 +- .../i386/latx/include/wrappedlibxss_private.h | 2 +- .../i386/latx/include/wrappedlibxt_private.h | 6 +- .../i386/latx/include/wrappedvulkan_private.h | 32 +-- target/i386/latx/include/wrapper.h | 44 ++++ 28 files changed, 680 insertions(+), 392 deletions(-) diff --git a/target/i386/latx/context/wrappedlibegl.c b/target/i386/latx/context/wrappedlibegl.c index 6b16a579519..5eb59d473ff 100644 --- a/target/i386/latx/context/wrappedlibegl.c +++ b/target/i386/latx/context/wrappedlibegl.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -28,6 +29,38 @@ const char* libeglName = "libEGL.so.1"; #include "generated/wrappedlibegltypes.h" #include "wrappercallback.h" +static char* make_proc_name(const char* prefix, const char* name, const char* suffix) +{ + const size_t prefix_len = strlen(prefix); + const size_t name_len = strlen(name); + const size_t suffix_len = strlen(suffix); + if(name_len > SIZE_MAX - prefix_len - suffix_len - 1) + return NULL; + char* result = (char*)malloc(prefix_len + name_len + suffix_len + 1); + if(!result) + return NULL; + memcpy(result, prefix, prefix_len); + memcpy(result + prefix_len, name, name_len); + memcpy(result + prefix_len + name_len, suffix, suffix_len + 1); + return result; +} + +static khint_t find_egl_wrapper(kh_symbolmap_t* wrappers, const char* rname) +{ + khint_t k = kh_get(symbolmap, wrappers, rname); + static const char* const suffixes[] = {"ARB", "EXT"}; + for(size_t i = 0; k == kh_end(wrappers) && i < sizeof(suffixes) / sizeof(suffixes[0]); ++i) { + if(strstr(rname, suffixes[i]) != NULL) + continue; + char* alternate = make_proc_name("", rname, suffixes[i]); + if(!alternate) + return kh_end(wrappers); + k = kh_get(symbolmap, wrappers, alternate); + free(alternate); + } + return k; +} + EXPORT void* my_eglGetProcAddress(void* name); EXPORT void* my_eglGetProcAddress(void* name) @@ -41,15 +74,18 @@ EXPORT void* my_eglGetProcAddress(void* name) // get proc adress using actual glXGetProcAddress k = kh_get(symbolmap, my_context->glmymap, rname); int is_my = (k==kh_end(my_context->glmymap))?0:1; - void* symbol; + void* native_symbol = my->eglGetProcAddress((void*)rname); + void* symbol = native_symbol; if(is_my) { // try again, by using custom "my_" now... - char tmp[200]; - strcpy(tmp, "my_"); - strcat(tmp, rname); - symbol = dlsym(my_context->box64lib, tmp); - } else - symbol = my->eglGetProcAddress((void*)rname); + if(!native_symbol) + symbol = NULL; + else { + char* alternate = make_proc_name("my_", rname, ""); + symbol = alternate ? dlsym(my_context->box64lib, alternate) : NULL; + free(alternate); + } + } if(!symbol) { if(relocation_logglwrappers, rname); - if(k==kh_end(my_context->glwrappers) && strstr(rname, "ARB")==NULL) { - // try again, adding ARB at the end if not present - char tmp[200]; - strcpy(tmp, rname); - strcat(tmp, "ARB"); - k = kh_get(symbolmap, my_context->glwrappers, tmp); - } - if(k==kh_end(my_context->glwrappers) && strstr(rname, "EXT")==NULL) { - // try again, adding EXT at the end if not present - char tmp[200]; - strcpy(tmp, rname); - strcat(tmp, "EXT"); - k = kh_get(symbolmap, my_context->glwrappers, tmp); - } + k = find_egl_wrapper(my_context->glwrappers, rname); if(k==kh_end(my_context->glwrappers)) { return NULL; } diff --git a/target/i386/latx/context/wrappedlibgl.c b/target/i386/latx/context/wrappedlibgl.c index 02e3faad3a9..32bcf52d0d7 100644 --- a/target/i386/latx/context/wrappedlibgl.c +++ b/target/i386/latx/context/wrappedlibgl.c @@ -7,8 +7,10 @@ */ #include +#include #include #include +#include #include #include "debug.h" @@ -134,11 +136,49 @@ typedef void* (*glprocaddress_t)(const char* name); void* getGLProcAddress(glprocaddress_t procaddr, const char* rname); EXPORT void* my_glXGetProcAddress(void* name); EXPORT void my_glDebugMessageCallback(void* prod, void* param); +EXPORT void my_glDebugMessageCallbackARB(void* prod, void* param); +EXPORT void my_glDebugMessageCallbackAMD(void* prod, void* param); +EXPORT void my_glDebugMessageCallbackKHR(void* prod, void* param); EXPORT int my_glXSwapIntervalMESA(int interval); -EXPORT void my_glProgramCallbackMESA(void* f, void* data); +EXPORT void my_glProgramCallbackMESA(uint32_t target, void* f, void* data); EXPORT void my_eglSetBlobCacheFuncsANDROID(void* dpy, void* set, void* get); EXPORT int my_eglDebugMessageControlKHR(void* prod, void* param); -//EXPORT void* my_glGetVkProcAddrNV(void* name); +EXPORT void* my_glGetVkProcAddrNV(void* name); + +static pFp_t host_glGetVkProcAddrNV = NULL; + +static char* make_proc_name(const char* prefix, const char* name, const char* suffix) +{ + const size_t prefix_len = strlen(prefix); + const size_t name_len = strlen(name); + const size_t suffix_len = strlen(suffix); + if(name_len > SIZE_MAX - prefix_len - suffix_len - 1) + return NULL; + char* result = (char*)malloc(prefix_len + name_len + suffix_len + 1); + if(!result) + return NULL; + memcpy(result, prefix, prefix_len); + memcpy(result + prefix_len, name, name_len); + memcpy(result + prefix_len + name_len, suffix, suffix_len + 1); + return result; +} + +static khint_t find_gl_wrapper(kh_symbolmap_t* wrappers, const char* rname) +{ + khint_t k = kh_get(symbolmap, wrappers, rname); + static const char* const suffixes[] = {"ARB", "EXT"}; + for(size_t i = 0; k == kh_end(wrappers) && i < sizeof(suffixes) / sizeof(suffixes[0]); ++i) { + if(strstr(rname, suffixes[i]) != NULL) + continue; + char* alternate = make_proc_name("", rname, suffixes[i]); + if(!alternate) + return kh_end(wrappers); + k = kh_get(symbolmap, wrappers, alternate); + free(alternate); + } + return k; +} + EXPORT void* my_glXGetProcAddress(void* name) { /* @@ -155,17 +195,22 @@ EXPORT void* my_glXGetProcAddress(void* name) // get proc adress using actual glXGetProcAddress k = kh_get(symbolmap, my_context->glmymap, rname); int is_my = (k==kh_end(my_context->glmymap))?0:1; - void* symbol = NULL; + void* native_symbol = NULL; + if (my_context->glxprocaddress) + native_symbol = my_context->glxprocaddress(rname); + if(latx_wine && !native_symbol) + native_symbol = dlsym(my_context->box64lib, rname); + void* symbol = native_symbol; if(is_my) { - // try again, by using custom "my_" now... - char tmp[200]; - strcpy(tmp, "my_"); - strcat(tmp, rname); - symbol = dlsym(my_context->box64lib, tmp); - } else { - if (my_context->glxprocaddress) symbol = my_context->glxprocaddress(rname); - if(latx_wine &&!symbol) {//hacking for wine64 - symbol = dlsym(my_context->box64lib, rname); + // A custom wrapper is valid only when the native implementation exists. + if(!native_symbol) + symbol = NULL; + else { + if(!strcmp(rname, "glGetVkProcAddrNV")) + host_glGetVkProcAddrNV = (pFp_t)native_symbol; + char* alternate = make_proc_name("my_", rname, ""); + symbol = alternate ? dlsym(my_context->box64lib, alternate) : NULL; + free(alternate); } } if(!symbol) { @@ -179,21 +224,7 @@ EXPORT void* my_glXGetProcAddress(void* name) return (void*)ret; // already bridged } // get wrapper - k = kh_get(symbolmap, my_context->glwrappers, rname); - if(k==kh_end(my_context->glwrappers) && strstr(rname, "ARB")==NULL) { - // try again, adding ARB at the end if not present - char tmp[200]; - strcpy(tmp, rname); - strcat(tmp, "ARB"); - k = kh_get(symbolmap, my_context->glwrappers, tmp); - } - if(k==kh_end(my_context->glwrappers) && strstr(rname, "EXT")==NULL) { - // try again, adding EXT at the end if not present - char tmp[200]; - strcpy(tmp, rname); - strcat(tmp, "EXT"); - k = kh_get(symbolmap, my_context->glwrappers, tmp); - } + k = find_gl_wrapper(my_context->glwrappers, rname); if(k==kh_end(my_context->glwrappers)) { printf_dlsym(LOG_DEBUG, "%p\n", NULL); printf_dlsym(LOG_INFO, "Warning, no wrapper for %s\n", rname); @@ -257,6 +288,30 @@ static void* find_debug_callback_Fct(void* fct) return NULL; } +// GLDEBUGPROCAMD has six arguments, unlike the seven-argument core/ARB/KHR callback. +#define GO(A) \ +static uintptr_t my_debug_amd_callback_fct_##A = 0; \ +static void my_debug_amd_callback_##A(uint32_t a, uint32_t b, uint32_t c, int32_t d, const char* e, const void* f) \ +{ \ + RunFunctionWithState(my_debug_amd_callback_fct_##A, 6, a, b, c, d, e, f); \ +} +SUPER() +#undef GO + +static void* find_debug_amd_callback_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_debug_amd_callback_fct_##A == (uintptr_t)fct) return my_debug_amd_callback_##A; + SUPER() + #undef GO + #define GO(A) if(my_debug_amd_callback_fct_##A == 0) {my_debug_amd_callback_fct_##A = (uintptr_t)fct; return my_debug_amd_callback_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for libGL AMD debug callback\n"); + return NULL; +} + // program_callback ... #define GO(A) \ static uintptr_t my_program_callback_fct_##A = 0; \ @@ -330,7 +385,7 @@ static void* find_glXSwapIntervalMESA_Fct(void* fct) // set_blob_func ... #define GO(A) \ static uintptr_t my_set_blob_func_fct_##A = 0; \ -static void my_set_blob_func_##A(const void* a, int32_t b, const void* c, int32_t d) \ +static void my_set_blob_func_##A(const void* a, ssize_t b, const void* c, ssize_t d) \ { \ RunFunctionWithState(my_set_blob_func_fct_##A, 4, a, b, c, d); \ } @@ -354,9 +409,9 @@ static void* find_set_blob_func_Fct(void* fct) // get_blob_func ... #define GO(A) \ static uintptr_t my_get_blob_func_fct_##A = 0; \ -static int32_t my_get_blob_func_##A(const void* a, int32_t b, void* c, int32_t d) \ +static ssize_t my_get_blob_func_##A(const void* a, ssize_t b, void* c, ssize_t d) \ { \ - return (int32_t)RunFunctionWithState(my_get_blob_func_fct_##A, 4, a, b, c, d); \ + return (ssize_t)RunFunctionWithState(my_get_blob_func_fct_##A, 4, a, b, c, d); \ } SUPER() #undef GO @@ -377,23 +432,41 @@ static void* find_get_blob_func_Fct(void* fct) #undef SUPER +static vFpp_t get_debug_message_callback(const char* name, vFpp_t fallback) +{ + vFpp_t callback = NULL; + if(my_context && my_context->glxprocaddress) + callback = (vFpp_t)my_context->glxprocaddress(name); + return callback ? callback : fallback; +} + EXPORT void my_glDebugMessageCallback(void* prod, void* param) { - static vFpp_t DebugMessageCallback = NULL; - static int init = 1; - if(init) { - //fix: glxprocaddress is working ? - DebugMessageCallback = my_context->glxprocaddress("glDebugMessageCallback"); - init = 0; - } - if(!DebugMessageCallback) - return; - DebugMessageCallback(find_debug_callback_Fct(prod), param); + vFpp_t callback = get_debug_message_callback("glDebugMessageCallback", my->glDebugMessageCallback); + if(callback) + callback(find_debug_callback_Fct(prod), param); +} + +EXPORT void my_glDebugMessageCallbackARB(void* prod, void* param) +{ + vFpp_t callback = get_debug_message_callback("glDebugMessageCallbackARB", my->glDebugMessageCallbackARB); + if(callback) + callback(find_debug_callback_Fct(prod), param); } -EXPORT void my_glDebugMessageCallbackARB(void* prod, void* param) __attribute__((alias("my_glDebugMessageCallback"))); -EXPORT void my_glDebugMessageCallbackAMD(void* prod, void* param) __attribute__((alias("my_glDebugMessageCallback"))); -EXPORT void my_glDebugMessageCallbackKHR(void* prod, void* param) __attribute__((alias("my_glDebugMessageCallback"))); +EXPORT void my_glDebugMessageCallbackKHR(void* prod, void* param) +{ + vFpp_t callback = get_debug_message_callback("glDebugMessageCallbackKHR", my->glDebugMessageCallbackKHR); + if(callback) + callback(find_debug_callback_Fct(prod), param); +} + +EXPORT void my_glDebugMessageCallbackAMD(void* prod, void* param) +{ + vFpp_t callback = get_debug_message_callback("glDebugMessageCallbackAMD", my->glDebugMessageCallbackAMD); + if(callback) + callback(find_debug_amd_callback_Fct(prod), param); +} EXPORT int my_glXSwapIntervalMESA(int interval) { @@ -408,9 +481,9 @@ EXPORT int my_glXSwapIntervalMESA(int interval) return SwapIntervalMESA(interval); } -EXPORT void my_glProgramCallbackMESA(void* f, void* data) +EXPORT void my_glProgramCallbackMESA(uint32_t target, void* f, void* data) { - static vFpp_t ProgramCallbackMESA = NULL; + static vFipp_t ProgramCallbackMESA = NULL; static int init = 1; if(init) { ProgramCallbackMESA = my_context->glxprocaddress("glProgramCallbackMESA"); @@ -418,7 +491,7 @@ EXPORT void my_glProgramCallbackMESA(void* f, void* data) } if(!ProgramCallbackMESA) return; - ProgramCallbackMESA(find_program_callback_Fct(f), data); + ProgramCallbackMESA(target, find_program_callback_Fct(f), data); } EXPORT void my_eglSetBlobCacheFuncsANDROID(void* dpy, void* set, void* get) @@ -453,26 +526,21 @@ EXPORT void* my_glXCreateContextAttribsARB(my_XDisplay_t* dpy, void* v2, void*v3 latx_dpy_xcb_sync(dpy); return ret; } -EXPORT int32_t my_glXMakeCurrent(my_XDisplay_t*, void*, void*); -EXPORT int32_t my_glXMakeCurrent(my_XDisplay_t* dpy, void* v2, void* v3) +EXPORT int32_t my_glXMakeCurrent(my_XDisplay_t*, unsigned long, void*); +EXPORT int32_t my_glXMakeCurrent(my_XDisplay_t* dpy, unsigned long v2, void* v3) { int32_t ret = my->glXMakeCurrent(dpy,v2,v3); latx_dpy_xcb_sync(dpy); return ret; } -#if 0 -void* my_GetVkProcAddr(void* name, void*(*getaddr)(void*)); // defined in wrappedvulkan.c +void* my_GetVkProcAddr(void* name, void*(*getaddr)(const char*)); // defined in wrappedvulkan.c EXPORT void* my_glGetVkProcAddrNV(void* name) { - static pFp_t GetVkProcAddrNV = NULL; - static int init = 1; - if(init) { - GetVkProcAddrNV = my_context->glxprocaddress("glGetVkProcAddrNV"); - init = 0; - } - return my_GetVkProcAddr(name, GetVkProcAddrNV); + pFp_t getaddr = host_glGetVkProcAddrNV ? host_glGetVkProcAddrNV : my->glGetVkProcAddrNV; + if(!getaddr && my_context && my_context->glxprocaddress) + getaddr = (pFp_t)my_context->glxprocaddress("glGetVkProcAddrNV"); + return getaddr ? my_GetVkProcAddr(name, (void*(*)(const char*))getaddr) : NULL; } -#endif #define PRE_INIT if(libGL) {lib->priv.w.lib = dlopen(libGL, RTLD_LAZY | RTLD_GLOBAL); lib->path = strdup(libGL);} else #define CUSTOM_INIT \ @@ -578,25 +646,30 @@ void* getGLProcAddress(glprocaddress_t procaddr, const char* rname) // get proc adress using actual glXGetProcAddress k = kh_get(symbolmap, wrappers->glmymap, rname); int is_my = (k==kh_end(wrappers->glmymap))?0:1; - void* symbol; + void* native_symbol = procaddr ? procaddr(rname) : NULL; + void* symbol = native_symbol; if(is_my) { // try again, by using custom "my_" now... - #define GO(A, B) else if(!strcmp(rname, #B)) symbol = find_##B##_Fct(procaddr(rname)); + #define GO(A, B) else if(!strcmp(rname, #B)) symbol = find_##B##_Fct(native_symbol); if(0) {} SUPER() else { if(strcmp(rname, "glXGetProcAddress") && strcmp(rname, "glXGetProcAddressARB")) { printf_log(LOG_NONE, "Warning, %s defined as GOM, but find_%s_Fct not defined\n", rname, rname); } - char tmp[200]; - strcpy(tmp, "my_"); - strcat(tmp, rname); - symbol = dlsym(my_context->box64lib, tmp); + if(!native_symbol) + symbol = NULL; + else { + if(!strcmp(rname, "glGetVkProcAddrNV")) + host_glGetVkProcAddrNV = (pFp_t)native_symbol; + char* alternate = make_proc_name("my_", rname, ""); + symbol = alternate ? dlsym(my_context->box64lib, alternate) : NULL; + free(alternate); + } } #undef GO #undef SUPER - } else - symbol = procaddr(rname); + } if(!symbol) { printf_dlsym(LOG_DEBUG, "%p\n", NULL); return NULL; // easy @@ -608,21 +681,7 @@ void* getGLProcAddress(glprocaddress_t procaddr, const char* rname) return (void*)ret; // already bridged } // get wrapper - k = kh_get(symbolmap, wrappers->glwrappers, rname); - if(k==kh_end(wrappers->glwrappers) && strstr(rname, "ARB")==NULL) { - // try again, adding ARB at the end if not present - char tmp[200]; - strcpy(tmp, rname); - strcat(tmp, "ARB"); - k = kh_get(symbolmap, wrappers->glwrappers, tmp); - } - if(k==kh_end(wrappers->glwrappers) && strstr(rname, "EXT")==NULL) { - // try again, adding EXT at the end if not present - char tmp[200]; - strcpy(tmp, rname); - strcat(tmp, "EXT"); - k = kh_get(symbolmap, wrappers->glwrappers, tmp); - } + k = find_gl_wrapper(wrappers->glwrappers, rname); if(k==kh_end(wrappers->glwrappers)) { printf_dlsym(LOG_DEBUG, "%p\n", NULL); printf_dlsym(LOG_INFO, "Warning, no wrapper for %s\n", rname); diff --git a/target/i386/latx/context/wrappedlibglx.c b/target/i386/latx/context/wrappedlibglx.c index 16e58cac21b..00c5f60e0a8 100644 --- a/target/i386/latx/context/wrappedlibglx.c +++ b/target/i386/latx/context/wrappedlibglx.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -27,50 +28,71 @@ const char* libglxName = "libGLX.so.0"; #include "generated/wrappedlibglxtypes.h" #include "wrappercallback.h" -EXPORT void my_glXDestroyContext(void* dpy, void* v2); -EXPORT void my_glXDestroyContext(void* dpy, void* v2) +EXPORT void myx_glXDestroyContext(void* dpy, void* v2); +EXPORT void myx_glXDestroyContext(void* dpy, void* v2) { my->glXDestroyContext(dpy,v2); latx_dpy_xcb_sync(dpy); } -EXPORT void my_glXDestroyPbuffer(void* dpy, void* v2); -EXPORT void my_glXDestroyPbuffer(void* dpy, void* v2) +EXPORT void myx_glXDestroyPbuffer(void* dpy, unsigned long v2); +EXPORT void myx_glXDestroyPbuffer(void* dpy, unsigned long v2) { - my->glXDestroyPbuffer(dpy,v2); + my->glXDestroyPbuffer(dpy, v2); latx_dpy_xcb_sync(dpy); } -EXPORT void* my_glXCreatePbuffer(void* dpy, void* v2, void* v3); -EXPORT void* my_glXCreatePbuffer(void* dpy, void* v2, void* v3) +EXPORT unsigned long myx_glXCreatePbuffer(void* dpy, void* v2, void* v3); +EXPORT unsigned long myx_glXCreatePbuffer(void* dpy, void* v2, void* v3) { - void* ret = my->glXCreatePbuffer(dpy,v2, v3); + unsigned long ret = my->glXCreatePbuffer(dpy,v2, v3); latx_dpy_xcb_sync(dpy); return ret; } -EXPORT int32_t my_glXMakeContextCurrent(void* dpy, void* v2, void* v3, void* v4); -EXPORT int32_t my_glXMakeContextCurrent(void* dpy, void* v2, void* v3, void* v4) +EXPORT int32_t myx_glXMakeContextCurrent(void* dpy, unsigned long v2, unsigned long v3, void* v4); +EXPORT int32_t myx_glXMakeContextCurrent(void* dpy, unsigned long v2, unsigned long v3, void* v4) { - int32_t ret = my->glXMakeContextCurrent(dpy,v2, v3, v4); + int32_t ret = my->glXMakeContextCurrent(dpy, v2, v3, v4); latx_dpy_xcb_sync(dpy); return ret; } -EXPORT void* my_glXCreateNewContext(void*, void*, int32_t, void*, int32_t); -EXPORT void* my_glXCreateNewContext(void* v1, void* v2, int32_t v3, void* v4, int32_t v5) +EXPORT void* myx_glXCreateNewContext(void*, void*, int32_t, void*, int32_t); +EXPORT void* myx_glXCreateNewContext(void* v1, void* v2, int32_t v3, void* v4, int32_t v5) { void* ret = my->glXCreateNewContext(v1,v2, v3, v4, v5); latx_dpy_xcb_sync(v1); return ret; } +EXPORT int32_t myx_glXMakeCurrent(void* dpy, unsigned long drawable, void* context); +EXPORT int32_t myx_glXMakeCurrent(void* dpy, unsigned long drawable, void* context) +{ + if(!my->glXMakeCurrent) + return 0; + int32_t ret = my->glXMakeCurrent(dpy, drawable, context); + latx_dpy_xcb_sync(dpy); + return ret; +} + +// libGL.so.1 shares these synchronization wrappers under the regular my_ prefix. +EXPORT void my_glXDestroyContext(void* dpy, void* context) __attribute__((alias("myx_glXDestroyContext"))); +EXPORT void my_glXDestroyPbuffer(void* dpy, unsigned long pbuffer) __attribute__((alias("myx_glXDestroyPbuffer"))); +EXPORT unsigned long my_glXCreatePbuffer(void* dpy, void* config, void* attributes) __attribute__((alias("myx_glXCreatePbuffer"))); +EXPORT int32_t my_glXMakeContextCurrent(void* dpy, unsigned long draw, unsigned long read, void* context) __attribute__((alias("myx_glXMakeContextCurrent"))); + +static void freeGLXProcWrapper(void); + #define CUSTOM_INIT \ - getMy(lib); + getMy(lib); \ + SETALT(myx_); \ + if (!box64->glxprocaddress) \ + box64->glxprocaddress = (procaddess_t)my->glXGetProcAddress; #define CUSTOM_FINI \ + freeGLXProcWrapper(); \ freeMy(); #include "wrappedlib_init.h" -#if 0 #define SUPER() \ GO(0) \ GO(1) \ @@ -80,14 +102,6 @@ GO(3) \ #undef SUPER -#define CUSTOM_INIT \ - getMy(lib); \ - SETALT(myx_); \ - -#define CUSTOM_FINI \ - freeMy(); - - typedef void* (*glprocaddress_t)(const char* name); typedef struct gl_wrappers_s { @@ -101,7 +115,7 @@ KHASH_MAP_INIT_INT64(gl_wrappers, gl_wrappers_t*) static kh_gl_wrappers_t *gl_wrappers = NULL; -gl_wrappers_t* getGLProcWrapper(glprocaddress_t procaddress) +static gl_wrappers_t* getGLXProcWrapper(glprocaddress_t procaddress) { int cnt, ret; khint_t k; @@ -136,7 +150,7 @@ gl_wrappers_t* getGLProcWrapper(glprocaddress_t procaddress) } return wrappers; } -void freeGLProcWrapper() +static void freeGLXProcWrapper(void) { if(!gl_wrappers) return; @@ -148,21 +162,23 @@ void freeGLProcWrapper() kh_destroy(symbolmap, wrappers->glmymap); wrappers->glwrappers = NULL; wrappers->glmymap = NULL; + free(wrappers); ); kh_destroy(gl_wrappers, gl_wrappers); gl_wrappers = NULL; } -void* getGLProcAddress(glprocaddress_t procaddr, const char* rname) +static void* getGLXProcAddress(glprocaddress_t procaddr, const char* rname) { khint_t k; printf_dlsym(LOG_DEBUG, "Calling getGLProcAddress[%p](\"%s\") => ", procaddr, rname); - gl_wrappers_t* wrappers = getGLProcWrapper(procaddr); + gl_wrappers_t* wrappers = getGLXProcWrapper(procaddr); // check if glxprocaddress is filled, and search for lib and fill it if needed // get proc adress using actual glXGetProcAddress k = kh_get(symbolmap, wrappers->glmymap, rname); int is_my = (k==kh_end(wrappers->glmymap))?0:1; - void* symbol; + void* native_symbol = procaddr ? procaddr(rname) : NULL; + void* symbol = native_symbol; if(is_my) { // try again, by using custom "my_" now... #define GO(A, B) else if(!strcmp(rname, #B)) symbol = find_##B##_Fct(procaddr(rname)); @@ -172,15 +188,22 @@ void* getGLProcAddress(glprocaddress_t procaddr, const char* rname) if(strcmp(rname, "glXGetProcAddress") && strcmp(rname, "glXGetProcAddressARB")) { printf_log(LOG_NONE, "Warning, %s defined as GOM, but find_%s_Fct not defined\n", rname, rname); } - char tmp[200]; - strcpy(tmp, "my_"); - strcat(tmp, rname); + if(!native_symbol) + return NULL; + size_t length = strlen(rname); + if(length > SIZE_MAX - 5) + return NULL; + char* tmp = (char*)malloc(length + 5); + if(!tmp) + return NULL; + memcpy(tmp, "myx_", 4); + memcpy(tmp + 4, rname, length + 1); symbol = dlsym(my_context->box64lib, tmp); + free(tmp); //} #undef GO #undef SUPER - } else - symbol = procaddr(rname); + } if(!symbol) { printf_dlsym(LOG_DEBUG, "%p\n", NULL); return NULL; // easy @@ -195,17 +218,29 @@ void* getGLProcAddress(glprocaddress_t procaddr, const char* rname) k = kh_get(symbolmap, wrappers->glwrappers, rname); if(k==kh_end(wrappers->glwrappers) && strstr(rname, "ARB")==NULL) { // try again, adding ARB at the end if not present - char tmp[200]; - strcpy(tmp, rname); - strcat(tmp, "ARB"); - k = kh_get(symbolmap, wrappers->glwrappers, tmp); + size_t length = strlen(rname); + if(length > SIZE_MAX - 4) + return NULL; + char* tmp = (char*)malloc(length + 4); + if(tmp) { + memcpy(tmp, rname, length); + memcpy(tmp + length, "ARB", 4); + k = kh_get(symbolmap, wrappers->glwrappers, tmp); + free(tmp); + } } if(k==kh_end(wrappers->glwrappers) && strstr(rname, "EXT")==NULL) { // try again, adding EXT at the end if not present - char tmp[200]; - strcpy(tmp, rname); - strcat(tmp, "EXT"); - k = kh_get(symbolmap, wrappers->glwrappers, tmp); + size_t length = strlen(rname); + if(length > SIZE_MAX - 4) + return NULL; + char* tmp = (char*)malloc(length + 4); + if(tmp) { + memcpy(tmp, rname, length); + memcpy(tmp + length, "EXT", 4); + k = kh_get(symbolmap, wrappers->glwrappers, tmp); + free(tmp); + } } if(k==kh_end(wrappers->glwrappers)) { printf_dlsym(LOG_DEBUG, "%p\n", NULL); @@ -219,19 +254,16 @@ void* getGLProcAddress(glprocaddress_t procaddr, const char* rname) return (void*)ret; } +EXPORT void* myx_glXGetProcAddress(void* name); EXPORT void* myx_glXGetProcAddress(void* name) { - khint_t k; const char* rname = (const char*)name; - return getGLProcAddress((glprocaddress_t)my->glXGetProcAddress, rname); + return getGLXProcAddress((glprocaddress_t)my->glXGetProcAddress, rname); } +EXPORT void* myx_glXGetProcAddressARB(void* name); EXPORT void* myx_glXGetProcAddressARB(void* name) { - khint_t k; const char* rname = (const char*)name; - return getGLProcAddress((glprocaddress_t)my->glXGetProcAddressARB, rname); + return getGLXProcAddress((glprocaddress_t)my->glXGetProcAddressARB, rname); } - - -#endif diff --git a/target/i386/latx/context/wrappedlibx11.c b/target/i386/latx/context/wrappedlibx11.c index f316df68486..a729112dcbd 100644 --- a/target/i386/latx/context/wrappedlibx11.c +++ b/target/i386/latx/context/wrappedlibx11.c @@ -871,7 +871,7 @@ void* my_XGetSubImage(void* disp, void* drawable , uint32_t w, uint32_t h, uintptr_t plane, int32_t fmt , void* image, int32_t dst_x, int32_t dst_y); -void my_XDestroyImage(void* image); +int32_t my_XDestroyImage(void* image); #ifdef PANDORA void* my_XLoadQueryFont(void* d, void* name); @@ -1255,7 +1255,7 @@ EXPORT void* my_XGetSubImage(void* disp, void* drawable return img; } -EXPORT void my_XDestroyImage(void* image) +EXPORT int32_t my_XDestroyImage(void* image) { UnbridgeImageFunc((XImage*)image); @@ -1269,7 +1269,7 @@ EXPORT void my_XDestroyImage(void* image) RunFunctionWithState((uintptr_t)x86free ,1, img->data); img->data = la_data; } - my->XDestroyImage(image); + return my->XDestroyImage(image); } typedef struct xintasync_s { @@ -1660,11 +1660,11 @@ EXPORT int32_t my_XNextEvent(my_XDisplay_t *dpy, void* v2) return ret; } -EXPORT void my_XPending(my_XDisplay_t* dpy); -EXPORT void my_XPending(my_XDisplay_t* dpy) +EXPORT int32_t my_XPending(my_XDisplay_t* dpy); +EXPORT int32_t my_XPending(my_XDisplay_t* dpy) { bridge_XInternalAsyncHandlers(dpy, findXPendingAsyncHandlerFct); - my->XPending(dpy); + return my->XPending(dpy); } EXPORT int32_t my_XGetWindowProperty(my_XDisplay_t* dpy, void* v2, void* v3, intptr_t v4, intptr_t v5, int32_t v6, void* v7, void* v8, void* v9, void* v10, void* v11, void* v12); EXPORT int32_t my_XGetWindowProperty(my_XDisplay_t* dpy, void* v2, void* v3, intptr_t v4, intptr_t v5, int32_t v6, void* v7, void* v8, void* v9, void* v10, void* v11, void* v12) diff --git a/target/i386/latx/context/wrappedlibxcb.c b/target/i386/latx/context/wrappedlibxcb.c index 68bfdcaaffa..016d91515a7 100644 --- a/target/i386/latx/context/wrappedlibxcb.c +++ b/target/i386/latx/context/wrappedlibxcb.c @@ -91,6 +91,14 @@ EXPORT void* my_xcb_connect(void* dispname, void* screen) return add_xcb_connection(my->xcb_connect(dispname, screen)); } +EXPORT void* my_xcb_connect_to_display_with_auth_info(void* dispname, + void* auth, + void* screen) +{ + return add_xcb_connection( + my->xcb_connect_to_display_with_auth_info(dispname, auth, screen)); +} + EXPORT void my_xcb_disconnect(void* conn) { my->xcb_disconnect(align_xcb_connection(conn)); diff --git a/target/i386/latx/context/wrappedlibxt.c b/target/i386/latx/context/wrappedlibxt.c index d96ecce7305..5e2ad661db6 100644 --- a/target/i386/latx/context/wrappedlibxt.c +++ b/target/i386/latx/context/wrappedlibxt.c @@ -48,9 +48,9 @@ GO(7) // Event #define GO(A) \ static uintptr_t my_Event_fct_##A = 0; \ -static void my_Event_##A(void* w, void* data, void* event) \ -{ \ - RunFunctionWithState(my_Event_fct_##A, 3, w, data, event);\ +static void my_Event_##A(void* w, void* data, void* event, void* cont) \ +{ \ + RunFunctionWithState(my_Event_fct_##A, 4, w, data, event, cont); \ } SUPER() #undef GO @@ -114,12 +114,19 @@ static void* findInputCallbackFct(void* fct) #undef SUPER -EXPORT void my_XtAddEventHandler(void* w, uint32_t mask, int32_t maskable, void* cb, void* data) +EXPORT void my_XtAddEventHandler(void* w, uintptr_t mask, int32_t maskable, void* cb, void* data) { void* fct = findEventFct(cb); my->XtAddEventHandler(w, mask, maskable, fct, data); } +EXPORT void my_XtRemoveEventHandler(void* w, uintptr_t mask, + int32_t maskable, void* cb, void* data) +{ + void* fct = findEventFct(cb); + my->XtRemoveEventHandler(w, mask, maskable, fct, data); +} + EXPORT long my_XtAppAddWorkProc(void* context, void* proc, void* data) { return my->XtAppAddWorkProc(context, findWorkProcFct(proc), data); diff --git a/target/i386/latx/context/wrappedvulkan.c b/target/i386/latx/context/wrappedvulkan.c index e3b9a4389b0..fd77fae8f58 100644 --- a/target/i386/latx/context/wrappedvulkan.c +++ b/target/i386/latx/context/wrappedvulkan.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -54,15 +55,32 @@ static void updateInstance(vulkan_my_t* my) void fillVulkanProcWrapper(box64context_t*); void freeVulkanProcWrapper(box64context_t*); -static symbol1_t* getWrappedSymbol(const char* rname, int warning) +static char* make_proc_name(const char* prefix, const char* name, const char* suffix) +{ + const size_t prefix_len = strlen(prefix); + const size_t name_len = strlen(name); + const size_t suffix_len = strlen(suffix); + if(name_len > SIZE_MAX - prefix_len - suffix_len - 1) + return NULL; + char* result = (char*)malloc(prefix_len + name_len + suffix_len + 1); + if(!result) + return NULL; + memcpy(result, prefix, prefix_len); + memcpy(result + prefix_len, name, name_len); + memcpy(result + prefix_len + name_len, suffix, suffix_len + 1); + return result; +} + +static symbol1_t* getWrappedSymbol(const char* rname, int warning, const char** constname) { khint_t k = kh_get(symbol1map, my_context->vkwrappers, rname); if(k==kh_end(my_context->vkwrappers) && strstr(rname, "KHR")==NULL) { // try again, adding KHR at the end if not present - char tmp[200]; - strcpy(tmp, rname); - strcat(tmp, "KHR"); - k = kh_get(symbol1map, my_context->vkwrappers, tmp); + char* alternate = make_proc_name("", rname, "KHR"); + if(alternate) { + k = kh_get(symbol1map, my_context->vkwrappers, alternate); + free(alternate); + } } if(k==kh_end(my_context->vkwrappers)) { if(warning) { @@ -71,16 +89,19 @@ static symbol1_t* getWrappedSymbol(const char* rname, int warning) } return NULL; } + if(constname) + *constname = kh_key(my_context->vkwrappers, k); return &kh_value(my_context->vkwrappers, k); } static void* resolveSymbol(void* symbol, const char* rname) { // get wrapper - symbol1_t *s = getWrappedSymbol(rname, 1); + const char* constname = NULL; + symbol1_t *s = getWrappedSymbol(rname, 1, &constname); + if(!s) + return NULL; if(!s->resolved) { - khint_t k = kh_get(symbol1map, my_context->vkwrappers, rname); - const char* constname = kh_key(my_context->vkwrappers, k); s->addr = AddCheckBridge(my_context->system, s->w, symbol, 0, constname); s->resolved = 1; } @@ -97,7 +118,7 @@ EXPORT void* my_vkGetDeviceProcAddr(void* device, void* name) printf_dlsym(LOG_DEBUG, "Calling my_vkGetDeviceProcAddr(%p, \"%s\") => ", device, rname); if(!my_context->vkwrappers) fillVulkanProcWrapper(my_context); - symbol1_t* s = getWrappedSymbol(rname, 0); + symbol1_t* s = getWrappedSymbol(rname, 0, NULL); if(s && s->resolved) { void* ret = (void*)s->addr; printf_dlsym(LOG_DEBUG, "%p (cached)\n", ret); @@ -108,10 +129,9 @@ EXPORT void* my_vkGetDeviceProcAddr(void* device, void* name) void* symbol = my->vkGetDeviceProcAddr(device, name); if(symbol && is_my) { // only wrap if symbol exist // try again, by using custom "my_" now... - char tmp[200]; - strcpy(tmp, "my_"); - strcat(tmp, rname); - symbol = dlsym(my_context->box64lib, tmp); + char* alternate = make_proc_name("my_", rname, ""); + symbol = alternate ? dlsym(my_context->box64lib, alternate) : NULL; + free(alternate); // need to update symbol link maybe #define GO(A, W) if(!strcmp(rname, #A)) my->A = (W)my->vkGetDeviceProcAddr(device, name); SUPER() @@ -136,7 +156,7 @@ EXPORT void* my_vkGetInstanceProcAddr(void* instance, void* name) my->currentInstance = instance; updateInstance(my); } - symbol1_t* s = getWrappedSymbol(rname, 0); + symbol1_t* s = getWrappedSymbol(rname, 0, NULL); if(s && s->resolved) { void* ret = (void*)s->addr; printf_dlsym(LOG_DEBUG, "%p (cached)\n", ret); @@ -153,15 +173,18 @@ EXPORT void* my_vkGetInstanceProcAddr(void* instance, void* name) } if(is_my) { // try again, by using custom "my_" now... - char tmp[200]; - strcpy(tmp, "my_"); - strcat(tmp, rname); - symbol = dlsym(my_context->box64lib, tmp); + char* alternate = make_proc_name("my_", rname, ""); + symbol = alternate ? dlsym(my_context->box64lib, alternate) : NULL; + free(alternate); // need to update symbol link maybe #define GO(A, W) if(!strcmp(rname, #A)) my->A = (W)my_context->vkprocaddress(instance, rname);; SUPER() #undef GO } + if(!symbol) { + printf_dlsym(LOG_DEBUG, "%p\n", NULL); + return NULL; + } return resolveSymbol(symbol, rname); } @@ -173,7 +196,7 @@ void* my_GetVkProcAddr(void* name, void*(*getaddr)(const char*)) printf_dlsym(LOG_DEBUG, "Calling my_GetVkProcAddr(\"%s\", %p) => ", rname, getaddr); if(!my_context->vkwrappers) fillVulkanProcWrapper(my_context); - symbol1_t* s = getWrappedSymbol(rname, 0); + symbol1_t* s = getWrappedSymbol(rname, 0, NULL); if(s && s->resolved) { void* ret = (void*)s->addr; printf_dlsym(LOG_DEBUG, "%p (cached)\n", ret); @@ -190,15 +213,18 @@ void* my_GetVkProcAddr(void* name, void*(*getaddr)(const char*)) } if(is_my) { // try again, by using custom "my_" now... - char tmp[200]; - strcpy(tmp, "my_"); - strcat(tmp, rname); - symbol = dlsym(my_context->box64lib, tmp); + char* alternate = make_proc_name("my_", rname, ""); + symbol = alternate ? dlsym(my_context->box64lib, alternate) : NULL; + free(alternate); // need to update symbol link maybe #define GO(A, W) if(!strcmp(rname, #A)) my->A = (W)getaddr(rname); SUPER() #undef GO } + if(!symbol) { + printf_dlsym(LOG_DEBUG, "%p\n", NULL); + return NULL; + } return resolveSymbol(symbol, rname); } @@ -585,6 +611,7 @@ CREATE(vkCreateQueryPool) CREATE(vkCreateRenderPass) CREATE(vkCreateSampler) CREATE(vkCreateSamplerYcbcrConversion) +CREATE(vkCreateSamplerYcbcrConversionKHR) CREATE(vkCreateSemaphore) CREATE(vkCreateShaderModule) @@ -801,10 +828,10 @@ EXPORT int my_vkCreateDebugReportCallbackEXT(void* instance, return my->vkCreateDebugReportCallbackEXT(instance, &dbg, find_VkAllocationCallbacks(&my_alloc, alloc), callback); } -EXPORT int my_vkDestroyDebugReportCallbackEXT(void* instance, void* callback, void* alloc) +EXPORT void my_vkDestroyDebugReportCallbackEXT(void* instance, void* callback, void* alloc) { my_VkAllocationCallbacks_t my_alloc; - return my->vkDestroyDebugReportCallbackEXT(instance, callback, find_VkAllocationCallbacks(&my_alloc, alloc)); + my->vkDestroyDebugReportCallbackEXT(instance, callback, find_VkAllocationCallbacks(&my_alloc, alloc)); } #define VK_ICD_WSI_PLATFORM_WAYLAND 1 #define VK_ICD_WSI_PLATFORM_XCB 3 diff --git a/target/i386/latx/context/wrapper.c b/target/i386/latx/context/wrapper.c index 05a27892353..0696386d268 100644 --- a/target/i386/latx/context/wrapper.c +++ b/target/i386/latx/context/wrapper.c @@ -269,6 +269,7 @@ typedef int32_t (*iFuUu_t)(uint32_t, uint64_t, uint32_t); typedef int32_t (*iFuff_t)(uint32_t, float, float); typedef int32_t (*iFpii_t)(void*, int32_t, int32_t); typedef int32_t (*iFpiL_t)(void*, int32_t, uintptr_t); +typedef int32_t (*iFpiLL_t)(void*, int32_t, uintptr_t, uintptr_t); typedef int32_t (*iFpip_t)(void*, int32_t, void*); typedef int32_t (*iFpui_t)(void*, uint32_t, int32_t); typedef int32_t (*iFpuu_t)(void*, uint32_t, uint32_t); @@ -1143,7 +1144,7 @@ typedef uintptr_t (*LFuui_t)(uint32_t, uint32_t, int32_t); typedef void* (*pFEiippppppp_t)(int32_t, int32_t, void*, void*, void*, void*, void*, void*, void*); typedef void* (*pFEppApp_t)(void*, void*, void*, void*, void*); typedef void* (*pFEpppp_t)(void*, void*, void*, void*); -typedef void* (*pFEpppp_t)(void*, void*, void*, void*); +typedef void* (*pFEppp_t)(void*, void*, void*); typedef void* (*pFEppppV_t)(void*, void*, void*, void*, void*); typedef void* (*pFEpppuipV_t)(void*, void*, void*, uint32_t, int32_t, void*, void*); typedef void* (*pFiiLp_t)(int32_t, int32_t, uintptr_t, void*); @@ -1205,6 +1206,7 @@ typedef void (*vFEppip_t)(void*, void*, int32_t, void*); typedef void (*vFEppipA_t)(void*, void*, int32_t, void*, void*); typedef void (*vFEppipppp_t)(void*, void*, int32_t, void*, void*, void*, void*); typedef void (*vFEppipV_t)(void*, void*, int32_t, void*, void*); +typedef void (*vFEpLipp_t)(void*, uintptr_t, int32_t, void*, void*); typedef void (*vFEppLippp_t)(void*, void*, uintptr_t, int32_t, void*, void*, void*); typedef void (*vFEpppiippp_t)(void*, void*, void*, int32_t, int32_t, void*, void*, void*); typedef void (*vFEpppiipppp_t)(void*, void*, void*, int32_t, int32_t, void*, void*, void*, void*); @@ -1337,6 +1339,45 @@ typedef int32_t (*iFEpUppp_t)(void*, uint64_t, void*, void*, void*); typedef int32_t (*iFEpUup_t)(void*, uint64_t, uint32_t, void*); typedef int32_t (*iFEpuppp_t)(void*, uint32_t, void*, void*, void*); typedef int32_t (*iFEpUUuppp_t)(void*, uint64_t, uint64_t, uint32_t, void*, void*, void*); +typedef uint8_t (*CFU_t)(uint64_t); +typedef uint8_t (*CFl_t)(intptr_t); +typedef uintptr_t (*LFppL_t)(void*, void*, uintptr_t); +typedef uintptr_t (*LFppLp_t)(void*, void*, uintptr_t, void*); +typedef uint64_t (*UFuiCiu_t)(uint32_t, int32_t, uint8_t, int32_t, uint32_t); +typedef int32_t (*iFpLLp_t)(void*, uintptr_t, uintptr_t, void*); +typedef int32_t (*iFpuuuuuup_t)(void*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, void*); +typedef intptr_t (*lFpuip_t)(void*, uint32_t, int32_t, void*); +typedef intptr_t (*lFui_t)(uint32_t, int32_t); +typedef void* (*pFulu_t)(uint32_t, intptr_t, uint32_t); +typedef void (*vFLiii_t)(uintptr_t, int32_t, int32_t, int32_t); +typedef void (*vFUu_t)(uint64_t, uint32_t); +typedef void (*vFcc_t)(int8_t, int8_t); +typedef void (*vFccc_t)(int8_t, int8_t, int8_t); +typedef void (*vFcccc_t)(int8_t, int8_t, int8_t, int8_t); +typedef void (*vFlu_t)(intptr_t, uint32_t); +typedef void (*vFluipp_t)(intptr_t, uint32_t, int32_t, void*, void*); +typedef void (*vFpLip_t)(void*, uintptr_t, int32_t, void*); +typedef void (*vFpLp_t)(void*, uintptr_t, void*); +typedef void (*vFuI_t)(uint32_t, int64_t); +typedef void (*vFuII_t)(uint32_t, int64_t, int64_t); +typedef void (*vFuIII_t)(uint32_t, int64_t, int64_t, int64_t); +typedef void (*vFuIIII_t)(uint32_t, int64_t, int64_t, int64_t, int64_t); +typedef void (*vFuUU_t)(uint32_t, uint64_t, uint64_t); +typedef void (*vFuUUU_t)(uint32_t, uint64_t, uint64_t, uint64_t); +typedef void (*vFuUUUU_t)(uint32_t, uint64_t, uint64_t, uint64_t, uint64_t); +typedef void (*vFuUuuuuuuuuu_t)(uint32_t, uint64_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); +typedef void (*vFuUuuuuuuuuuuu_t)(uint32_t, uint64_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t); +typedef void (*vFuiupuffup_t)(uint32_t, int32_t, uint32_t, void*, uint32_t, float, float, uint32_t, void*); +typedef void (*vFuuUl_t)(uint32_t, uint32_t, uint64_t, intptr_t); +typedef void (*vFuuiuil_t)(uint32_t, uint32_t, int32_t, uint32_t, int32_t, intptr_t); +typedef void (*vFuuli_t)(uint32_t, uint32_t, intptr_t, int32_t); +typedef void (*vFuulluup_t)(uint32_t, uint32_t, intptr_t, intptr_t, uint32_t, uint32_t, void*); +typedef void (*vFuupuuiuuf_t)(uint32_t, uint32_t, void*, uint32_t, uint32_t, int32_t, uint32_t, uint32_t, float); +typedef void (*vFuuuil_t)(uint32_t, uint32_t, uint32_t, int32_t, intptr_t); +typedef void (*vFuuuiuCil_t)(uint32_t, uint32_t, uint32_t, int32_t, uint32_t, uint8_t, int32_t, intptr_t); +typedef void (*vFuuuiuil_t)(uint32_t, uint32_t, uint32_t, int32_t, uint32_t, int32_t, intptr_t); +typedef void (*vFuuuli_t)(uint32_t, uint32_t, uint32_t, intptr_t, int32_t); +typedef void (*vFuuuull_t)(uint32_t, uint32_t, uint32_t, uint32_t, intptr_t, intptr_t); //endvulkan //xcbV2 typedef void* (*pFb_t)(void*); @@ -1435,6 +1476,7 @@ typedef uint8_t (*CFbupp_t)(void*, uint32_t, void*, void*); typedef uint32_t (*uFbup_t)(void*, uint32_t, void*); typedef void (*vFpC_t)(void*, uint8_t); typedef unsigned __int128 (*HFpp_t)(void*, void*); +typedef unsigned __int128 (*HFH_t)(unsigned __int128); typedef uint32_t (*uFbuU_t)(void*, uint32_t, uint64_t); typedef void* (*pFbppU_t)(void*, void*, void*, uint64_t); typedef uint32_t (*uFbCuuuwwwwwwWW_t)(void*, uint8_t, uint32_t, uint32_t, uint32_t, int16_t, int16_t, int16_t, int16_t, int16_t, int16_t, uint16_t, uint16_t); @@ -1521,6 +1563,7 @@ typedef void (*vFpppiipi_t)(void*, void*, void*, int32_t, int32_t, void*, int32_ typedef void (*vFppppipi_t)(void*, void*, void*, void*, int32_t, void*, int32_t); typedef int32_t (*iFpiiiiii_t)(void*, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t); typedef int32_t (*iFpiuiipp_t)(void*, int32_t, uint32_t, int32_t, int32_t, void*, void*); +typedef int32_t (*iFpiuiiLLL_t)(void*, int32_t, uint32_t, int32_t, int32_t, uintptr_t, uintptr_t, uintptr_t); typedef int32_t (*iFpuiuupp_t)(void*, uint32_t, int32_t, uint32_t, uint32_t, void*, void*); typedef int32_t (*iFpLipipi_t)(void*, uintptr_t, int32_t, void*, int32_t, void*, int32_t); typedef int32_t (*iFppiiuup_t)(void*, void*, int32_t, int32_t, uint32_t, uint32_t, void*); @@ -1724,6 +1767,7 @@ void iFuUu(uintptr_t fcn) { __CPU; iFuUu_t fn = (iFuUu_t)fcn; R_RAX=(int32_t)fn void iFuff(uintptr_t fcn) { __CPU; register float f0 __asm__("f16"); register float f1 __asm__("f17"); iFuff_t fn = (iFuff_t)fcn; R_RAX=(int32_t)fn((uint32_t)R_RDI, f0, f1); DEBUG_LOG; (void)cpu; } void iFpii(uintptr_t fcn) { __CPU; iFpii_t fn = (iFpii_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX); DEBUG_LOG; (void)cpu; } void iFpiL(uintptr_t fcn) { __CPU; iFpiL_t fn = (iFpiL_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (uintptr_t)R_RDX); DEBUG_LOG; (void)cpu; } +void iFpiLL(uintptr_t fcn) { __CPU; iFpiLL_t fn = (iFpiLL_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (uintptr_t)R_RDX, (uintptr_t)R_RCX); DEBUG_LOG; (void)cpu; } void iFpip(uintptr_t fcn) { __CPU; iFpip_t fn = (iFpip_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX); DEBUG_LOG; (void)cpu; } void iFpui(uintptr_t fcn) { __CPU; iFpui_t fn = (iFpui_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (uint32_t)R_RSI, (int32_t)R_RDX); DEBUG_LOG; (void)cpu; } void iFpuu(uintptr_t fcn) { __CPU; iFpuu_t fn = (iFpuu_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX); DEBUG_LOG; (void)cpu; } @@ -2584,6 +2628,7 @@ void lFppupp(uintptr_t fcn) { __CPU; lFppupp_t fn = (lFppupp_t)fcn; R_RAX=(intpt void LFuui(uintptr_t fcn) { __CPU; LFuui_t fn = (LFuui_t)fcn; R_RAX=(uintptr_t)fn((uint32_t)R_RDI, (uint32_t)R_RSI, (int32_t)R_RDX); DEBUG_LOG; (void)cpu; } void pFEiippppppp(uintptr_t fcn) { __CPU; pFEiippppppp_t fn = (pFEiippppppp_t)fcn; R_RAX=(uintptr_t)fn((int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24)); DEBUG_LOG; (void)cpu; } void pFEppApp(uintptr_t fcn) { __CPU; pFEppApp_t fn = (pFEppApp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8); DEBUG_LOG; (void)cpu; } +void pFEppp(uintptr_t fcn) { __CPU; pFEppp_t fn = (pFEppp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX); DEBUG_LOG; (void)cpu; } void pFEpppp(uintptr_t fcn) { __CPU; pFEpppp_t fn = (pFEpppp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX); DEBUG_LOG; (void)cpu; } void pFEppppV(uintptr_t fcn) { __CPU; pFEppppV_t fn = (pFEppppV_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } void pFEpppuipV(uintptr_t fcn) { __CPU; pFEpppuipV_t fn = (pFEpppuipV_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (uint32_t)R_RCX, (int32_t)R_R8, (void*)R_R9, (void*)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } @@ -2642,6 +2687,7 @@ void vFEppip(uintptr_t fcn) { __CPU; vFEppip_t fn = (vFEppip_t)fcn; fn((void*)R_ void vFEppipA(uintptr_t fcn) { __CPU; vFEppipA_t fn = (vFEppipA_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)R_R8); DEBUG_LOG; (void)cpu; } void vFEppipppp(uintptr_t fcn) { __CPU; vFEppipppp_t fn = (vFEppipppp_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } void vFEppipV(uintptr_t fcn) { __CPU; vFEppipV_t fn = (vFEppipV_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } +void vFEpLipp(uintptr_t fcn) { __CPU; vFEpLipp_t fn = (vFEpLipp_t)fcn; fn((void*)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)R_R8); DEBUG_LOG; (void)cpu; } void vFEppLippp(uintptr_t fcn) { __CPU; vFEppLippp_t fn = (vFEppLippp_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (int32_t)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } void vFEpppiippp(uintptr_t fcn) { __CPU; vFEpppiippp_t fn = (vFEpppiippp_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16)); DEBUG_LOG; (void)cpu; } void vFEpppiipppp(uintptr_t fcn) { __CPU; vFEpppiipppp_t fn = (vFEpppiipppp_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24)); DEBUG_LOG; (void)cpu; } @@ -2726,6 +2772,7 @@ void vFpppiipi(uintptr_t fcn) { __CPU; vFpppiipi_t fn = (vFpppiipi_t)fcn; fn((vo void vFppppipi(uintptr_t fcn) { __CPU; vFppppipi_t fn = (vFppppipi_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (int32_t)R_R8, (void*)R_R9, *(int32_t*)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } void iFpiiiiii(uintptr_t fcn) { __CPU; iFpiiiiii_t fn = (iFpiiiiii_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (int32_t)R_R9, *(int32_t*)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } void iFpiuiipp(uintptr_t fcn) { __CPU; iFpiuiipp_t fn = (iFpiuiipp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (uint32_t)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } +void iFpiuiiLLL(uintptr_t fcn) { __CPU; iFpiuiiLLL_t fn = (iFpiuiiLLL_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (uint32_t)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (uintptr_t)R_R9, *(uintptr_t*)(R_RSP + 8), *(uintptr_t*)(R_RSP + 16)); DEBUG_LOG; (void)cpu; } void iFpuiuupp(uintptr_t fcn) { __CPU; iFpuiuupp_t fn = (iFpuiuupp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (uint32_t)R_RSI, (int32_t)R_RDX, (uint32_t)R_RCX, (uint32_t)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } void iFpLipipi(uintptr_t fcn) { __CPU; iFpLipipi_t fn = (iFpLipipi_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (int32_t)R_R8, (void*)R_R9, *(int32_t*)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } void iFppiiuup(uintptr_t fcn) { __CPU; iFppiiuup_t fn = (iFppiiuup_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (uint32_t)R_R8, (uint32_t)R_R9, *(void**)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } @@ -2899,6 +2946,45 @@ void iFEpUup(uintptr_t fcn) { __CPU; iFEpUup_t fn = (iFEpUup_t)fcn; R_RAX=(int32 void iFEpuppp(uintptr_t fcn) { __CPU; iFEpuppp_t fn = (iFEpuppp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (uint32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8); DEBUG_LOG; (void)cpu; } void iFEpuvvppp(uintptr_t fcn) { __CPU; iFEpuppp_t fn = (iFEpuppp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (uint32_t)R_RSI, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } void iFEpUUuppp(uintptr_t fcn) { __CPU; iFEpUUuppp_t fn = (iFEpUUuppp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (uint32_t)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } +void CFU(uintptr_t fcn) { __CPU; CFU_t fn = (CFU_t)fcn; R_RAX=(uint8_t)fn((uint64_t)R_RDI); DEBUG_LOG; (void)cpu; } +void CFl(uintptr_t fcn) { __CPU; CFl_t fn = (CFl_t)fcn; R_RAX=(uint8_t)fn((intptr_t)R_RDI); DEBUG_LOG; (void)cpu; } +void LFppL(uintptr_t fcn) { __CPU; LFppL_t fn = (LFppL_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX); DEBUG_LOG; (void)cpu; } +void LFppLp(uintptr_t fcn) { __CPU; LFppLp_t fn = (LFppLp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (void*)R_RCX); DEBUG_LOG; (void)cpu; } +void UFuiCiu(uintptr_t fcn) { __CPU; UFuiCiu_t fn = (UFuiCiu_t)fcn; R_RAX=fn((uint32_t)R_RDI, (int32_t)R_RSI, (uint8_t)R_RDX, (int32_t)R_RCX, (uint32_t)R_R8); DEBUG_LOG; (void)cpu; } +void iFpLLp(uintptr_t fcn) { __CPU; iFpLLp_t fn = (iFpLLp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (uintptr_t)R_RSI, (uintptr_t)R_RDX, (void*)R_RCX); DEBUG_LOG; (void)cpu; } +void iFpuuuuuup(uintptr_t fcn) { __CPU; iFpuuuuuup_t fn = (iFpuuuuuup_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX, (uint32_t)R_RCX, (uint32_t)R_R8, (uint32_t)R_R9, *(uint32_t*)(R_RSP + 8), *(void**)(R_RSP + 16)); DEBUG_LOG; (void)cpu; } +void lFpuip(uintptr_t fcn) { __CPU; lFpuip_t fn = (lFpuip_t)fcn; R_RAX=(intptr_t)fn((void*)R_RDI, (uint32_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX); DEBUG_LOG; (void)cpu; } +void lFui(uintptr_t fcn) { __CPU; lFui_t fn = (lFui_t)fcn; R_RAX=(intptr_t)fn((uint32_t)R_RDI, (int32_t)R_RSI); DEBUG_LOG; (void)cpu; } +void pFulu(uintptr_t fcn) { __CPU; pFulu_t fn = (pFulu_t)fcn; R_RAX=(uintptr_t)fn((uint32_t)R_RDI, (intptr_t)R_RSI, (uint32_t)R_RDX); DEBUG_LOG; (void)cpu; } +void vFLiii(uintptr_t fcn) { __CPU; vFLiii_t fn = (vFLiii_t)fcn; fn((uintptr_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX); DEBUG_LOG; (void)cpu; } +void vFUu(uintptr_t fcn) { __CPU; vFUu_t fn = (vFUu_t)fcn; fn((uint64_t)R_RDI, (uint32_t)R_RSI); DEBUG_LOG; (void)cpu; } +void vFcc(uintptr_t fcn) { __CPU; vFcc_t fn = (vFcc_t)fcn; fn((int8_t)R_RDI, (int8_t)R_RSI); DEBUG_LOG; (void)cpu; } +void vFccc(uintptr_t fcn) { __CPU; vFccc_t fn = (vFccc_t)fcn; fn((int8_t)R_RDI, (int8_t)R_RSI, (int8_t)R_RDX); DEBUG_LOG; (void)cpu; } +void vFcccc(uintptr_t fcn) { __CPU; vFcccc_t fn = (vFcccc_t)fcn; fn((int8_t)R_RDI, (int8_t)R_RSI, (int8_t)R_RDX, (int8_t)R_RCX); DEBUG_LOG; (void)cpu; } +void vFlu(uintptr_t fcn) { __CPU; vFlu_t fn = (vFlu_t)fcn; fn((intptr_t)R_RDI, (uint32_t)R_RSI); DEBUG_LOG; (void)cpu; } +void vFluipp(uintptr_t fcn) { __CPU; vFluipp_t fn = (vFluipp_t)fcn; fn((intptr_t)R_RDI, (uint32_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)R_R8); DEBUG_LOG; (void)cpu; } +void vFpLip(uintptr_t fcn) { __CPU; vFpLip_t fn = (vFpLip_t)fcn; fn((void*)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX); DEBUG_LOG; (void)cpu; } +void vFpLp(uintptr_t fcn) { __CPU; vFpLp_t fn = (vFpLp_t)fcn; fn((void*)R_RDI, (uintptr_t)R_RSI, (void*)R_RDX); DEBUG_LOG; (void)cpu; } +void vFuI(uintptr_t fcn) { __CPU; vFuI_t fn = (vFuI_t)fcn; fn((uint32_t)R_RDI, (int64_t)R_RSI); DEBUG_LOG; (void)cpu; } +void vFuII(uintptr_t fcn) { __CPU; vFuII_t fn = (vFuII_t)fcn; fn((uint32_t)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX); DEBUG_LOG; (void)cpu; } +void vFuIII(uintptr_t fcn) { __CPU; vFuIII_t fn = (vFuIII_t)fcn; fn((uint32_t)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX); DEBUG_LOG; (void)cpu; } +void vFuIIII(uintptr_t fcn) { __CPU; vFuIIII_t fn = (vFuIIII_t)fcn; fn((uint32_t)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (int64_t)R_R8); DEBUG_LOG; (void)cpu; } +void vFuUU(uintptr_t fcn) { __CPU; vFuUU_t fn = (vFuUU_t)fcn; fn((uint32_t)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX); DEBUG_LOG; (void)cpu; } +void vFuUUU(uintptr_t fcn) { __CPU; vFuUUU_t fn = (vFuUUU_t)fcn; fn((uint32_t)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX); DEBUG_LOG; (void)cpu; } +void vFuUUUU(uintptr_t fcn) { __CPU; vFuUUUU_t fn = (vFuUUUU_t)fcn; fn((uint32_t)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX, (uint64_t)R_R8); DEBUG_LOG; (void)cpu; } +void vFuUuuuuuuuuu(uintptr_t fcn) { __CPU; vFuUuuuuuuuuu_t fn = (vFuUuuuuuuuuu_t)fcn; fn((uint32_t)R_RDI, (uint64_t)R_RSI, (uint32_t)R_RDX, (uint32_t)R_RCX, (uint32_t)R_R8, (uint32_t)R_R9, *(uint32_t*)(R_RSP + 8), *(uint32_t*)(R_RSP + 16), *(uint32_t*)(R_RSP + 24), *(uint32_t*)(R_RSP + 32), *(uint32_t*)(R_RSP + 40)); DEBUG_LOG; (void)cpu; } +void vFuUuuuuuuuuuuu(uintptr_t fcn) { __CPU; vFuUuuuuuuuuuuu_t fn = (vFuUuuuuuuuuuuu_t)fcn; fn((uint32_t)R_RDI, (uint64_t)R_RSI, (uint32_t)R_RDX, (uint32_t)R_RCX, (uint32_t)R_R8, (uint32_t)R_R9, *(uint32_t*)(R_RSP + 8), *(uint32_t*)(R_RSP + 16), *(uint32_t*)(R_RSP + 24), *(uint32_t*)(R_RSP + 32), *(uint32_t*)(R_RSP + 40), *(uint32_t*)(R_RSP + 48), *(uint32_t*)(R_RSP + 56)); DEBUG_LOG; (void)cpu; } +void vFuiupuffup(uintptr_t fcn) { __CPU; register float f0 __asm__("f16"); register float f1 __asm__("f17"); vFuiupuffup_t fn = (vFuiupuffup_t)fcn; fn((uint32_t)R_RDI, (int32_t)R_RSI, (uint32_t)R_RDX, (void*)R_RCX, (uint32_t)R_R8, f0, f1, (uint32_t)R_R9, *(void**)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } +void vFuuUl(uintptr_t fcn) { __CPU; vFuuUl_t fn = (vFuuUl_t)fcn; fn((uint32_t)R_RDI, (uint32_t)R_RSI, (uint64_t)R_RDX, (intptr_t)R_RCX); DEBUG_LOG; (void)cpu; } +void vFuuiuil(uintptr_t fcn) { __CPU; vFuuiuil_t fn = (vFuuiuil_t)fcn; fn((uint32_t)R_RDI, (uint32_t)R_RSI, (int32_t)R_RDX, (uint32_t)R_RCX, (int32_t)R_R8, (intptr_t)R_R9); DEBUG_LOG; (void)cpu; } +void vFuuli(uintptr_t fcn) { __CPU; vFuuli_t fn = (vFuuli_t)fcn; fn((uint32_t)R_RDI, (uint32_t)R_RSI, (intptr_t)R_RDX, (int32_t)R_RCX); DEBUG_LOG; (void)cpu; } +void vFuulluup(uintptr_t fcn) { __CPU; vFuulluup_t fn = (vFuulluup_t)fcn; fn((uint32_t)R_RDI, (uint32_t)R_RSI, (intptr_t)R_RDX, (intptr_t)R_RCX, (uint32_t)R_R8, (uint32_t)R_R9, *(void**)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } +void vFuupuuiuuf(uintptr_t fcn) { __CPU; register float f0 __asm__("f16"); vFuupuuiuuf_t fn = (vFuupuuiuuf_t)fcn; fn((uint32_t)R_RDI, (uint32_t)R_RSI, (void*)R_RDX, (uint32_t)R_RCX, (uint32_t)R_R8, (int32_t)R_R9, *(uint32_t*)(R_RSP + 8), *(uint32_t*)(R_RSP + 16), f0); DEBUG_LOG; (void)cpu; } +void vFuuuil(uintptr_t fcn) { __CPU; vFuuuil_t fn = (vFuuuil_t)fcn; fn((uint32_t)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX, (int32_t)R_RCX, (intptr_t)R_R8); DEBUG_LOG; (void)cpu; } +void vFuuuiuCil(uintptr_t fcn) { __CPU; vFuuuiuCil_t fn = (vFuuuiuCil_t)fcn; fn((uint32_t)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX, (int32_t)R_RCX, (uint32_t)R_R8, (uint8_t)R_R9, *(int32_t*)(R_RSP + 8), *(intptr_t*)(R_RSP + 16)); DEBUG_LOG; (void)cpu; } +void vFuuuiuil(uintptr_t fcn) { __CPU; vFuuuiuil_t fn = (vFuuuiuil_t)fcn; fn((uint32_t)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX, (int32_t)R_RCX, (uint32_t)R_R8, (int32_t)R_R9, *(intptr_t*)(R_RSP + 8)); DEBUG_LOG; (void)cpu; } +void vFuuuli(uintptr_t fcn) { __CPU; vFuuuli_t fn = (vFuuuli_t)fcn; fn((uint32_t)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX, (intptr_t)R_RCX, (int32_t)R_R8); DEBUG_LOG; (void)cpu; } +void vFuuuull(uintptr_t fcn) { __CPU; vFuuuull_t fn = (vFuuuull_t)fcn; fn((uint32_t)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX, (uint32_t)R_RCX, (intptr_t)R_R8, (intptr_t)R_R9); DEBUG_LOG; (void)cpu; } //endvulkan //xcbV2 void pFb(uintptr_t fcn) { __CPU; pFb_t fn = (pFb_t)fcn; void *aligned_xcb = align_xcb_connection((void*)R_RDI); R_RAX=(uintptr_t)fn(aligned_xcb); unalign_xcb_connection(aligned_xcb, (void*)R_RDI); DEBUG_LOG; (void)cpu; } @@ -2997,6 +3083,7 @@ void CFbupp(uintptr_t fcn) { __CPU; CFbupp_t fn = (CFbupp_t)fcn; void *aligned_x void uFbup(uintptr_t fcn) { __CPU; uFbup_t fn = (uFbup_t)fcn; void *aligned_xcb = align_xcb_connection((void*)R_RDI); R_RAX=(uint32_t)fn(aligned_xcb, (uint32_t)R_RSI, (void*)R_RDX); unalign_xcb_connection(aligned_xcb, (void*)R_RDI); DEBUG_LOG; (void)cpu; } void vFpC(uintptr_t fcn) { __CPU; vFpC_t fn = (vFpC_t)fcn; fn((void*)R_RDI, (uint8_t)R_RSI); DEBUG_LOG; (void)cpu; } void HFpp(uintptr_t fcn) { __CPU; HFpp_t fn = (HFpp_t)fcn; unsigned __int128 u128 = fn((void*)R_RDI, (void*)R_RSI); R_RAX=(u128&0xFFFFFFFFFFFFFFFFL); R_RDX=(u128>>64)&0xFFFFFFFFFFFFFFFFL; DEBUG_LOG; (void)cpu; } +void HFH(uintptr_t fcn) { __CPU; HFH_t fn = (HFH_t)fcn; unsigned __int128 arg = (unsigned __int128)R_RDI | ((unsigned __int128)R_RSI << 64); unsigned __int128 ret = fn(arg); R_RAX=(uint64_t)ret; R_RDX=(uint64_t)(ret>>64); DEBUG_LOG; (void)cpu; } void uFbuU(uintptr_t fcn) { __CPU; uFbuU_t fn = (uFbuU_t)fcn; void *aligned_xcb = align_xcb_connection((void*)R_RDI); R_RAX=(uint32_t)fn(aligned_xcb, (uint32_t)R_RSI, (uint64_t)R_RDX); unalign_xcb_connection(aligned_xcb, (void*)R_RDI); DEBUG_LOG; (void)cpu; } void pFbppU(uintptr_t fcn) { __CPU; pFbppU_t fn = (pFbppU_t)fcn; void *aligned_xcb = align_xcb_connection((void*)R_RDI); R_RAX=(uintptr_t)fn(aligned_xcb, (void*)R_RSI, (void*)R_RDX, (uint64_t)R_RCX); unalign_xcb_connection(aligned_xcb, (void*)R_RDI); DEBUG_LOG; (void)cpu; } void uFbCuuuwwwwwwWW(uintptr_t fcn) { __CPU; uFbCuuuwwwwwwWW_t fn = (uFbCuuuwwwwwwWW_t)fcn; void *aligned_xcb = align_xcb_connection((void*)R_RDI); R_RAX=(uint32_t)fn(aligned_xcb, (uint8_t)R_RSI, (uint32_t)R_RDX, (uint32_t)R_RCX, (uint32_t)R_R8, (int16_t)R_R9, *(int16_t*)(R_RSP + 8), *(int16_t*)(R_RSP + 16), *(int16_t*)(R_RSP + 24), *(int16_t*)(R_RSP + 32), *(int16_t*)(R_RSP + 40), *(uint16_t*)(R_RSP + 48), *(uint16_t*)(R_RSP + 56)); unalign_xcb_connection(aligned_xcb, (void*)R_RDI); DEBUG_LOG; (void)cpu; } diff --git a/target/i386/latx/include/generated/wrappedlibgltypes.h b/target/i386/latx/include/generated/wrappedlibgltypes.h index 661e0cf906b..8e125869a0b 100644 --- a/target/i386/latx/include/generated/wrappedlibgltypes.h +++ b/target/i386/latx/include/generated/wrappedlibgltypes.h @@ -14,7 +14,7 @@ typedef void* (*pFp_t)(void*); typedef void (*vFpp_t)(void*, void*); typedef void (*vFipp_t)(int32_t, void*, void*); typedef void* (*pFpppip_t)(void*, void*, void*, int32_t, void*); -typedef int32_t (*iFppp_t)(void*, void*, void*); +typedef int32_t (*iFpLp_t)(void*, uintptr_t, void*); typedef void (*vFppp_t)(void*, void*, void*); #define SUPER() ADDED_FUNCTIONS() \ @@ -29,7 +29,7 @@ typedef void (*vFppp_t)(void*, void*, void*); GO(eglDebugMessageControlKHR, iFpp_t) \ GO(glProgramCallbackMESA, vFipp_t) \ GO(glXCreateContextAttribsARB, pFpppip_t) \ - GO(glXMakeCurrent,iFppp_t) \ + GO(glXMakeCurrent,iFpLp_t) \ GO(eglSetBlobCacheFuncsANDROID, vFppp_t) #endif // __wrappedlibglTYPES_H_ diff --git a/target/i386/latx/include/generated/wrappedlibglxtypes.h b/target/i386/latx/include/generated/wrappedlibglxtypes.h index 9a70f143f36..578b72c565e 100644 --- a/target/i386/latx/include/generated/wrappedlibglxtypes.h +++ b/target/i386/latx/include/generated/wrappedlibglxtypes.h @@ -10,17 +10,20 @@ typedef void* (*pFp_t)(void*); typedef void (*vFpp_t)(void*, void*); -typedef void* (*pFppp_t)(void*, void*, void*); -typedef int32_t (*iFpppp_t)(void*, void*, void*, void*); +typedef uintptr_t (*LFppp_t)(void*, void*, void*); +typedef void (*vFpL_t)(void*, uintptr_t); +typedef int32_t (*iFpLLp_t)(void*, uintptr_t, uintptr_t, void*); +typedef int32_t (*iFpLp_t)(void*, uintptr_t, void*); typedef void* (*pFppipi_t)(void*, void*, int32_t, void*, int32_t); #define SUPER() ADDED_FUNCTIONS() \ GO(glXGetProcAddress, pFp_t) \ GO(glXGetProcAddressARB, pFp_t) \ GO(glXDestroyContext,vFpp_t) \ - GO(glXDestroyPbuffer,vFpp_t) \ - GO(glXCreatePbuffer,pFppp_t) \ - GO(glXMakeContextCurrent,iFpppp_t) \ + GO(glXDestroyPbuffer,vFpL_t) \ + GO(glXCreatePbuffer,LFppp_t) \ + GO(glXMakeContextCurrent,iFpLLp_t) \ + GO(glXMakeCurrent,iFpLp_t) \ GO(glXCreateNewContext,pFppipi_t) #endif // __wrappedlibglxTYPES_H_ diff --git a/target/i386/latx/include/generated/wrappedlibxcbtypes.h b/target/i386/latx/include/generated/wrappedlibxcbtypes.h index 36050b29888..d6f2e4d7b81 100644 --- a/target/i386/latx/include/generated/wrappedlibxcbtypes.h +++ b/target/i386/latx/include/generated/wrappedlibxcbtypes.h @@ -16,7 +16,7 @@ typedef void* (*pFpup_t)(void*, uint32_t, void*); typedef void* (*pFpp_t)(void*, void*); typedef void* (*pFpUp_t)(void*, uint64_t, void*); typedef void (*vFp_t)(void*); -typedef void* (*pFpp_t)(void*, void*); +typedef void* (*pFppp_t)(void*, void*, void*); typedef int32_t (*iFb_t)(void*); #define SUPER() ADDED_FUNCTIONS() \ @@ -25,6 +25,7 @@ typedef int32_t (*iFb_t)(void*); GO(xcb_wait_for_reply64, pFpUp_t) \ GO(xcb_disconnect, vFp_t) \ GO(xcb_connect, pFpp_t) \ + GO(xcb_connect_to_display_with_auth_info, pFppp_t) \ GO(xcb_wait_for_special_event, pFpp_t) \ GO(xcb_flush, iFb_t) diff --git a/target/i386/latx/include/generated/wrappedlibxttypes.h b/target/i386/latx/include/generated/wrappedlibxttypes.h index cc5251c0e00..940fda94dee 100644 --- a/target/i386/latx/include/generated/wrappedlibxttypes.h +++ b/target/i386/latx/include/generated/wrappedlibxttypes.h @@ -12,12 +12,13 @@ #endif typedef intptr_t (*lFppp_t)(void*, void*, void*); -typedef void (*vFpuipp_t)(void*, uint32_t, int32_t, void*, void*); +typedef void (*vFpLipp_t)(void*, uintptr_t, int32_t, void*, void*); typedef intptr_t (*lFpippp_t)(void*, int32_t, void*, void*, void*); #define SUPER() ADDED_FUNCTIONS() \ GO(XtAppAddWorkProc, lFppp_t) \ - GO(XtAddEventHandler, vFpuipp_t) \ + GO(XtAddEventHandler, vFpLipp_t) \ + GO(XtRemoveEventHandler, vFpLipp_t) \ GO(XtAppAddInput, lFpippp_t) #endif // __wrappedlibxtTYPES_H_ diff --git a/target/i386/latx/include/generated/wrappedvulkantypes.h b/target/i386/latx/include/generated/wrappedvulkantypes.h index 5bd0fec1c8c..bfe897fd878 100644 --- a/target/i386/latx/include/generated/wrappedvulkantypes.h +++ b/target/i386/latx/include/generated/wrappedvulkantypes.h @@ -76,10 +76,10 @@ typedef int32_t (*iFpuUp_t)(void*, uint32_t, uint64_t, void*); GO(vkDestroyVideoSessionKHR, vFpUp_t) \ GO(vkDestroyVideoSessionParametersKHR, vFpUp_t) \ GO(vkDestroyDebugUtilsMessengerEXT, vFppp_t) \ - GO(vkFreeMemory, iFpUp_t) \ + GO(vkFreeMemory, vFpUp_t) \ GO(vkCreateDeferredOperationKHR, iFppp_t) \ GO(vkCreateInstance, iFppp_t) \ - GO(vkDestroyDebugReportCallbackEXT, iFppp_t) \ + GO(vkDestroyDebugReportCallbackEXT, vFppp_t) \ GO(vkGetPhysicalDeviceDisplayPropertiesKHR, iFppp_t) \ GO(vkGetDisplayPlaneCapabilitiesKHR, iFpUup_t) \ GO(vkAllocateMemory, iFpppp_t) \ diff --git a/target/i386/latx/include/wrappedlibgl_private.h b/target/i386/latx/include/wrappedlibgl_private.h index 92736e31083..aa1932e502b 100644 --- a/target/i386/latx/include/wrappedlibgl_private.h +++ b/target/i386/latx/include/wrappedlibgl_private.h @@ -140,7 +140,7 @@ GO(glTestFenceAPPLE,iFu) GO(glTestObjectAPPLE,iFuu) //APPLE_flush_buffer_range GO(glBufferParameteriAPPLE,vFuui) -GO(glFlushMappedBufferRangeAPPLE,vFuii) +GO(glFlushMappedBufferRangeAPPLE,vFull) //APPLE_object_purgeable GO(glGetObjectParameterivAPPLE,vFuuup) GO(glObjectPurgeableAPPLE,uFuuu) @@ -182,16 +182,16 @@ GO(glGetFragDataIndex,iFup) GO(glCreateSyncFromCLeventARB,pFppi) //ARB_clear_buffer_object GO(glClearBufferData,vFuuuup) -GO(glClearBufferSubData,vFuuiiuup) +GO(glClearBufferSubData,vFuulluup) GO(glClearNamedBufferDataEXT,vFuuuup) -GO(glClearNamedBufferSubDataEXT,vFuuuuiip) +GO(glClearNamedBufferSubDataEXT,vFuulluup) //ARB_color_buffer_float GO(glClampColorARB,vFuu) //ARB_compute_shader GO(glDispatchCompute,vFuuu) -GO(glDispatchComputeIndirect,vFi) +GO(glDispatchComputeIndirect,vFl) //ARB_copy_buffer -GO(glCopyBufferSubData,vFuuiii) +GO(glCopyBufferSubData,vFuulll) //ARB_copy_image GO(glCopyImageSubData,vFuuiiiiuuiiiiiii) //ARB_debug_output @@ -523,15 +523,15 @@ GO(glFenceSync,pFiu) GO(glGetInteger64v,vFup) GO(glGetSynciv,vFpuipp) GO(glIsSync,iFp) -GO(glWaitSync,vFpiu) +GO(glWaitSync,vFpuU) //ARB_tessellation_shader GO(glPatchParameterfv,vFup) GO(glPatchParameteri,vFui) //ARB_texture_buffer_object GO(glTexBufferARB,vFuuu) //ARB_texture_buffer_range -GO(glTexBufferRange,vFuuuii) -GO(glTextureBufferRangeEXT,vFuuuuii) +GO(glTexBufferRange,vFuuull) +GO(glTextureBufferRangeEXT,vFuuuull) //ARB_texture_compression GO(glCompressedTexImage1DARB,vFuiuiiip) GO(glCompressedTexImage2DARB,vFuiuiiiip) @@ -609,8 +609,8 @@ GO(glVertexAttribL4d,vFudddd) GO(glVertexAttribL4dv,vFup) GO(glVertexAttribLPointer,vFuiuip) //ARB_vertex_attrib_binding -GO(glBindVertexBuffer,vFuuii) -GO(glVertexArrayBindVertexBufferEXT,vFuuuii) +GO(glBindVertexBuffer,vFuuli) +GO(glVertexArrayBindVertexBufferEXT,vFuuuli) GO(glVertexArrayVertexAttribBindingEXT,vFuuu) GO(glVertexArrayVertexAttribFormatEXT,vFuuiuiu) GO(glVertexArrayVertexAttribIFormatEXT,vFuuiuu) @@ -634,13 +634,13 @@ GO(glWeightuivARB,vFip) GO(glWeightusvARB,vFip) //ARB_vertex_buffer_object GO(glBindBufferARB,vFuu) -GO(glBufferDataARB,vFuipu) -GO(glBufferSubDataARB,vFuiip) +GO(glBufferDataARB,vFulpu) +GO(glBufferSubDataARB,vFullp) GO(glDeleteBuffersARB,vFip) GO(glGenBuffersARB,vFip) GO(glGetBufferParameterivARB,vFuup) GO(glGetBufferPointervARB,vFuup) -GO(glGetBufferSubDataARB,vFuiip) +GO(glGetBufferSubDataARB,vFullp) GO(glIsBufferARB,iFu) GO(glMapBufferARB,pFuu) GO(glUnmapBufferARB,iFu) @@ -878,7 +878,7 @@ GO(glVertexStream4sATI,vFuiiii) GO(glVertexStream4svATI,vFup) //EXT_bindable_uniform GO(glGetUniformBufferSizeEXT,iFui) -GO(glGetUniformOffsetEXT,iFui) +GO(glGetUniformOffsetEXT,lFui) GO(glUniformBufferEXT,vFuiu) //EXT_blend_color GO(glBlendColorEXT,vFffff) @@ -976,7 +976,7 @@ GO(glEnableClientStateIndexedEXT,vFuu) GO(glEnableClientStateiEXT,vFuu) GO(glEnableVertexArrayAttribEXT,vFuu) GO(glEnableVertexArrayEXT,vFuu) -GO(glFlushMappedNamedBufferRangeEXT,vFuii) +GO(glFlushMappedNamedBufferRangeEXT,vFull) GO(glFramebufferDrawBufferEXT,vFuu) GO(glFramebufferDrawBuffersEXT,vFuip) GO(glFramebufferReadBufferEXT,vFuu) @@ -1003,7 +1003,7 @@ GO(glGetMultiTexParameterfvEXT,vFuuup) GO(glGetMultiTexParameterivEXT,vFuuup) GO(glGetNamedBufferParameterivEXT,vFuup) GO(glGetNamedBufferPointervEXT,vFuup) -GO(glGetNamedBufferSubDataEXT,vFuiip) +GO(glGetNamedBufferSubDataEXT,vFullp) GO(glGetNamedFramebufferAttachmentParameterivEXT,vFuuup) GO(glGetNamedProgramLocalParameterIivEXT,vFuuup) GO(glGetNamedProgramLocalParameterIuivEXT,vFuuup) @@ -1026,7 +1026,7 @@ GO(glGetVertexArrayIntegervEXT,vFuup) GO(glGetVertexArrayPointeri_vEXT,vFuuup) GO(glGetVertexArrayPointervEXT,vFuup) GO(glMapNamedBufferEXT,pFuu) -GO(glMapNamedBufferRangeEXT,pFuiii) +GO(glMapNamedBufferRangeEXT,pFullu) GO(glMatrixFrustumEXT,vFudddddd) GO(glMatrixLoadIdentityEXT,vFu) GO(glMatrixLoadTransposedEXT,vFup) @@ -1071,9 +1071,9 @@ GO(glMultiTexRenderbufferEXT,vFuuu) GO(glMultiTexSubImage1DEXT,vFuuiiiuup) GO(glMultiTexSubImage2DEXT,vFuuiiiiiuup) GO(glMultiTexSubImage3DEXT,vFuuiiiiiiiuup) -GO(glNamedBufferDataEXT,vFuipu) -GO(glNamedBufferSubDataEXT,vFuiip) -GO(glNamedCopyBufferSubDataEXT,vFuuiii) +GO(glNamedBufferDataEXT,vFulpu) +GO(glNamedBufferSubDataEXT,vFullp) +GO(glNamedCopyBufferSubDataEXT,vFuulll) GO(glNamedFramebufferRenderbufferEXT,vFuuuu) GO(glNamedFramebufferTexture1DEXT,vFuuuui) GO(glNamedFramebufferTexture2DEXT,vFuuuui) @@ -1162,17 +1162,17 @@ GO(glTextureSubImage1DEXT,vFuuiiiuup) GO(glTextureSubImage2DEXT,vFuuiiiiiuup) GO(glTextureSubImage3DEXT,vFuuiiiiiiiuup) GO(glUnmapNamedBufferEXT,iFu) -GO(glVertexArrayColorOffsetEXT,vFuuiuii) -GO(glVertexArrayEdgeFlagOffsetEXT,vFuuii) -GO(glVertexArrayFogCoordOffsetEXT,vFuuuii) -GO(glVertexArrayIndexOffsetEXT,vFuuuii) -GO(glVertexArrayMultiTexCoordOffsetEXT,vFuuuiuii) -GO(glVertexArrayNormalOffsetEXT,vFuuuii) -GO(glVertexArraySecondaryColorOffsetEXT,vFuuiuii) -GO(glVertexArrayTexCoordOffsetEXT,vFuuiuii) -GO(glVertexArrayVertexAttribIOffsetEXT,vFuuuiuii) -GO(glVertexArrayVertexAttribOffsetEXT,vFuuuiuiii) -GO(glVertexArrayVertexOffsetEXT,vFuuiuii) +GO(glVertexArrayColorOffsetEXT,vFuuiuil) +GO(glVertexArrayEdgeFlagOffsetEXT,vFuuil) +GO(glVertexArrayFogCoordOffsetEXT,vFuuuil) +GO(glVertexArrayIndexOffsetEXT,vFuuuil) +GO(glVertexArrayMultiTexCoordOffsetEXT,vFuuuiuil) +GO(glVertexArrayNormalOffsetEXT,vFuuuil) +GO(glVertexArraySecondaryColorOffsetEXT,vFuuiuil) +GO(glVertexArrayTexCoordOffsetEXT,vFuuiuil) +GO(glVertexArrayVertexAttribIOffsetEXT,vFuuuiuil) +GO(glVertexArrayVertexAttribOffsetEXT,vFuuuiuCil) +GO(glVertexArrayVertexOffsetEXT,vFuuiuil) //EXT_draw_buffers2 GO(glColorMaskIndexedEXT,vFuiiii) GO(glDisableIndexedEXT,vFuu) @@ -1331,8 +1331,8 @@ GO(glGetQueryObjectui64vEXT,vFuup) //EXT_transform_feedback GO(glBeginTransformFeedbackEXT,vFu) GO(glBindBufferBaseEXT,vFuuu) -GO(glBindBufferOffsetEXT,vFuuui) -GO(glBindBufferRangeEXT,vFuuuii) +GO(glBindBufferOffsetEXT,vFuuul) +GO(glBindBufferRangeEXT,vFuuull) GO(glEndTransformFeedbackEXT,vFv) GO(glGetTransformFeedbackVaryingEXT,vFuuipppp) GO(glTransformFeedbackVaryingsEXT,vFuipu) @@ -1348,7 +1348,7 @@ GO(glTexCoordPointerEXT,vFiuiip) GO(glVertexPointerEXT,vFiuiip) //EXT_vertex_attrib_64bit GO(glGetVertexAttribLdvEXT,vFuup) -GO(glVertexArrayVertexAttribLOffsetEXT,vFuuuiuii) +GO(glVertexArrayVertexAttribLOffsetEXT,vFuuuiuil) GO(glVertexAttribL1dEXT,vFud) GO(glVertexAttribL1dvEXT,vFup) GO(glVertexAttribL2dEXT,vFudd) @@ -1406,7 +1406,7 @@ GO(glVertexWeightPointerEXT,vFiuip) GO(glVertexWeightfEXT,vFf) GO(glVertexWeightfvEXT,vFp) //EXT_x11_sync_object -GO(glImportSyncEXT,pFuii) +GO(glImportSyncEXT,pFulu) //GREMEDY_frame_terminator GO(glFrameTerminatorGREMEDY,vFv) //GREMEDY_string_marker @@ -1485,18 +1485,18 @@ GO(glWindowPos4svMESA,vFp) GO(glBeginConditionalRenderNVX,vFu) GO(glEndConditionalRenderNVX,vFv) //NV_bindless_texture -GO(glGetImageHandleNV,uFuiiiu) -GO(glGetTextureHandleNV,uFu) -GO(glGetTextureSamplerHandleNV,uFuu) -GO(glIsImageHandleResidentNV,iFu) -GO(glIsTextureHandleResidentNV,iFu) -GO(glMakeImageHandleNonResidentNV,vFu) -GO(glMakeImageHandleResidentNV,vFuu) -GO(glMakeTextureHandleNonResidentNV,vFu) -GO(glMakeTextureHandleResidentNV,vFu) -GO(glProgramUniformHandleui64NV,vFuiu) +GO(glGetImageHandleNV,UFuiCiu) +GO(glGetTextureHandleNV,UFu) +GO(glGetTextureSamplerHandleNV,UFuu) +GO(glIsImageHandleResidentNV,CFU) +GO(glIsTextureHandleResidentNV,CFU) +GO(glMakeImageHandleNonResidentNV,vFU) +GO(glMakeImageHandleResidentNV,vFUu) +GO(glMakeTextureHandleNonResidentNV,vFU) +GO(glMakeTextureHandleResidentNV,vFU) +GO(glProgramUniformHandleui64NV,vFuiU) GO(glProgramUniformHandleui64vNV,vFuiip) -GO(glUniformHandleui64NV,vFiu) +GO(glUniformHandleui64NV,vFiU) GO(glUniformHandleui64vNV,vFiip) //NV_conditional_render GO(glBeginConditionalRenderNV,vFuu) @@ -1567,37 +1567,37 @@ GO(glGetProgramSubroutineParameteruivNV,vFuup) GO(glProgramSubroutineParametersuivNV,vFuip) //NV_gpu_shader5 GO(glGetUniformi64vNV,vFuip) -GO(glProgramUniform1i64NV,vFuii) +GO(glProgramUniform1i64NV,vFuiI) GO(glProgramUniform1i64vNV,vFuiip) -GO(glProgramUniform1ui64NV,vFuiu) +GO(glProgramUniform1ui64NV,vFuiU) GO(glProgramUniform1ui64vNV,vFuiip) -GO(glProgramUniform2i64NV,vFuiii) +GO(glProgramUniform2i64NV,vFuiII) GO(glProgramUniform2i64vNV,vFuiip) -GO(glProgramUniform2ui64NV,vFuiuu) +GO(glProgramUniform2ui64NV,vFuiUU) GO(glProgramUniform2ui64vNV,vFuiip) -GO(glProgramUniform3i64NV,vFuiiii) +GO(glProgramUniform3i64NV,vFuiIII) GO(glProgramUniform3i64vNV,vFuiip) -GO(glProgramUniform3ui64NV,vFuiuuu) +GO(glProgramUniform3ui64NV,vFuiUUU) GO(glProgramUniform3ui64vNV,vFuiip) -GO(glProgramUniform4i64NV,vFuiiiii) +GO(glProgramUniform4i64NV,vFuiIIII) GO(glProgramUniform4i64vNV,vFuiip) -GO(glProgramUniform4ui64NV,vFuiuuuu) +GO(glProgramUniform4ui64NV,vFuiUUUU) GO(glProgramUniform4ui64vNV,vFuiip) -GO(glUniform1i64NV,vFii) +GO(glUniform1i64NV,vFiI) GO(glUniform1i64vNV,vFiip) -GO(glUniform1ui64NV,vFiu) +GO(glUniform1ui64NV,vFiU) GO(glUniform1ui64vNV,vFiip) -GO(glUniform2i64NV,vFiii) +GO(glUniform2i64NV,vFiII) GO(glUniform2i64vNV,vFiip) -GO(glUniform2ui64NV,vFiuu) +GO(glUniform2ui64NV,vFiUU) GO(glUniform2ui64vNV,vFiip) -GO(glUniform3i64NV,vFiiii) +GO(glUniform3i64NV,vFiIII) GO(glUniform3i64vNV,vFiip) -GO(glUniform3ui64NV,vFiuuu) +GO(glUniform3ui64NV,vFiUUU) GO(glUniform3ui64vNV,vFiip) -GO(glUniform4i64NV,vFiiiii) +GO(glUniform4i64NV,vFiIIII) GO(glUniform4i64vNV,vFiip) -GO(glUniform4ui64NV,vFiuuuu) +GO(glUniform4ui64NV,vFiUUUU) GO(glUniform4ui64vNV,vFiip) //NV_half_float GO(glColor3hNV,vFiii) @@ -1669,8 +1669,8 @@ GO(glGetVideoi64vNV,vFuup) GO(glGetVideoivNV,vFuup) GO(glGetVideoui64vNV,vFuup) GO(glGetVideouivNV,vFuup) -GO(glPresentFrameDualFillNV,vFuuuuuuuuuuuuu) -GO(glPresentFrameKeyedNV,vFuuuuuuuuuuu) +GO(glPresentFrameDualFillNV,vFuUuuuuuuuuuuu) +GO(glPresentFrameKeyedNV,vFuUuuuuuuuuu) //NV_primitive_restart GO(glPrimitiveRestartIndexNV,vFu) GO(glPrimitiveRestartNV,vFv) @@ -1702,9 +1702,9 @@ GO(glMakeBufferNonResidentNV,vFu) GO(glMakeBufferResidentNV,vFuu) GO(glMakeNamedBufferNonResidentNV,vFu) GO(glMakeNamedBufferResidentNV,vFuu) -GO(glProgramUniformui64NV,vFuiu) +GO(glProgramUniformui64NV,vFuiU) GO(glProgramUniformui64vNV,vFuiip) -GO(glUniformui64NV,vFiu) +GO(glUniformui64NV,vFiU) GO(glUniformui64vNV,vFiip) //NV_texture_barrier GO(glTextureBarrierNV,vFv) @@ -1719,8 +1719,8 @@ GO(glTextureImage3DMultisampleNV,vFuuiiiiii) GO(glActiveVaryingNV,vFup) GO(glBeginTransformFeedbackNV,vFu) GO(glBindBufferBaseNV,vFuuu) -GO(glBindBufferOffsetNV,vFuuui) -GO(glBindBufferRangeNV,vFuuuii) +GO(glBindBufferOffsetNV,vFuuul) +GO(glBindBufferRangeNV,vFuuull) GO(glEndTransformFeedbackNV,vFv) GO(glGetActiveVaryingNV,vFuuipppp) GO(glGetTransformFeedbackVaryingNV,vFuup) @@ -1738,40 +1738,40 @@ GO(glPauseTransformFeedbackNV,vFv) GO(glResumeTransformFeedbackNV,vFv) //NV_vdpau_interop GO(glVDPAUFiniNV,vFv) -GO(glVDPAUGetSurfaceivNV,vFuuipp) +GO(glVDPAUGetSurfaceivNV,vFluipp) GO(glVDPAUInitNV,vFpp) -GO(glVDPAUIsSurfaceNV,vFu) +GO(glVDPAUIsSurfaceNV,CFl) GO(glVDPAUMapSurfacesNV,vFip) -GO(glVDPAURegisterOutputSurfaceNV,uFpuip) -GO(glVDPAURegisterVideoSurfaceNV,uFpuip) -GO(glVDPAUSurfaceAccessNV,vFuu) +GO(glVDPAURegisterOutputSurfaceNV,lFpuip) +GO(glVDPAURegisterVideoSurfaceNV,lFpuip) +GO(glVDPAUSurfaceAccessNV,vFlu) GO(glVDPAUUnmapSurfacesNV,vFip) -GO(glVDPAUUnregisterSurfaceNV,vFu) +GO(glVDPAUUnregisterSurfaceNV,vFl) //NV_vertex_array_range GO(glFlushVertexArrayRangeNV,vFv) GO(glVertexArrayRangeNV,vFip) //NV_vertex_attrib_integer_64bit GO(glGetVertexAttribLi64vNV,vFuup) GO(glGetVertexAttribLui64vNV,vFuup) -GO(glVertexAttribL1i64NV,vFui) +GO(glVertexAttribL1i64NV,vFuI) GO(glVertexAttribL1i64vNV,vFup) -GO(glVertexAttribL1ui64NV,vFuu) +GO(glVertexAttribL1ui64NV,vFuU) GO(glVertexAttribL1ui64vNV,vFup) -GO(glVertexAttribL2i64NV,vFuii) +GO(glVertexAttribL2i64NV,vFuII) GO(glVertexAttribL2i64vNV,vFup) -GO(glVertexAttribL2ui64NV,vFuuu) +GO(glVertexAttribL2ui64NV,vFuUU) GO(glVertexAttribL2ui64vNV,vFup) -GO(glVertexAttribL3i64NV,vFuiii) +GO(glVertexAttribL3i64NV,vFuIII) GO(glVertexAttribL3i64vNV,vFup) -GO(glVertexAttribL3ui64NV,vFuuuu) +GO(glVertexAttribL3ui64NV,vFuUUU) GO(glVertexAttribL3ui64vNV,vFup) -GO(glVertexAttribL4i64NV,vFuiiii) +GO(glVertexAttribL4i64NV,vFuIIII) GO(glVertexAttribL4i64vNV,vFup) -GO(glVertexAttribL4ui64NV,vFuuuuu) +GO(glVertexAttribL4ui64NV,vFuUUUU) GO(glVertexAttribL4ui64vNV,vFup) GO(glVertexAttribLFormatNV,vFuiui) //NV_vertex_buffer_unified_memory -GO(glBufferAddressRangeNV,vFuuui) +GO(glBufferAddressRangeNV,vFuuUl) GO(glColorFormatNV,vFiui) GO(glEdgeFlagFormatNV,vFi) GO(glFogCoordFormatNV,vFui) @@ -1874,7 +1874,7 @@ GO(glVertexAttribI4usvEXT,vFup) GO(glVertexAttribIPointerEXT,vFuiuip) //NV_video_capture GO(glBeginVideoCaptureNV,vFu) -GO(glBindVideoCaptureStreamBufferNV,vFuuui) +GO(glBindVideoCaptureStreamBufferNV,vFuuul) GO(glBindVideoCaptureStreamTextureNV,vFuuuuu) GO(glEndVideoCaptureNV,vFu) GO(glGetVideoCaptureStreamdvNV,vFuuup) @@ -1902,11 +1902,11 @@ GO(glTexCoord3bOES,vFiii) GO(glTexCoord3bvOES,vFp) GO(glTexCoord4bOES,vFiiii) GO(glTexCoord4bvOES,vFp) -GO(glVertex2bOES,vFi) +GO(glVertex2bOES,vFcc) GO(glVertex2bvOES,vFp) -GO(glVertex3bOES,vFii) +GO(glVertex3bOES,vFccc) GO(glVertex3bvOES,vFp) -GO(glVertex4bOES,vFiii) +GO(glVertex4bOES,vFcccc) GO(glVertex4bvOES,vFp) //OES_fixed_point GO(glAccumxOES,vFui) @@ -2659,8 +2659,8 @@ GO(glWindowPos3sv,vFp) //VERSION_1_5 GO(glBeginQuery,vFuu) GO(glBindBuffer,vFuu) -GO(glBufferData,vFuipu) -GO(glBufferSubData,vFuiip) +GO(glBufferData,vFulpu) +GO(glBufferSubData,vFullp) GO(glDeleteBuffers,vFip) GO(glDeleteQueries,vFip) GO(glEndQuery,vFu) @@ -2668,7 +2668,7 @@ GO(glGenBuffers,vFip) GO(glGenQueries,vFip) GO(glGetBufferParameteriv,vFuup) GO(glGetBufferPointerv,vFuup) -GO(glGetBufferSubData,vFuiip) +GO(glGetBufferSubData,vFullp) GO(glGetQueryObjectiv,vFuup) GO(glGetQueryObjectuiv,vFuup) GO(glGetQueryiv,vFuup) @@ -2781,7 +2781,7 @@ GO(glUniformMatrix4x3fv,vFiiip) GO(glBeginConditionalRender,vFuu) GO(glBeginTransformFeedback,vFu) GO(glBindBufferBase,vFuuu) -GO(glBindBufferRange,vFuuuii) +GO(glBindBufferRange,vFuuull) GO(glBindFragDataLocation,vFuup) GO(glClampColor,vFuu) GO(glClearBufferfi,vFuifi) @@ -2862,7 +2862,7 @@ GO(glBindImageTextures, vFuip) GO(glBindSamplers, vFuip) GO(glBindTextures, vFuip) GO(glBindVertexBuffers, vFuippp) -GO(glBufferStorage, vFiupu) +GO(glBufferStorage, vFulpu) GO(glClearTexImage, vFuiiip) GO(glClearTexSubImage, vFuiiiiiiiiip) //VERSION_4_5 @@ -3007,48 +3007,48 @@ GO(TexPageCommitmentARB, vFiiiiiiiii) GO(glXBindHyperpipeSGIX,iFpi) GO(glXBindTexImageEXT, vFppip) GO(glXBindSwapBarrierNV, iFpuu) -GO(glXBindSwapBarrierSGIX,vFii) +GO(glXBindSwapBarrierSGIX,vFpLi) GO(glXBindVideoCaptureDeviceNV, iFpup) GO(glXBindVideoDeviceNV, iFpuup) GO(glXBindVideoImageNV, iFpppi) GO(glXChangeDrawableAttributes,vFp) GO(glXChangeDrawableAttributesSGIX,vFp) GO(glXClientInfo,vFv) -GO(glXCopyContext,vFppp) +GO(glXCopyContext,vFpppL) GO(glXChooseFBConfig, pFpipp) GO(glXChooseFBConfigSGIX, pFpipp) GO(glXCreateContext,pFpppi) GO(glXCreateContextAttribsARB, pFpppip) GO(glXCreateContextWithConfigSGIX,pFppipi) GO(glXCreateGLXPbufferSGIX,pFppuup) -GO(glXCreateGLXPixmap,pFppp) +GO(glXCreateGLXPixmap,LFppL) GO(glXCreateGLXPixmapWithConfigSGIX,pFppp) GO(glXCreateGLXVideoSourceSGIX,pFpippip) GO(glXCreateNewContext,pFppipi) -GOM(glXCreatePbuffer,pFppp) -GO(glXCreatePixmap,pFpppp) -GO(glXCreateWindow,pFpppp) +GOM(glXCreatePbuffer,LFppp) +GO(glXCreatePixmap,LFppLp) +GO(glXCreateWindow,LFppLp) GO(glXChooseVisual, pFpip) GO(glXCopyImageSubDataNV, vFppuiiiiipuiiiiiiii) GO(glXCopySubBufferMESA, vFppiiii) GOM(glXDestroyContext,vFpp) GO(glXDestroyGLXPbufferSGIX,vFpp) -GO(glXDestroyGLXPixmap,vFpp) +GO(glXDestroyGLXPixmap,vFpL) GO(glXDestroyGLXVideoSourceSGIX,vFpp) GO(glXDestroyHyperpipeConfigSGIX,iFpi) -GOM(glXDestroyPbuffer,vFpp) -GO(glXDestroyPixmap,vFpp) -GO(glXDestroyWindow,vFpp) +GOM(glXDestroyPbuffer,vFpL) +GO(glXDestroyPixmap,vFpL) +GO(glXDestroyWindow,vFpL) GO(glXEnumerateVideoCaptureDevicesNV, pFpip) GO(glXEnumerateVideoDevicesNV, pFpip) GO(glXFreeContextEXT, vFpp) GO(glXGetClientString, pFpi) GO(glXGetConfig, iFppip) -GO(glXGetContextIDEXT, uFp) +GO(glXGetContextIDEXT, LFp) GO(glXGetCurrentContext, pFv) GO(glXGetCurrentDisplay, pFv) -GO(glXGetCurrentDrawable, pFv) -GO(glXGetCurrentReadDrawable, pFv) +GO(glXGetCurrentDrawable, LFv) +GO(glXGetCurrentReadDrawable, LFv) GO(glXGetDrawableAttributes,vFi) GO(glXGetDrawableAttributesSGIX,vFi) GO(glXGetFBConfigs,pFpip) @@ -3056,7 +3056,7 @@ GO(glXGetFBConfigAttrib, iFppip) GO(glXGetFBConfigAttribSGIX, iFppip) GO(glXGetFBConfigFromVisualSGIX, pFpp) GO(glXGetFBConfigsSGIX,pFpip) -GO(glXGetSelectedEvent, vFppp) +GO(glXGetSelectedEvent, vFpLp) GO(glXGetSelectedEventSGIX, vFppp) GO(glXGetVideoDeviceNV, iFpiip) GO(glXGetVideoInfoNV, iFpippp) @@ -3066,16 +3066,16 @@ GO(glXGetVisualFromFBConfig, pFpp) GO(glXGetVisualFromFBConfigSGIX, pFpp) GO(glXHyperpipeAttribSGIX,iFpiiip) //GO(glXHyperpipeConfigSGIX,iFpii?p) -GO(glXImportContextEXT, pFpu) +GO(glXImportContextEXT, pFpL) GO(glXIsDirect,iFpp) GO(glXJoinSwapGroupNV, iFppu) -GO(glXJoinSwapGroupSGIX,vFpp) +GO(glXJoinSwapGroupSGIX,vFpLL) GO(glXLockVideoCaptureDeviceNV, vFpp) -GOM(glXMakeContextCurrent,iFpppp) -GOM(glXMakeCurrent,iFppp) +GOM(glXMakeContextCurrent,iFpLLp) +GOM(glXMakeCurrent,iFpLp) GO(glXQueryContext,iFppip) GO(glXQueryContextInfoEXT,iFppip) -GO(glXQueryDrawable, iFppip) +GO(glXQueryDrawable, vFpLip) GO(glXQueryExtension, iFppp) GO(glXQueryExtensionsString,pFpi) GO(glXQueryFrameCountNV, iFpip) @@ -3084,10 +3084,10 @@ GO(glXQueryHyperpipeAttribSGIX,iFpiiip) GO(glXQueryHyperpipeBestAttribSGIX,iFpiiipp) GO(glXQueryHyperpipeConfigSGIX,pFpip) GO(glXQueryHyperpipeNetworkSGIX,pFpp) -GO(glXQueryMaxSwapBarriersSGIX,pFpp) //? +GO(glXQueryMaxSwapBarriersSGIX,iFpip) GO(glXQueryMaxSwapGroupsNV, iFpipp) GO(glXQueryServerString,pFpii) -GO(glXQuerySwapGroupNV, iFpipp) +GO(glXQuerySwapGroupNV, iFpLpp) GO(glXQueryVersion,iFppp) GO(glXQueryVideoCaptureDeviceNV, iFppip) GO(glXReleaseTexImageEXT, vFppi) @@ -3097,11 +3097,11 @@ GO(glXReleaseVideoImageNV, iFpp) //GO(glXRender,vFv) //GO(glXRenderLarge,vFv) GO(glXResetFrameCountNV, iFpi) -GO(glXSelectEvent, vFppu) -GO(glXSelectEventSGIX, vFppu) +GO(glXSelectEvent, vFpLL) +GO(glXSelectEventSGIX, vFpLL) GO(glXSendPbufferToVideoNV, iFppipi) -GO(glXSwapBuffers,vFpp) -GO(glXUseXFont,vFpiii) +GO(glXSwapBuffers,vFpL) +GO(glXUseXFont,vFLiii) //GO(glXVendorPrivate,vFv) //GO(glXVendorPrivateWithReply,vFv) GO(glXWaitGL,vFv) @@ -3125,7 +3125,7 @@ GO(glXWaitForMscOML, iFppIIIppp) GO(glXWaitForSbcOML, iFppIppp) //GLX_EXT_swap_control -GO(glXSwapIntervalEXT,pFppi) +GO(glXSwapIntervalEXT,vFpLi) //GLX_EXT_swap_control_tear //nothing @@ -3320,7 +3320,7 @@ GO(glPathSubCommandsNV, vFulllplip) GO(glPathSubCoordsNV, vFullip) GO(glPathStringNV, vFuilp) GO(glPathGlyphsNV, vFuipulipiuf) -GO(glPathGlyphRangeNV, vFuipuliuf) +GO(glPathGlyphRangeNV, vFuupuuiuuf) GO(glWeightPathsNV, vFulpp) GO(glCopyPathNV, vFuu) GO(glInterpolatePathsNV, vFuuuf) @@ -3348,7 +3348,7 @@ GO(glGetPathCoordsNV, vFup) GO(glGetPathDashArrayNV, vFup) GO(glGetPathMetricsNV, vFulipulp) GO(glGetPathMetricRangeNV, vFuullp) -GO(glGetPathSpacingNV, vFilipufip) +GO(glGetPathSpacingNV, vFuiupuffup) GO(glIsPointInFillPathNV, iFuuff) GO(glIsPointInStrokePathNV, iFuff) GO(glGetPathLengthNV, fFull) @@ -3616,8 +3616,7 @@ GO(glConservativeRasterParameteriNV, vFii) // GL_NV_draw_vulkan_image GO(glDrawVkImageNV, vFUufffffffff) -//GOM(glGetVkProcAddrNV, pFEp)//latx -GO(glGetVkProcAddrNV, pFEp)//latx +GOM(glGetVkProcAddrNV, pFEp)//latx GO(glWaitVkSemaphoreNV, vFU) GO(glSignalVkSemaphoreNV, vFU) GO(glSignalVkFenceNV, vFU) diff --git a/target/i386/latx/include/wrappedlibglx_private.h b/target/i386/latx/include/wrappedlibglx_private.h index fb5bea25a67..9885f176873 100644 --- a/target/i386/latx/include/wrappedlibglx_private.h +++ b/target/i386/latx/include/wrappedlibglx_private.h @@ -16,45 +16,44 @@ // __glXGLLoadGLXFunction GO(glXChooseFBConfig, pFpipp) GO(glXChooseVisual, pFpip) -GO(glXCopyContext,vFppp) +GO(glXCopyContext,vFpppL) GO(glXCreateContext,pFpppi) -GO(glXCreateGLXPixmap,pFppp) +GO(glXCreateGLXPixmap,LFppL) GOM(glXCreateNewContext,pFppipi) -GOM(glXCreatePbuffer,pFppp) -GO(glXCreatePixmap,pFppp) -GO(glXCreateWindow,pFpppp) +GOM(glXCreatePbuffer,LFppp) +GO(glXCreatePixmap,LFppLp) +GO(glXCreateWindow,LFppLp) GOM(glXDestroyContext,vFpp) -GO(glXDestroyGLXPixmap,vFpp) -GOM(glXDestroyPbuffer,vFpp) -GO(glXDestroyPixmap,vFpp) -GO(glXDestroyWindow,vFpp) +GO(glXDestroyGLXPixmap,vFpL) +GOM(glXDestroyPbuffer,vFpL) +GO(glXDestroyPixmap,vFpL) +GO(glXDestroyWindow,vFpL) GO(glXGetClientString, pFpi) GO(glXGetConfig, iFppip) GO(glXGetCurrentContext, pFv) GO(glXGetCurrentDisplay, pFv) -GO(glXGetCurrentDrawable, pFv) -GO(glXGetCurrentReadDrawable, pFv) +GO(glXGetCurrentDrawable, LFv) +GO(glXGetCurrentReadDrawable, LFv) GO(glXGetFBConfigAttrib, iFppip) GO(glXGetFBConfigs,pFpip) GOM(glXGetProcAddress, pFEp) GOM(glXGetProcAddressARB, pFEp) -GO(glXGetSelectedEvent, vFppp) +GO(glXGetSelectedEvent, vFpLp) GO(glXGetVisualFromFBConfig, pFpp) GO(glXIsDirect,iFpp) -GOM(glXMakeContextCurrent,iFpppp) -GOM(glXMakeCurrent,iFppp) +GOM(glXMakeContextCurrent,iFpLLp) +GOM(glXMakeCurrent,iFpLp) GO(glXQueryContext,iFppip) -GO(glXQueryDrawable, iFppip) +GO(glXQueryDrawable, vFpLip) GO(glXQueryExtension, iFppp) GO(glXQueryExtensionsString,pFpi) GO(glXQueryServerString,pFpii) GO(glXQueryVersion,iFppp) -GO(glXSelectEvent, vFppu) -GO(glXSwapBuffers,vFpp) -GO(glXUseXFont,vFpiii) +GO(glXSelectEvent, vFpLL) +GO(glXSwapBuffers,vFpL) +GO(glXUseXFont,vFLiii) GO(glXWaitGL,vFv) GO(glXWaitX,vFv) #endif - diff --git a/target/i386/latx/include/wrappedlibx11_private.h b/target/i386/latx/include/wrappedlibx11_private.h index eb7c0da8d75..59bc5458604 100644 --- a/target/i386/latx/include/wrappedlibx11_private.h +++ b/target/i386/latx/include/wrappedlibx11_private.h @@ -83,7 +83,7 @@ GO(XBitmapUnit, iFp) GO(XBlackPixel, LFpi) //GO(XBlackPixelOfScreen //GO(XCellsOfScreen -GO(XChangeActivePointerGrab, vFpupp) +GO(XChangeActivePointerGrab, iFpuLL) GOM(XChangeGC, iFppLp) GO(XChangeKeyboardControl, iFpLp) GO(XChangeKeyboardMapping, iFpiipi) @@ -333,7 +333,7 @@ GO(_XEatData, vFpL) GO(_XEatDataWords, vFpL) //GO(XEHeadOfExtensionList GO(XEmptyRegion, iFp) -GO(XEnableAccessControl, vFp) +GO(XEnableAccessControl, iFp) GO(_XEnq, vFpp) GO(XEqualRegion, iFpp) GOM(_XError, iFpp) @@ -895,8 +895,8 @@ GOM(XRegisterIMInstantiateCallback, iFEpppppp) // _XRegisterInternalConnection GOM(XRemoveConnectionWatch, iFEppp) GO(XRemoveFromSaveSet, iFpL) -GO(XRemoveHost, vFpp) -GO(XRemoveHosts, vFppi) +GO(XRemoveHost, iFpp) +GO(XRemoveHosts, iFppi) GO(XReparentWindow, iFpppii) GOM(_XReply, iFppii) GO(XResetScreenSaver, iFp) @@ -949,7 +949,7 @@ GO(XSelectInput, iFppl) GO(_XSend, vFppl) GO(XSendEvent, iFppilp) GO(XServerVendor, pFp) -GO(XSetAccessControl, vFpi) +GO(XSetAccessControl, iFpi) GOM(XSetAfterFunction, pFEpp) GO(XSetArcMode, iFppi) //GO(XSetAuthorization diff --git a/target/i386/latx/include/wrappedlibxcb_private.h b/target/i386/latx/include/wrappedlibxcb_private.h index de1bce53546..eb7bdf24677 100644 --- a/target/i386/latx/include/wrappedlibxcb_private.h +++ b/target/i386/latx/include/wrappedlibxcb_private.h @@ -120,7 +120,7 @@ GO(xcb_configure_window, pFbuWp) //GO(xcb_configure_window_value_list_unpack, GOM(xcb_connect, pFEpp) GO(xcb_connection_has_error, iFb) -GO(xcb_connect_to_display_with_auth_info, pFbpp) +GOM(xcb_connect_to_display_with_auth_info, pFEppp) //GO(xcb_connect_to_fd, GO(xcb_convert_selection, pFbuuuuu) //GO(xcb_convert_selection_checked, @@ -223,7 +223,7 @@ GO(xcb_get_file_descriptor, iFb) //GO(xcb_get_font_path, //GO(xcb_get_font_path_path_iterator, //GO(xcb_get_font_path_path_length, -GO(xcb_get_font_path_reply, pFbpup) +GO(xcb_get_font_path_reply, pFbup) //GO(xcb_get_font_path_sizeof, //GO(xcb_get_font_path_unchecked, GO(xcb_get_geometry, pFbu) @@ -339,13 +339,13 @@ GO(xcb_intern_atom_unchecked, uFbCWp) //GO(xcb_list_extensions, //GO(xcb_list_extensions_names_iterator, //GO(xcb_list_extensions_names_length, -GO(xcb_list_extensions_reply, pFbpup) +GO(xcb_list_extensions_reply, pFbup) //GO(xcb_list_extensions_sizeof, //GO(xcb_list_extensions_unchecked, //GO(xcb_list_fonts, //GO(xcb_list_fonts_names_iterator, //GO(xcb_list_fonts_names_length, -GO(xcb_list_fonts_reply, pFbpup) +GO(xcb_list_fonts_reply, pFbup) //GO(xcb_list_fonts_sizeof, //GO(xcb_list_fonts_unchecked, //GO(xcb_list_fonts_with_info, @@ -361,7 +361,7 @@ GO(xcb_list_fonts_reply, pFbpup) //GO(xcb_list_hosts, //GO(xcb_list_hosts_hosts_iterator, //GO(xcb_list_hosts_hosts_length, -GO(xcb_list_hosts_reply, pFbpup) +GO(xcb_list_hosts_reply, pFbup) //GO(xcb_list_hosts_sizeof, //GO(xcb_list_hosts_unchecked, //GO(xcb_list_installed_colormaps, @@ -375,11 +375,11 @@ GO(xcb_list_hosts_reply, pFbpup) //GO(xcb_list_properties_atoms, //GO(xcb_list_properties_atoms_end, //GO(xcb_list_properties_atoms_length, -GO(xcb_list_properties_reply, pFbpup) +GO(xcb_list_properties_reply, pFbup) //GO(xcb_list_properties_sizeof, //GO(xcb_list_properties_unchecked, //GO(xcb_lookup_color, -GO(xcb_lookup_color_reply, pFbpup) +GO(xcb_lookup_color_reply, pFbup) //GO(xcb_lookup_color_sizeof, //GO(xcb_lookup_color_unchecked, GO(xcb_map_subwindows, uFbu) @@ -468,17 +468,17 @@ GO(xcb_put_image_checked, pFbCuuWWwwCCup) //GO(xcb_put_image_data_length, //GO(xcb_put_image_sizeof, //GO(xcb_query_best_size, -GO(xcb_query_best_size_reply, pFbpup) +GO(xcb_query_best_size_reply, pFbup) //GO(xcb_query_best_size_unchecked, //GO(xcb_query_colors, //GO(xcb_query_colors_colors, //GO(xcb_query_colors_colors_iterator, //GO(xcb_query_colors_colors_length, -GO(xcb_query_colors_reply, pFbpup) +GO(xcb_query_colors_reply, pFbup) //GO(xcb_query_colors_sizeof, //GO(xcb_query_colors_unchecked, //GO(xcb_query_extension, -GO(xcb_query_extension_reply, pFbpup) +GO(xcb_query_extension_reply, pFbup) //GO(xcb_query_extension_sizeof, //GO(xcb_query_extension_unchecked, //GO(xcb_query_font, @@ -488,7 +488,7 @@ GO(xcb_query_extension_reply, pFbpup) //GO(xcb_query_font_properties, //GO(xcb_query_font_properties_iterator, //GO(xcb_query_font_properties_length, -GO(xcb_query_font_reply, pFbpup) +GO(xcb_query_font_reply, pFbup) //GO(xcb_query_font_sizeof, //GO(xcb_query_font_unchecked, GO(xcb_query_keymap, pFbp) diff --git a/target/i386/latx/include/wrappedlibxcbrandr_private.h b/target/i386/latx/include/wrappedlibxcbrandr_private.h index 2cb2291f1e5..ef3d7c9a524 100755 --- a/target/i386/latx/include/wrappedlibxcbrandr_private.h +++ b/target/i386/latx/include/wrappedlibxcbrandr_private.h @@ -105,7 +105,7 @@ GO(xcb_randr_get_output_info_modes, pFp) //GO(xcb_randr_get_output_info_modes_end, GO(xcb_randr_get_output_info_modes_length, iFp) GO(xcb_randr_get_output_info_name, pFp) -GO(xcb_randr_get_output_info_name_end, pFp) +GO(xcb_randr_get_output_info_name_end, HFp) GO(xcb_randr_get_output_info_name_length, iFp) GO(xcb_randr_get_output_info_reply, pFbup) //GO(xcb_randr_get_output_info_sizeof, @@ -115,7 +115,7 @@ GO(xcb_randr_get_output_primary_reply, pFbup) GO(xcb_randr_get_output_primary_unchecked, pFbpu) GO(xcb_randr_get_output_property, pFbppppuuCC) GO(xcb_randr_get_output_property_data, pFp) -GO(xcb_randr_get_output_property_data_end, pFpp) +GO(xcb_randr_get_output_property_data_end, HFp) GO(xcb_randr_get_output_property_data_length, iFp) GO(xcb_randr_get_output_property_reply, pFbup) //GO(xcb_randr_get_output_property_sizeof, @@ -219,10 +219,10 @@ DATA(xcb_randr_id, 8) //GO(xcb_randr_mode_info_end, GO(xcb_randr_mode_info_next, vFp) //GO(xcb_randr_mode_next, -GO(xcb_randr_monitor_info_end, pFpp) +GO(xcb_randr_monitor_info_end, HFH) GO(xcb_randr_monitor_info_next, vFp) GO(xcb_randr_monitor_info_outputs, pFp) -GO(xcb_randr_monitor_info_outputs_end, pFpp) +GO(xcb_randr_monitor_info_outputs_end, HFp) GO(xcb_randr_monitor_info_outputs_length, iFp) GO(xcb_randr_monitor_info_sizeof, iFp) //GO(xcb_randr_notify_data_end, diff --git a/target/i386/latx/include/wrappedlibxcbrenderutil_private.h b/target/i386/latx/include/wrappedlibxcbrenderutil_private.h index c20964de657..389c0640d69 100644 --- a/target/i386/latx/include/wrappedlibxcbrenderutil_private.h +++ b/target/i386/latx/include/wrappedlibxcbrenderutil_private.h @@ -9,11 +9,10 @@ //GO(xcb_render_util_composite_text_stream, //GO(xcb_render_util_disconnect, //GO(xcb_render_util_find_format, -GO(xcb_render_util_find_standard_format, uFpi) +GO(xcb_render_util_find_standard_format, pFpu) GO(xcb_render_util_find_visual_format, pFpp) //GO(xcb_render_util_glyphs_16, //GO(xcb_render_util_glyphs_32, //GO(xcb_render_util_glyphs_8, //GO(xcb_render_util_query_formats, //GO(xcb_render_util_query_version, - diff --git a/target/i386/latx/include/wrappedlibxcbshm_private.h b/target/i386/latx/include/wrappedlibxcbshm_private.h index aded2c5f24b..921af44a6e5 100755 --- a/target/i386/latx/include/wrappedlibxcbshm_private.h +++ b/target/i386/latx/include/wrappedlibxcbshm_private.h @@ -23,5 +23,5 @@ GO(xcb_shm_put_image_checked, pFbuuWWWWWWwwCCCuu) GO(xcb_shm_query_version, uFb) GO(xcb_shm_query_version_reply, pFbup) GO(xcb_shm_query_version_unchecked, uFb) -GO(xcb_shm_seg_end, pFpii) +GO(xcb_shm_seg_end, HFH) GO(xcb_shm_seg_next, vFp) diff --git a/target/i386/latx/include/wrappedlibxcbxfixes_private.h b/target/i386/latx/include/wrappedlibxcbxfixes_private.h index df57bfed997..3084768f269 100755 --- a/target/i386/latx/include/wrappedlibxcbxfixes_private.h +++ b/target/i386/latx/include/wrappedlibxcbxfixes_private.h @@ -94,7 +94,7 @@ GO(xcb_xfixes_select_selection_input_checked, uFbuuu) GO(xcb_xfixes_set_cursor_name, pFbpWp) GO(xcb_xfixes_set_cursor_name_checked, pFbpWp) GO(xcb_xfixes_set_cursor_name_name, pFp) -GO(xcb_xfixes_set_cursor_name_name_end, pFp) +GO(xcb_xfixes_set_cursor_name_name_end, HFp) GO(xcb_xfixes_set_cursor_name_name_length, iFp) GO(xcb_xfixes_set_cursor_name_sizeof, iFp) //GO(xcb_xfixes_set_gc_clip_region, diff --git a/target/i386/latx/include/wrappedlibxcbxinput_private.h b/target/i386/latx/include/wrappedlibxcbxinput_private.h index 573255069f0..27bce90134c 100644 --- a/target/i386/latx/include/wrappedlibxcbxinput_private.h +++ b/target/i386/latx/include/wrappedlibxcbxinput_private.h @@ -335,7 +335,7 @@ GO(xcb_input_xi_query_version, uFbWW) GO(xcb_input_xi_query_version_reply, pFbup) //GO(xcb_input_button_class_state, GO(xcb_input_button_class_labels_length, iFp) -GO(xcb_input_button_class_labels_end, pFp) +GO(xcb_input_button_class_labels_end, HFp) GO(xcb_input_button_class_labels, pFp) //GO(xcb_input_button_class_next, //GO(xcb_input_button_class_end, @@ -359,14 +359,14 @@ GO(xcb_input_button_class_labels, pFp) //GO(xcb_input_device_class_data_serialize, //GO(xcb_input_device_class_data_unpack, GO(xcb_input_device_class_next, vFp) -GO(xcb_input_device_class_end, HFpp) +GO(xcb_input_device_class_end, HFH) GO(xcb_input_xi_device_info_classes_length, iFp) GO(xcb_input_xi_device_info_classes_iterator, HFp) GO(xcb_input_xi_device_info_name, pFp) GO(xcb_input_xi_device_info_name_length, iFp) -GO(xcb_input_xi_device_info_name_end, pFp) +GO(xcb_input_xi_device_info_name_end, HFp) GO(xcb_input_xi_device_info_next, vFp) -GO(xcb_input_xi_device_info_end, HFpp) +GO(xcb_input_xi_device_info_end, HFH) GO(xcb_input_xi_query_device, uFbu) GO(xcb_input_xi_query_device_unchecked, uFbu) GO(xcb_input_xi_query_device_infos_length, iFp) diff --git a/target/i386/latx/include/wrappedlibxi_private.h b/target/i386/latx/include/wrappedlibxi_private.h index f10c4af4f65..933d0ba7d9d 100644 --- a/target/i386/latx/include/wrappedlibxi_private.h +++ b/target/i386/latx/include/wrappedlibxi_private.h @@ -15,7 +15,7 @@ GO(XDeleteDeviceProperty, vFppp) //GO(XDeviceBell, //GO(XFreeDeviceControl, GO(XFreeDeviceList, iFp) -GO(XFreeDeviceMotionEvents, iFv) +GO(XFreeDeviceMotionEvents, vFp) GO(XFreeDeviceState, vFp) //GO(XFreeFeedbackList, GO(XGetDeviceButtonMapping, iFpppi) @@ -44,7 +44,7 @@ GO(XIFreeDeviceInfo, vFp) GO(XIGetClientPointer, iFppp) //GO(XIGetFocus, GO(XIGetProperty, iFpipllipppppp) -GO(XIGetSelectedEvents, iFpppi) +GO(XIGetSelectedEvents, pFpLp) GO(XIGrabButton, iFpiippiiipip) GOM(XIGrabDevice, iFpipLpiiip) //GO(XIGrabEnter, diff --git a/target/i386/latx/include/wrappedlibxrandr_private.h b/target/i386/latx/include/wrappedlibxrandr_private.h index 3071329e4f8..d84923aca1c 100644 --- a/target/i386/latx/include/wrappedlibxrandr_private.h +++ b/target/i386/latx/include/wrappedlibxrandr_private.h @@ -60,7 +60,7 @@ GO(XRRGetProviderResources, pFpp) //GO(XRRFreeModeInfo //GO(XRRChangeOutputProperty GO(XRRGetCrtcGamma, pFpu) -GO(XRRSetPanning, pFppu) +GO(XRRSetPanning, iFppLp) GO(XRRSelectInput,vFppi) GO(XRRGetCrtcTransform, iFpUp) GO(XRRTimes,uFpip) @@ -70,4 +70,4 @@ GO(XRRGetOutputInfo, pFppu) GO(XRRAllocateMonitor, pFpi) GO(XRRGetMonitors, pFppip) GO(XRRSetMonitor, vFppp) -GO(XRRFreeMonitors, vFp) \ No newline at end of file +GO(XRRFreeMonitors, vFp) diff --git a/target/i386/latx/include/wrappedlibxss_private.h b/target/i386/latx/include/wrappedlibxss_private.h index d345f049e9a..259ca486f3d 100644 --- a/target/i386/latx/include/wrappedlibxss_private.h +++ b/target/i386/latx/include/wrappedlibxss_private.h @@ -7,7 +7,7 @@ GO(XScreenSaverGetRegistered, uFpipp) GO(XScreenSaverQueryExtension, iFppp) GO(XScreenSaverQueryInfo, iFppp) GO(XScreenSaverQueryVersion, iFppp) -GO(XScreenSaverRegister, vFpiup) +GO(XScreenSaverRegister, iFpiLL) GO(XScreenSaverSelectInput, vFppu) GO(XScreenSaverSetAttributes, vFppiiuuuiupup) GO(XScreenSaverSuspend, vFpi) diff --git a/target/i386/latx/include/wrappedlibxt_private.h b/target/i386/latx/include/wrappedlibxt_private.h index 3aaa02fb92c..d0e2c0359d5 100644 --- a/target/i386/latx/include/wrappedlibxt_private.h +++ b/target/i386/latx/include/wrappedlibxt_private.h @@ -9,7 +9,7 @@ //GO(XtAddCallbacks, //GO(XtAddConverter, //GO(_XtAddDefaultConverters, -GOM(XtAddEventHandler, vFEpuipp) +GOM(XtAddEventHandler, vFEpLipp) //GO(_XtAddEventSeqToStateTree, //GO(XtAddExposureToRegion, //GO(XtAddGrab, @@ -233,7 +233,7 @@ GO(XtGrabButton, vFpipiuiipp) //GO(_XtGrabInitialize, GO(XtGrabKey, vFpppiii) GO(XtGrabKeyboard, iFpiiiu) -GO(XtGrabPointer, iFpiuiipp) +GO(XtGrabPointer, iFpiuiiLLL) //GO(_XtHandleFocus, //GO(XtHasCallbacks, //GO(_XtHeapAlloc, @@ -342,7 +342,7 @@ GO(XtRegisterDrawable, vFppp) //GO(XtRemoveCallback, //GO(_XtRemoveCallback, //GO(XtRemoveCallbacks, -GO(XtRemoveEventHandler, vFpup) // need to wrap to free event handler? +GOM(XtRemoveEventHandler, vFEpLipp) //GO(XtRemoveEventTypeHandler, //GO(XtRemoveGrab, GO(XtRemoveInput, vFl) diff --git a/target/i386/latx/include/wrappedvulkan_private.h b/target/i386/latx/include/wrappedvulkan_private.h index 8bf4330ad9d..de65273d047 100644 --- a/target/i386/latx/include/wrappedvulkan_private.h +++ b/target/i386/latx/include/wrappedvulkan_private.h @@ -139,8 +139,8 @@ GO(vkEnumeratePhysicalDevices, iFppp) GO(vkFlushMappedMemoryRanges, iFpup) // should wrap the array of VkMappedMemoryRange GO(vkFreeCommandBuffers, vFpUup) GO(vkFreeDescriptorSets, iFpUup) -GOM(vkFreeMemory, iFEpUp) -GO(vkGetBufferMemoryRequirements, iFpUp) +GOM(vkFreeMemory, vFEpUp) +GO(vkGetBufferMemoryRequirements, vFpUp) GO(vkGetDeviceMemoryCommitment, vFpUp) GOM(vkGetDeviceProcAddr, pFEpp) GO(vkGetDeviceQueue, vFpuup) @@ -187,7 +187,7 @@ GOM(vkDestroyDescriptorUpdateTemplate, vFEpUp) GOM(vkDestroySamplerYcbcrConversion, vFEpUp) GO(vkEnumerateInstanceVersion, iFp) GO(vkEnumeratePhysicalDeviceGroups, iFppp) //VkPhysicalDeviceGroupProperties seems OK -GO(vkGetBufferMemoryRequirements2, iFppp) +GO(vkGetBufferMemoryRequirements2, vFppp) GO(vkGetImageMemoryRequirements2, vFppp) GO(vkGetImageSparseMemoryRequirements2, vFpppp) GO(vkGetDescriptorSetLayoutSupport, vFppp) @@ -265,7 +265,7 @@ GO(vkCmdSetViewportWithCount, vFpup) // VK_EXT_debug_report GOM(vkCreateDebugReportCallbackEXT, iFEpppp) GO(vkDebugReportMessageEXT, vFpiiULipp) -GOM(vkDestroyDebugReportCallbackEXT, iFEppp) +GOM(vkDestroyDebugReportCallbackEXT, vFEppp) //VK_EXT_debug_utils GO(vkCmdBeginDebugUtilsLabelEXT, vFpp) //TODO: Check alignement of this extension @@ -286,7 +286,7 @@ GO(vkGetPhysicalDeviceExternalBufferPropertiesKHR, vFppp) // VK_KHR_get_physical_device_properties2 GO(vkGetPhysicalDeviceFeatures2KHR, vFpp) GO(vkGetPhysicalDeviceFormatProperties2KHR, vFpip) -GO(vkGetPhysicalDeviceImageFormatProperties2KHR, vFppp) +GO(vkGetPhysicalDeviceImageFormatProperties2KHR, iFppp) GO(vkGetPhysicalDeviceMemoryProperties2KHR, vFpp) GO(vkGetPhysicalDeviceProperties2KHR, vFpp) GO(vkGetPhysicalDeviceQueueFamilyProperties2KHR, vFppp) @@ -370,7 +370,7 @@ GO(vkGetPhysicalDeviceWaylandPresentationSupportKHR, iFpup) GO(vkEnumeratePhysicalDeviceGroupsKHR, iFppp) // VK_KHR_get_memory_requirements2 -GO(vkGetBufferMemoryRequirements2KHR, iFppp) +GO(vkGetBufferMemoryRequirements2KHR, vFppp) GO(vkGetImageMemoryRequirements2KHR, vFppp) GO(vkGetImageSparseMemoryRequirements2KHR, vFpppp) @@ -827,14 +827,14 @@ GO(vkGetDescriptorSetLayoutHostMappingInfoVALVE, vFppp) GO(vkCmdBindDescriptorBufferEmbeddedSamplersEXT, vFppUu) GO(vkCmdBindDescriptorBuffersEXT, vFpup) GO(vkCmdSetDescriptorBufferOffsetsEXT, vFppUuupp) -GO(vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT, vFppp) -GO(vkGetBufferOpaqueCaptureDescriptorDataEXT, vFppp) +GO(vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT, iFppp) +GO(vkGetBufferOpaqueCaptureDescriptorDataEXT, iFppp) GO(vkGetDescriptorEXT, vFppLp) GO(vkGetDescriptorSetLayoutBindingOffsetEXT, vFpUup) GO(vkGetDescriptorSetLayoutSizeEXT, vFpUp) -GO(vkGetImageOpaqueCaptureDescriptorDataEXT, vFppp) -GO(vkGetImageViewOpaqueCaptureDescriptorDataEXT, vFppp) -GO(vkGetSamplerOpaqueCaptureDescriptorDataEXT, vFppp) +GO(vkGetImageOpaqueCaptureDescriptorDataEXT, iFppp) +GO(vkGetImageViewOpaqueCaptureDescriptorDataEXT, iFppp) +GO(vkGetSamplerOpaqueCaptureDescriptorDataEXT, iFppp) // VK_KHR_cooperative_matrix GO(vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR, iFppp) @@ -855,7 +855,7 @@ GO(vkCmdDrawMeshTasksIndirectCountEXT, vFpUUUUuu) GO(vkCmdDrawMeshTasksIndirectEXT, vFpUUuu) // VK_EXT_opacity_micromap -GO(vkBuildMicromapsEXT, iFpiup) +GO(vkBuildMicromapsEXT, iFppup) GO(vkCmdBuildMicromapsEXT, vFpup) GO(vkCmdCopyMemoryToMicromapEXT, vFpp) GO(vkCmdCopyMicromapEXT, vFpp) @@ -921,7 +921,7 @@ GO(vkGetDynamicRenderingTilePropertiesQCOM, iFppp) GO(vkGetFramebufferTilePropertiesQCOM, iFpUpp) // VK_NV_external_memory_capabilities -GO(vkGetPhysicalDeviceExternalImageFormatPropertiesNV, iFpuuuuup) +GO(vkGetPhysicalDeviceExternalImageFormatPropertiesNV, iFpuuuuuup) // VK_EXT_pipeline_properties GO(vkGetPipelinePropertiesEXT, iFppp) @@ -958,10 +958,10 @@ GO(vkSetLatencyMarkerNV, vFpUp) GO(vkSetLatencySleepModeNV, iFpUp) // VK_AMDX_shader_enqueue -GO(vkCmdDispatchGraphAMDX, vFpUp) -GO(vkCmdDispatchGraphIndirectAMDX, vFpUp) +GO(vkCmdDispatchGraphAMDX, vFpUUp) +GO(vkCmdDispatchGraphIndirectAMDX, vFpUUp) GO(vkCmdDispatchGraphIndirectCountAMDX, vFpUU) -GO(vkCmdInitializeGraphScratchMemoryAMDX, vFpU) +GO(vkCmdInitializeGraphScratchMemoryAMDX, vFpUU) GOM(vkCreateExecutionGraphPipelinesAMDX, iFEpUuppp) GO(vkGetExecutionGraphPipelineNodeIndexAMDX, iFpUpp) GO(vkGetExecutionGraphPipelineScratchSizeAMDX, iFpUp) diff --git a/target/i386/latx/include/wrapper.h b/target/i386/latx/include/wrapper.h index 924f179aa97..05b4d58d505 100644 --- a/target/i386/latx/include/wrapper.h +++ b/target/i386/latx/include/wrapper.h @@ -189,6 +189,7 @@ void iFuUu(uintptr_t fnc); void iFuff(uintptr_t fnc); void iFpii(uintptr_t fnc); void iFpiL(uintptr_t fnc); +void iFpiLL(uintptr_t fnc); void iFpip(uintptr_t fnc); void iFpui(uintptr_t fnc); void iFpuu(uintptr_t fnc); @@ -1051,6 +1052,7 @@ void lFppupp(uintptr_t fcn); void LFuui(uintptr_t fcn); void pFEiippppppp(uintptr_t fcn); void pFEppApp(uintptr_t fcn); +void pFEppp(uintptr_t fcn); void pFEpppp(uintptr_t fcn); void pFEppppV(uintptr_t fcn); void pFEpppuipV(uintptr_t fcn); @@ -1109,6 +1111,7 @@ void vFEppip(uintptr_t fcn); void vFEppipA(uintptr_t fcn); void vFEppipppp(uintptr_t fcn); void vFEppipV(uintptr_t fcn); +void vFEpLipp(uintptr_t fcn); void vFEppLippp(uintptr_t fcn); void vFEpppiippp(uintptr_t fcn); void vFEpppiipppp(uintptr_t fcn); @@ -1201,6 +1204,7 @@ void vFpppiipi(uintptr_t fnc); void vFppppipi(uintptr_t fnc); void iFpiiiiii(uintptr_t fnc); void iFpiuiipp(uintptr_t fnc); +void iFpiuiiLLL(uintptr_t fnc); void iFpuiuupp(uintptr_t fnc); void iFpLipipi(uintptr_t fnc); void iFppiiuup(uintptr_t fnc); @@ -1374,6 +1378,45 @@ void iFEpUup(uintptr_t fcn); void iFEpuppp(uintptr_t fcn); void iFEpuvvppp(uintptr_t fcn); void iFEpUUuppp(uintptr_t fcn); +void CFU(uintptr_t fcn); +void CFl(uintptr_t fcn); +void LFppL(uintptr_t fcn); +void LFppLp(uintptr_t fcn); +void UFuiCiu(uintptr_t fcn); +void iFpLLp(uintptr_t fcn); +void iFpuuuuuup(uintptr_t fcn); +void lFpuip(uintptr_t fcn); +void lFui(uintptr_t fcn); +void pFulu(uintptr_t fcn); +void vFLiii(uintptr_t fcn); +void vFUu(uintptr_t fcn); +void vFcc(uintptr_t fcn); +void vFccc(uintptr_t fcn); +void vFcccc(uintptr_t fcn); +void vFlu(uintptr_t fcn); +void vFluipp(uintptr_t fcn); +void vFpLip(uintptr_t fcn); +void vFpLp(uintptr_t fcn); +void vFuI(uintptr_t fcn); +void vFuII(uintptr_t fcn); +void vFuIII(uintptr_t fcn); +void vFuIIII(uintptr_t fcn); +void vFuUU(uintptr_t fcn); +void vFuUUU(uintptr_t fcn); +void vFuUUUU(uintptr_t fcn); +void vFuUuuuuuuuuu(uintptr_t fcn); +void vFuUuuuuuuuuuuu(uintptr_t fcn); +void vFuiupuffup(uintptr_t fcn); +void vFuuUl(uintptr_t fcn); +void vFuuiuil(uintptr_t fcn); +void vFuuli(uintptr_t fcn); +void vFuulluup(uintptr_t fcn); +void vFuupuuiuuf(uintptr_t fcn); +void vFuuuil(uintptr_t fcn); +void vFuuuiuCil(uintptr_t fcn); +void vFuuuiuil(uintptr_t fcn); +void vFuuuli(uintptr_t fcn); +void vFuuuull(uintptr_t fcn); //endvulkan //xcbV2 void pFb(uintptr_t fcn); @@ -1472,6 +1515,7 @@ void CFbupp(uintptr_t fcn); void uFbup(uintptr_t fcn); void vFpC(uintptr_t fcn); void HFpp(uintptr_t fcn); +void HFH(uintptr_t fcn); void uFbuU(uintptr_t fcn); void pFbppU(uintptr_t fcn); void uFbCuuuwwwwwwWW(uintptr_t fcn); From 483be7a77e8c5ac45ad7eb012694efe175008c95 Mon Sep 17 00:00:00 2001 From: Hanlu Li Date: Thu, 13 Aug 2026 19:14:30 +0800 Subject: [PATCH 3/3] LATX, refactor: Share dlfcn wrapper implementation Resolve guest dlfcn entry points through one provider helper and compile one shared implementation for both ABI modes. Keep only provider order, ABI-specific registration, and ABI 2.0 KZT initialization conditional. Signed-off-by: Hanlu Li --- target/i386/latx/context/meson.build | 7 +- target/i386/latx/context/wrappedlibc.c | 838 +----------------------- target/i386/latx/context/wrappedlibdl.c | 75 +-- target/i386/latx/context/x86dlfun.c | 45 ++ target/i386/latx/include/x86dlfun.h | 24 + 5 files changed, 101 insertions(+), 888 deletions(-) create mode 100644 target/i386/latx/context/x86dlfun.c create mode 100644 target/i386/latx/include/x86dlfun.h diff --git a/target/i386/latx/context/meson.build b/target/i386/latx/context/meson.build index 2fc5d4d73cd..4e832ffd945 100644 --- a/target/i386/latx/context/meson.build +++ b/target/i386/latx/context/meson.build @@ -1,4 +1,3 @@ -latx_new_world = 'CONFIG_LOONGARCH_NEW_WORLD' in config_host my_file = files( 'wrappedvulkan.c', 'wrappedlibc.c', @@ -75,11 +74,9 @@ my_file = files( 'callback.c', 'kzt_public_loader_observer.c', 'kzt_relocation_transaction.c', + 'wrappedlibdl.c', + 'x86dlfun.c', 'wrappertbbridge.c' ) -if not latx_new_world - my_file += files('wrappedlibdl.c') -endif - i386_ss.add(when: 'CONFIG_LATX', if_true: my_file) diff --git a/target/i386/latx/context/wrappedlibc.c b/target/i386/latx/context/wrappedlibc.c index 4cfcf652826..7fa2c9ac099 100644 --- a/target/i386/latx/context/wrappedlibc.c +++ b/target/i386/latx/context/wrappedlibc.c @@ -69,6 +69,7 @@ #include "elfloader_private.h" #include "bridge.h" #include "globalsymbols.h" +#include "x86dlfun.h" #define LIBNAME libc const char* libcName = @@ -2922,10 +2923,6 @@ EXPORT int my___libc_alloca_cutoff(size_t size) return (size<=(65536*4)); } -// DL functions from wrappedlibdl.c -void* my_dlopen(void *filename, int flag); -int my_dlclose(void *handle); -void* my_dlsym(void *handle, void *symbol); EXPORT int my___libc_dlclose(void* handle) { return my_dlclose(handle); @@ -3495,838 +3492,5 @@ int box64_isglibc234 = 1; #pragma GCC diagnostic pop -#ifdef CONFIG_LOONGARCH_NEW_WORLD -#include "elfloader.h" -#include "elfloader_private.h" -#include "callback.h" -#include "myalign.h" -#include "fileutils.h" -#include "library.h" - -#define FORWORDBACK 0 -dlprivate_t *NewDLPrivate(void) { - dlprivate_t* dl = (dlprivate_t*)box_calloc(1, sizeof(dlprivate_t)); - return dl; -} -void FreeDLPrivate(dlprivate_t **lib) { - box_free(*lib); -} - -void* my_dlopen(void *filename, int flag) EXPORT; -void* my_dlmopen(void* mlid, void *filename, int flag) EXPORT; -char* my_dlerror(void) EXPORT; -void* my_dlsym(void *handle, void *symbol) EXPORT; -int my_dlclose(void *handle) EXPORT; -int my_dladdr(void *addr, void *info) EXPORT; -int my_dladdr1(void *addr, void *info, void** extra_info, int flags) EXPORT; -void* my_dlvsym(void *handle, void *symbol, const char *vername) EXPORT; -int my_dlinfo(void* handle, int request, void* info) EXPORT; - - -static __thread char dl_error_buffer[512]; -static __thread int dl_error_pending; - -static void clear_dl_error(dlprivate_t *dl) -{ - if (dl && dl->x86dlerror) - (void)RunFunctionWithState((uintptr_t)dl->x86dlerror, 0); - dl_error_pending = 0; -} - -static void set_dl_error(dlprivate_t *dl, const char *message) -{ - (void)dl; - snprintf(dl_error_buffer, sizeof(dl_error_buffer), "%s", message); - dl_error_pending = 1; -} - -static void set_dl_errorf(dlprivate_t *dl, const char *format, ...) -{ - char message[512]; - va_list args; - - va_start(args, format); - vsnprintf(message, sizeof(message), format, args); - va_end(args); - set_dl_error(dl, message); -} - -#define CLEARERR clear_dl_error(dl); - -static int replace_path_token(char **path, const char *token, - const char *replacement) -{ - const size_t token_len = strlen(token); - const size_t replacement_len = strlen(replacement); - size_t search_from = 0; - char *match; - - while ((match = strstr(*path + search_from, token))) { - const size_t prefix_len = (size_t)(match - *path); - const size_t suffix_len = strlen(match + token_len); - size_t expanded_len; - char *expanded; - - if (suffix_len == SIZE_MAX || - prefix_len > SIZE_MAX - replacement_len || - prefix_len + replacement_len > SIZE_MAX - suffix_len - 1) - return -1; - expanded_len = prefix_len + replacement_len + suffix_len + 1; - expanded = box_malloc(expanded_len); - if (!expanded) - return -1; - memcpy(expanded, *path, prefix_len); - memcpy(expanded + prefix_len, replacement, replacement_len); - memcpy(expanded + prefix_len + replacement_len, - match + token_len, suffix_len + 1); - box_free(*path); - *path = expanded; - search_from = prefix_len + replacement_len; - } - return 0; -} - -static char *expand_dlopen_path(const char *filename) -{ - char *path = box_strdup(filename); - char *origin; - char *slash; - - if (!path) - return NULL; - origin = box_strdup(my_context->fullpath ? my_context->fullpath : ""); - if (!origin) { - box_free(path); - return NULL; - } - slash = strrchr(origin, '/'); - - if (slash) - *slash = '\0'; - else - origin[0] = '\0'; - if (replace_path_token(&path, "${ORIGIN}", origin) || - replace_path_token(&path, "${PLATFORM}", "x86_64")) { - box_free(path); - path = NULL; - } - box_free(origin); - return path; -} -//#define R_RSP cpu->regs[R_ESP] -static void Push64(CPUX86State *cpu, uint64_t v) -{ - cpu->regs[R_ESP] -= 8; - *((uint64_t*)cpu->regs[R_ESP]) = v; -} - -void kzt_wine_init_x86(void); -int init_x86dlfun(void); -int init_x86dlfun(void) -{ - elfheader_t* h = NULL; - h = loadElfFromFile("libc.so.6"); - lsassert(h); - const char* syms[] = { - "dlopen", "dlsym", "dlclose", "dladdr", - "dladdr1", "dlinfo", "dlvsym", "dlerror", - }; - void *rsyms[8] = {0}; - int rrsyms = 0; - ResetSpecialCaseElf(h, syms, 8, rsyms, &rrsyms); - if (rrsyms != 8) { - h = loadElfFromFile("libdl.so.2"); - ResetSpecialCaseElf(h, syms, 8, rsyms, &rrsyms); - } - lsassert(rrsyms == 8); - my_context->dlprivate->x86dlopen = rsyms[0]; - my_context->dlprivate->x86dlsym = rsyms[1]; - my_context->dlprivate->x86dlclose = rsyms[2]; - my_context->dlprivate->x86dladdr = rsyms[3]; - my_context->dlprivate->x86dladdr1 = rsyms[4]; - my_context->dlprivate->x86dlinfo = rsyms[5]; - my_context->dlprivate->x86dlvsym = rsyms[6]; - my_context->dlprivate->x86dlerror = rsyms[7]; - kzt_wine_init_x86(); - return 0; -} -static int callx86dlopen(void *filename, int flag, elfheader_t * h, int is_local) { - struct link_map* ret = (struct link_map*)(uintptr_t)RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dlopen, 2, filename, flag); - if (ret) { - printf_dlsym(LOG_DEBUG, "latx RunFunctionWithState dlopen %s addr %p\n", (char *)filename, (void *)ret->l_addr); - h->lib->x86linkmap = ret; - } else { - //open error - return -1; - } - h->delta = ret->l_addr; - linkmap_t* lm = getLinkMapLib(h->lib); - if (lm) { - lm->l_addr = ret->l_addr; - } - h->latx_hasfix = 1; - lib_t *maplib = (is_local)?h->lib->maplib:my_context->maplib; - if(AddSymbolsLibrary(maplib, h->lib)) { // also add needed libs - printf_dlsym(LOG_INFO, "Failure to Add lib => fail\n"); - lsassert(0); - } - return 0; -} -static void LatxResetElf(elfheader_t * h) -{ - h->latx_hasfix = 0; - h->had_RelocateElfPlt = 0; - h->had_RelocateElf = 0; - h->latx_type = 0; - h->latx_hasfix = 0; -} -void* my_dlopen(void *filename, int flag){ - // TODO, handling special values for filename, like RTLD_SELF? - // TODO, handling flags? - library_t *lib = NULL; - dlprivate_t *dl = my_context->dlprivate; - size_t dlopened = 0; - int is_local = (flag&0x100)?0:1; // if not global, then local, and that means symbols are not put in the global "pot" for other libs - CLEARERR - if (!dl->x86dlopen) { - init_x86dlfun(); - lsassert(dl->x86dlopen); - } - if(filename) { - char* rfilename = expand_dlopen_path((char*)filename); - if (!rfilename) { - set_dl_error(dl, "Cannot expand dlopen path"); - return NULL; - } - printf_dlsym(LOG_DEBUG, "Call to dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag); - if (rfilename[0] == '/' && !FileExist(rfilename, IS_FILE)) { - const size_t interp_len = strlen(interp_prefix); - const size_t filename_len = strlen(rfilename); - if (filename_len == SIZE_MAX || - interp_len > SIZE_MAX - filename_len - 1) { - box_free(rfilename); - set_dl_error(dl, "Cannot prefix dlopen path"); - return NULL; - } - char *prefixed = box_malloc(interp_len + filename_len + 1); - if (!prefixed) { - box_free(rfilename); - set_dl_error(dl, "Cannot prefix dlopen path"); - return NULL; - } - strcpy(prefixed, interp_prefix); - strcat(prefixed, rfilename); - box_free(rfilename); - rfilename = prefixed; - printf_dlsym(LOG_DEBUG, "dlopen filename change to \"%s\"\n", rfilename); - } - // check if alread dlopenned... - for (size_t i=0; ilib_sz; ++i) { - if(IsSameLib(dl->libs[i], rfilename)) { - if(dl->count[i]==0 && dl->dlopened[i]) { // need to lauch init again! - int idx = GetElfIndex(dl->libs[i]); - if(idx!=-1) { - printf_dlsym(LOG_DEBUG, "dlopen: Recycling, calling Init for %p (%s)\n", (void*)(i+1), rfilename); - //TODO - if (IsEmuLib(dl->libs[i])) { - elfheader_t * h = my_context->elfs[idx]; - lsassert(h); - LatxResetElf(h); - callx86dlopen(rfilename, flag, h, is_local); - } - ReloadLibrary(dl->libs[i]); // reset memory image, redo reloc, run inits - } - } - if(!(flag&0x4)) - dl->count[i] = dl->count[i]+1; - printf_dlsym(LOG_DEBUG, "dlopen: Recycling %s/%p count=%ld (dlopened=%ld, elf_index=%d)\n", rfilename, (void*)(i+1), dl->count[i], dl->dlopened[i], GetElfIndex(dl->libs[i])); - box_free(rfilename); - return (void*)(i+1); - } - } - if(strstr(rfilename, "libGL.so")){ - box_free(rfilename); - rfilename = box_strdup("libGL.so.1"); - if (!rfilename) { - set_dl_error(dl, "Cannot rewrite dlopen path"); - return NULL; - } - } - dlopened = (GetLibInternal(rfilename)==NULL); - // Then open the lib - const char* libs[] = {rfilename}; - my_context->deferedInit = 1; - int bindnow = (flag&0x2)?1:0; - if (!FindLibIsWrapped(basename(rfilename))) { -#if FORWORDBACK - lsassert(dl->x86dlopen); - __MY_CPU; - Push64(cpu, (uint64_t)dl->x86dlopen); - printf_dlsym(LOG_DEBUG, "warning call x86dlopen filename is %s %x\n", (char *)filename, flag); - return NULL; -#else - uint64_t ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dlopen, 2, filename, flag); - printf_dlsym(LOG_DEBUG, "warning call call x86dlopen filename %s %x ret=0x%lx\n", (char *)filename, flag, ret); - //lsassert(0); - if (ret) { - box_free(rfilename); - return (void *)ret; - } - set_dl_errorf(dl, "filename \"%s\" flag=%x\n", - (char *)filename, flag); - box_free(rfilename); - return NULL; -#endif - } - if(AddNeededLib(NULL, NULL, NULL, is_local, bindnow, libs, 1, my_context)) { - printf_dlsym(strchr(rfilename,'/')?LOG_DEBUG:LOG_INFO, "Warning: Cannot dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag); - set_dl_errorf(dl, "Cannot dlopen(\"%s\"/%p, %X)\n", - rfilename, filename, flag); - box_free(rfilename); - return NULL; - } - lib = GetLibInternal(rfilename); - if (!lib) { - box_free(rfilename); - return NULL; - } - lib->x86dlopenflag = flag; - if (lib && lib->type == LIB_EMULATED) { - // if dlopened = 0 ---> lib added but not loaded - int libidx = GetElfIndex(lib); - lsassert(libidx >= 0); - elfheader_t * h = my_context->elfs[libidx]; - lsassert(h); - if (!h->latx_hasfix || !lib->x86linkmap) {//lib->x86linkmap is null ---- this lib has been needed by other elf and opened - callx86dlopen(rfilename, flag, h, is_local); - } - } - //TODO:RunDeferedElfInit; - box_free(rfilename); - } else { - // check if already dlopenned... - for (size_t i=0; ilib_sz; ++i) { - if(!dl->libs[i]) { - dl->count[i] = dl->count[i]+1; - return (void*)(i+1); - } - } - printf_dlsym(LOG_DEBUG, "Call to dlopen(NULL, %X) forword call x86dlopen \n", flag); - lsassert(dl->x86dlopen); - __MY_CPU; - Push64(cpu, (uint64_t)dl->x86dlopen); - return NULL; - } - //get the lib and add it to the collection - - if(dl->lib_sz == dl->lib_cap) { - dl->lib_cap += 4; - dl->libs = (library_t**)box_realloc(dl->libs, sizeof(library_t*)*dl->lib_cap); - dl->count = (size_t*)box_realloc(dl->count, sizeof(size_t)*dl->lib_cap); - dl->dlopened = (size_t*)box_realloc(dl->dlopened, sizeof(size_t)*dl->lib_cap); - // memset count... - memset(dl->count+dl->lib_sz, 0, (dl->lib_cap-dl->lib_sz)*sizeof(size_t)); - } - intptr_t idx = dl->lib_sz++; - dl->libs[idx] = lib; - dl->count[idx] = dl->count[idx]+1; - dl->dlopened[idx] = dlopened; - printf_dlsym(LOG_DEBUG, "dlopen: New handle %p (%s), dlopened=%ld\n", (void*)(idx+1), (char*)filename, dlopened); - if (lib && lib->type == LIB_EMULATED) { - return lib->x86linkmap; - } - return (void*)(idx+1); -} - -void* my_dlmopen(void* lmid, void *filename, int flag) -{ - dlprivate_t *dl = my_context->dlprivate; - - if ((Lmid_t)lmid != LM_ID_BASE) { - char error[160]; - snprintf(error, sizeof(error), - "dlmopen namespace %p is unsupported", lmid); - set_dl_error(dl, error); - printf_dlsym(LOG_INFO, - "Warning, dlmopen(%p, %p(\"%s\"), 0x%x) rejected: unsupported namespace\n", - lmid, filename, filename ? (char*)filename : "self", flag); - return NULL; - } - return my_dlopen(filename, flag); -} - -KHASH_SET_INIT_INT(libs); - -static int recursive_dlsym_lib(kh_libs_t* collection, library_t* lib, const char* rsymbol, uintptr_t *start, uintptr_t *end, int version, const char* vername) -{ - if(!lib) - return 0; - khint_t k = kh_get(libs, collection, (uintptr_t)lib); - if(k != kh_end(collection)) - return 0; - int ret; - kh_put(libs, collection, (uintptr_t)lib, &ret); - // look in the library itself - khint_t pre_k = kh_str_hash_func(rsymbol); - if(lib->get(lib, rsymbol, pre_k, start, end, version, vername, 1)) - return 1; - // look in other libs - int n = GetNeededLibN(lib); - for (int i=0; i 0 && raw_handle <= dl->lib_sz) { - *index = raw_handle - 1; - return 1; - } - for (size_t i = 0; i < dl->lib_sz; ++i) { - if (dl->libs[i] && dl->libs[i]->x86linkmap == handle) { - *index = i; - return 1; - } - } - return 0; -} - -void* my_dlsym(void *handle, void *symbol){ - dlprivate_t *dl = my_context->dlprivate; - uintptr_t start = 0, end = 0; - char* rsymbol = (char*)symbol; - CLEARERR - if (!dl->x86dlsym) { - init_x86dlfun(); - lsassert(dl->x86dlsym); - } - printf_dlsym(LOG_DEBUG, "Call to dlsym(%p, \"%s\")%s\n", handle, rsymbol, dlsym_error?"":"\n"); - if (handle && handle != (void*)~0LL) { - size_t known_index; - if (!find_dl_library_index(dl, handle, &known_index)) { - uint64_t ret = RunFunctionWithState( - (uintptr_t)dl->x86dlsym, 2, handle, symbol); - if (!ret) - set_dl_errorf(dl, "Symbol \"%s\" not found in %p\n", - rsymbol, handle); - return (void*)ret; - } - } - //lsassert(!strstr(rsymbol, "XcursorGetDefaultSize")); - if(handle==NULL) { - // special case, look globably - // special case (RTLD_DEFAULT) -#ifdef LATX_RELOCATION_SAVE_SYMBOLS - if(GetGlobalSymbolStartEnd(my_context->maplib, rsymbol, &start, &end, NULL, -1, NULL)) { - printf_dlsym(LOG_NEVER, "%p\n", (void*)start); - return (void*)start; - } -#endif -#if 0 - lsassert(dl->x86dlsym); - __MY_CPU; - Push64(cpu, (uint64_t)dl->x86dlsym); - printf_dlsym(LOG_DEBUG, "warning call x86dlsym filename is NULL\n"); - return NULL; -#else - uint64_t ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dlsym, 2, handle, symbol); - printf_dlsym(LOG_DEBUG, "warning call x86dlsym filename is NULL ret=0x%lx\n", ret); - if (ret) { - return (void *)ret; - } else { - if(GetGlobalSymbolStartEnd(my_context->maplib, rsymbol, &start, &end, NULL, -1, NULL)) { - printf_dlsym(LOG_NEVER, "%p\n", (void*)start); - return (void*)start; - } - printf_dlsym(LOG_NEVER, "debug my %d\n", __LINE__); - } - set_dl_errorf(dl, "Symbol \"%s\" not found in %p)\n", rsymbol, - handle); - return NULL; -#endif - } - if(handle==(void*)~0LL) { - // special case (RTLD_NEXT) -- call x86dlsym - lsassert(dl->x86dlsym); - __MY_CPU; - Push64(cpu, (uint64_t)dl->x86dlsym); - printf_dlsym(LOG_DEBUG, "warning call x86dlsym filename is RTLD_NEXT\n"); - return NULL; - } - size_t nlib = (size_t)handle; - if(nlib > dl->lib_sz) { - for (int i = 0; i < dl->lib_sz; i++) { - if (dl->libs[i] && dl->libs[i]->active && dl->libs[i]->type == LIB_EMULATED && ((size_t)dl->libs[i]->x86linkmap) == nlib) { - nlib = i + 1; - break; - } - } - } - --nlib; - // size_t is unsigned - if(nlib>=dl->lib_sz) { -#ifdef LATX_RELOCATION_SAVE_SYMBOLS - if(GetGlobalSymbolStartEnd(my_context->maplib, rsymbol, &start, &end, NULL, -1, NULL)) { - printf_dlsym(LOG_NEVER, "%p\n", (void*)start); - return (void*)start; - } -#endif - const char* lmfile = ((struct link_map *)handle)->l_name; - if (strlen(lmfile)) { - const char* libs[] = {basename(lmfile)}; - //try to wrapper. - int iswrapped = 0.; - if (FindLibIsWrapped((char *)libs[0])) { - //if file is wrapped. - iswrapped = 1; - printf_dlsym(LOG_DEBUG, "find lib \"%s\" shuold be wrapped. init it.\n", libs[0]); - if(AddNeededLib(NULL, NULL, NULL, 0, 1, libs, 1, my_context)) { - printf_dlsym(LOG_DEBUG, "Warning: Cannot AddNeededLib(\"%s\")\n", libs[0]); - } - printf_dlsym(LOG_DEBUG, "info: success AddNeededLib(\"%s\")\n", libs[0]); - if(GetGlobalSymbolStartEnd(my_context->maplib, rsymbol, &start, &end, NULL, -1, NULL)) { - printf_dlsym(LOG_NEVER, "%p\n", (void*)start); - return (void*)start; - } - } - if (iswrapped) { - //Perhaps exe want to test func for earch libs, return nil. - printf_dlsym(LOG_NEVER, "%p\n", (void*)NULL); - return NULL; - } - } -#if !defined(LATX_RELOCATION_SAVE_SYMBOLS) - else {//dlopen(NULL) --- dlopen self maplink filename is "NULL". - if(GetGlobalSymbolStartEnd(my_context->maplib, rsymbol, &start, &end, NULL, -1, NULL)) { - printf_dlsym(LOG_NEVER, "%p\n", (void*)start); - return (void*)start; - } - } -#endif -#if FORWORDBACK - __MY_CPU; - lsassert(dl->x86dlsym); - Push64(cpu, (uint64_t)dl->x86dlsym); - printf_dlsym(LOG_DEBUG, "warning call x86dlsym filename is %s 0x%lx %s\n", strlen(lmfile)?lmfile:"NULL", cpu->regs[R_EDI], (char*)symbol); - return NULL; -#else - uint64_t ret = RunFunctionWithState( - (uintptr_t)my_context->dlprivate->x86dlsym, 2, handle, - symbol); - printf_dlsym(LOG_DEBUG, "warning call call x86dlsym filename is %s handle %p ret=0x%lx\n", strlen(lmfile)?lmfile:"NULL", handle, ret); - if (ret) { - return (void *)ret; - } - set_dl_errorf(dl, "Symbol \"%s\" not found in %p)\n", rsymbol, - handle); - return NULL; -#endif - } - if(dl->count[nlib]==0) { - set_dl_errorf(dl, "Bad handle %p (already closed))\n", handle); - return NULL; - } - if(dl->libs[nlib]) { - if(my_dlsym_lib(dl->libs[nlib], rsymbol, &start, &end, -1, NULL)==0) { - // not found - __MY_CPU; - #if 1 - if(!dl->libs[nlib]->x86linkmap) { - //redlopen - uint64_t ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dlopen, 2, dl->libs[nlib]->name, dl->libs[nlib]->x86dlopenflag); - if (!ret) {//user sometime test for finding a func. - printf_dlsym(LOG_NEVER, "redlopen %p return %p\n", rsymbol, (void*)NULL); - return NULL; - } - lsassert(ret); - dl->libs[nlib]->x86linkmap = (void *)ret; - ret = RunFunctionWithState( - (uintptr_t)my_context->dlprivate->x86dlsym, 2, - dl->libs[nlib]->x86linkmap, symbol); - printf_dlsym(LOG_DEBUG, "call x86dlsym filename %s is wrapped but not find symbol, dlsym(%p, %s) ret=0x%lx\n", - dl->libs[nlib]->name, dl->libs[nlib]->x86linkmap, (char *)symbol, ret); - return (void *)ret; - } - #endif - lsassert(dl->x86dlsym); - if (dl->libs[nlib]->x86linkmap != handle) { - cpu->regs[R_EDI] = (uintptr_t)dl->libs[nlib]->x86linkmap; - } -#if FORWORDBACK - Push64(cpu, (uint64_t)dl->x86dlsym); - printf_dlsym(LOG_DEBUG, "warning call x86dlsym filename is %s %lx\n", dl->libs[nlib]->x86linkmap->l_name, cpu->regs[R_EDI]); - return NULL; -#else - uint64_t ret = RunFunctionWithState( - (uintptr_t)my_context->dlprivate->x86dlsym, 2, - dl->libs[nlib]->x86linkmap, symbol); - printf_dlsym(LOG_DEBUG, "call x86dlsym filename is %s %s ret=0x%lx\n", dl->libs[nlib]->x86linkmap->l_name, (char *)symbol, ret); - if (ret) { - return (void *)ret; - } - set_dl_errorf(dl, "Symbol \"%s\" not found in %p)\n", rsymbol, - handle); - return NULL; -#endif - } - } else { - // still usefull? - // => look globably -#ifdef LATX_RELOCATION_SAVE_SYMBOLS - if(GetGlobalSymbolStartEnd(my_context->maplib, rsymbol, &start, &end, NULL, -1, NULL)) { - printf_dlsym(LOG_NEVER, "%p\n", (void*)start); - return (void*)start; - } -#endif - set_dl_errorf(dl, "Symbol \"%s\" not found in %p)\n", rsymbol, - handle); - printf_dlsym(LOG_NEVER, "%p\n", NULL); - return NULL; - } - printf_dlsym(LOG_NEVER, "%p\n", (void*)start); - return (void*)start; -} - -int my_dlclose(void *handle) -{ - printf_dlsym(LOG_DEBUG, "Call to dlclose(%p)\n", handle); - dlprivate_t *dl = my_context->dlprivate; - CLEARERR - if (!dl->x86dlclose) { - init_x86dlfun(); - lsassert(dl->x86dlclose); - } - size_t nlib = (size_t)handle; - if(nlib > dl->lib_sz) { - for (int i = 0; i < dl->lib_sz; i++) { - if (dl->libs[i] && dl->libs[i]->active && dl->libs[i]->type == LIB_EMULATED && ((size_t)dl->libs[i]->x86linkmap) == nlib) { - nlib = i + 1; - break; - } - } - } - --nlib; - // size_t is unsigned - if(nlib>=dl->lib_sz) { - int ret = -1; - if (dl->x86dlclose) { - __MY_CPU; - Push64(cpu, (uint64_t)dl->x86dlclose); - return 0; - } - set_dl_errorf(dl, "Bad handle %p, ret = %d)\n", handle, ret); - return -1; - } - if(dl->count[nlib]==0) { - set_dl_errorf(dl, "Bad handle %p (already closed))\n", handle); - return -1; - } - dl->count[nlib] = dl->count[nlib]-1; - if(dl->count[nlib]==0 && dl->dlopened[nlib]) { // need to call Fini... - int idx = GetElfIndex(dl->libs[nlib]); - if(idx!=-1) { - printf_dlsym(LOG_DEBUG, "dlclose: Call to Fini for %p\n", handle); - InactiveLibrary(dl->libs[nlib]); - if (dl->x86dlclose) { - __MY_CPU; - if (dl->libs[nlib]->x86linkmap != handle) { - cpu->regs[R_EDI] = (uintptr_t)dl->libs[nlib]->x86linkmap; - } - Push64(cpu, (uint64_t)dl->x86dlclose); - return 0; - } - } - } - return 0; -} - -char* my_dlerror(void) -{ - dlprivate_t *dl = my_context->dlprivate; - - if (!dl->x86dlerror) - init_x86dlfun(); - if (dl_error_pending) { - if (dl->x86dlerror) - (void)RunFunctionWithState((uintptr_t)dl->x86dlerror, 0); - dl_error_pending = 0; - return dl_error_buffer; - } - if (!dl->x86dlerror) - return NULL; - return (char*)(uintptr_t)RunFunctionWithState( - (uintptr_t)dl->x86dlerror, 0); -} - -int my_dladdr1(void *addr, void *i, void** extra_info, int flags) -{ - //int dladdr(void *addr, Dl_info *info); - dlprivate_t *dl = my_context->dlprivate; - CLEARERR - if (!dl->x86dladdr1) { - init_x86dlfun(); - lsassert(dl->x86dladdr1); - } - Dl_info *info = (Dl_info*)i; - printf_dlsym(LOG_DEBUG, "Warning: partially unimplement call to dladdr/dladdr1(%p, %p, %p, %d)\n", addr, info, extra_info, flags); - __MY_CPU; - uint64_t ret = 0; - if (extra_info == NULL && flags == 0) { - ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dladdr, 2, cpu->regs[R_EDI], cpu->regs[R_ESI]); - } else { - ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dladdr1, 4, cpu->regs[R_EDI], cpu->regs[R_ESI], cpu->regs[R_EDX], cpu->regs[R_ECX]); - } - printf_dlsym(LOG_DEBUG, " call to x86dladdr1 return saddr=%p, fname=\"%s\", sname=\"%s\" ret=%ld\n", info->dli_saddr, info->dli_sname?info->dli_sname:"", info->dli_fname?info->dli_fname:"", ret); - if (ret == 1) { - return ret; - } - //emu->quit = 1; - library_t* lib = NULL; - info->dli_saddr = NULL; - info->dli_fname = NULL; - info->dli_sname = FindSymbolName(my_context->maplib, addr, &info->dli_saddr, NULL, &info->dli_fname, &info->dli_fbase, &lib); - printf_dlsym(LOG_DEBUG, " dladdr return saddr=%p, fname=\"%s\", sname=\"%s\"\n", info->dli_saddr, info->dli_sname?info->dli_sname:"", info->dli_fname?info->dli_fname:""); - if(flags==RTLD_DL_SYMENT) { - printf_dlsym(LOG_INFO, "Warning, unimplement call to dladdr1 with RTLD_DL_SYMENT flags\n"); - } else if (flags==RTLD_DL_LINKMAP) { - printf_dlsym(LOG_INFO, "Warning, partially unimplemented call to dladdr1 with RTLD_DL_LINKMAP flags\n"); - *(linkmap_t**)extra_info = getLinkMapLib(lib); - } - return (info->dli_sname)?1:0; // success is non-null here... -} -int my_dladdr(void *addr, void *i) -{ - dlprivate_t *dl = my_context->dlprivate; - CLEARERR - if (!dl->x86dladdr) { - init_x86dlfun(); - lsassert(dl->x86dladdr); - } -#ifdef CONFIG_LATX_DEBUG - Dl_info *info = (Dl_info*)i; -#endif - printf_dlsym(LOG_DEBUG, "Warning: partially unimplement call to dladdr(%p, %p)\n", addr, info); - __MY_CPU; - uint64_t ret = RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dladdr, 2, cpu->regs[R_EDI], cpu->regs[R_ESI]); - printf_dlsym(LOG_DEBUG, " call to x86dladdr return saddr=%p, fname=\"%s\", sname=\"%s\" ret=%ld\n", info->dli_saddr, info->dli_sname?info->dli_sname:"", info->dli_fname?info->dli_fname:"", ret); - if (ret == 1) { - return ret; - } - return my_dladdr1(addr, i, NULL, 0); -} -void* my_dlvsym(void *handle, void *symbol, const char *vername) -{ - printf_dlsym(LOG_DEBUG, "Call to dlvsym(%p, \"%s\", %s)", handle, (char *)symbol, vername?vername:"(nil)"); - dlprivate_t *dl = my_context->dlprivate; - size_t nlib; - void *guest_handle = handle; - - clear_dl_error(dl); - if (!dl->x86dlvsym) - init_x86dlfun(); - if (!dl->x86dlvsym) { - set_dl_error(dl, "dlvsym is unavailable in the guest loader"); - return NULL; - } - if (handle == (void*)~0LL) { - __MY_CPU; - Push64(cpu, (uint64_t)dl->x86dlvsym); - return NULL; - } - if (!handle) - return (void*)(uintptr_t)RunFunctionWithState( - (uintptr_t)dl->x86dlvsym, 3, guest_handle, symbol, vername); - if (find_dl_library_index(dl, handle, &nlib)) { - if (!dl->count[nlib]) { - set_dl_errorf(dl, "Bad handle %p (already closed)\n", handle); - return NULL; - } - if (!dl->libs[nlib]) { - return (void*)(uintptr_t)RunFunctionWithState( - (uintptr_t)dl->x86dlvsym, 3, NULL, symbol, vername); - } - guest_handle = dl->libs[nlib]->x86linkmap; - if (!guest_handle) { - guest_handle = (void*)(uintptr_t)RunFunctionWithState( - (uintptr_t)dl->x86dlopen, 2, dl->libs[nlib]->name, - dl->libs[nlib]->x86dlopenflag); - dl->libs[nlib]->x86linkmap = guest_handle; - if (!guest_handle) { - set_dl_errorf(dl, "Missing guest link_map for handle %p\n", - handle); - return NULL; - } - } - } - uintptr_t ret = RunFunctionWithState( - (uintptr_t)dl->x86dlvsym, 3, guest_handle, symbol, vername); - return (void*)ret; -} - -int my_dlinfo(void* handle, int request, void* info) -{ - printf_dlsym(LOG_DEBUG, "Call to dlinfo(%p, %d, %p)\n", handle, request, info); - dlprivate_t *dl = my_context->dlprivate; - CLEARERR - if (!dl->x86dlinfo) { - init_x86dlfun(); - lsassert(dl->x86dlinfo); - } - size_t nlib; - void *guest_handle = handle; - if (find_dl_library_index(dl, handle, &nlib)) { - if (!dl->count[nlib]) { - set_dl_errorf(dl, "Bad handle %p (already closed)\n", handle); - return -1; - } - if (!dl->libs[nlib]) { - guest_handle = NULL; - } else { - guest_handle = dl->libs[nlib]->x86linkmap; - if (!guest_handle) { - guest_handle = (void*)(uintptr_t)RunFunctionWithState( - (uintptr_t)dl->x86dlopen, 2, dl->libs[nlib]->name, - dl->libs[nlib]->x86dlopenflag); - dl->libs[nlib]->x86linkmap = guest_handle; - if (!guest_handle) { - set_dl_errorf(dl, - "Cannot open guest library for handle %p\n", - handle); - return -1; - } - } - if (request == RTLD_DI_LINKMAP) { - if (!info) { - set_dl_errorf(dl, - "Invalid dlinfo result for handle %p\n", - handle); - return -1; - } - *(struct link_map**)info = guest_handle; - return 0; - } - } - } - uint64_t ret = RunFunctionWithState( - (uintptr_t)dl->x86dlinfo, 3, guest_handle, request, info); - return ret; -} -#endif #include "wrappedlib_init.h" diff --git a/target/i386/latx/context/wrappedlibdl.c b/target/i386/latx/context/wrappedlibdl.c index 3043da61cdf..f4740b2ef92 100644 --- a/target/i386/latx/context/wrappedlibdl.c +++ b/target/i386/latx/context/wrappedlibdl.c @@ -6,6 +6,7 @@ * SPDX-License-Identifier: MIT */ +#include "config-host.h" #include #include #include @@ -29,6 +30,12 @@ #include "callback.h" #include "myalign.h" #include "fileutils.h" +#include "x86dlfun.h" + +#ifndef CONFIG_LOONGARCH_NEW_WORLD +#define LIBNAME libdl +const char *libdlName = "libdl.so.2"; +#endif #define FORWORDBACK 0 dlprivate_t *NewDLPrivate(void) { @@ -39,19 +46,6 @@ void FreeDLPrivate(dlprivate_t **lib) { box_free(*lib); } -void* my_dlopen(void *filename, int flag) EXPORT; -void* my_dlmopen(void* mlid, void *filename, int flag) EXPORT; -char* my_dlerror(void) EXPORT; -void* my_dlsym(void *handle, void *symbol) EXPORT; -int my_dlclose(void *handle) EXPORT; -int my_dladdr(void *addr, void *info) EXPORT; -int my_dladdr1(void *addr, void *info, void** extra_info, int flags) EXPORT; -void* my_dlvsym(void *handle, void *symbol, const char *vername) EXPORT; -int my_dlinfo(void* handle, int request, void* info) EXPORT; - -#define LIBNAME libdl -const char* libdlName = "libdl.so.2"; - static __thread char dl_error_buffer[512]; static __thread int dl_error_pending; @@ -149,32 +143,19 @@ static void Push64(CPUX86State *cpu, uint64_t v) *((uint64_t*)cpu->regs[R_ESP]) = v; } -int init_x86dlfun(void); -int init_x86dlfun(void) +#ifdef CONFIG_LOONGARCH_NEW_WORLD +void kzt_wine_init_x86(void); +#endif + +static int init_x86dlfun(void) { - elfheader_t* h = loadElfFromFile("libdl.so.2"); - lsassert(h); - const char* syms[] = { - "dlopen", "dlsym", "dlclose", "dladdr", - "dladdr1", "dlinfo", "dlvsym", "dlerror", - }; - void *rsyms[8] = {0}; - int rrsyms = 0; - ResetSpecialCaseElf(h, syms, 8, rsyms, &rrsyms); - if (rrsyms != 8) { - h = loadElfFromFile("libc.so.6"); - ResetSpecialCaseElf(h, syms, 8, rsyms, &rrsyms); - } - lsassert(rrsyms == 8); - my_context->dlprivate->x86dlopen = rsyms[0]; - my_context->dlprivate->x86dlsym = rsyms[1]; - my_context->dlprivate->x86dlclose = rsyms[2]; - my_context->dlprivate->x86dladdr = rsyms[3]; - my_context->dlprivate->x86dladdr1 = rsyms[4]; - my_context->dlprivate->x86dlinfo = rsyms[5]; - my_context->dlprivate->x86dlvsym = rsyms[6]; - my_context->dlprivate->x86dlerror = rsyms[7]; +#ifdef CONFIG_LOONGARCH_NEW_WORLD + init_x86dlfun_from("libc.so.6", "libdl.so.2"); + kzt_wine_init_x86(); return 0; +#else + return init_x86dlfun_from("libdl.so.2", "libc.so.6"); +#endif } static int callx86dlopen(void *filename, int flag, elfheader_t * h, int is_local) { struct link_map* ret = (struct link_map*)(uintptr_t)RunFunctionWithState((uintptr_t)my_context->dlprivate->x86dlopen, 2, filename, flag); @@ -206,7 +187,7 @@ static void LatxResetElf(elfheader_t * h) h->latx_type = 0; h->latx_hasfix = 0; } -void* my_dlopen(void *filename, int flag){ +EXPORT void* my_dlopen(void *filename, int flag){ // TODO, handling special values for filename, like RTLD_SELF? // TODO, handling flags? library_t *lib = NULL; @@ -364,7 +345,7 @@ void* my_dlopen(void *filename, int flag){ return (void*)(idx+1); } -void* my_dlmopen(void* lmid, void *filename, int flag) +EXPORT void* my_dlmopen(void* lmid, void *filename, int flag) { dlprivate_t *dl = my_context->dlprivate; @@ -433,7 +414,7 @@ static int find_dl_library_index(dlprivate_t *dl, void *handle, size_t *index) return 0; } -void* my_dlsym(void *handle, void *symbol){ +EXPORT void* my_dlsym(void *handle, void *symbol){ dlprivate_t *dl = my_context->dlprivate; uintptr_t start = 0, end = 0; char* rsymbol = (char*)symbol; @@ -628,7 +609,7 @@ void* my_dlsym(void *handle, void *symbol){ return (void*)start; } -int my_dlclose(void *handle) +EXPORT int my_dlclose(void *handle) { printf_dlsym(LOG_DEBUG, "Call to dlclose(%p)\n", handle); dlprivate_t *dl = my_context->dlprivate; @@ -681,7 +662,7 @@ int my_dlclose(void *handle) return 0; } -char* my_dlerror(void) +EXPORT char* my_dlerror(void) { dlprivate_t *dl = my_context->dlprivate; @@ -699,7 +680,7 @@ char* my_dlerror(void) (uintptr_t)dl->x86dlerror, 0); } -int my_dladdr1(void *addr, void *i, void** extra_info, int flags) +EXPORT int my_dladdr1(void *addr, void *i, void** extra_info, int flags) { //int dladdr(void *addr, Dl_info *info); dlprivate_t *dl = my_context->dlprivate; @@ -735,7 +716,7 @@ int my_dladdr1(void *addr, void *i, void** extra_info, int flags) } return (info->dli_sname)?1:0; // success is non-null here... } -int my_dladdr(void *addr, void *i) +EXPORT int my_dladdr(void *addr, void *i) { dlprivate_t *dl = my_context->dlprivate; CLEARERR @@ -755,7 +736,7 @@ int my_dladdr(void *addr, void *i) } return my_dladdr1(addr, i, NULL, 0); } -void* my_dlvsym(void *handle, void *symbol, const char *vername) +EXPORT void* my_dlvsym(void *handle, void *symbol, const char *vername) { printf_dlsym(LOG_DEBUG, "Call to dlvsym(%p, \"%s\", %s)", handle, (char *)symbol, vername?vername:"(nil)"); dlprivate_t *dl = my_context->dlprivate; @@ -804,7 +785,7 @@ void* my_dlvsym(void *handle, void *symbol, const char *vername) return (void*)ret; } -int my_dlinfo(void* handle, int request, void* info) +EXPORT int my_dlinfo(void* handle, int request, void* info) { printf_dlsym(LOG_DEBUG, "Call to dlinfo(%p, %d, %p)\n", handle, request, info); dlprivate_t *dl = my_context->dlprivate; @@ -854,4 +835,6 @@ int my_dlinfo(void* handle, int request, void* info) return ret; } +#ifndef CONFIG_LOONGARCH_NEW_WORLD #include "wrappedlib_init.h" +#endif diff --git a/target/i386/latx/context/x86dlfun.c b/target/i386/latx/context/x86dlfun.c new file mode 100644 index 00000000000..d8ed666e2f8 --- /dev/null +++ b/target/i386/latx/context/x86dlfun.c @@ -0,0 +1,45 @@ +/* + * This file is derived from Box64. + * + * SPDX-FileCopyrightText: 2020 ptitSeb + * + * SPDX-License-Identifier: MIT + */ + +#include "box64context.h" +#include "debug.h" +#include "elfloader.h" +#include "myalign.h" +#include "x86dlfun.h" + +int init_x86dlfun_from(const char *primary, const char *fallback) +{ + enum { X86_DL_SYMBOL_COUNT = 8 }; + static const char *symbols[X86_DL_SYMBOL_COUNT] = { + "dlopen", "dlsym", "dlclose", "dladdr", + "dladdr1", "dlinfo", "dlvsym", "dlerror", + }; + void *resolved[X86_DL_SYMBOL_COUNT] = {0}; + elfheader_t *header = loadElfFromFile(primary); + int resolved_count = 0; + + lsassert(header); + ResetSpecialCaseElf(header, symbols, X86_DL_SYMBOL_COUNT, + resolved, &resolved_count); + if (resolved_count != X86_DL_SYMBOL_COUNT) { + header = loadElfFromFile(fallback); + ResetSpecialCaseElf(header, symbols, X86_DL_SYMBOL_COUNT, + resolved, &resolved_count); + } + lsassert(resolved_count == X86_DL_SYMBOL_COUNT); + + my_context->dlprivate->x86dlopen = resolved[0]; + my_context->dlprivate->x86dlsym = resolved[1]; + my_context->dlprivate->x86dlclose = resolved[2]; + my_context->dlprivate->x86dladdr = resolved[3]; + my_context->dlprivate->x86dladdr1 = resolved[4]; + my_context->dlprivate->x86dlinfo = resolved[5]; + my_context->dlprivate->x86dlvsym = resolved[6]; + my_context->dlprivate->x86dlerror = resolved[7]; + return 0; +} diff --git a/target/i386/latx/include/x86dlfun.h b/target/i386/latx/include/x86dlfun.h new file mode 100644 index 00000000000..ee42d72ebd6 --- /dev/null +++ b/target/i386/latx/include/x86dlfun.h @@ -0,0 +1,24 @@ +/* + * This file is derived from Box64. + * + * SPDX-FileCopyrightText: 2020 ptitSeb + * + * SPDX-License-Identifier: MIT + */ + +#ifndef LATX_X86DLFUN_H +#define LATX_X86DLFUN_H + +void *my_dlopen(void *filename, int flag); +void *my_dlmopen(void *lmid, void *filename, int flag); +char *my_dlerror(void); +void *my_dlsym(void *handle, void *symbol); +int my_dlclose(void *handle); +int my_dladdr(void *addr, void *info); +int my_dladdr1(void *addr, void *info, void **extra_info, int flags); +void *my_dlvsym(void *handle, void *symbol, const char *vername); +int my_dlinfo(void *handle, int request, void *info); + +int init_x86dlfun_from(const char *primary, const char *fallback); + +#endif