diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-07-12 10:52:21 -0500 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-07-12 10:52:21 -0500 |
| commit | 77421d2eed152ed2d1481aa77999d015444937c9 (patch) | |
| tree | 785247dddff6e7a4fd7d37e739894ed7028b5757 /src | |
| parent | 78b9b0cec8ad87e4ac982465a9270e570d146e4f (diff) | |
| download | box64-77421d2eed152ed2d1481aa77999d015444937c9.tar.gz box64-77421d2eed152ed2d1481aa77999d015444937c9.zip | |
Added a bunch of wrapped libc function (for #41)
Diffstat (limited to 'src')
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 7 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibctypes.h | 7 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc.c | 33 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc_private.h | 26 |
4 files changed, 50 insertions, 23 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index e453eb35..18f0e19c 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -1521,6 +1521,9 @@ wrappedlibc: - siglongjmp - vFpu: - _ITM_registerTMCloneTable +- vFpV: + - warn + - warnx - iFpi: - __sigsetjmp - backtrace @@ -1555,6 +1558,7 @@ wrappedlibc: - vFipp: - vsyslog - vFipV: + - err - syslog - vFpii: - backtrace_symbols_fd @@ -1576,6 +1580,7 @@ wrappedlibc: - sigaction - iFipV: - __printf_chk + - errx - iFpLi: - mprotect - iFppi: @@ -1591,6 +1596,7 @@ wrappedlibc: - execve - vasprintf - vfprintf + - vfscanf - vsscanf - iFppV: - __asprintf @@ -1624,6 +1630,7 @@ wrappedlibc: - glob - glob64 - iFpipV: + - __asprintf_chk - __fprintf_chk - iFpLpp: - __vsnprintf diff --git a/src/wrapped/generated/wrappedlibctypes.h b/src/wrapped/generated/wrappedlibctypes.h index 3ac1150d..0a9a7bf9 100644 --- a/src/wrapped/generated/wrappedlibctypes.h +++ b/src/wrapped/generated/wrappedlibctypes.h @@ -19,6 +19,7 @@ typedef uintptr_t (*LFv_t)(void); typedef uintptr_t (*LFL_t)(uintptr_t); typedef void (*vFpi_t)(void*, int64_t); typedef void (*vFpu_t)(void*, uint64_t); +typedef void (*vFpV_t)(void*, void*); typedef int64_t (*iFpi_t)(void*, int64_t); typedef int64_t (*iFpL_t)(void*, uintptr_t); typedef int64_t (*iFpp_t)(void*, void*); @@ -80,6 +81,8 @@ typedef int64_t (*iFpippppp_t)(void*, int64_t, void*, void*, void*, void*, void* GO(longjmp, vFpi_t) \ GO(siglongjmp, vFpi_t) \ GO(_ITM_registerTMCloneTable, vFpu_t) \ + GO(warn, vFpV_t) \ + GO(warnx, vFpV_t) \ GO(__sigsetjmp, iFpi_t) \ GO(backtrace, iFpi_t) \ GO(munmap, iFpL_t) \ @@ -104,6 +107,7 @@ typedef int64_t (*iFpippppp_t)(void*, int64_t, void*, void*, void*, void*, void* GO(fopen64, pFpp_t) \ GO(realpath, pFpp_t) \ GO(vsyslog, vFipp_t) \ + GO(err, vFipV_t) \ GO(syslog, vFipV_t) \ GO(backtrace_symbols_fd, vFpii_t) \ GO(_ITM_addUserCommitAction, vFpup_t) \ @@ -119,6 +123,7 @@ typedef int64_t (*iFpippppp_t)(void*, int64_t, void*, void*, void*, void*, void* GO(__xstat64, iFipp_t) \ GO(sigaction, iFipp_t) \ GO(__printf_chk, iFipV_t) \ + GO(errx, iFipV_t) \ GO(mprotect, iFpLi_t) \ GO(ftw, iFppi_t) \ GO(ftw64, iFppi_t) \ @@ -131,6 +136,7 @@ typedef int64_t (*iFpippppp_t)(void*, int64_t, void*, void*, void*, void*, void* GO(execve, iFppp_t) \ GO(vasprintf, iFppp_t) \ GO(vfprintf, iFppp_t) \ + GO(vfscanf, iFppp_t) \ GO(vsscanf, iFppp_t) \ GO(__asprintf, iFppV_t) \ GO(__isoc99_fscanf, iFppV_t) \ @@ -154,6 +160,7 @@ typedef int64_t (*iFpippppp_t)(void*, int64_t, void*, void*, void*, void*, void* GO(__vasprintf_chk, iFpipp_t) \ GO(glob, iFpipp_t) \ GO(glob64, iFpipp_t) \ + GO(__asprintf_chk, iFpipV_t) \ GO(__fprintf_chk, iFpipV_t) \ GO(__vsnprintf, iFpLpp_t) \ GO(__vsnprintf_chk, iFpLpp_t) \ diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index a4488780..b4bfe2d1 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -771,19 +771,12 @@ EXPORT int my___vasprintf_chk(x64emu_t* emu, void* buff, int flags, void* fmt, x int r = vasprintf(buff, fmt, VARARGS); return r; } -#if 0 -EXPORT int my___asprintf_chk(x64emu_t* emu, void* result_ptr, int flags, void* fmt, void* b, va_list V) +EXPORT int my___asprintf_chk(x64emu_t* emu, void* result_ptr, int flags, void* fmt, void* b) { - #ifndef NOALIGN - myStackAlign((const char*)fmt, b, emu->scratch); + myStackAlign(emu, (const char*)fmt, b, emu->scratch, R_EAX, 3); PREPARE_VALIST; - void* f = vasprintf; - return ((iFppp_t)f)(result_ptr, fmt, VARARGS); - #else - return vasprintf((char**)result_ptr, (char*)fmt, V); - #endif + return vasprintf((char**)result_ptr, (char*)fmt, VARARGS); } -#endif EXPORT int my_vswprintf(x64emu_t* emu, void* buff, size_t s, void * fmt, x64_va_list_t b) { (void)emu; CONVERT_VALIST(b); @@ -826,6 +819,26 @@ EXPORT void my_vwarn(x64emu_t* emu, void* fmt, void* b) { #endif } #endif +EXPORT void my_err(x64emu_t *emu, int eval, void* fmt, void* b) { + myStackAlign(emu, (const char*)fmt, b, emu->scratch, R_EAX, 2); + PREPARE_VALIST; + verr(eval, (const char*)fmt, VARARGS); +} +EXPORT void my_errx(x64emu_t *emu, int eval, void* fmt, void* b) { + myStackAlign(emu, (const char*)fmt, b, emu->scratch, R_EAX, 2); + PREPARE_VALIST; + verrx(eval, (const char*)fmt, VARARGS); +} +EXPORT void my_warn(x64emu_t *emu, void* fmt, void* b) { + myStackAlign(emu, (const char*)fmt, b, emu->scratch, R_EAX, 1); + PREPARE_VALIST; + vwarn((const char*)fmt, VARARGS); +} +EXPORT void my_warnx(x64emu_t *emu, void* fmt, void* b) { + myStackAlign(emu, (const char*)fmt, b, emu->scratch, R_EAX, 1); + PREPARE_VALIST; + vwarnx((const char*)fmt, VARARGS); +} EXPORT void my_syslog(x64emu_t* emu, int priority, const char* fmt, uint64_t* b) { diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index c36ac941..1a7f0faf 100755 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -57,7 +57,7 @@ GO(asctime, pFp) GOW(asctime_r, pFpp) GOM(__asprintf, iFEppV) GOM(asprintf, iFEppV) //Weak -//GO(__asprintf_chk, +GOM(__asprintf_chk, iFEpipV) //GO(__assert, GO(__assert_fail, vFppup) GO(__assert_perror_fail, vFipup) @@ -270,7 +270,7 @@ GOM(epoll_wait, iFEipii) #endif GO(erand48, dFp) //GOW(erand48_r, -//GO(err, +GOM(err, vFEipV) //DATAB(errno, GO(__errno_location, pFv) //GOW(error, @@ -278,7 +278,7 @@ GO(__errno_location, pFv) //DATAB(error_message_count, //DATAB(error_one_per_line, //DATAB(error_print_progname, -//GO(errx, +GOM(errx, iFEipV) //GO(ether_aton, //GO(ether_aton_r, //GO(ether_hostton, @@ -1147,7 +1147,7 @@ GOW(memmem, pFpLpL) GO(memmove, pFppL) GO(__memmove_chk, pFppLL) //GOI(__mempcpy, -//GOI(mempcpy, +GO(mempcpy, pFppL) //GOI(__mempcpy_chk, GOW(memrchr, pFpiL) GO(memset, pFpiL) @@ -1275,7 +1275,7 @@ GOM(open64, iFEpOu) //Weak GO(__open64_2, iFpO) //GO(__open64_nocancel, GOW(openat, iFipON) -//GO(__openat_2, +GO(__openat_2, iFipO) GOW(openat64, iFipON) GO(__openat64_2, iFipO) //GO(open_by_handle_at, @@ -1564,9 +1564,9 @@ GOM(scandir64, iFEpppp) //weak //GOW(scandirat, //GO(scandirat64, //GO(scanf, -//GO(__sched_cpualloc, +GO(__sched_cpualloc, pFL) GO(__sched_cpucount, iFLp) -//GO(__sched_cpufree, +GO(__sched_cpufree, vFp) GO(sched_getaffinity, iFLLp) //GO(sched_getcpu, GO(__sched_getparam, iFLp) @@ -1608,7 +1608,7 @@ GO(setbuf, vFpp) GOW(setbuffer, vFppL) //GOW(setcontext, //GO(setdomainname, -//GO(setegid, +GO(setegid, iFu) GOW(setenv, iFppi) //GO(_seterr_reply, GO(seteuid, iFu) @@ -2054,7 +2054,7 @@ GOW(versionsort64, iFpp) GOM(vfprintf, iFEppp) GOM(__vfprintf_chk, iFEpvpp) //GO(__vfscanf, -//GOW(vfscanf, +GOM(vfscanf, iFEppp) //Weak //GOW(vfwprintf, //GO(__vfwprintf_chk, //GOW(vfwscanf, @@ -2089,8 +2089,8 @@ GOW(wait4, lFlpip) GOW(waitid, iFiupi) GO(__waitpid, lFlpi) GOW(waitpid, lFlpi) -//GO(warn, -//GO(warnx, +GOM(warn, vFEpV) +GOM(warnx, vFEpV) //GOW(wcpcpy, //GO(__wcpcpy_chk, //GOW(wcpncpy, @@ -2180,7 +2180,7 @@ GOW(wcstoull, UFppi) //GO(wcstoumax, //GOW(wcstouq, //GOW(wcswcs, -//GO(wcswidth, +GO(wcswidth, iFpL) GO(wcsxfrm, LFppL) GO(__wcsxfrm_l, LFppLL) GOW(wcsxfrm_l, LFppLL) @@ -2200,7 +2200,7 @@ GOW(wmemcpy, pFppL) GO(__wmemcpy_chk, pFppLL) GOW(wmemmove, pFppL) //GO(__wmemmove_chk, -//GOW(wmempcpy, +GOW(wmempcpy, pFppL) //GO(__wmempcpy_chk, GO(wmemset, pFpuL) //GOI(__wmemset_chk, |