about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-12-14 19:43:20 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-12-14 19:43:20 +0100
commit6a5d8313312ca254b7382019dc99912cabc5dafd (patch)
tree1dc766bf24382ff707030bbe1862814f4329d078 /src
parent2164c564f26a0c144b3ef2f0d1abd790714a59e1 (diff)
downloadbox64-6a5d8313312ca254b7382019dc99912cabc5dafd.tar.gz
box64-6a5d8313312ca254b7382019dc99912cabc5dafd.zip
[BOX32][WRAPPER] Fixes and improves libc wrapping
Diffstat (limited to 'src')
-rw-r--r--src/box32.c10
-rw-r--r--src/wrapped32/generated/functions_list.txt15
-rw-r--r--src/wrapped32/generated/wrappedlibctypes32.h14
-rw-r--r--src/wrapped32/generated/wrapper32.c2
-rw-r--r--src/wrapped32/generated/wrapper32.h1
-rwxr-xr-xsrc/wrapped32/wrappedlibc.c8
-rwxr-xr-xsrc/wrapped32/wrappedlibc_private.h20
7 files changed, 55 insertions, 15 deletions
diff --git a/src/box32.c b/src/box32.c
index a4c1a1b4..7ef84fbf 100644
--- a/src/box32.c
+++ b/src/box32.c
@@ -147,11 +147,11 @@ ulong_t to_hash_d(uintptr_t p) {
 }
 
 typedef struct struct_locale_s {
-	void* p0[13];
+	void* p0[13];   // struct __locale_data *
 	void* p1;   //const unsigned short int *__ctype_b;
 	void* p2;   //const int *__ctype_tolower;
 	void* p3;   //const int *__ctype_toupper;
-	void* p4[13];
+	void* p4[13];   //const char*
 } struct_locale_t;
 // not a real structure
 #define LOCALE_SIGN 0x54abcd845412LL
@@ -180,7 +180,7 @@ void to_struct_locale(ptr_t d, const struct_locale_t *src) {
 	    dest->p0[i] = to_hashv(src->p0[i]);
     }
     for(int i=0; i<13; ++i) {
-	    dest->p4[i] = to_hashv(src->p4[i]);
+	    dest->p4[i] = to_cstring(src->p4[i]);
     }
     // copy the 3 ctype int (1st is short int, but int will do)
     memcpy(dest->type_b, src->p1-128*sizeof(short), 384*sizeof(short));
