about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-03-09 20:36:49 +0100
committerptitSeb <sebastien.chev@gmail.com>2021-03-09 20:36:49 +0100
commit70ad747a9c6d5f86d9bbb97406f44d3af128d528 (patch)
tree784b8684ac26010822842259ea95e378cb6bae7e /src
parentce322774d8ef2ee343bfb67695fc246e4f12b457 (diff)
downloadbox64-70ad747a9c6d5f86d9bbb97406f44d3af128d528.tar.gz
box64-70ad747a9c6d5f86d9bbb97406f44d3af128d528.zip
Aligned struct stat64 for fxstat(64) also
Diffstat (limited to 'src')
-rw-r--r--src/wrapped/generated/functions_list.txt3
-rw-r--r--src/wrapped/generated/wrapper.c6
-rw-r--r--src/wrapped/generated/wrapper.h3
-rwxr-xr-xsrc/wrapped/wrappedlibc.c98
-rwxr-xr-xsrc/wrapped/wrappedlibc_private.h10
5 files changed, 15 insertions, 105 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index 9e07a6e9..1cc942aa 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -334,6 +334,7 @@
 #() vFpppu
 #() vFpppp
 #() cFpiii
+#() iFEiip
 #() iFEiiN
 #() iFEipp
 #() iFEupp
@@ -502,7 +503,6 @@
 #() iFEppiV
 #() iFEpppp
 #() iFiiupp
-#() iFiippi
 #() iFipiii
 #() iFipppi
 #() iFpiiii
@@ -609,6 +609,7 @@
 #() vFppiipi
 #() vFppupii
 #() vFpppppp
+#() iFEiippi
 #() iFEpippi
 #() iFEpuppp
 #() iFEppppp
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index fa25ebe3..a84ddf5f 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -367,6 +367,7 @@ typedef void (*vFpppi_t)(void*, void*, void*, int32_t);
 typedef void (*vFpppu_t)(void*, void*, void*, uint32_t);
 typedef void (*vFpppp_t)(void*, void*, void*, void*);
 typedef int8_t (*cFpiii_t)(void*, int32_t, int32_t, int32_t);
+typedef int32_t (*iFEiip_t)(x64emu_t*, int32_t, int32_t, void*);
 typedef int32_t (*iFEiiN_t)(x64emu_t*, int32_t, int32_t, ...);
 typedef int32_t (*iFEipp_t)(x64emu_t*, int32_t, void*, void*);
 typedef int32_t (*iFEupp_t)(x64emu_t*, uint32_t, void*, void*);
@@ -535,7 +536,6 @@ typedef int32_t (*iFEpLpp_t)(x64emu_t*, void*, uintptr_t, void*, void*);
 typedef int32_t (*iFEppiV_t)(x64emu_t*, void*, void*, int32_t, void*);
 typedef int32_t (*iFEpppp_t)(x64emu_t*, void*, void*, void*, void*);
 typedef int32_t (*iFiiupp_t)(int32_t, int32_t, uint32_t, void*, void*);
-typedef int32_t (*iFiippi_t)(int32_t, int32_t, void*, void*, int32_t);
 typedef int32_t (*iFipiii_t)(int32_t, void*, int32_t, int32_t, int32_t);
 typedef int32_t (*iFipppi_t)(int32_t, void*, void*, void*, int32_t);
 typedef int32_t (*iFpiiii_t)(void*, int32_t, int32_t, int32_t, int32_t);
@@ -642,6 +642,7 @@ typedef void (*vFppiiii_t)(void*, void*, int32_t, int32_t, int32_t, int32_t);
 typedef void (*vFppiipi_t)(void*, void*, int32_t, int32_t, void*, int32_t);
 typedef void (*vFppupii_t)(void*, void*, uint32_t, void*, int32_t, int32_t);
 typedef void (*vFpppppp_t)(void*, void*, void*, void*, void*, void*);
