about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-03-09 19:35:00 +0100
committerptitSeb <sebastien.chev@gmail.com>2021-03-09 19:35:00 +0100
commit25937c5b7328d94b95c139acc5764916de4b98dd (patch)
treea11c5f2ef5a49cfd809efdf1a1a69938f3fa235b /src
parent43833df09294ef2fa86a59a2f2181b732c5b4993 (diff)
downloadbox64-25937c5b7328d94b95c139acc5764916de4b98dd.tar.gz
box64-25937c5b7328d94b95c139acc5764916de4b98dd.zip
Alignement of struct stat / stat64
Diffstat (limited to 'src')
-rwxr-xr-xsrc/include/myalign.h2
-rwxr-xr-xsrc/libtools/myalign.c45
-rwxr-xr-xsrc/wrapped/wrappedlibc.c22
-rwxr-xr-xsrc/wrapped/wrappedlibc_private.h4
4 files changed, 52 insertions, 21 deletions
diff --git a/src/include/myalign.h b/src/include/myalign.h
index c2c7214f..a222e3ff 100755
--- a/src/include/myalign.h
+++ b/src/include/myalign.h
@@ -89,6 +89,8 @@ void myStackAlign(x64emu_t* emu, const char* fmt, uint64_t* st, uint64_t* mystac
 void myStackAlignGVariantNew(x64emu_t* emu, const char* fmt, uint64_t* st, uint64_t* mystack, int xmm, int pos);
 void myStackAlignW(x64emu_t* emu, const char* fmt, uint64_t* st, uint64_t* mystack, int xmm, int pos);
 
+void UnalignStat64(const void* source, void* dest);
+
 // defined in wrapperlibc.c
 int of_convert(int);    // x86->arm
 int of_unconvert(int);  // arm->x86
diff --git a/src/libtools/myalign.c b/src/libtools/myalign.c
index e027558a..650d6040 100755
--- a/src/libtools/myalign.c
+++ b/src/libtools/myalign.c
@@ -5,6 +5,7 @@
 #include <wchar.h>
 #include <sys/epoll.h>
 #include <fts.h>
+#include <sys/stat.h>
 
 #include "x64emu.h"
 #include "emu/x64emu_private.h"
@@ -431,3 +432,47 @@ void myStackAlignW(const char* fmt, uint32_t* st, uint32_t* mystack)
     }
 }
 #endif
+
+#undef st_atime
+#undef st_mtime
+#undef st_ctime
+
+struct x64_stat64 {                   /* x86_64       arm64 */
+    uint64_t st_dev;                    /* 0   */   /* 0   */
+    uint64_t st_ino;                    /* 8   */   /* 8   */
+    uint64_t st_nlink;                  /* 16  */   /* 20  */
+    uint32_t st_mode;                   /* 24  */   /* 16  */
+    uint32_t st_uid;                    /* 28  */   /* 24  */
+    uint32_t st_gid;                    /* 32  */   /* 28  */
+    int __pad0;                         /* 36  */   /* --- */
+    uint64_t st_rdev;                   /* 40  */   /* 32  */
+    int64_t st_size;                    /* 48  */   /* 48  */
+    int64_t st_blksize;                 /* 56  */   /* 56  */
+    uint64_t st_blocks;                 /* 64  */   /* 64  */
+    struct timespec st_atim;            /* 72  */   /* 72  */
+    struct timespec st_mtim;            /* 88  */   /* 88  */
+    struct timespec st_ctim;            /* 104 */   /* 104 */
+    uint64_t __glibc_reserved[3];       /* 120 */   /* 120 */
+} __attribute__((packed));              /* 144 */   /* 128 */
+
+void UnalignStat64(const void* source, void* dest)
+{
+    struct x64_stat64 *x64st = (struct x64_stat64*)dest;
+    struct stat *st = (struct stat*) source;
+    
+    x64st->__pad0 = 0;
+	memset(x64st->__glibc_reserved, 0, sizeof(x64st->__glibc_reserved));
+    x64st->st_dev      = st->st_dev;
+    x64st->st_ino      = st->st_ino;
+    x64st->st_mode     = st->st_mode;
+    x64st->st_nlink    = st->st_nlink;
+    x64st->st_uid      = st->st_uid;
+    x64st->st_gid      = st->st_gid;
+    x64st->st_rdev     = st->st_rdev;
+    x64st->st_size     = st->st_size;
+    x64st->st_blksize  = st->st_blksize;
+    x64st->st_blocks   = st->st_blocks;
+    x64st->st_atim     = st->st_atim;
+    x64st->st_mtim     = st->st_mtim;
+    x64st->st_ctim     = st->st_ctim;
+}
\ No newline at end of file
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index bae44fbf..4dbf4136 100755
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -1010,28 +1010,12 @@ 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)
 {
-    if (v == 1)
-    {
-        static iFipp_t f = NULL;
-        if(!f) {
-            library_t* lib = my_lib;
-            if(!lib)
-            {
-                errno = EINVAL;
-                return -1;
-            }
-            f = (iFipp_t)dlsym(lib->priv.w.lib, "__xstat");
-        }
-
-        return f(v, path, buf);
-    }
     struct stat64 st;
     int r = stat64((const char*)path, &st);
-    if (r) return r;
-    r = FillStatFromStat64(v, &st, buf);
+    UnalignStat64(&st, buf);
     return r;
 }
 
@@ -1042,7 +1026,7 @@ EXPORT int my___xstat64(x64emu_t* emu, int v, void* path, void* buf)
     UnalignStat64(&st, buf);
     return r;
 }
-
+#if 0
 EXPORT int my___lxstat(x64emu_t* emu, int v, void* name, void* buf)
 {
     if (v == 1)
diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h
index a36f1442..66545de1 100755
--- a/src/wrapped/wrappedlibc_private.h
+++ b/src/wrapped/wrappedlibc_private.h
@@ -2282,8 +2282,8 @@ GOW(writev, lFipi)
 //GO(__xpg_strerror_r, 
 //GO(xprt_register, 
 //GO(xprt_unregister, 
-GO(__xstat, iFipp)
-GO(__xstat64, iFipp)
+GOM(__xstat, iFEipp)
+GOM(__xstat64, iFEipp)
 
 GOM(_Jv_RegisterClasses, vFv)   // dummy