From 252d95124ea414bbca2c9ca851a9fbc3d576e475 Mon Sep 17 00:00:00 2001 From: Yang Liu Date: Mon, 17 Jun 2024 23:34:19 +0800 Subject: [PATCH] Fixed some symbols not found error for libc and libresolv wrapping --- src/wrapped/generated/functions_list.txt | 8 ++++++-- src/wrapped/generated/wrappedlibctypes.h | 4 ++++ src/wrapped/generated/wrapper.c | 10 ++++------ src/wrapped/generated/wrapper.h | 4 ++-- src/wrapped/wrappedlibc.c | 14 ++++++++++++++ src/wrapped/wrappedlibc_private.h | 4 ++-- src/wrapped/wrappedlibresolv_private.h | 6 +++--- 7 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index 33537cb65..2c44ef887 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -3062,9 +3062,9 @@ #!defined(NOALIGN) iFEipiip #!defined(STATICBUILD) iFlip #!defined(STATICBUILD) iFLLi -#!defined(STATICBUILD) iFipup #!defined(STATICBUILD) iFLLiW -#!defined(STATICBUILD) iFiipup +#!defined(STATICBUILD) iFEipup +#!defined(STATICBUILD) iFEiipup #!defined(STATICBUILD) iFpipppL #() vFEv -> vFE #() iFEv -> iFE @@ -4262,6 +4262,8 @@ wrappedlibc: - __vdprintf_chk - iFipii: - epoll_wait +- iFipup: + - __xmknod - iFippi: - fstatat - fstatat64 @@ -4298,6 +4300,8 @@ wrappedlibc: - ptrace - vFpLLpp: - qsort_r +- iFiipup: + - __xmknodat - iFiippi: - __fxstatat - __fxstatat64 diff --git a/src/wrapped/generated/wrappedlibctypes.h b/src/wrapped/generated/wrappedlibctypes.h index 098ed02d8..a9b5dbb1e 100644 --- a/src/wrapped/generated/wrappedlibctypes.h +++ b/src/wrapped/generated/wrappedlibctypes.h @@ -67,6 +67,7 @@ typedef int32_t (*iFiiiN_t)(int32_t, int32_t, int32_t, ...); typedef int32_t (*iFiipV_t)(int32_t, int32_t, void*, ...); typedef int32_t (*iFiipA_t)(int32_t, int32_t, void*, va_list); typedef int32_t (*iFipii_t)(int32_t, void*, int32_t, int32_t); +typedef int32_t (*iFipup_t)(int32_t, void*, uint32_t, void*); typedef int32_t (*iFippi_t)(int32_t, void*, void*, int32_t); typedef int32_t (*iFippL_t)(int32_t, void*, void*, uintptr_t); typedef int32_t (*iFpipp_t)(void*, int32_t, void*, void*); @@ -79,6 +80,7 @@ typedef int32_t (*iFppiV_t)(void*, void*, int32_t, ...); typedef int32_t (*iFpppp_t)(void*, void*, void*, void*); typedef intptr_t (*lFuipp_t)(uint32_t, int32_t, void*, void*); typedef void (*vFpLLpp_t)(void*, uintptr_t, uintptr_t, void*, void*); +typedef int32_t (*iFiipup_t)(int32_t, int32_t, void*, uint32_t, void*); typedef int32_t (*iFiippi_t)(int32_t, int32_t, void*, void*, int32_t); typedef int32_t (*iFiLLLL_t)(int32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); typedef int32_t (*iFipiip_t)(int32_t, void*, int32_t, int32_t, void*); @@ -247,6 +249,7 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void* GO(__dprintf_chk, iFiipV_t) \ GO(__vdprintf_chk, iFiipA_t) \ GO(epoll_wait, iFipii_t) \ + GO(__xmknod, iFipup_t) \ GO(fstatat, iFippi_t) \ GO(fstatat64, iFippi_t) \ GO(readlinkat, iFippL_t) \ @@ -271,6 +274,7 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void* GO(scandir64, iFpppp_t) \ GO(ptrace, lFuipp_t) \ GO(qsort_r, vFpLLpp_t) \ + GO(__xmknodat, iFiipup_t) \ GO(__fxstatat, iFiippi_t) \ GO(__fxstatat64, iFiippi_t) \ GO(prctl, iFiLLLL_t) \ diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index e97e08c31..efd489149 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -3114,9 +3114,9 @@ typedef int32_t (*iFEipiip_t)(x64emu_t*, int32_t, void*, int32_t, int32_t, void* #if !defined(STATICBUILD) typedef int32_t (*iFlip_t)(intptr_t, int32_t, void*); typedef int32_t (*iFLLi_t)(uintptr_t, uintptr_t, int32_t); -typedef int32_t (*iFipup_t)(int32_t, void*, uint32_t, void*); typedef int32_t (*iFLLiW_t)(uintptr_t, uintptr_t, int32_t, uint16_t); -typedef int32_t (*iFiipup_t)(int32_t, int32_t, void*, uint32_t, void*); +typedef int32_t (*iFEipup_t)(x64emu_t*, int32_t, void*, uint32_t, void*); +typedef int32_t (*iFEiipup_t)(x64emu_t*, int32_t, int32_t, void*, uint32_t, void*); typedef int32_t (*iFpipppL_t)(void*, int32_t, void*, void*, void*, uintptr_t); #endif @@ -6198,9 +6198,9 @@ void iFEipiip(x64emu_t *emu, uintptr_t fcn) { iFEipiip_t fn = (iFEipiip_t)fcn; R #if !defined(STATICBUILD) void iFlip(x64emu_t *emu, uintptr_t fcn) { iFlip_t fn = (iFlip_t)fcn; R_RAX=(int32_t)fn((intptr_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX); } void iFLLi(x64emu_t *emu, uintptr_t fcn) { iFLLi_t fn = (iFLLi_t)fcn; R_RAX=(int32_t)fn((uintptr_t)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX); } -void iFipup(x64emu_t *emu, uintptr_t fcn) { iFipup_t fn = (iFipup_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (void*)R_RSI, (uint32_t)R_RDX, (void*)R_RCX); } void iFLLiW(x64emu_t *emu, uintptr_t fcn) { iFLLiW_t fn = (iFLLiW_t)fcn; R_RAX=(int32_t)fn((uintptr_t)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX, (uint16_t)R_RCX); } -void iFiipup(x64emu_t *emu, uintptr_t fcn) { iFiipup_t fn = (iFiipup_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (uint32_t)R_RCX, (void*)R_R8); } +void iFEipup(x64emu_t *emu, uintptr_t fcn) { iFEipup_t fn = (iFEipup_t)fcn; R_RAX=(int32_t)fn(emu, (int32_t)R_RDI, (void*)R_RSI, (uint32_t)R_RDX, (void*)R_RCX); } +void iFEiipup(x64emu_t *emu, uintptr_t fcn) { iFEiipup_t fn = (iFEiipup_t)fcn; R_RAX=(int32_t)fn(emu, (int32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (uint32_t)R_RCX, (void*)R_R8); } void iFpipppL(x64emu_t *emu, uintptr_t fcn) { iFpipppL_t fn = (iFpipppL_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (uintptr_t)R_R9); } #endif @@ -8040,9 +8040,7 @@ int isSimpleWrapper(wrapper_t fun) { #if !defined(STATICBUILD) if (fun == &iFlip) return 1; if (fun == &iFLLi) return 1; - if (fun == &iFipup) return 1; if (fun == &iFLLiW) return 1; - if (fun == &iFiipup) return 1; if (fun == &iFpipppL) return 1; #endif return 0; diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index 76937d358..a26ea7c3f 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -3114,9 +3114,9 @@ void iFEipiip(x64emu_t *emu, uintptr_t fnc); #if !defined(STATICBUILD) void iFlip(x64emu_t *emu, uintptr_t fnc); void iFLLi(x64emu_t *emu, uintptr_t fnc); -void iFipup(x64emu_t *emu, uintptr_t fnc); void iFLLiW(x64emu_t *emu, uintptr_t fnc); -void iFiipup(x64emu_t *emu, uintptr_t fnc); +void iFEipup(x64emu_t *emu, uintptr_t fnc); +void iFEiipup(x64emu_t *emu, uintptr_t fnc); void iFpipppL(x64emu_t *emu, uintptr_t fnc); #endif diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 299c0f58b..f0e51241b 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -1209,6 +1209,20 @@ EXPORT int my___fxstat64(x64emu_t *emu, int vers, int fd, void* buf) return r; } +EXPORT int my___xmknod(x64emu_t* emu, int v, char* path, uint32_t mode, dev_t* dev) +{ + (void)emu; + (void)v; + return mknod((const char*)path, mode, *dev); +} + +EXPORT int my___xmknodat(x64emu_t* emu, int v, int dirfd, char* path, uint32_t mode, dev_t* dev) +{ + (void)emu; + (void)v; + return mknodat(dirfd, (const char*)path, mode, *dev); +} + EXPORT int my___xstat(x64emu_t* emu, int v, void* path, void* buf) { (void)emu; (void)v; diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index 4244c943c..52eebf0a7 100644 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -2409,8 +2409,8 @@ GO(xdr_void, iFv) //GO(__xmknod, iFipup) //GO(__xmknodat, iFiipup) #else -GO(__xmknod, iFipup) -GO(__xmknodat, iFiipup) +GOM(__xmknod, iFEipup) +GOM(__xmknodat, iFEiipup) #endif GO(__xpg_basename, pFp) GOW(__xpg_sigpause, iFi) diff --git a/src/wrapped/wrappedlibresolv_private.h b/src/wrapped/wrappedlibresolv_private.h index 1d73f4fee..28279f3a4 100644 --- a/src/wrapped/wrappedlibresolv_private.h +++ b/src/wrapped/wrappedlibresolv_private.h @@ -92,11 +92,11 @@ GO(__res_nsearch, iFppiipi) //DATA(_res_opcodes, 4) GO(__res_ownok, iFp) GO(__res_queriesmatch, iFpppp) -GO(__res_query, iFpiipi) +GO2(__res_query, iFpiipi, res_query) GOW(res_query, iFpiipi) -GO(__res_querydomain, iFppiipi) +GO2(__res_querydomain, iFppiipi, res_querydomain) GOW(res_querydomain, iFppiipi) -GO(__res_search, iFpiipi) +GO2(__res_search, iFpiipi, res_search) GOW(res_search, iFpiipi) GO(__res_send, iFpipi) //GO(res_send_setqhook