diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-07-12 14:27:12 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-07-12 14:27:12 +0200 |
| commit | 2976bf5e6abda3f16ab86e29a2c6916a187d5612 (patch) | |
| tree | 7371975688b9e3ab305598bf58d228e7f2f27017 | |
| parent | b370540447780896d234d7ecbbf08e84c303b358 (diff) | |
| download | box64-2976bf5e6abda3f16ab86e29a2c6916a187d5612.tar.gz box64-2976bf5e6abda3f16ab86e29a2c6916a187d5612.zip | |
Added some more libc wrapped functions
| -rwxr-xr-x | src/dynarec/dynarec_arm64_functions.c | 2 | ||||
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 6 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibctypes.h | 2 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.c | 19 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.h | 7 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc.c | 9 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc_private.h | 31 |
7 files changed, 60 insertions, 16 deletions
diff --git a/src/dynarec/dynarec_arm64_functions.c b/src/dynarec/dynarec_arm64_functions.c index 9333d2b4..d2e4493e 100755 --- a/src/dynarec/dynarec_arm64_functions.c +++ b/src/dynarec/dynarec_arm64_functions.c @@ -326,7 +326,7 @@ int isNativeCall(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t* calladdress, int uintptr_t a1 = addr + 6 + (PK32(2)); // need to add a check to see if the address is from the GOT ! addr = *(uintptr_t*)a1; } - if(addr<0x10000) // too low, that is suspicious + if(addr<0x20000) // too low, that is suspicious return 0; onebridge_t *b = (onebridge_t*)(addr); if(b->CC==0xCC && b->S=='S' && b->C=='C' && b->w!=(wrapper_t)0 && b->f!=(uintptr_t)PltResolver) { diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index 970c6a35..e453eb35 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -291,6 +291,7 @@ #() iFuLL #() iFupL #() iFfff +#() iFlll #() iFLwp #() iFLip #() iFLLp @@ -785,6 +786,7 @@ #() iFipppi #() iFipppp #() iFuppLp +#() iFlppLp #() iFpiiii #() iFpiiiu #() iFpiiiL @@ -1387,9 +1389,11 @@ #!defined(HAVE_LD80BITS) KFK #!defined(HAVE_LD80BITS) KFKK #!defined(HAVE_LD80BITS) KFKp +#defined(NOALIGN) iFipiip #!defined(NOALIGN) iFEppu #!defined(NOALIGN) iFEiiip #!defined(NOALIGN) iFEipii +#!defined(NOALIGN) iFEipiip #() vFEv -> vFE #() lFEv -> lFE #() LFEv -> LFE @@ -1644,6 +1648,8 @@ wrappedlibc: - iFiippi: - __fxstatat - __fxstatat64 +- iFipiip: + - epoll_pwait - iFpilpV: - __sprintf_chk - iFpuppp: diff --git a/src/wrapped/generated/wrappedlibctypes.h b/src/wrapped/generated/wrappedlibctypes.h index 8d4d05bb..3ac1150d 100644 --- a/src/wrapped/generated/wrappedlibctypes.h +++ b/src/wrapped/generated/wrappedlibctypes.h @@ -55,6 +55,7 @@ typedef int64_t (*iFppiV_t)(void*, void*, int64_t, void*); typedef int64_t (*iFpppp_t)(void*, void*, void*, void*); typedef void (*vFpLLpp_t)(void*, uintptr_t, uintptr_t, void*, void*); typedef int64_t (*iFiippi_t)(int64_t, int64_t, void*, void*, int64_t); +typedef int64_t (*iFipiip_t)(int64_t, void*, int64_t, int64_t, void*); typedef int64_t (*iFpilpV_t)(void*, int64_t, intptr_t, void*, void*); typedef int64_t (*iFpuppp_t)(void*, uint64_t, void*, void*, void*); typedef void* (*pFpLLiN_t)(void*, uintptr_t, uintptr_t, int64_t, ...); @@ -170,6 +171,7 @@ typedef int64_t (*iFpippppp_t)(void*, int64_t, void*, void*, void*, void*, void* GO(qsort_r, vFpLLpp_t) \ GO(__fxstatat, iFiippi_t) \ GO(__fxstatat64, iFiippi_t) \ + GO(epoll_pwait, iFipiip_t) \ GO(__sprintf_chk, iFpilpV_t) \ GO(__vswprintf_chk, iFpuppp_t) \ GO(vswprintf, iFpuppp_t) \ diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index ab6b09ef..dfb685a0 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -325,6 +325,7 @@ typedef int64_t (*iFuff_t)(uint64_t, float, float); typedef int64_t (*iFuLL_t)(uint64_t, uintptr_t, uintptr_t); typedef int64_t (*iFupL_t)(uint64_t, void*, uintptr_t); typedef int64_t (*iFfff_t)(float, float, float); +typedef int64_t (*iFlll_t)(intptr_t, intptr_t, intptr_t); typedef int64_t (*iFLwp_t)(uintptr_t, int16_t, void*); typedef int64_t (*iFLip_t)(uintptr_t, int64_t, void*); typedef int64_t (*iFLLp_t)(uintptr_t, uintptr_t, void*); @@ -819,6 +820,7 @@ typedef int64_t (*iFippLp_t)(int64_t, void*, void*, uintptr_t, void*); typedef int64_t (*iFipppi_t)(int64_t, void*, void*, void*, int64_t); typedef int64_t (*iFipppp_t)(int64_t, void*, void*, void*, void*); typedef int64_t (*iFuppLp_t)(uint64_t, void*, void*, uintptr_t, void*); +typedef int64_t (*iFlppLp_t)(intptr_t, void*, void*, uintptr_t, void*); typedef int64_t (*iFpiiii_t)(void*, int64_t, int64_t, int64_t, int64_t); typedef int64_t (*iFpiiiu_t)(void*, int64_t, int64_t, int64_t, uint64_t); typedef int64_t (*iFpiiiL_t)(void*, int64_t, int64_t, int64_t, uintptr_t); @@ -1428,10 +1430,15 @@ typedef double (*KFKK_t)(double, double); typedef double (*KFKp_t)(double, void*); #endif +#if defined(NOALIGN) +typedef int64_t (*iFipiip_t)(int64_t, void*, int64_t, int64_t, void*); +#endif + #if !defined(NOALIGN) typedef int64_t (*iFEppu_t)(x64emu_t*, void*, void*, uint64_t); typedef int64_t (*iFEiiip_t)(x64emu_t*, int64_t, int64_t, int64_t, void*); typedef int64_t (*iFEipii_t)(x64emu_t*, int64_t, void*, int64_t, int64_t); +typedef int64_t (*iFEipiip_t)(x64emu_t*, int64_t, void*, int64_t, int64_t, void*); #endif void vFE(x64emu_t *emu, uintptr_t fcn) { vFE_t fn = (vFE_t)fcn; fn(emu); } @@ -1727,6 +1734,7 @@ void iFuff(x64emu_t *emu, uintptr_t fcn) { iFuff_t fn = (iFuff_t)fcn; R_RAX=(int void iFuLL(x64emu_t *emu, uintptr_t fcn) { iFuLL_t fn = (iFuLL_t)fcn; R_RAX=(int64_t)fn((uint64_t)R_RDI, (uintptr_t)R_RSI, (uintptr_t)R_RDX); } void iFupL(x64emu_t *emu, uintptr_t fcn) { iFupL_t fn = (iFupL_t)fcn; R_RAX=(int64_t)fn((uint64_t)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX); } void iFfff(x64emu_t *emu, uintptr_t fcn) { iFfff_t fn = (iFfff_t)fcn; R_RAX=(int64_t)fn(emu->xmm[0].f[0], emu->xmm[1].f[0], emu->xmm[2].f[0]); } +void iFlll(x64emu_t *emu, uintptr_t fcn) { iFlll_t fn = (iFlll_t)fcn; R_RAX=(int64_t)fn((intptr_t)R_RDI, (intptr_t)R_RSI, (intptr_t)R_RDX); } void iFLwp(x64emu_t *emu, uintptr_t fcn) { iFLwp_t fn = (iFLwp_t)fcn; R_RAX=(int64_t)fn((uintptr_t)R_RDI, (int16_t)R_RSI, (void*)R_RDX); } void iFLip(x64emu_t *emu, uintptr_t fcn) { iFLip_t fn = (iFLip_t)fcn; R_RAX=(int64_t)fn((uintptr_t)R_RDI, (int64_t)R_RSI, (void*)R_RDX); } void iFLLp(x64emu_t *emu, uintptr_t fcn) { iFLLp_t fn = (iFLLp_t)fcn; R_RAX=(int64_t)fn((uintptr_t)R_RDI, (uintptr_t)R_RSI, (void*)R_RDX); } @@ -2221,6 +2229,7 @@ void iFippLp(x64emu_t *emu, uintptr_t fcn) { iFippLp_t fn = (iFippLp_t)fcn; R_RA void iFipppi(x64emu_t *emu, uintptr_t fcn) { iFipppi_t fn = (iFipppi_t)fcn; R_RAX=(int64_t)fn((int64_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (int64_t)R_R8); } void iFipppp(x64emu_t *emu, uintptr_t fcn) { iFipppp_t fn = (iFipppp_t)fcn; R_RAX=(int64_t)fn((int64_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8); } void iFuppLp(x64emu_t *emu, uintptr_t fcn) { iFuppLp_t fn = (iFuppLp_t)fcn; R_RAX=(int64_t)fn((uint64_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX, (void*)R_R8); } +void iFlppLp(x64emu_t *emu, uintptr_t fcn) { iFlppLp_t fn = (iFlppLp_t)fcn; R_RAX=(int64_t)fn((intptr_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX, (void*)R_R8); } void iFpiiii(x64emu_t *emu, uintptr_t fcn) { iFpiiii_t fn = (iFpiiii_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (int64_t)R_R8); } void iFpiiiu(x64emu_t *emu, uintptr_t fcn) { iFpiiiu_t fn = (iFpiiiu_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (uint64_t)R_R8); } void iFpiiiL(x64emu_t *emu, uintptr_t fcn) { iFpiiiL_t fn = (iFpiiiL_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (uintptr_t)R_R8); } @@ -2830,10 +2839,15 @@ void KFKK(x64emu_t *emu, uintptr_t fcn) { KFKK_t fn = (KFKK_t)fcn; double db=fn( void KFKp(x64emu_t *emu, uintptr_t fcn) { KFKp_t fn = (KFKp_t)fcn; double db=fn(FromLD((void*)(R_RSP + 8)), (void*)R_RDI); fpu_do_push(emu); ST0val = db; } #endif +#if defined(NOALIGN) +void iFipiip(x64emu_t *emu, uintptr_t fcn) { iFipiip_t fn = (iFipiip_t)fcn; R_RAX=(int64_t)fn((int64_t)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (void*)R_R8); } +#endif + #if !defined(NOALIGN) void iFEppu(x64emu_t *emu, uintptr_t fcn) { iFEppu_t fn = (iFEppu_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uint64_t)R_RDX); } void iFEiiip(x64emu_t *emu, uintptr_t fcn) { iFEiiip_t fn = (iFEiiip_t)fcn; R_RAX=(int64_t)fn(emu, (int64_t)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (void*)R_RCX); } void iFEipii(x64emu_t *emu, uintptr_t fcn) { iFEipii_t fn = (iFEipii_t)fcn; R_RAX=(int64_t)fn(emu, (int64_t)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX); } +void iFEipiip(x64emu_t *emu, uintptr_t fcn) { iFEipiip_t fn = (iFEipiip_t)fcn; R_RAX=(int64_t)fn(emu, (int64_t)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (void*)R_R8); } #endif void vFEv(x64emu_t *emu, uintptr_t fcn) { vFE_t fn = (vFE_t)fcn; fn(emu); } @@ -3096,6 +3110,7 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &iFuLL) return 1; if (fun == &iFupL) return 1; if (fun == &iFfff) return 4; + if (fun == &iFlll) return 1; if (fun == &iFLwp) return 1; if (fun == &iFLip) return 1; if (fun == &iFLLp) return 1; @@ -3522,6 +3537,7 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &iFipppi) return 1; if (fun == &iFipppp) return 1; if (fun == &iFuppLp) return 1; + if (fun == &iFlppLp) return 1; if (fun == &iFpiiii) return 1; if (fun == &iFpiiiu) return 1; if (fun == &iFpiiiL) return 1; @@ -3776,5 +3792,8 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &vFuffiiffiip) return 5; if (fun == &vFuddiiddiip) return 5; if (fun == &vFppdddddddd) return 9; +#if defined(NOALIGN) + if (fun == &iFipiip) return 1; +#endif return 0; } diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index e8466e81..b70137b9 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -321,6 +321,7 @@ void iFuff(x64emu_t *emu, uintptr_t fnc); void iFuLL(x64emu_t *emu, uintptr_t fnc); void iFupL(x64emu_t *emu, uintptr_t fnc); void iFfff(x64emu_t *emu, uintptr_t fnc); +void iFlll(x64emu_t *emu, uintptr_t fnc); void iFLwp(x64emu_t *emu, uintptr_t fnc); void iFLip(x64emu_t *emu, uintptr_t fnc); void iFLLp(x64emu_t *emu, uintptr_t fnc); @@ -815,6 +816,7 @@ void iFippLp(x64emu_t *emu, uintptr_t fnc); void iFipppi(x64emu_t *emu, uintptr_t fnc); void iFipppp(x64emu_t *emu, uintptr_t fnc); void iFuppLp(x64emu_t *emu, uintptr_t fnc); +void iFlppLp(x64emu_t *emu, uintptr_t fnc); void iFpiiii(x64emu_t *emu, uintptr_t fnc); void iFpiiiu(x64emu_t *emu, uintptr_t fnc); void iFpiiiL(x64emu_t *emu, uintptr_t fnc); @@ -1424,10 +1426,15 @@ void KFKK(x64emu_t *emu, uintptr_t fnc); void KFKp(x64emu_t *emu, uintptr_t fnc); #endif +#if defined(NOALIGN) +void iFipiip(x64emu_t *emu, uintptr_t fnc); +#endif + #if !defined(NOALIGN) void iFEppu(x64emu_t *emu, uintptr_t fnc); void iFEiiip(x64emu_t *emu, uintptr_t fnc); void iFEipii(x64emu_t *emu, uintptr_t fnc); +void iFEipiip(x64emu_t *emu, uintptr_t fnc); #endif void vFEv(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index b3552cf7..a4488780 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -1485,6 +1485,15 @@ EXPORT int32_t my_epoll_wait(x64emu_t* emu, int32_t epfd, void* events, int32_t UnalignEpollEvent(events, _events, ret); return ret; } +EXPORT int32_t my_epoll_pwait(x64emu_t* emu, int32_t epfd, void* events, int32_t maxevents, int32_t timeout, const sigset_t *sigmask) +{ + struct epoll_event _events[maxevents]; + //AlignEpollEvent(_events, events, maxevents); + int32_t ret = epoll_pwait(epfd, events?_events:NULL, maxevents, timeout, sigmask); + if(ret>0) + UnalignEpollEvent(events, _events, ret); + return ret; +} #endif EXPORT int32_t my_glob64(x64emu_t *emu, void* pat, int32_t flags, void* errfnc, void* pglob) diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index 351581fc..6d090bb3 100755 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -6,13 +6,14 @@ // typedef unsigned long int nfds_t; // key_t is S32 // uid_t is u32 +// gid_t is u32 //GO(a64l, GO(abort, vFv) //DATAB(__abort_msg, //GO(abs, GO(accept, iFipp) -//GO(accept4, +GO(accept4, iFippi) GOW(access, iFpi) //GO(acct, GOW(addmntent, iFpp) @@ -260,11 +261,11 @@ GO(epoll_create, iFi) GO(epoll_create1, iFO) #ifdef NOALIGN GO(epoll_ctl, iFiiip) -//GO(epoll_pwait, +GO(epoll_pwait, iFipiip) GO(epoll_wait, iFipii) #else GOM(epoll_ctl, iFEiiip) // struct epoll_event is 12byte on x86_64 and 16bytes (8bytes aligned) on arm64 -//GO(epoll_pwait, +GOM(epoll_pwait, iFEipiip) GOM(epoll_wait, iFEipii) #endif GO(erand48, dFp) @@ -401,7 +402,7 @@ GO(fputws, iFpp) GO(fputws_unlocked, iFpp) GOW(fread, LFpLLp) GO(__freadable, iFp) -//GO(__fread_chk, +GO(__fread_chk, LFpLLLp) GO(__freading, iFp) GOW(fread_unlocked, LFpLLp) GO(__fread_unlocked_chk, LFpLLLp) @@ -510,10 +511,10 @@ GOW(geteuid, pFv) GOW(getgid, iFv) GO(getgrent, pFv) //GO(getgrent_r, -//GO(getgrgid, -//GO(getgrgid_r, -//GO(getgrnam, -//GO(getgrnam_r, +GO(getgrgid, pFl) +GO(getgrgid_r, iFlppLp) +GO(getgrnam, pFp) +GO(getgrnam_r, iFpppLp) //GO(getgrouplist, GOW(getgroups, iFip) //GO(__getgroups_chk, @@ -1003,7 +1004,7 @@ GO(killpg, iFii) //GO(l64a, //GO(labs, //GO(lchmod, -//GOW(lchown, +GOW(lchown, iFpuu) //GOW(lckpwdf, GO(lcong48, vFp) //GOW(lcong48_r, @@ -1070,7 +1071,7 @@ GOM(__libc_start_main, iFEpippppp) //GO(__libc_thread_freeres, GO(__libc_valloc, pFL) //GO(__libc_vfork, -//GOW(link, +GOW(link, iFpp) GO(linkat, iFipipi) GOW(listen, iFii) //GO(listxattr, @@ -1616,7 +1617,7 @@ GO(seteuid, iFu) //GO(setfsuid, GOW(setgid, iFp) //GO(setgrent, -//GO(setgroups, +GO(setgroups, iFip) GO(sethostent, vFi) //GO(sethostid, GO(sethostname, iFpL) @@ -1640,8 +1641,8 @@ GOW(setpriority, iFiii) GO(setprotoent, vFi) //GO(setpwent, //GOW(setregid, -//GOW(setresgid, -//GOW(setresuid, +GOW(setresgid, iFlll) +GOW(setresuid, iFuuu) GOW(setreuid, iFuu) GOW(setrlimit, iFip) GOW(setrlimit64, iFip) @@ -2001,8 +2002,8 @@ GOW(truncate, iFpl) GOW(truncate64, iFpI) //GO(__tsearch, //GOW(tsearch, -//GO(ttyname, -//GOW(ttyname_r, +GO(ttyname, pFi) +GOW(ttyname_r, iFipL) //GO(__ttyname_r_chk, //GO(ttyslot, //GO(__twalk, |