@@ -194,9 +194,9 @@ void free_struct_locale(const struct_locale_t *src) {
     for(int i=0; i<13; ++i) {
 	    to_hash_d((uintptr_t)src->p0[i]);
     }
-    for(int i=0; i<13; ++i) {
+    /*for(int i=0; i<13; ++i) {
 	    to_hash_d((uintptr_t)src->p4[i]);
-    }
+    }*/
 }
 
 // Convert from locale key to original 64bits value
diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt
index 88fbb09c..f688ba69 100644
--- a/src/wrapped32/generated/functions_list.txt
+++ b/src/wrapped32/generated/functions_list.txt
@@ -712,6 +712,7 @@
 #() pEppBp_ -> pEppB
 #() pFppbp_ -> pFppB
 #() pFXLbL_ -> pFXLB
+#() iEpprLL_ -> iEppB
 #() iFXLbpp_ -> iFXLB
 #() iFXbLC_i -> iFXBi
 #() vFLbL_bL_ -> vFLBB
@@ -1962,6 +1963,7 @@ wrappedlibc:
   - _obstack_newchunk
 - vEpu:
 - vEpp:
+- iFip:
 - iEip:
   - fstatvfs
   - fstatvfs64
@@ -1980,6 +1982,7 @@ wrappedlibc:
   - statvfs
   - statvfs64
   - utimes
+- iFpp:
 - iEpV:
   - execl
   - execlp
@@ -2022,14 +2025,17 @@ wrappedlibc:
 - iEppi:
   - regcomp
 - iEppp:
+  - __isoc23_vsscanf
   - execvpe
   - vswscanf
 - iEppV:
-  - __isoc99_fscanf
+  - __isoc23_sscanf
   - swscanf
 - iEpON:
 - iESpp:
 - iESpV:
+  - __isoc23_fscanf
+  - __isoc99_fscanf
   - fscanf
 - lEipi:
   - readv
@@ -2047,12 +2053,19 @@ wrappedlibc:
 - pEpLL:
 - pEppi:
   - __realpath_chk
+- IEpBp_i:
+  - __isoc23_strtoll
+- UEpBp_i:
+  - __isoc23_strtoull
 - KEpBp_a:
   - __strtold_l
   - strtold_l
 - lEpBp_i:
+  - __isoc23_strtol
+  - __isoc23_wcstol
   - wcstol
 - LEpBp_i:
+  - __isoc23_strtoul
   - wcstoul
 - vEiipp:
   - __vsyslog_chk
diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h
index 10566663..45a2a970 100644
--- a/src/wrapped32/generated/wrappedlibctypes32.h
+++ b/src/wrapped32/generated/wrappedlibctypes32.h
@@ -43,11 +43,13 @@ typedef void (*vEip_t)(int32_t, void*);
 typedef void (*vEpi_t)(void*, int32_t);
 typedef void (*vEpu_t)(void*, uint32_t);
 typedef void (*vEpp_t)(void*, void*);
+typedef int32_t (*iFip_t)(int32_t, void*);
 typedef int32_t (*iEip_t)(int32_t, void*);
 typedef int32_t (*iEup_t)(uint32_t, void*);
 typedef int32_t (*iEpi_t)(void*, int32_t);
 typedef int32_t (*iEpL_t)(void*, uintptr_t);
 typedef int32_t (*iEpp_t)(void*, void*);
+typedef int32_t (*iFpp_t)(void*, void*);
 typedef int32_t (*iEpV_t)(void*, ...);
 typedef int64_t (*IEII_t)(int64_t, int64_t);
 typedef uint64_t (*UEUU_t)(uint64_t, uint64_t);
@@ -86,6 +88,8 @@ typedef void* (*pEpII_t)(void*, int64_t, int64_t);
 typedef void* (*pFpui_t)(void*, uint32_t, int32_t);
 typedef void* (*pEpLL_t)(void*, uintptr_t, uintptr_t);
 typedef void* (*pEppi_t)(void*, void*, int32_t);
+typedef int64_t (*IEpBp_i_t)(void*, struct_p_t*, int32_t);
+typedef uint64_t (*UEpBp_i_t)(void*, struct_p_t*, int32_t);
 typedef double (*KEpBp_a_t)(void*, struct_p_t*, void*);
 typedef intptr_t (*lEpBp_i_t)(void*, struct_p_t*, int32_t);
 typedef uintptr_t (*LEpBp_i_t)(void*, struct_p_t*, int32_t);
@@ -203,10 +207,13 @@ typedef int32_t (*iFpuippupp_t)(void*, uint32_t, int32_t, void*, void*, uint32_t
 	GO(_ITM_addUserCommitAction, vEpup_t) \
 	GO(posix_spawn_file_actions_adddup2, iEpii_t) \
 	GO(regcomp, iEppi_t) \
+	GO(__isoc23_vsscanf, iEppp_t) \
 	GO(execvpe, iEppp_t) \
 	GO(vswscanf, iEppp_t) \
-	GO(__isoc99_fscanf, iEppV_t) \
+	GO(__isoc23_sscanf, iEppV_t) \
 	GO(swscanf, iEppV_t) \
+	GO(__isoc23_fscanf, iESpV_t) \
+	GO(__isoc99_fscanf, iESpV_t) \
 	GO(fscanf, iESpV_t) \
 	GO(readv, lEipi_t) \
 	GO(recvmsg, lEipi_t) \
@@ -215,9 +222,14 @@ typedef int32_t (*iFpuippupp_t)(void*, uint32_t, int32_t, void*, void*, uint32_t
 	GO(shmat, pEipi_t) \
 	GO(gethostbyaddr, pFpui_t) \
 	GO(__realpath_chk, pEppi_t) \
+	GO(__isoc23_strtoll, IEpBp_i_t) \
+	GO(__isoc23_strtoull, UEpBp_i_t) \
 	GO(__strtold_l, KEpBp_a_t) \
 	GO(strtold_l, KEpBp_a_t) \
+	GO(__isoc23_strtol, lEpBp_i_t) \
+	GO(__isoc23_wcstol, lEpBp_i_t) \
 	GO(wcstol, lEpBp_i_t) \
+	GO(__isoc23_strtoul, LEpBp_i_t) \
 	GO(wcstoul, LEpBp_i_t) \
 	GO(__vsyslog_chk, vEiipp_t) \
 	GO(__syslog_chk, vEiipV_t) \
diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c
index 18149a10..259f5551 100644
--- a/src/wrapped32/generated/wrapper32.c
+++ b/src/wrapped32/generated/wrapper32.c
@@ -803,6 +803,7 @@ typedef void* (*pEppbp__t)(void*, void*, struct_p_t*);
 typedef void* (*pEppBp__t)(void*, void*, struct_p_t*);
 typedef void* (*pFppbp__t)(void*, void*, struct_p_t*);
 typedef void* (*pFXLbL__t)(void*, uintptr_t, struct_L_t*);
+typedef int32_t (*iEpprLL__t)(void*, void*, struct_LL_t*);
 typedef int32_t (*iFXLbpp__t)(void*, uintptr_t, struct_pp_t*);
 typedef int32_t (*iFXbLC_i_t)(void*, struct_LC_t*, int32_t);
 typedef void (*vFLbL_bL__t)(uintptr_t, struct_L_t*, struct_L_t*);
@@ -2572,6 +2573,7 @@ void pEppbp__32(x64emu_t *emu, uintptr_t fcn) { pEppbp__t fn = (pEppbp__t)fcn; e
 void pEppBp__32(x64emu_t *emu, uintptr_t fcn) { pEppBp__t fn = (pEppBp__t)fcn; errno = emu->libc_err; struct_p_t arg_12={0}; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), *(ptr_t*)(from_ptr((R_ESP + 12))) ? &arg_12 : NULL)); if (*(ptr_t*)(from_ptr((R_ESP + 12)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 12))), &arg_12); emu->libc_err = errno; }
 void pFppbp__32(x64emu_t *emu, uintptr_t fcn) { pFppbp__t fn = (pFppbp__t)fcn; struct_p_t arg_12={0}; if (*(ptr_t*)(from_ptr((R_ESP + 12)))) from_struct_p(&arg_12, *(ptr_t*)(from_ptr((R_ESP + 12)))); R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), *(ptr_t*)(from_ptr((R_ESP + 12))) ? &arg_12 : NULL)); if (*(ptr_t*)(from_ptr((R_ESP + 12)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 12))), &arg_12); }
 void pFXLbL__32(x64emu_t *emu, uintptr_t fcn) { pFXLbL__t fn = (pFXLbL__t)fcn; struct_L_t arg_12={0}; if (*(ptr_t*)(from_ptr((R_ESP + 12)))) from_struct_L(&arg_12, *(ptr_t*)(from_ptr((R_ESP + 12)))); R_EAX = to_ptrv(fn(getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), *(ptr_t*)(from_ptr((R_ESP + 12))) ? &arg_12 : NULL)); if (*(ptr_t*)(from_ptr((R_ESP + 12)))) to_struct_L(*(ptr_t*)(from_ptr((R_ESP + 12))), &arg_12); }
