diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-03-08 20:41:51 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-03-08 20:41:51 +0100 |
| commit | fa24bbd96ad1c2c13fe5f87a90c9a2f9fa8c77a1 (patch) | |
| tree | 01f1d89706a85f138932667af66cd8d906104a00 | |
| parent | 5eca802a5a110ec2f1b032886d30ff5084f59477 (diff) | |
| download | box64-fa24bbd96ad1c2c13fe5f87a90c9a2f9fa8c77a1.tar.gz box64-fa24bbd96ad1c2c13fe5f87a90c9a2f9fa8c77a1.zip | |
Added wrapped vfprintf and fprintf functions
| -rwxr-xr-x | rebuild_wrappers.py | 4 | ||||
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 4 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.c | 5 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.h | 4 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc.c | 36 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc_private.h | 16 |
6 files changed, 33 insertions, 36 deletions
diff --git a/rebuild_wrappers.py b/rebuild_wrappers.py index ac3b1d66..285d3446 100755 --- a/rebuild_wrappers.py +++ b/rebuild_wrappers.py @@ -336,7 +336,7 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc); reg_arg = ["R_RDI", "R_RSI", "R_RDX", "R_RCX", "R_R8", "R_R9"] # vreg: value is in a general register # E e v c w i I C W u U f d D K l L p V O S N M H - vreg = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 2, 2] + vreg = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 2, 2] # vxmm: value is in a XMM register # E e v c w i I C W u U f d D K l L p V O S N M H vxmm = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] @@ -345,7 +345,7 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc); vother = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0] # vstack: value is on the stack (or out of register) # E e v c w i I C W u U f d D K l L p V O S N M, H - vstack = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 0, 1, 1, 1, 2, 2] + vstack = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 0, 1, 1, 1, 2, 2] arg_s = [ "", # E "", # e diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index 20157fc9..6c05edc8 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -306,6 +306,7 @@ #() iFEpip #() iFEppi #() iFEppp +#() iFEppV #() iFiiii #() iFiiiu #() iFippi @@ -810,3 +811,6 @@ #!defined(HAVE_LD80BITS) KFKp #() iFEv -> iFE #() pFEv -> pFE +#() iFEvpp -> iFEpp +#() iFEpvpp -> iFEppp +#() iFEpvpV -> iFEppV diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index b1b965c8..6f731c8d 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -339,6 +339,7 @@ typedef int32_t (*iFEupp_t)(x64emu_t*, uint32_t, void*, void*); typedef int32_t (*iFEpip_t)(x64emu_t*, void*, int32_t, void*); typedef int32_t (*iFEppi_t)(x64emu_t*, void*, void*, int32_t); typedef int32_t (*iFEppp_t)(x64emu_t*, void*, void*, void*); +typedef int32_t (*iFEppV_t)(x64emu_t*, void*, void*, void*); typedef int32_t (*iFiiii_t)(int32_t, int32_t, int32_t, int32_t); typedef int32_t (*iFiiiu_t)(int32_t, int32_t, int32_t, uint32_t); typedef int32_t (*iFippi_t)(int32_t, void*, void*, int32_t); @@ -1156,6 +1157,7 @@ void iFEupp(x64emu_t *emu, uintptr_t fcn) { iFEupp_t fn = (iFEupp_t)fcn; R_RAX=f void iFEpip(x64emu_t *emu, uintptr_t fcn) { iFEpip_t fn = (iFEpip_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX); } void iFEppi(x64emu_t *emu, uintptr_t fcn) { iFEppi_t fn = (iFEppi_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX); } void iFEppp(x64emu_t *emu, uintptr_t fcn) { iFEppp_t fn = (iFEppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX); } +void iFEppV(x64emu_t *emu, uintptr_t fcn) { iFEppV_t fn = (iFEppV_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)(R_RSP + 8)); } void iFiiii(x64emu_t *emu, uintptr_t fcn) { iFiiii_t fn = (iFiiii_t)fcn; R_RAX=fn((int32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX); } void iFiiiu(x64emu_t *emu, uintptr_t fcn) { iFiiiu_t fn = (iFiiiu_t)fcn; R_RAX=fn((int32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (uint32_t)R_RCX); } void iFippi(x64emu_t *emu, uintptr_t fcn) { iFippi_t fn = (iFippi_t)fcn; R_RAX=fn((int32_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (int32_t)R_RCX); } @@ -1667,3 +1669,6 @@ void KFKp(x64emu_t *emu, uintptr_t fcn) { KFKp_t fn = (KFKp_t)fcn; double db=fn( void iFEv(x64emu_t *emu, uintptr_t fcn) { iFE_t fn = (iFE_t)fcn; R_RAX=fn(emu); } void pFEv(x64emu_t *emu, uintptr_t fcn) { pFE_t fn = (pFE_t)fcn; R_RAX=(uintptr_t)fn(emu); } +void iFEvpp(x64emu_t *emu, uintptr_t fcn) { iFEpp_t fn = (iFEpp_t)fcn; R_RAX=fn(emu, (void*)R_RSI, (void*)R_RDX); } +void iFEpvpp(x64emu_t *emu, uintptr_t fcn) { iFEppp_t fn = (iFEppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RDX, (void*)R_RCX); } +void iFEpvpV(x64emu_t *emu, uintptr_t fcn) { iFEppV_t fn = (iFEppV_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RDX, (void*)(R_RSP + 8)); } diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index 7e4773da..84d00bb1 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -336,6 +336,7 @@ void iFEupp(x64emu_t *emu, uintptr_t fnc); void iFEpip(x64emu_t *emu, uintptr_t fnc); void iFEppi(x64emu_t *emu, uintptr_t fnc); void iFEppp(x64emu_t *emu, uintptr_t fnc); +void iFEppV(x64emu_t *emu, uintptr_t fnc); void iFiiii(x64emu_t *emu, uintptr_t fnc); void iFiiiu(x64emu_t *emu, uintptr_t fnc); void iFippi(x64emu_t *emu, uintptr_t fnc); @@ -847,5 +848,8 @@ void KFKp(x64emu_t *emu, uintptr_t fnc); void iFEv(x64emu_t *emu, uintptr_t fnc); void pFEv(x64emu_t *emu, uintptr_t fnc); +void iFEvpp(x64emu_t *emu, uintptr_t fnc); +void iFEpvpp(x64emu_t *emu, uintptr_t fnc); +void iFEpvpV(x64emu_t *emu, uintptr_t fnc); #endif //__WRAPPER_H_ diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 4790b868..52826426 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -582,37 +582,21 @@ EXPORT int my_vprintf(x64emu_t *emu, void* fmt, x64_va_list_t b) { } EXPORT int my___vprintf_chk(x64emu_t *emu, void* fmt, x64_va_list_t b) __attribute__((alias("my_vprintf"))); -#if 0 -EXPORT int my_vfprintf(x64emu_t *emu, void* F, void* fmt, void* b) { - #ifndef NOALIGN - // need to align on arm - myStackAlign((const char*)fmt, (uint32_t*)b, emu->scratch); - PREPARE_VALIST; - void* f = vfprintf; - return ((iFppp_t)f)(F, fmt, VARARGS); - #else - // other platform don't need that - void* f = vfprintf; - return ((iFppp_t)f)(F, fmt, (uint32_t*)b); - #endif +EXPORT int my_vfprintf(x64emu_t *emu, void* F, void* fmt, x64_va_list_t b) { + CONVERT_VALIST(b); + return vfprintf(F, fmt, VARARGS); } -EXPORT int my___vfprintf_chk(x64emu_t *emu, void* F, void* fmt, void* b) __attribute__((alias("my_vfprintf"))); -EXPORT int my__IO_vfprintf(x64emu_t *emu, void* F, void* fmt, void* b) __attribute__((alias("my_vfprintf"))); +EXPORT int my___vfprintf_chk(x64emu_t *emu, void* F, void* fmt, x64_va_list_t b) __attribute__((alias("my_vfprintf"))); +EXPORT int my__IO_vfprintf(x64emu_t *emu, void* F, void* fmt, x64_va_list_t b) __attribute__((alias("my_vfprintf"))); -EXPORT int my_fprintf(x64emu_t *emu, void* F, void* fmt, void* b, va_list V) { - #ifndef NOALIGN - // need to align on arm - myStackAlign((const char*)fmt, b, emu->scratch); +EXPORT int my_fprintf(x64emu_t *emu, void* F, void* fmt, void* b) { + myStackAlign(emu, (const char*)fmt, b, emu->scratch, R_EAX, 1); PREPARE_VALIST; - void* f = vfprintf; - return ((iFppp_t)f)(F, fmt, VARARGS); - #else - // other platform don't need that - return vfprintf((FILE*)F, (const char*)fmt, V); - #endif + return vfprintf(F, fmt, VARARGS); } -EXPORT int my___fprintf_chk(x64emu_t *emu, void* F, void* fmt, void* b, va_list V) __attribute__((alias("my_fprintf"))); +EXPORT int my___fprintf_chk(x64emu_t *emu, void* F, void* fmt, void* b) __attribute__((alias("my_fprintf"))); +#if 0 EXPORT int my_wprintf(x64emu_t *emu, void* fmt, void* b, va_list V) { #ifndef NOALIGN // need to align on arm diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index 5b2e36b5..7b27c6fe 100755 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -375,8 +375,8 @@ GOM(fork, iFEv) // Weak //GO(__fortify_fail, //GOW(fpathconf, //GO(__fpending, -//GO(fprintf, -//GO(__fprintf_chk, +GOM(fprintf, iFEppV) +GOM(__fprintf_chk, iFEpvpV) //DATA(__fpu_control, //GO(__fpurge, //GO(fputc, @@ -1732,9 +1732,9 @@ GOM(__stack_chk_fail, vFE) //GOW(statvfs, //GOW(statvfs64, //GO(statx, -DATA(stderr, 8) -DATA(stdin, 8) -DATA(stdout, 8) +DATA(stderr, sizeof(void*)) +DATA(stdin, sizeof(void*)) +DATA(stdout, sizeof(void*)) //GOW(step, //GO(stime, //GOI(__stpcpy, @@ -2045,8 +2045,8 @@ GO(usleep, iFu) //GOW(versionsort64, //GO(__vfork, //GOW(vfork, -//GO(vfprintf, -//GO(__vfprintf_chk, +GOM(vfprintf, iFEppp) +GOM(__vfprintf_chk, iFEpvpp) //GO(__vfscanf, //GOW(vfscanf, //GOW(vfwprintf, @@ -2056,7 +2056,7 @@ GO(usleep, iFu) //GO(vlimit, //GO(vmsplice, GOM(vprintf, iFEpp) -//GO(__vprintf_chk, +GOM(__vprintf_chk, iFEvpp) //GOW(vscanf, //GOW(__vsnprintf, //GOW(vsnprintf, |