+typedef int32_t (*iFEiippi_t)(x64emu_t*, int32_t, int32_t, void*, void*, int32_t);
 typedef int32_t (*iFEpippi_t)(x64emu_t*, void*, int32_t, void*, void*, int32_t);
 typedef int32_t (*iFEpuppp_t)(x64emu_t*, void*, uint32_t, void*, void*, void*);
 typedef int32_t (*iFEppppp_t)(x64emu_t*, void*, void*, void*, void*, void*);
@@ -1245,6 +1246,7 @@ void vFpppi(x64emu_t *emu, uintptr_t fcn) { vFpppi_t fn = (vFpppi_t)fcn; fn((voi
 void vFpppu(x64emu_t *emu, uintptr_t fcn) { vFpppu_t fn = (vFpppu_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (uint32_t)R_RCX); }
 void vFpppp(x64emu_t *emu, uintptr_t fcn) { vFpppp_t fn = (vFpppp_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX); }
 void cFpiii(x64emu_t *emu, uintptr_t fcn) { cFpiii_t fn = (cFpiii_t)fcn; R_RAX=fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX); }
+void iFEiip(x64emu_t *emu, uintptr_t fcn) { iFEiip_t fn = (iFEiip_t)fcn; R_RAX=fn(emu, (int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX); }
 void iFEiiN(x64emu_t *emu, uintptr_t fcn) { iFEiiN_t fn = (iFEiiN_t)fcn; R_RAX=fn(emu, (int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX); }
 void iFEipp(x64emu_t *emu, uintptr_t fcn) { iFEipp_t fn = (iFEipp_t)fcn; R_RAX=fn(emu, (int32_t)R_RDI, (void*)R_RSI, (void*)R_RDX); }
 void iFEupp(x64emu_t *emu, uintptr_t fcn) { iFEupp_t fn = (iFEupp_t)fcn; R_RAX=fn(emu, (uint32_t)R_RDI, (void*)R_RSI, (void*)R_RDX); }
@@ -1413,7 +1415,6 @@ void iFEpLpp(x64emu_t *emu, uintptr_t fcn) { iFEpLpp_t fn = (iFEpLpp_t)fcn; R_RA
 void iFEppiV(x64emu_t *emu, uintptr_t fcn) { iFEppiV_t fn = (iFEppiV_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)(R_RSP + 8)); }
 void iFEpppp(x64emu_t *emu, uintptr_t fcn) { iFEpppp_t fn = (iFEpppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX); }
 void iFiiupp(x64emu_t *emu, uintptr_t fcn) { iFiiupp_t fn = (iFiiupp_t)fcn; R_RAX=fn((int32_t)R_RDI, (int32_t)R_RSI, (uint32_t)R_RDX, (void*)R_RCX, (void*)R_R8); }
-void iFiippi(x64emu_t *emu, uintptr_t fcn) { iFiippi_t fn = (iFiippi_t)fcn; R_RAX=fn((int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (int32_t)R_R8); }
 void iFipiii(x64emu_t *emu, uintptr_t fcn) { iFipiii_t fn = (iFipiii_t)fcn; R_RAX=fn((int32_t)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (int32_t)R_R8); }
 void iFipppi(x64emu_t *emu, uintptr_t fcn) { iFipppi_t fn = (iFipppi_t)fcn; R_RAX=fn((int32_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (int32_t)R_R8); }
 void iFpiiii(x64emu_t *emu, uintptr_t fcn) { iFpiiii_t fn = (iFpiiii_t)fcn; R_RAX=fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (int32_t)R_R8); }
@@ -1520,6 +1521,7 @@ void vFppiiii(x64emu_t *emu, uintptr_t fcn) { vFppiiii_t fn = (vFppiiii_t)fcn; f
 void vFppiipi(x64emu_t *emu, uintptr_t fcn) { vFppiipi_t fn = (vFppiipi_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (void*)R_R8, (int32_t)R_R9); }
 void vFppupii(x64emu_t *emu, uintptr_t fcn) { vFppupii_t fn = (vFppupii_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (uint32_t)R_RDX, (void*)R_RCX, (int32_t)R_R8, (int32_t)R_R9); }
 void vFpppppp(x64emu_t *emu, uintptr_t fcn) { vFpppppp_t fn = (vFpppppp_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9); }
+void iFEiippi(x64emu_t *emu, uintptr_t fcn) { iFEiippi_t fn = (iFEiippi_t)fcn; R_RAX=fn(emu, (int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (int32_t)R_R8); }
 void iFEpippi(x64emu_t *emu, uintptr_t fcn) { iFEpippi_t fn = (iFEpippi_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (int32_t)R_R8); }
 void iFEpuppp(x64emu_t *emu, uintptr_t fcn) { iFEpuppp_t fn = (iFEpuppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (uint32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8); }
 void iFEppppp(x64emu_t *emu, uintptr_t fcn) { iFEppppp_t fn = (iFEppppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8); }
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index 67bd8cd2..9c8202a4 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -364,6 +364,7 @@ void vFpppi(x64emu_t *emu, uintptr_t fnc);
 void vFpppu(x64emu_t *emu, uintptr_t fnc);
 void vFpppp(x64emu_t *emu, uintptr_t fnc);
 void cFpiii(x64emu_t *emu, uintptr_t fnc);
+void iFEiip(x64emu_t *emu, uintptr_t fnc);
 void iFEiiN(x64emu_t *emu, uintptr_t fnc);
 void iFEipp(x64emu_t *emu, uintptr_t fnc);
 void iFEupp(x64emu_t *emu, uintptr_t fnc);
@@ -532,7 +533,6 @@ void iFEpLpp(x64emu_t *emu, uintptr_t fnc);
 void iFEppiV(x64emu_t *emu, uintptr_t fnc);
 void iFEpppp(x64emu_t *emu, uintptr_t fnc);
 void iFiiupp(x64emu_t *emu, uintptr_t fnc);
-void iFiippi(x64emu_t *emu, uintptr_t fnc);
 void iFipiii(x64emu_t *emu, uintptr_t fnc);
 void iFipppi(x64emu_t *emu, uintptr_t fnc);
 void iFpiiii(x64emu_t *emu, uintptr_t fnc);
@@ -639,6 +639,7 @@ void vFppiiii(x64emu_t *emu, uintptr_t fnc);
 void vFppiipi(x64emu_t *emu, uintptr_t fnc);
 void vFppupii(x64emu_t *emu, uintptr_t fnc);
 void vFpppppp(x64emu_t *emu, uintptr_t fnc);
+void iFEiippi(x64emu_t *emu, uintptr_t fnc);
 void iFEpippi(x64emu_t *emu, uintptr_t fnc);
 void iFEpuppp(x64emu_t *emu, uintptr_t fnc);
 void iFEppppp(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index 4dbf4136..54354e83 100755
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -899,106 +899,12 @@ EXPORT void my__ITM_addUserCommitAction(x64emu_t* emu, void* cb, uint32_t b, voi
 EXPORT void my__ITM_registerTMCloneTable(x64emu_t* emu, void* p, uint32_t s) {}
 EXPORT void my__ITM_deregisterTMCloneTable(x64emu_t* emu, void* p) {}
 
-#if 0
-struct i386_stat {
-	uint64_t  st_dev;
-	uint32_t  __pad1;
-	uint32_t  st_ino;
-	uint32_t  st_mode;
-	uint32_t  st_nlink;
-	uint32_t  st_uid;
-	uint32_t  st_gid;
-	uint64_t  st_rdev;
-	uint32_t  __pad2;
-	int32_t   st_size;
-	int32_t   st_blksize;
-	int32_t   st_blocks;
-	int32_t   st_atime_sec;
-	uint32_t  st_atime_nsec;
-	int32_t   st_mtime_sec;
-	uint32_t  st_mtime_nsec;
-	int32_t   st_ctime_sec;
-	uint32_t  st_ctime_nsec;
-	uint32_t  __unused4;
-	uint32_t  __unused5;
-} __attribute__((packed));
-
-static int FillStatFromStat64(int vers, const struct stat64 *st64, void *st32)
-{
-    struct i386_stat *i386st = (struct i386_stat *)st32;
-
-    if (vers != 3)
-    {
-        errno = EINVAL;
-        return -1;
-    }
-
-    i386st->st_dev = st64->st_dev;
-    i386st->__pad1 = 0;
-    if (fix_64bit_inodes)
-    {
-        i386st->st_ino = st64->st_ino ^ (st64->st_ino >> 32);
-    }
-    else
-    {
-        i386st->st_ino = st64->st_ino;
-        if ((st64->st_ino >> 32) != 0)
-        {
-            errno = EOVERFLOW;
-            return -1;
-        }
-    }
-    i386st->st_mode = st64->st_mode;
-    i386st->st_nlink = st64->st_nlink;
-    i386st->st_uid = st64->st_uid;
-    i386st->st_gid = st64->st_gid;
-    i386st->st_rdev = st64->st_rdev;
-    i386st->__pad2 = 0;
-    i386st->st_size = st64->st_size;
-    if ((i386st->st_size >> 31) != (int32_t)(st64->st_size >> 32))
-    {
-        errno = EOVERFLOW;
-        return -1;
-    }
-    i386st->st_blksize = st64->st_blksize;
-    i386st->st_blocks = st64->st_blocks;
-    if ((i386st->st_blocks >> 31) != (int32_t)(st64->st_blocks >> 32))
-    {
-        errno = EOVERFLOW;
-        return -1;
-    }
-    i386st->st_atime_sec = st64->st_atim.tv_sec;
-    i386st->st_atime_nsec = st64->st_atim.tv_nsec;
-    i386st->st_mtime_sec = st64->st_mtim.tv_sec;
-    i386st->st_mtime_nsec = st64->st_mtim.tv_nsec;
-    i386st->st_ctime_sec = st64->st_ctim.tv_sec;
-    i386st->st_ctime_nsec = st64->st_ctim.tv_nsec;
-    i386st->__unused4 = 0;
-    i386st->__unused5 = 0;
-    return 0;
-}
 
 EXPORT int my___fxstat(x64emu_t *emu, int vers, int fd, void* buf)
 {
-    if (vers == 1)
-    {
-        static iFiip_t f = NULL;
-        if(!f) {
-            library_t* lib = my_lib;
-            if(!lib)
-            {
-                errno = EINVAL;
-                return -1;
-            }
-            f = (iFiip_t)dlsym(lib->priv.w.lib, "__fxstat");
-        }
-
-        return f(vers, fd, buf);
-    }
     struct stat64 st;
     int r = fstat64(fd, &st);
-    if (r) return r;
-    r = FillStatFromStat64(vers, &st, buf);
+    UnalignStat64(&st, buf);
     return r;
 }
 
@@ -1010,7 +916,7 @@ EXPORT int my___fxstat64(x64emu_t *emu, int vers, int fd, void* buf)
     UnalignStat64(&st, buf);
     return r;
 }
-#endif
+
 EXPORT int my___xstat(x64emu_t* emu, int v, void* path, void* buf)
 {
     struct stat64 st;
diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h
index e514bc62..afe351dd 100755
--- a/src/wrapped/wrappedlibc_private.h
+++ b/src/wrapped/wrappedlibc_private.h
@@ -3,7 +3,7 @@
 #endif
 
 //GO(a64l, 
-//GO(abort, 
+GO(abort, vFv)
 //DATAB(__abort_msg, 
 //GO(abs, 
 //GO(accept, 
@@ -451,10 +451,10 @@ GOW(fwrite, LFpLLp)
 //GO(fwrite_unlocked, 
 //GO(__fwriting, 
 //GO(fwscanf, 
-GO(__fxstat, iFiip)
-GO(__fxstat64, iFiip)
-GO(__fxstatat, iFiippi)
-GO(__fxstatat64, iFiippi)
+GOM(__fxstat, iFEiip)
+GOM(__fxstat64, iFEiip)
+GOM(__fxstatat, iFEiippi)
+GOM(__fxstatat64, iFEiippi)
 //GO(__gai_sigqueue, 
 //GO(gai_strerror, 
 //GO(__gconv_get_alias_db,