+void iEpprLL__32(x64emu_t *emu, uintptr_t fcn) { iEpprLL__t fn = (iEpprLL__t)fcn; errno = emu->libc_err; struct_LL_t arg_12={0}; if (*(ptr_t*)(from_ptr((R_ESP + 12)))) from_struct_LL(&arg_12, *(ptr_t*)(from_ptr((R_ESP + 12)))); R_EAX = fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), *(ptr_t*)(from_ptr((R_ESP + 12))) ? &arg_12 : NULL); emu->libc_err = errno; }
 void iFXLbpp__32(x64emu_t *emu, uintptr_t fcn) { iFXLbpp__t fn = (iFXLbpp__t)fcn; struct_pp_t arg_12={0}; if (*(ptr_t*)(from_ptr((R_ESP + 12)))) from_struct_pp(&arg_12, *(ptr_t*)(from_ptr((R_ESP + 12)))); R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), *(ptr_t*)(from_ptr((R_ESP + 12))) ? &arg_12 : NULL); if (*(ptr_t*)(from_ptr((R_ESP + 12)))) to_struct_pp(*(ptr_t*)(from_ptr((R_ESP + 12))), &arg_12); }
 void iFXbLC_i_32(x64emu_t *emu, uintptr_t fcn) { iFXbLC_i_t fn = (iFXbLC_i_t)fcn; struct_LC_t arg_8={0}; if (*(ptr_t*)(from_ptr((R_ESP + 8)))) from_struct_LC(&arg_8, *(ptr_t*)(from_ptr((R_ESP + 8)))); R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL, from_ptri(int32_t, R_ESP + 12)); if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_LC(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); }
 void vFLbL_bL__32(x64emu_t *emu, uintptr_t fcn) { vFLbL_bL__t fn = (vFLbL_bL__t)fcn; struct_L_t arg_8={0}; if (*(ptr_t*)(from_ptr((R_ESP + 8)))) from_struct_L(&arg_8, *(ptr_t*)(from_ptr((R_ESP + 8)))); struct_L_t arg_12={0}; if (*(ptr_t*)(from_ptr((R_ESP + 12)))) from_struct_L(&arg_12, *(ptr_t*)(from_ptr((R_ESP + 12)))); fn(from_ulong(from_ptri(ulong_t, R_ESP + 4)), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL, *(ptr_t*)(from_ptr((R_ESP + 12))) ? &arg_12 : NULL); if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_L(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); if (*(ptr_t*)(from_ptr((R_ESP + 12)))) to_struct_L(*(ptr_t*)(from_ptr((R_ESP + 12))), &arg_12); }
diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h
index 0d38a813..14808964 100644
--- a/src/wrapped32/generated/wrapper32.h
+++ b/src/wrapped32/generated/wrapper32.h
@@ -753,6 +753,7 @@ void pEppbp__32(x64emu_t *emu, uintptr_t fnc);
 void pEppBp__32(x64emu_t *emu, uintptr_t fnc);
 void pFppbp__32(x64emu_t *emu, uintptr_t fnc);
 void pFXLbL__32(x64emu_t *emu, uintptr_t fnc);
+void iEpprLL__32(x64emu_t *emu, uintptr_t fnc);
 void iFXLbpp__32(x64emu_t *emu, uintptr_t fnc);
 void iFXbLC_i_32(x64emu_t *emu, uintptr_t fnc);
 void vFLbL_bL__32(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped32/wrappedlibc.c b/src/wrapped32/wrappedlibc.c
index 2aa9382a..e0082e9e 100755
--- a/src/wrapped32/wrappedlibc.c
+++ b/src/wrapped32/wrappedlibc.c
@@ -1162,7 +1162,7 @@ EXPORT int my32_stat(char* path, void* buf)
 {
     struct stat64 st;
     int r = stat64(path, &st);
-    UnalignStat64_32(&st, buf);
+    FillStatFromStat64(3, &st, buf);
     return r;
 }
 
@@ -1170,7 +1170,7 @@ EXPORT int my32_fstat(int fd, void* buf)
 {
     struct stat64 st;
     int r = fstat64(fd, &st);
-    UnalignStat64_32(&st, buf);
+    FillStatFromStat64(3, &st, buf);
     return r;
 }
 
@@ -1178,7 +1178,7 @@ EXPORT int my32_lstat(char* path, void* buf)
 {
     struct stat64 st;
     int r = lstat64(path, &st);
-    UnalignStat64_32(&st, buf);
+    FillStatFromStat64(3, &st, buf);
     return r;
 }
 
@@ -2628,7 +2628,7 @@ EXPORT void* my32_localeconv(x64emu_t* emu)
     memcpy(&ret.int_frac_digits, &l->int_frac_digits, 14);
     return &ret;
 }
