diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2022-07-09 11:58:35 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2022-07-09 11:58:35 +0200 |
| commit | ec3786f86295b0fb769970bcb3c77b4ffffd7d48 (patch) | |
| tree | eeda9ecd7394e93eac2f759786ac3f7c19a1334b /src/wrapped | |
| parent | 0e761801deb4aa045e6052dee454973587e8dd4b (diff) | |
| download | box64-ec3786f86295b0fb769970bcb3c77b4ffffd7d48.tar.gz box64-ec3786f86295b0fb769970bcb3c77b4ffffd7d48.zip | |
Various improvement and some workaround to support musl binary (for #324)
Diffstat (limited to 'src/wrapped')
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 12 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedcurltypes.h | 2 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibctypes.h | 5 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibpthreadtypes.h | 2 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.c | 7 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.h | 3 | ||||
| -rwxr-xr-x | src/wrapped/wrappedcurl.c | 108 | ||||
| -rwxr-xr-x | src/wrapped/wrappedcurl_private.h | 6 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc.c | 22 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc_private.h | 5 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibdl.c | 8 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibm_private.h | 10 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibpthread_private.h | 4 |
13 files changed, 185 insertions, 9 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index 69be082b..465b9e10 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -685,6 +685,7 @@ #() iFEpip #() iFEpiV #() iFEpiA +#() iFEpup #() iFEpUp #() iFEpLi #() iFEpLp @@ -815,6 +816,7 @@ #() uFEppp #() uFifff #() uFuuuu +#() uFpiip #() uFpipu #() uFpipp #() uFpCCC @@ -852,6 +854,7 @@ #() lFppii #() lFppip #() lFpppL +#() LFEppL #() LFEppp #() LFippL #() LFippp @@ -2138,6 +2141,8 @@ wrappedcrypto: - PEM_write_bio_ECPrivateKey - PEM_write_bio_RSAPrivateKey wrappedcurl: +- iFpup: + - curl_multi_setopt - uFpup: - curl_easy_setopt wrappeddbus: @@ -2679,6 +2684,7 @@ wrappedlibc: - iopl - iFp: - _setjmp + - atexit - getcontext - setcontext - setjmp @@ -2713,6 +2719,7 @@ wrappedlibc: - iFpi: - __sigsetjmp - backtrace + - sigsetjmp - iFpL: - munmap - iFpp: @@ -2813,6 +2820,9 @@ wrappedlibc: - __wprintf_chk - lFppL: - readlink +- LFppL: + - strlcat + - strlcpy - pFpip: - fts_open - pFppp: @@ -3058,12 +3068,14 @@ wrappedlibpthread: - pthread_barrierattr_init - pthread_condattr_destroy - pthread_condattr_init + - pthread_getattr_default_np - pthread_mutex_destroy - pthread_mutex_lock - pthread_mutex_trylock - pthread_mutex_unlock - pthread_mutexattr_destroy - pthread_mutexattr_init + - pthread_setattr_default_np - vFpi: - _pthread_cleanup_pop - _pthread_cleanup_pop_restore diff --git a/src/wrapped/generated/wrappedcurltypes.h b/src/wrapped/generated/wrappedcurltypes.h index e5f8c9cd..4542b673 100644 --- a/src/wrapped/generated/wrappedcurltypes.h +++ b/src/wrapped/generated/wrappedcurltypes.h @@ -11,9 +11,11 @@ #define ADDED_FUNCTIONS() #endif +typedef int64_t (*iFpup_t)(void*, uint64_t, void*); typedef uint64_t (*uFpup_t)(void*, uint64_t, void*); #define SUPER() ADDED_FUNCTIONS() \ + GO(curl_multi_setopt, iFpup_t) \ GO(curl_easy_setopt, uFpup_t) #endif // __wrappedcurlTYPES_H_ diff --git a/src/wrapped/generated/wrappedlibctypes.h b/src/wrapped/generated/wrappedlibctypes.h index 2e911b45..989cdf64 100644 --- a/src/wrapped/generated/wrappedlibctypes.h +++ b/src/wrapped/generated/wrappedlibctypes.h @@ -50,6 +50,7 @@ typedef int64_t (*iFppA_t)(void*, void*, va_list); typedef int64_t (*iFpOu_t)(void*, int32_t, uint64_t); typedef intptr_t (*lFipV_t)(int64_t, void*, ...); typedef intptr_t (*lFppL_t)(void*, void*, uintptr_t); +typedef uintptr_t (*LFppL_t)(void*, void*, uintptr_t); typedef void* (*pFpip_t)(void*, int64_t, void*); typedef void* (*pFppp_t)(void*, void*, void*); typedef void (*vFiipV_t)(int64_t, int64_t, void*, ...); @@ -93,6 +94,7 @@ typedef int64_t (*iFppipppp_t)(void*, void*, int64_t, void*, void*, void*, void* GO(vfork, iFv_t) \ GO(iopl, iFi_t) \ GO(_setjmp, iFp_t) \ + GO(atexit, iFp_t) \ GO(getcontext, iFp_t) \ GO(setcontext, iFp_t) \ GO(setjmp, iFp_t) \ @@ -117,6 +119,7 @@ typedef int64_t (*iFppipppp_t)(void*, void*, int64_t, void*, void*, void*, void* GO(fstat64, iFip_t) \ GO(__sigsetjmp, iFpi_t) \ GO(backtrace, iFpi_t) \ + GO(sigsetjmp, iFpi_t) \ GO(munmap, iFpL_t) \ GO(__vprintf_chk, iFpp_t) \ GO(dl_iterate_phdr, iFpp_t) \ @@ -193,6 +196,8 @@ typedef int64_t (*iFppipppp_t)(void*, void*, int64_t, void*, void*, void*, void* GO(open64, iFpOu_t) \ GO(__wprintf_chk, lFipV_t) \ GO(readlink, lFppL_t) \ + GO(strlcat, LFppL_t) \ + GO(strlcpy, LFppL_t) \ GO(fts_open, pFpip_t) \ GO(tsearch, pFppp_t) \ GO(__syslog_chk, vFiipV_t) \ diff --git a/src/wrapped/generated/wrappedlibpthreadtypes.h b/src/wrapped/generated/wrappedlibpthreadtypes.h index c22ae27b..ae6e10a3 100644 --- a/src/wrapped/generated/wrappedlibpthreadtypes.h +++ b/src/wrapped/generated/wrappedlibpthreadtypes.h @@ -42,12 +42,14 @@ typedef int64_t (*iFpppp_t)(void*, void*, void*, void*); GO(pthread_barrierattr_init, iFp_t) \ GO(pthread_condattr_destroy, iFp_t) \ GO(pthread_condattr_init, iFp_t) \ + GO(pthread_getattr_default_np, iFp_t) \ GO(pthread_mutex_destroy, iFp_t) \ GO(pthread_mutex_lock, iFp_t) \ GO(pthread_mutex_trylock, iFp_t) \ GO(pthread_mutex_unlock, iFp_t) \ GO(pthread_mutexattr_destroy, iFp_t) \ GO(pthread_mutexattr_init, iFp_t) \ + GO(pthread_setattr_default_np, iFp_t) \ GO(_pthread_cleanup_pop, vFpi_t) \ GO(_pthread_cleanup_pop_restore, vFpi_t) \ GO(pthread_getattr_np, iFLp_t) \ diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index 2a214391..f9606533 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -719,6 +719,7 @@ typedef int64_t (*iFEpii_t)(x64emu_t*, void*, int64_t, int64_t); typedef int64_t (*iFEpip_t)(x64emu_t*, void*, int64_t, void*); typedef int64_t (*iFEpiV_t)(x64emu_t*, void*, int64_t, void*); typedef int64_t (*iFEpiA_t)(x64emu_t*, void*, int64_t, void*); +typedef int64_t (*iFEpup_t)(x64emu_t*, void*, uint64_t, void*); typedef int64_t (*iFEpUp_t)(x64emu_t*, void*, uint64_t, void*); typedef int64_t (*iFEpLi_t)(x64emu_t*, void*, uintptr_t, int64_t); typedef int64_t (*iFEpLp_t)(x64emu_t*, void*, uintptr_t, void*); @@ -849,6 +850,7 @@ typedef uint64_t (*uFEpup_t)(x64emu_t*, void*, uint64_t, void*); typedef uint64_t (*uFEppp_t)(x64emu_t*, void*, void*, void*); typedef uint64_t (*uFifff_t)(int64_t, float, float, float); typedef uint64_t (*uFuuuu_t)(uint64_t, uint64_t, uint64_t, uint64_t); +typedef uint64_t (*uFpiip_t)(void*, int64_t, int64_t, void*); typedef uint64_t (*uFpipu_t)(void*, int64_t, void*, uint64_t); typedef uint64_t (*uFpipp_t)(void*, int64_t, void*, void*); typedef uint64_t (*uFpCCC_t)(void*, uint8_t, uint8_t, uint8_t); @@ -886,6 +888,7 @@ typedef intptr_t (*lFpilp_t)(void*, int64_t, intptr_t, void*); typedef intptr_t (*lFppii_t)(void*, void*, int64_t, int64_t); typedef intptr_t (*lFppip_t)(void*, void*, int64_t, void*); typedef intptr_t (*lFpppL_t)(void*, void*, void*, uintptr_t); +typedef uintptr_t (*LFEppL_t)(x64emu_t*, void*, void*, uintptr_t); typedef uintptr_t (*LFEppp_t)(x64emu_t*, void*, void*, void*); typedef uintptr_t (*LFippL_t)(int64_t, void*, void*, uintptr_t); typedef uintptr_t (*LFippp_t)(int64_t, void*, void*, void*); @@ -2814,6 +2817,7 @@ void iFEpii(x64emu_t *emu, uintptr_t fcn) { iFEpii_t fn = (iFEpii_t)fcn; R_RAX=( void iFEpip(x64emu_t *emu, uintptr_t fcn) { iFEpip_t fn = (iFEpip_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (int64_t)R_RSI, (void*)R_RDX); } void iFEpiV(x64emu_t *emu, uintptr_t fcn) { iFEpiV_t fn = (iFEpiV_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (int64_t)R_RSI, (void*)(R_RSP + 8)); } void iFEpiA(x64emu_t *emu, uintptr_t fcn) { iFEpiA_t fn = (iFEpiA_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (int64_t)R_RSI, (void*)R_RDX); } +void iFEpup(x64emu_t *emu, uintptr_t fcn) { iFEpup_t fn = (iFEpup_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (uint64_t)R_RSI, (void*)R_RDX); } void iFEpUp(x64emu_t *emu, uintptr_t fcn) { iFEpUp_t fn = (iFEpUp_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (uint64_t)R_RSI, (void*)R_RDX); } void iFEpLi(x64emu_t *emu, uintptr_t fcn) { iFEpLi_t fn = (iFEpLi_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (int64_t)R_RDX); } void iFEpLp(x64emu_t *emu, uintptr_t fcn) { iFEpLp_t fn = (iFEpLp_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (void*)R_RDX); } @@ -2944,6 +2948,7 @@ void uFEpup(x64emu_t *emu, uintptr_t fcn) { uFEpup_t fn = (uFEpup_t)fcn; R_RAX=( void uFEppp(x64emu_t *emu, uintptr_t fcn) { uFEppp_t fn = (uFEppp_t)fcn; R_RAX=(uint64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX); } void uFifff(x64emu_t *emu, uintptr_t fcn) { uFifff_t fn = (uFifff_t)fcn; R_RAX=(uint64_t)fn((int64_t)R_RDI, emu->xmm[0].f[0], emu->xmm[1].f[0], emu->xmm[2].f[0]); } void uFuuuu(x64emu_t *emu, uintptr_t fcn) { uFuuuu_t fn = (uFuuuu_t)fcn; R_RAX=(uint64_t)fn((uint64_t)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX); } +void uFpiip(x64emu_t *emu, uintptr_t fcn) { uFpiip_t fn = (uFpiip_t)fcn; R_RAX=(uint64_t)fn((void*)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (void*)R_RCX); } void uFpipu(x64emu_t *emu, uintptr_t fcn) { uFpipu_t fn = (uFpipu_t)fcn; R_RAX=(uint64_t)fn((void*)R_RDI, (int64_t)R_RSI, (void*)R_RDX, (uint64_t)R_RCX); } void uFpipp(x64emu_t *emu, uintptr_t fcn) { uFpipp_t fn = (uFpipp_t)fcn; R_RAX=(uint64_t)fn((void*)R_RDI, (int64_t)R_RSI, (void*)R_RDX, (void*)R_RCX); } void uFpCCC(x64emu_t *emu, uintptr_t fcn) { uFpCCC_t fn = (uFpCCC_t)fcn; R_RAX=(uint64_t)fn((void*)R_RDI, (uint8_t)R_RSI, (uint8_t)R_RDX, (uint8_t)R_RCX); } @@ -2981,6 +2986,7 @@ void lFpilp(x64emu_t *emu, uintptr_t fcn) { lFpilp_t fn = (lFpilp_t)fcn; R_RAX=( void lFppii(x64emu_t *emu, uintptr_t fcn) { lFppii_t fn = (lFppii_t)fcn; R_RAX=(intptr_t)fn((void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX); } void lFppip(x64emu_t *emu, uintptr_t fcn) { lFppip_t fn = (lFppip_t)fcn; R_RAX=(intptr_t)fn((void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (void*)R_RCX); } void lFpppL(x64emu_t *emu, uintptr_t fcn) { lFpppL_t fn = (lFpppL_t)fcn; R_RAX=(intptr_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX); } +void LFEppL(x64emu_t *emu, uintptr_t fcn) { LFEppL_t fn = (LFEppL_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX); } void LFEppp(x64emu_t *emu, uintptr_t fcn) { LFEppp_t fn = (LFEppp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX); } void LFippL(x64emu_t *emu, uintptr_t fcn) { LFippL_t fn = (LFippL_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX); } void LFippp(x64emu_t *emu, uintptr_t fcn) { LFippp_t fn = (LFippp_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX); } @@ -4928,6 +4934,7 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &IFpppp) return 1; if (fun == &uFifff) return 4; if (fun == &uFuuuu) return 1; + if (fun == &uFpiip) return 1; if (fun == &uFpipu) return 1; if (fun == &uFpipp) return 1; if (fun == &uFpCCC) return 1; diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index 756eb081..f4aca073 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -718,6 +718,7 @@ void iFEpii(x64emu_t *emu, uintptr_t fnc); void iFEpip(x64emu_t *emu, uintptr_t fnc); void iFEpiV(x64emu_t *emu, uintptr_t fnc); void iFEpiA(x64emu_t *emu, uintptr_t fnc); +void iFEpup(x64emu_t *emu, uintptr_t fnc); void iFEpUp(x64emu_t *emu, uintptr_t fnc); void iFEpLi(x64emu_t *emu, uintptr_t fnc); void iFEpLp(x64emu_t *emu, uintptr_t fnc); @@ -848,6 +849,7 @@ void uFEpup(x64emu_t *emu, uintptr_t fnc); void uFEppp(x64emu_t *emu, uintptr_t fnc); void uFifff(x64emu_t *emu, uintptr_t fnc); void uFuuuu(x64emu_t *emu, uintptr_t fnc); +void uFpiip(x64emu_t *emu, uintptr_t fnc); void uFpipu(x64emu_t *emu, uintptr_t fnc); void uFpipp(x64emu_t *emu, uintptr_t fnc); void uFpCCC(x64emu_t *emu, uintptr_t fnc); @@ -885,6 +887,7 @@ void lFpilp(x64emu_t *emu, uintptr_t fnc); void lFppii(x64emu_t *emu, uintptr_t fnc); void lFppip(x64emu_t *emu, uintptr_t fnc); void lFpppL(x64emu_t *emu, uintptr_t fnc); +void LFEppL(x64emu_t *emu, uintptr_t fnc); void LFEppp(x64emu_t *emu, uintptr_t fnc); void LFippL(x64emu_t *emu, uintptr_t fnc); void LFippp(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped/wrappedcurl.c b/src/wrapped/wrappedcurl.c index e9dc02fb..d13930d0 100755 --- a/src/wrapped/wrappedcurl.c +++ b/src/wrapped/wrappedcurl.c @@ -30,6 +30,7 @@ const char* curlName = "libcurl.so.4"; #define FUNCTIONPOINT 20000 #define OFF_T 30000 #define CINIT(name,type,number) CURLOPT_ ## name = type + number +#define CURLOPT(na,t,nu) na = t + nu typedef enum { CINIT(WRITEDATA, OBJECTPOINT, 1), @@ -305,11 +306,33 @@ typedef enum { CINIT(ALTSVC, STRINGPOINT, 287), CURLOPT_LASTENTRY /* the last unused */ } CURLoption; + +typedef enum { + CURLOPT(CURLMOPT_SOCKETFUNCTION, FUNCTIONPOINT, 1), + CURLOPT(CURLMOPT_SOCKETDATA, OBJECTPOINT, 2), + CURLOPT(CURLMOPT_PIPELINING, LONG, 3), + CURLOPT(CURLMOPT_TIMERFUNCTION, FUNCTIONPOINT, 4), + CURLOPT(CURLMOPT_TIMERDATA, OBJECTPOINT, 5), + CURLOPT(CURLMOPT_MAXCONNECTS, LONG, 6), + CURLOPT(CURLMOPT_MAX_HOST_CONNECTIONS, LONG, 7), + CURLOPT(CURLMOPT_MAX_PIPELINE_LENGTH, LONG, 8), + CURLOPT(CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, OFF_T, 9), + CURLOPT(CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, OFF_T, 10), + CURLOPT(CURLMOPT_PIPELINING_SITE_BL, OBJECTPOINT, 11), + CURLOPT(CURLMOPT_PIPELINING_SERVER_BL, OBJECTPOINT, 12), + CURLOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, LONG, 13), + CURLOPT(CURLMOPT_PUSHFUNCTION, FUNCTIONPOINT, 14), + CURLOPT(CURLMOPT_PUSHDATA, OBJECTPOINT, 15), + CURLOPT(CURLMOPT_MAX_CONCURRENT_STREAMS, LONG, 16), + CURLMOPT_LASTENTRY /* the last unused */ +} CURLMoption; + #undef LONG #undef OBJECTPOINT #undef STRINGPOINT #undef FUNCTIONPOINT #undef OFF_T +#undef CURLOPT #undef CINIT #define SUPER() \ @@ -478,6 +501,76 @@ static void* find_progress_int_Fct(void* fct) printf_log(LOG_NONE, "Warning, no more slot for curl progress_int callback\n"); return NULL; } + +// socket +#define GO(A) \ +static uintptr_t my_socket_fct_##A = 0; \ +static int my_socket_##A(void *a, int b, int c, void* d, void* e) \ +{ \ + return (int)RunFunction(my_context, my_socket_fct_##A, 5, a, b, c, d, e); \ +} +SUPER() +#undef GO +static void* find_socket_Fct(void* fct) +{ + if(!fct) return NULL; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_socket_fct_##A == (uintptr_t)fct) return my_socket_##A; + SUPER() + #undef GO + #define GO(A) if(my_socket_fct_##A == 0) {my_socket_fct_##A = (uintptr_t)fct; return my_socket_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for curl socket callback\n"); + return NULL; +} + +// timer +#define GO(A) \ +static uintptr_t my_timer_fct_##A = 0; \ +static int my_timer_##A(void *a, long b, void* c) \ +{ \ + return (int)RunFunction(my_context, my_timer_fct_##A, 3, a, b, c); \ +} +SUPER() +#undef GO +static void* find_timer_Fct(void* fct) +{ + if(!fct) return NULL; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_timer_fct_##A == (uintptr_t)fct) return my_timer_##A; + SUPER() + #undef GO + #define GO(A) if(my_timer_fct_##A == 0) {my_timer_fct_##A = (uintptr_t)fct; return my_timer_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for curl timer callback\n"); + return NULL; +} + +// push +#define GO(A) \ +static uintptr_t my_push_fct_##A = 0; \ +static int my_push_##A(void *a, void* b, size_t c, void* d, void* e) \ +{ \ + return (int)RunFunction(my_context, my_push_fct_##A, 5, a, b, c, d, e); \ +} +SUPER() +#undef GO +static void* find_push_Fct(void* fct) +{ + if(!fct) return NULL; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_push_fct_##A == (uintptr_t)fct) return my_push_##A; + SUPER() + #undef GO + #define GO(A) if(my_push_fct_##A == 0) {my_push_fct_##A = (uintptr_t)fct; return my_push_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for curl push callback\n"); + return NULL; +} + #undef SUPER EXPORT uint32_t my_curl_easy_setopt(x64emu_t* emu, void* handle, uint32_t option, void* param) @@ -542,6 +635,21 @@ EXPORT uint32_t my_curl_easy_setopt(x64emu_t* emu, void* handle, uint32_t option } } +EXPORT uint32_t my_curl_multi_setopt(x64emu_t* emu, void* handle, uint32_t option, void* param) +{ + (void)emu; + + switch(option) { + case CURLMOPT_SOCKETFUNCTION: + return my->curl_multi_setopt(handle, option, find_socket_Fct(param)); + case CURLMOPT_TIMERFUNCTION: + return my->curl_multi_setopt(handle, option, find_timer_Fct(param)); + case CURLMOPT_PUSHFUNCTION: + return my->curl_multi_setopt(handle, option, find_push_Fct(param)); + default: + return my->curl_multi_setopt(handle, option, param); + } +} #define CUSTOM_INIT \ getMy(lib); diff --git a/src/wrapped/wrappedcurl_private.h b/src/wrapped/wrappedcurl_private.h index 9d7e6cc5..ffcc1050 100755 --- a/src/wrapped/wrappedcurl_private.h +++ b/src/wrapped/wrappedcurl_private.h @@ -44,16 +44,16 @@ GO(curl_global_init, uFu) //GO(curl_msnprintf, //GO(curl_msprintf, GO(curl_multi_add_handle, uFpp) -//GO(curl_multi_assign, +GO(curl_multi_assign, uFpip) GO(curl_multi_cleanup, uFp) GO(curl_multi_fdset, uFppppp) GO(curl_multi_info_read, pFpp) GO(curl_multi_init, pFv) GO(curl_multi_perform, uFpp) GO(curl_multi_remove_handle, uFpp) -//GO(curl_multi_setopt, +GOM(curl_multi_setopt, iFEpup) //GO(curl_multi_socket, -//GO(curl_multi_socket_action, +GO(curl_multi_socket_action, uFpiip) //GO(curl_multi_socket_all, GO(curl_multi_strerror, pFi) GO(curl_multi_timeout, iFpp) diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 3ef151f5..6c407414 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -2149,7 +2149,10 @@ EXPORT int32_t my___sigsetjmp(x64emu_t* emu, /*struct __jmp_buf_tag __env[1]*/vo ((__jmp_buf_tag_t*)p)->__mask_was_saved = 0; return 0; } - +EXPORT int32_t my_sigsetjmp(x64emu_t* emu, /*struct __jmp_buf_tag __env[1]*/void *p, int savesigs) +{ + return my___sigsetjmp(emu, p, savesigs); +} EXPORT int32_t my__setjmp(x64emu_t* emu, /*struct __jmp_buf_tag __env[1]*/void *p) { return my___sigsetjmp(emu, p, 0); @@ -2730,6 +2733,23 @@ EXPORT void my___cxa_pure_virtual(x64emu_t* emu) abort(); } +EXPORT size_t my_strlcpy(x64emu_t* emu, void* dst, void* src, size_t l) +{ + strncpy(dst, src, l-1); + ((char*)dst)[l-1] = '\0'; + return strlen(src); +} +EXPORT size_t my_strlcat(x64emu_t* emu, void* dst, void* src, size_t l) +{ + size_t s = strlen(dst); + if(s>=l) + return l; + strncat(dst, src, l-1); + ((char*)dst)[l-1] = '\0'; + return s+strlen(src); +} + + EXPORT char** my_environ = NULL; EXPORT char** my__environ = NULL; EXPORT char** my___environ = NULL; // all aliases diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index 9811861c..492bd512 100755 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -62,6 +62,7 @@ GOM(__asprintf_chk, iFEpipV) GO(__assert, vFppi) GO(__assert_fail, vFppup) GO(__assert_perror_fail, vFipup) +GOM(atexit, iFEp) GO(atof, dFp) GO(atoi, iFp) GO(atol, lFp) @@ -1703,6 +1704,7 @@ GO(sigrelse, iFi) //GOW(sigreturn, iF!) GOM(sigset, pFEip) GOM(__sigsetjmp, iFEpi) +GOM(sigsetjmp, iFEpi) GOW(sigsetmask, iFi) //GO(sigstack, iF!!) GO(__sigsuspend, iFp) @@ -2303,6 +2305,9 @@ GOM(_ITM_deregisterTMCloneTable, vFEp) GOM(__register_frame_info, vFpp) // faked function GOM(__deregister_frame_info, pFp) +GOM(strlcpy, LFEppL) +GOM(strlcat, LFEppL) + GOWM(__cxa_pure_virtual, vFEv) // create a function to trap pure virtual call DATAM(program_invocation_name, sizeof(void*)) diff --git a/src/wrapped/wrappedlibdl.c b/src/wrapped/wrappedlibdl.c index d8582536..903c2b9e 100755 --- a/src/wrapped/wrappedlibdl.c +++ b/src/wrapped/wrappedlibdl.c @@ -62,7 +62,7 @@ void* my_dlopen(x64emu_t* emu, void *filename, int flag) 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 pther libs + 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(filename) { char* rfilename = (char*)alloca(MAX_PATH); @@ -138,7 +138,7 @@ void* my_dlopen(x64emu_t* emu, void *filename, int flag) // Then open the lib const char* libs[] = {rfilename}; my_context->deferedInit = 1; - int bindnow = (flag&0x2)?1:0; + int bindnow = (!box64_musl && (flag&0x2))?1:0; if(AddNeededLib(NULL, NULL, NULL, is_local, bindnow, libs, 1, emu->context, emu)) { printf_log(LOG_INFO, "Warning: Cannot dlopen(\"%s\"/%p, %X)\n", rfilename, filename, flag); if(!dl->last_error) @@ -553,5 +553,9 @@ int my_dlinfo(x64emu_t* emu, void* handle, int request, void* info) return -1; } +#define CUSTOM_INIT\ + setNeededLibs(lib, 1, "libc.so.6"); + + // define all standard library functions #include "wrappedlib_init.h" diff --git a/src/wrapped/wrappedlibm_private.h b/src/wrapped/wrappedlibm_private.h index b8245298..482c36b2 100755 --- a/src/wrapped/wrappedlibm_private.h +++ b/src/wrapped/wrappedlibm_private.h @@ -92,7 +92,11 @@ GO2(cbrtl, KFK, cbrt) // ccosl // Weak GOW(ceil, dFd) GOW(ceilf, fFf) -// ceill // Weak +#ifdef HAVE_LD80BITS +GOW(ceill, DFD) // Weak +#else +GO2(ceill, KFK, ceil) +#endif //GOS(cexp, pFpV) // Weak, return complex //GOM(cexpf, UFV) // Weak, return complex // cexpl // Weak @@ -185,8 +189,8 @@ GOW(expm1f, fFf) GOW(fabs, dFd) GOW(fabsf, fFf) // fabsl // Weak -// fdim // Weak -// fdimf // Weak +GOW(fdim, dFdd) +GOW(fdimf, fFff) // fdiml // Weak GO(feclearexcept, iFi) GO(fedisableexcept, iFi) diff --git a/src/wrapped/wrappedlibpthread_private.h b/src/wrapped/wrappedlibpthread_private.h index d2291657..bf92d775 100755 --- a/src/wrapped/wrappedlibpthread_private.h +++ b/src/wrapped/wrappedlibpthread_private.h @@ -119,8 +119,12 @@ GO(pthread_exit, vFp) GOM(pthread_getaffinity_np, iFEpLp) #ifdef NOALIGN GO(pthread_getattr_np, iFLp) +GO(pthread_getattr_default_np, iFp) +GO(pthread_setattr_default_np, iFp) #else GOM(pthread_getattr_np, iFELp) +GOM(pthread_getattr_default_np, iFEp) +GOM(pthread_setattr_default_np, iFEp) #endif //GO(pthread_getconcurrency, iFv) //GO(pthread_getcpuclockid, iFup) |