-
+locale_t l;
 EXPORT struct __processor_model
 {
   unsigned int __cpu_vendor;
diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h
index 8dc32395..02634910 100755
--- a/src/wrapped32/wrappedlibc_private.h
+++ b/src/wrapped32/wrappedlibc_private.h
@@ -417,6 +417,7 @@ GO(__fsetlocking, iESi)
 //GO(fsetpos, iEpp)
 //GO(fsetpos64, iEpp)
 GO(fsetxattr, iEippLi)
+GOM(fstat, iFip)    //%%,noE
 GOWM(fstatfs, iEip) //%%,noE
 GOWM(fstatfs64, iEip)    //%%,noE
 GOM(fstatvfs, iEEip)
@@ -894,7 +895,7 @@ GOW(isnanf, iEf)
 GO(__isnanf, iEf)
 // isnanl   // Weak
 // __isnanl
-GO2(__isoc99_fscanf, iEEppV, my32_fscanf)
+GO2(__isoc99_fscanf, iEESpV, my32_fscanf)
 // __isoc99_fwscanf
 // __isoc99_scanf
 GOM(__isoc99_sscanf, iEEppV)  //%%
@@ -906,6 +907,14 @@ GOM(__isoc99_sscanf, iEEppV)  //%%
 // __isoc99_vswscanf
 // __isoc99_vwscanf
 // __isoc99_wscanf
+GO2(__isoc23_fscanf, iEESpV, my32_fscanf)
+GO2(__isoc23_sscanf, iEEppV, my32_sscanf)
+GO2(__isoc23_vsscanf, iEEppp, my32_vsscanf)
+GO2(__isoc23_wcstol, lEpBp_i, my32_wcstol)
+GO2(__isoc23_strtoll, IEpBp_i, strtoll)
+GO2(__isoc23_strtoull, UEpBp_i, strtoull)
+GO2(__isoc23_strtol, lEpBp_i, my32_strtol)
+GO2(__isoc23_strtoul, LEpBp_i, my32_strtoul)
 GO(isprint, iEi)
 // __isprint_l
 // isprint_l    // Weak
@@ -1585,7 +1594,7 @@ GOW(sigsetmask, iEi)
 // sigstack
 GOW(sigsuspend, iEp)
 // __sigsuspend
-//GOW(sigtimedwait, iEppp)
+GOW(sigtimedwait, iEpprLL_)
 //GOW(sigvec, iEipp)
 //GOW(sigwait, iEpp)
 //GOW(sigwaitinfo, iEpp)
@@ -1611,6 +1620,7 @@ GOM(sscanf, iEEppV) //%%
 GOM(__stack_chk_fail, vEEv) //%%
 //GOM(lstat64, iEpp)	//%%,noE
 //GOM(stat64, iEpp)	//%%,noE
+GOM(stat, iFpp) //%%,noE
 GOWM(statfs, iEpp)  //%%,noE
 // __statfs
 GOWM(statfs64, iEpp)     //%%,noE
@@ -1667,6 +1677,8 @@ GO(strlen, LEp)
 GOW(strncasecmp, iEppL)
 // __strncasecmp_l
 // strncasecmp_l    // Weak
+GO(strlcat, pEppL)
+GO(strlcpy, pEppL)
 GO(strncat, pEppL)
 GO(__strncat_chk, pEppLL)
 GO(strncmp, iEppL)
@@ -2033,6 +2045,8 @@ GO(wctob, iEu)
 GO(__wctype_l, hEpa)
 GOW(wctype_l, hEpa)
 GO(wcwidth, iEu)
+GO(wcslcat, LFppL)
+GO(wcslcpy, LFppL)
 GOW(wmemchr, pEpiL)
 GO(wmemcmp, iEppL)
 GOW(wmemcpy, pEppL)
@@ -2198,9 +2212,7 @@ GO(__errno, pEv)
 //GO(__errno,
 #endif
 
-//GOM(stat,
 //GOM(lstat,
-//GOM(fstat,
 //GO(setprogname,
 //GO(getprogname,