diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-03-06 09:37:18 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-03-06 09:37:18 +0100 |
| commit | 75468d0c4c40c2ee2926c75d0ef0472cde982c23 (patch) | |
| tree | 353666c29e6b2e2ca4a055577b6ef69d8c299dab /src | |
| parent | 4978556ca924ae600750bcc41ce8be7095026bf9 (diff) | |
| download | box64-75468d0c4c40c2ee2926c75d0ef0472cde982c23.tar.gz box64-75468d0c4c40c2ee2926c75d0ef0472cde982c23.zip | |
More work on wrapped lib and elf relocations
Diffstat (limited to 'src')
| -rwxr-xr-x | src/elfs/elfloader.c | 2 | ||||
| -rwxr-xr-x | src/library_list.h | 4 | ||||
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 30 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.c | 72 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.h | 36 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc_private.h | 8 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibdl_private.h | 2 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibm.c | 92 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibm_private.h | 444 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibpthread_private.h | 6 |
10 files changed, 685 insertions, 11 deletions
diff --git a/src/elfs/elfloader.c b/src/elfs/elfloader.c index 2f48e15d..d34a1283 100755 --- a/src/elfs/elfloader.c +++ b/src/elfs/elfloader.c @@ -562,7 +562,7 @@ int RelocateElfRELA(lib_t *maplib, lib_t *local_maplib, elfheader_t* head, int c AddWeakSymbol(GetGlobalData(maplib), symname, offs, end-offs+1); } else { // Look for same symbol already loaded but not in self (so no need for local_maplib here) - if (GetGlobalNoWeakSymbolStartEnd(maplib, symname, &globoffs, &globend)) { + if (GetGlobalSymbolStartEnd(maplib, symname, &globoffs, &globend)) { offs = globoffs; end = globend; } diff --git a/src/library_list.h b/src/library_list.h index 3f1e5663..1edb1ca1 100755 --- a/src/library_list.h +++ b/src/library_list.h @@ -10,8 +10,8 @@ GO("librt.so.1", librt) //GO("libGLU.so.1", libglu) //GO("libX11.so.6", libx11) //GO("libasound.so.2", libasound) -//GO("libdl.so.2", libdl) -//GO("libm.so.6", libm) +GO("libdl.so.2", libdl) +GO("libm.so.6", libm) //GO("libSDL2-2.0.so.0", sdl2) //GO("libSDL2-2.0.so.1", sdl2) //GO("libSDL2.so", sdl2) diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index dc2c4ec6..f9ed2567 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -2,10 +2,18 @@ #() vFv #() vFp #() iFE +#() iFv #() iFi #() iFu +#() iFf +#() iFd #() iFp +#() IFf +#() IFd #() IFp +#() UFV +#() fFf +#() dFd #() dFp #() lFp #() LFv @@ -18,12 +26,28 @@ #() iFup #() iFLL #() iFLp +#() iFpi +#() fFif +#() fFfi +#() fFff +#() fFfp +#() dFid +#() dFdi +#() dFdd +#() dFdp #() pFEp #() pFLL +#() pFpV #() vFEpu +#() vFfpp +#() vFdpp #() iFEpp #() iFEpV #() iFpiu +#() fFfff +#() fFffp +#() dFddd +#() dFddp #() pFEpi #() pFEpp #() vFEpup @@ -36,5 +60,11 @@ #() iFEpppp #() iFipppi #() iFEpippppp +#defined(HAVE_LD80BITS) DFD +#defined(HAVE_LD80BITS) DFDD +#defined(HAVE_LD80BITS) DFDp +#!defined(HAVE_LD80BITS) KFK +#!defined(HAVE_LD80BITS) KFKK +#!defined(HAVE_LD80BITS) KFKp #() iFEv -> iFE #() pFEv -> pFE diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index 015fe604..0a0b5ce4 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -73,10 +73,18 @@ typedef void (*vFE_t)(x64emu_t*); typedef void (*vFv_t)(void); typedef void (*vFp_t)(void*); typedef int32_t (*iFE_t)(x64emu_t*); +typedef int32_t (*iFv_t)(void); typedef int32_t (*iFi_t)(int32_t); typedef int32_t (*iFu_t)(uint32_t); +typedef int32_t (*iFf_t)(float); +typedef int32_t (*iFd_t)(double); typedef int32_t (*iFp_t)(void*); +typedef int64_t (*IFf_t)(float); +typedef int64_t (*IFd_t)(double); typedef int64_t (*IFp_t)(void*); +typedef uint64_t (*UFV_t)(void*); +typedef float (*fFf_t)(float); +typedef double (*dFd_t)(double); typedef double (*dFp_t)(void*); typedef intptr_t (*lFp_t)(void*); typedef uintptr_t (*LFv_t)(void); @@ -89,12 +97,28 @@ typedef int32_t (*iFip_t)(int32_t, void*); typedef int32_t (*iFup_t)(uint32_t, void*); typedef int32_t (*iFLL_t)(uintptr_t, uintptr_t); typedef int32_t (*iFLp_t)(uintptr_t, void*); +typedef int32_t (*iFpi_t)(void*, int32_t); +typedef float (*fFif_t)(int32_t, float); +typedef float (*fFfi_t)(float, int32_t); +typedef float (*fFff_t)(float, float); +typedef float (*fFfp_t)(float, void*); +typedef double (*dFid_t)(int32_t, double); +typedef double (*dFdi_t)(double, int32_t); +typedef double (*dFdd_t)(double, double); +typedef double (*dFdp_t)(double, void*); typedef void* (*pFEp_t)(x64emu_t*, void*); typedef void* (*pFLL_t)(uintptr_t, uintptr_t); +typedef void* (*pFpV_t)(void*, void*); typedef void (*vFEpu_t)(x64emu_t*, void*, uint32_t); +typedef void (*vFfpp_t)(float, void*, void*); +typedef void (*vFdpp_t)(double, void*, void*); typedef int32_t (*iFEpp_t)(x64emu_t*, void*, void*); typedef int32_t (*iFEpV_t)(x64emu_t*, void*, void*); typedef int32_t (*iFpiu_t)(void*, int32_t, uint32_t); +typedef float (*fFfff_t)(float, float, float); +typedef float (*fFffp_t)(float, float, void*); +typedef double (*dFddd_t)(double, double, double); +typedef double (*dFddp_t)(double, double, void*); typedef void* (*pFEpi_t)(x64emu_t*, void*, int32_t); typedef void* (*pFEpp_t)(x64emu_t*, void*, void*); typedef void (*vFEpup_t)(x64emu_t*, void*, uint32_t, void*); @@ -108,14 +132,34 @@ typedef int32_t (*iFEpppp_t)(x64emu_t*, void*, void*, void*, void*); typedef int32_t (*iFipppi_t)(int32_t, void*, void*, void*, int32_t); typedef int32_t (*iFEpippppp_t)(x64emu_t*, void*, int32_t, void*, void*, void*, void*, void*); +#if defined(HAVE_LD80BITS) +typedef long double (*DFD_t)(long double); +typedef long double (*DFDD_t)(long double, long double); +typedef long double (*DFDp_t)(long double, void*); +#endif + +#if !defined(HAVE_LD80BITS) +typedef double (*KFK_t)(double); +typedef double (*KFKK_t)(double, double); +typedef double (*KFKp_t)(double, void*); +#endif + void vFE(x64emu_t *emu, uintptr_t fcn) { vFE_t fn = (vFE_t)fcn; fn(emu); } void vFv(x64emu_t *emu, uintptr_t fcn) { vFv_t fn = (vFv_t)fcn; fn(); } void vFp(x64emu_t *emu, uintptr_t fcn) { vFp_t fn = (vFp_t)fcn; fn((void*)R_RDI); } void iFE(x64emu_t *emu, uintptr_t fcn) { iFE_t fn = (iFE_t)fcn; R_RAX=fn(emu); } +void iFv(x64emu_t *emu, uintptr_t fcn) { iFv_t fn = (iFv_t)fcn; R_RAX=fn(); } void iFi(x64emu_t *emu, uintptr_t fcn) { iFi_t fn = (iFi_t)fcn; R_RAX=fn((int32_t)R_RDI); } void iFu(x64emu_t *emu, uintptr_t fcn) { iFu_t fn = (iFu_t)fcn; R_RAX=fn((uint32_t)R_RDI); } +void iFf(x64emu_t *emu, uintptr_t fcn) { iFf_t fn = (iFf_t)fcn; R_RAX=fn(emu->xmm[0].f[0]); } +void iFd(x64emu_t *emu, uintptr_t fcn) { iFd_t fn = (iFd_t)fcn; R_RAX=fn(emu->xmm[0].d[0]); } void iFp(x64emu_t *emu, uintptr_t fcn) { iFp_t fn = (iFp_t)fcn; R_RAX=fn((void*)R_RDI); } +void IFf(x64emu_t *emu, uintptr_t fcn) { IFf_t fn = (IFf_t)fcn; R_RAX=(uint64_t)fn(emu->xmm[0].f[0]); } +void IFd(x64emu_t *emu, uintptr_t fcn) { IFd_t fn = (IFd_t)fcn; R_RAX=(uint64_t)fn(emu->xmm[0].d[0]); } void IFp(x64emu_t *emu, uintptr_t fcn) { IFp_t fn = (IFp_t)fcn; R_RAX=(uint64_t)fn((void*)R_RDI); } +void UFV(x64emu_t *emu, uintptr_t fcn) { UFV_t fn = (UFV_t)fcn; R_RAX=fn((void*)(R_RSP + 8)); } +void fFf(x64emu_t *emu, uintptr_t fcn) { fFf_t fn = (fFf_t)fcn; emu->xmm[0].f[0]=fn(emu->xmm[0].f[0]); } +void dFd(x64emu_t *emu, uintptr_t fcn) { dFd_t fn = (dFd_t)fcn; emu->xmm[0].d[0]=fn(emu->xmm[0].d[0]); } void dFp(x64emu_t *emu, uintptr_t fcn) { dFp_t fn = (dFp_t)fcn; emu->xmm[0].d[0]=fn((void*)R_RDI); } void lFp(x64emu_t *emu, uintptr_t fcn) { lFp_t fn = (lFp_t)fcn; R_RAX=(intptr_t)fn((void*)R_RDI); } void LFv(x64emu_t *emu, uintptr_t fcn) { LFv_t fn = (LFv_t)fcn; R_RAX=(uintptr_t)fn(); } @@ -128,12 +172,28 @@ void iFip(x64emu_t *emu, uintptr_t fcn) { iFip_t fn = (iFip_t)fcn; R_RAX=fn((int void iFup(x64emu_t *emu, uintptr_t fcn) { iFup_t fn = (iFup_t)fcn; R_RAX=fn((uint32_t)R_RDI, (void*)R_RSI); } void iFLL(x64emu_t *emu, uintptr_t fcn) { iFLL_t fn = (iFLL_t)fcn; R_RAX=fn((uintptr_t)R_RDI, (uintptr_t)R_RSI); } void iFLp(x64emu_t *emu, uintptr_t fcn) { iFLp_t fn = (iFLp_t)fcn; R_RAX=fn((uintptr_t)R_RDI, (void*)R_RSI); } +void iFpi(x64emu_t *emu, uintptr_t fcn) { iFpi_t fn = (iFpi_t)fcn; R_RAX=fn((void*)R_RDI, (int32_t)R_RSI); } +void fFif(x64emu_t *emu, uintptr_t fcn) { fFif_t fn = (fFif_t)fcn; emu->xmm[0].f[0]=fn((int32_t)R_RDI, emu->xmm[0].f[0]); } +void fFfi(x64emu_t *emu, uintptr_t fcn) { fFfi_t fn = (fFfi_t)fcn; emu->xmm[0].f[0]=fn(emu->xmm[0].f[0], (int32_t)R_RDI); } +void fFff(x64emu_t *emu, uintptr_t fcn) { fFff_t fn = (fFff_t)fcn; emu->xmm[0].f[0]=fn(emu->xmm[0].f[0], emu->xmm[1].f[0]); } +void fFfp(x64emu_t *emu, uintptr_t fcn) { fFfp_t fn = (fFfp_t)fcn; emu->xmm[0].f[0]=fn(emu->xmm[0].f[0], (void*)R_RDI); } +void dFid(x64emu_t *emu, uintptr_t fcn) { dFid_t fn = (dFid_t)fcn; emu->xmm[0].d[0]=fn((int32_t)R_RDI, emu->xmm[0].d[0]); } +void dFdi(x64emu_t *emu, uintptr_t fcn) { dFdi_t fn = (dFdi_t)fcn; emu->xmm[0].d[0]=fn(emu->xmm[0].d[0], (int32_t)R_RDI); } +void dFdd(x64emu_t *emu, uintptr_t fcn) { dFdd_t fn = (dFdd_t)fcn; emu->xmm[0].d[0]=fn(emu->xmm[0].d[0], emu->xmm[1].d[0]); } +void dFdp(x64emu_t *emu, uintptr_t fcn) { dFdp_t fn = (dFdp_t)fcn; emu->xmm[0].d[0]=fn(emu->xmm[0].d[0], (void*)R_RDI); } void pFEp(x64emu_t *emu, uintptr_t fcn) { pFEp_t fn = (pFEp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI); } void pFLL(x64emu_t *emu, uintptr_t fcn) { pFLL_t fn = (pFLL_t)fcn; R_RAX=(uintptr_t)fn((uintptr_t)R_RDI, (uintptr_t)R_RSI); } +void pFpV(x64emu_t *emu, uintptr_t fcn) { pFpV_t fn = (pFpV_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)(R_RSP + 8)); } void vFEpu(x64emu_t *emu, uintptr_t fcn) { vFEpu_t fn = (vFEpu_t)fcn; fn(emu, (void*)R_RDI, (uint32_t)R_RSI); } +void vFfpp(x64emu_t *emu, uintptr_t fcn) { vFfpp_t fn = (vFfpp_t)fcn; fn(emu->xmm[0].f[0], (void*)R_RDI, (void*)R_RSI); } +void vFdpp(x64emu_t *emu, uintptr_t fcn) { vFdpp_t fn = (vFdpp_t)fcn; fn(emu->xmm[0].d[0], (void*)R_RDI, (void*)R_RSI); } void iFEpp(x64emu_t *emu, uintptr_t fcn) { iFEpp_t fn = (iFEpp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI); } void iFEpV(x64emu_t *emu, uintptr_t fcn) { iFEpV_t fn = (iFEpV_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)(R_RSP + 8)); } void iFpiu(x64emu_t *emu, uintptr_t fcn) { iFpiu_t fn = (iFpiu_t)fcn; R_RAX=fn((void*)R_RDI, (int32_t)R_RSI, (uint32_t)R_RDX); } +void fFfff(x64emu_t *emu, uintptr_t fcn) { fFfff_t fn = (fFfff_t)fcn; emu->xmm[0].f[0]=fn(emu->xmm[0].f[0], emu->xmm[1].f[0], emu->xmm[2].f[0]); } +void fFffp(x64emu_t *emu, uintptr_t fcn) { fFffp_t fn = (fFffp_t)fcn; emu->xmm[0].f[0]=fn(emu->xmm[0].f[0], emu->xmm[1].f[0], (void*)R_RDI); } +void dFddd(x64emu_t *emu, uintptr_t fcn) { dFddd_t fn = (dFddd_t)fcn; emu->xmm[0].d[0]=fn(emu->xmm[0].d[0], emu->xmm[1].d[0], emu->xmm[2].d[0]); } +void dFddp(x64emu_t *emu, uintptr_t fcn) { dFddp_t fn = (dFddp_t)fcn; emu->xmm[0].d[0]=fn(emu->xmm[0].d[0], emu->xmm[1].d[0], (void*)R_RDI); } void pFEpi(x64emu_t *emu, uintptr_t fcn) { pFEpi_t fn = (pFEpi_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (int32_t)R_RSI); } void pFEpp(x64emu_t *emu, uintptr_t fcn) { pFEpp_t fn = (pFEpp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI); } void vFEpup(x64emu_t *emu, uintptr_t fcn) { vFEpup_t fn = (vFEpup_t)fcn; fn(emu, (void*)R_RDI, (uint32_t)R_RSI, (void*)R_RDX); } @@ -147,5 +207,17 @@ void iFEpppp(x64emu_t *emu, uintptr_t fcn) { iFEpppp_t fn = (iFEpppp_t)fcn; R_RA void iFipppi(x64emu_t *emu, uintptr_t fcn) { iFipppi_t fn = (iFipppi_t)fcn; R_RAX=fn((int32_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (int32_t)R_R8); } void iFEpippppp(x64emu_t *emu, uintptr_t fcn) { iFEpippppp_t fn = (iFEpippppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); } +#if defined(HAVE_LD80BITS) +void DFD(x64emu_t *emu, uintptr_t fcn) { DFD_t fn = (DFD_t)fcn; long double ld=fn(*(long double*)(R_RSP + 8)); fpu_do_push(emu); ST0val = ld; } +void DFDD(x64emu_t *emu, uintptr_t fcn) { DFDD_t fn = (DFDD_t)fcn; long double ld=fn(*(long double*)(R_RSP + 8), *(long double*)(R_RSP + 24)); fpu_do_push(emu); ST0val = ld; } +void DFDp(x64emu_t *emu, uintptr_t fcn) { DFDp_t fn = (DFDp_t)fcn; long double ld=fn(*(long double*)(R_RSP + 8), (void*)R_RDI); fpu_do_push(emu); ST0val = ld; } +#endif + +#if !defined(HAVE_LD80BITS) +void KFK(x64emu_t *emu, uintptr_t fcn) { KFK_t fn = (KFK_t)fcn; double db=fn(FromLD((void*)(R_RSP + 8))); fpu_do_push(emu); ST0val = db; } +void KFKK(x64emu_t *emu, uintptr_t fcn) { KFKK_t fn = (KFKK_t)fcn; double db=fn(FromLD((void*)(R_RSP + 8)), FromLD((void*)(R_RSP + 24))); fpu_do_push(emu); ST0val = db; } +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 + 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); } diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index e7bb5765..00897837 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -34,10 +34,18 @@ void vFE(x64emu_t *emu, uintptr_t fnc); void vFv(x64emu_t *emu, uintptr_t fnc); void vFp(x64emu_t *emu, uintptr_t fnc); void iFE(x64emu_t *emu, uintptr_t fnc); +void iFv(x64emu_t *emu, uintptr_t fnc); void iFi(x64emu_t *emu, uintptr_t fnc); void iFu(x64emu_t *emu, uintptr_t fnc); +void iFf(x64emu_t *emu, uintptr_t fnc); +void iFd(x64emu_t *emu, uintptr_t fnc); void iFp(x64emu_t *emu, uintptr_t fnc); +void IFf(x64emu_t *emu, uintptr_t fnc); +void IFd(x64emu_t *emu, uintptr_t fnc); void IFp(x64emu_t *emu, uintptr_t fnc); +void UFV(x64emu_t *emu, uintptr_t fnc); +void fFf(x64emu_t *emu, uintptr_t fnc); +void dFd(x64emu_t *emu, uintptr_t fnc); void dFp(x64emu_t *emu, uintptr_t fnc); void lFp(x64emu_t *emu, uintptr_t fnc); void LFv(x64emu_t *emu, uintptr_t fnc); @@ -50,12 +58,28 @@ void iFip(x64emu_t *emu, uintptr_t fnc); void iFup(x64emu_t *emu, uintptr_t fnc); void iFLL(x64emu_t *emu, uintptr_t fnc); void iFLp(x64emu_t *emu, uintptr_t fnc); +void iFpi(x64emu_t *emu, uintptr_t fnc); +void fFif(x64emu_t *emu, uintptr_t fnc); +void fFfi(x64emu_t *emu, uintptr_t fnc); +void fFff(x64emu_t *emu, uintptr_t fnc); +void fFfp(x64emu_t *emu, uintptr_t fnc); +void dFid(x64emu_t *emu, uintptr_t fnc); +void dFdi(x64emu_t *emu, uintptr_t fnc); +void dFdd(x64emu_t *emu, uintptr_t fnc); +void dFdp(x64emu_t *emu, uintptr_t fnc); void pFEp(x64emu_t *emu, uintptr_t fnc); void pFLL(x64emu_t *emu, uintptr_t fnc); +void pFpV(x64emu_t *emu, uintptr_t fnc); void vFEpu(x64emu_t *emu, uintptr_t fnc); +void vFfpp(x64emu_t *emu, uintptr_t fnc); +void vFdpp(x64emu_t *emu, uintptr_t fnc); void iFEpp(x64emu_t *emu, uintptr_t fnc); void iFEpV(x64emu_t *emu, uintptr_t fnc); void iFpiu(x64emu_t *emu, uintptr_t fnc); +void fFfff(x64emu_t *emu, uintptr_t fnc); +void fFffp(x64emu_t *emu, uintptr_t fnc); +void dFddd(x64emu_t *emu, uintptr_t fnc); +void dFddp(x64emu_t *emu, uintptr_t fnc); void pFEpi(x64emu_t *emu, uintptr_t fnc); void pFEpp(x64emu_t *emu, uintptr_t fnc); void vFEpup(x64emu_t *emu, uintptr_t fnc); @@ -69,6 +93,18 @@ void iFEpppp(x64emu_t *emu, uintptr_t fnc); void iFipppi(x64emu_t *emu, uintptr_t fnc); void iFEpippppp(x64emu_t *emu, uintptr_t fnc); +#if defined(HAVE_LD80BITS) +void DFD(x64emu_t *emu, uintptr_t fnc); +void DFDD(x64emu_t *emu, uintptr_t fnc); +void DFDp(x64emu_t *emu, uintptr_t fnc); +#endif + +#if !defined(HAVE_LD80BITS) +void KFK(x64emu_t *emu, uintptr_t fnc); +void KFKK(x64emu_t *emu, uintptr_t fnc); +void KFKp(x64emu_t *emu, uintptr_t fnc); +#endif + void iFEv(x64emu_t *emu, uintptr_t fnc); void pFEv(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index b812a51d..14184df0 100755 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -1713,9 +1713,9 @@ GOM(__stack_chk_fail, vFE) //GOW(statvfs, //GOW(statvfs64, //GO(statx, -//DATA(stderr, -//DATA(stdin, -//DATA(stdout, +DATA(stderr, 8) +DATA(stdin, 8) +DATA(stdout, 8) //GOW(step, //GO(stime, //GO(__stpcpy_chk, @@ -1957,7 +1957,7 @@ GOM(syscall, iFEv) //GO(ttyslot, //GO(__twalk, //GOW(twalk, -DATA(__tzname, 4) +DATA(__tzname, 8) GOW(tzset, vFv) //GO(ualarm, //GO(__uflow, diff --git a/src/wrapped/wrappedlibdl_private.h b/src/wrapped/wrappedlibdl_private.h index 35a45d49..3e84b520 100755 --- a/src/wrapped/wrappedlibdl_private.h +++ b/src/wrapped/wrappedlibdl_private.h @@ -4,7 +4,7 @@ GOM(dladdr, iFEpp) // dladdr1 GOM(dlclose, iFEp) GOM(dlerror, pFE) -DATAB(_dlfcn_hook, 4) +DATAB(_dlfcn_hook, 8) GOM(dlinfo, iFEpip) GOM(dlmopen, pFEppi) GOM(dlopen, pFEpi) diff --git a/src/wrapped/wrappedlibm.c b/src/wrapped/wrappedlibm.c new file mode 100755 index 00000000..fdf9d3cc --- /dev/null +++ b/src/wrapped/wrappedlibm.c @@ -0,0 +1,92 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#define _GNU_SOURCE /* See feature_test_macros(7) */ +#include <dlfcn.h> +#include <complex.h> +#include <math.h> + +#include "wrappedlibs.h" + +#include "wrapper.h" +#include "bridge.h" +#include "librarian/library_private.h" +#include "x64emu.h" +#include "debug.h" + +const char* libmName = "libm.so.6"; +#define LIBNAME libm + +static library_t* my_lib = NULL; + +typedef float (*fFff_t) (float, float); +typedef double (*dFdd_t) (double, double); +typedef float (*fFf_t) (float); +typedef double (*dFd_t) (double); + +#undef GO_cFc + +#define FINITE(N, T, R, P, ...) \ +EXPORT R my___##N##_finite P \ +{ \ + static int check = 0; \ + T f = NULL; \ + if(!check) { \ + f = (T)dlsym(my_lib->priv.w.lib, "__" #N "_finite"); \ + ++check; \ + } \ + if(f) \ + return f(__VA_ARGS__); \ + else \ + return N (__VA_ARGS__); \ +} + +#define F1F(N) FINITE(N, fFf_t, float, (float a), a) +#define F1D(N) FINITE(N, dFd_t, double, (double a), a) +#define F2F(N) FINITE(N, fFff_t, float, (float a, float b), a, b) +#define F2D(N) FINITE(N, dFdd_t, double, (double a, double b), a, b) + +F2F(powf) +F2D(pow) +F1F(sinhf) +F1D(sinh) +F1F(sqrtf) +F1D(sqrt) +F1F(acosf) +F1D(acos) +F1F(acoshf) +F1D(acosh) +F1F(asinf) +F1D(asin) +F2F(atan2f) +F2D(atan2) +F1F(coshf) +F1D(cosh) +F1F(exp2f) +F1D(exp2) +F1F(expf) +F1D(exp) +F2F(hypotf) +F2D(hypot) +F1F(log10f) +F1D(log10) +F1F(log2f) +F1D(log2) +F1F(logf) +F1D(log) + +#undef F2D +#undef F2F +#undef F1D +#undef F1F +#undef FINITE + + +#define CUSTOM_INIT \ + my_lib = lib; + +#define CUSTOM_FINI \ + my_lib = NULL; + +#include "wrappedlib_init.h" + diff --git a/src/wrapped/wrappedlibm_private.h b/src/wrapped/wrappedlibm_private.h new file mode 100755 index 00000000..1ca89fd7 --- /dev/null +++ b/src/wrapped/wrappedlibm_private.h @@ -0,0 +1,444 @@ +#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)) +#error meh! +#endif + +GOW(acos, dFd) +GOW(acosf, fFf) +GOM(__acosf_finite, fFf) +GOM(__acos_finite, dFd) +GOW(acosh, dFd) +GOW(acoshf, fFf) +GOM(__acoshf_finite, fFf) +GOM(__acosh_finite, dFd) +#ifdef HAVE_LD80BITS +GOW(acoshl, DFD) +#else +GO2(acoshl, KFK, acosh) +#endif +#ifdef HAVE_LD80BITS +GOW(acpsl, DFD) +#else +GO2(acosl, KFK, acos) +#endif +GOW(asin, dFd) +GOW(asinf, fFf) +GOM(__asinf_finite, fFf) +GOM(__asin_finite, dFd) +GOW(asinh, dFd) +GOW(asinhf, fFf) +#ifdef HAVE_LD80BITS +GOW(asinhl, DFD) +#else +GO2(asinhl, KFK, asinh) +#endif +#ifdef HAVE_LD80BITS +GOW(asinl, DFD) +#else +GO2(asinl, KFK, asin) +#endif +GO(atan, dFd) +GOW(atan2, dFdd) +GOW(atan2f, fFff) +GOM(__atan2f_finite, fFff) +GOM(__atan2_finite, dFdd) +// atan2l // Weak +GOW(atanf, fFf) +GOW(atanh, dFd) +GOW(atanhf, fFf) +// __atanhf_finite +// __atanh_finite +#ifdef HAVE_LD80BITS +GOW(atanhl, DFD) +#else +GO2(atanhl, KFK, atanh) +#endif +// atanl // Weak +GOW(cabs, dFdd) // only 1 arg, but is a double complex +GOW(cabsf, fFff) // only 1 arg, but is a float complex +// cabsl // Weak +GOS(cacos, pFpV) // Weak, complex +GOM(cacosf, UFV) // Weak +GOS(cacosh, pFpV) // Weak, complex +GOM(cacoshf, UFV) // Weak +// cacoshl // Weak +// cacosl // Weak +GOW(carg, dFdd) // 1arg, double complex +GOW(cargf, fFff) // 1arg, float complex +// cargl // Weak +GOS(casin, pFpV) // Weak, complex +GOM(casinf, UFV) // Weak +GOS(casinh, pFpV) // Weak, complex +GOM(casinhf, UFV) // Weak +// casinhl // Weak +// casinl // Weak +GOS(catan, pFpV) // Weak, complex +GOM(catanf, UFV) // Weak +GOS(catanh, pFpV) // Weak, complex +GOM(catanhf, UFV) // Weak +// catanhl // Weak +// catanl // Weak +GOW(cbrt, dFd) +GOW(cbrtf, fFf) +#ifdef HAVE_LD80BITS +GOW(cbrtl, DFD) +#else +GO2(cbrtl, KFK, cbrt) +#endif +//GOS(ccos, pFpV) // Weak, return complex +//GOM(ccosf, UFV) // Weak, return complex +//GOS(ccosh, pFpV) // Weak, return complex +//GOM(ccoshf, UFV) // Weak, return complex +// ccoshl // Weak +// ccosl // Weak +//GOW(ceil, dFd) +//GOW(ceilf, fFf) +// ceill // Weak +//GOS(cexp, pFpV) // Weak, return complex +//GOM(cexpf, UFV) // Weak, return complex +// cexpl // Weak +// cimag // Weak +// cimagf // Weak +// cimagl // Weak +//GOS(clog, pFpV) // return a double complex, so ret 4 +// clog10 // Weak +// __clog10 +// clog10f // Weak +// __clog10f +// clog10l // Weak +// __clog10l +//GOM(clogf, UFV) // float complex doesn't trigger the ret 4, but return an u64! +// clogl // Weak +// conj // Weak +// conjf // Weak +// conjl // Weak +GOW(copysign, dFdd) +GOW(copysignf, fFff) +// copysignl // Weak +GOW(cos, dFd) +GOW(cosf, fFf) +GOW(cosh, dFd) +GOW(coshf, fFf) +GOM(__coshf_finite, fFf) +GOM(__cosh_finite, dFd) +// coshl // Weak +// cosl // Weak +//GOS(cpow, pFpVvvvvV) // Weak, return complex +//GOM(cpowf, UFVvvV) // Weak +// cpowl // Weak +//GOS(cproj, pFpV) // double complex +//GOM(cprojf, UFV) +// cprojl // Weak +// creal // Weak +// crealf // Weak +// creall // Weak +//GOS(csin, pFpV) // Weak, return complex +//GOM(csinf, UFV) // Weak, return complex +//GOS(csinh, pFpV) // Weak, return complex +//GOM(csinhf, UFV) // Weak, return complex +// csinhl // Weak +// csinl // Weak +//GOS(csqrt, pFpV) +//GOS(csqrtf, UFV) // Weak +// csqrtl // Weak +//GOS(ctan, pFpV) // Weak, return complex +//GOM(ctanf, UFV) // Weak, return complex +//GOS(ctanh, pFpV) // Weak, return complex +//GOM(ctanhf, UFV) // Weak, return complex +// ctanhl // Weak +// ctanl // Weak +// __cxa_finalize // Weak +// drem // Weak +// dremf // Weak +// dreml // Weak +GOW(erf, dFd) +GOW(erfc, dFd) +GOW(erfcf, fFf) +#ifdef HAVE_LD80BITS +GOW(erfcl, DFD) +#else +GO2(erfcl, KFK, erfc) +#endif +GOW(erff, fFf) +#ifdef HAVE_LD80BITS +GOW(erfl, DFD) +#else +GO2(erfl, KFK, erf) +#endif +GOW(exp, dFd) +GOW(exp10, dFd) +GOW(exp10f, fFf) +// __exp10f_finite +// __exp10_finite +// exp10l // Weak +GOW(exp2, dFd) +GOW(exp2f, fFf) +GOM(__exp2f_finite, fFf) +GOM(__exp2_finite, dFd) +// exp2l // Weak +GOW(expf, fFf) +GOM(__expf_finite, fFf) +GOM(__exp_finite, dFd) +// expl // Weak +GOW(expm1, dFd) +GOW(expm1f, fFf) +// expm1l // Weak +GOW(fabs, dFd) +GOW(fabsf, fFf) +// fabsl // Weak +// fdim // Weak +// fdimf // Weak +// fdiml // Weak +GO(feclearexcept, iFi) +GO(fedisableexcept, iFi) +GO(feenableexcept, iFi) +GO(fegetenv, iFp) +GO(fegetexcept, iFv) +GO(fegetexceptflag, iFpi) +GO(fegetround, iFv) +GO(feholdexcept, iFp) +GO(feraiseexcept, iFi) +GO(fesetenv, iFp) +GO(fesetexceptflag, iFpi) +GO(fesetround, iFi) +GO(fetestexcept, iFi) +GO(feupdateenv, iFp) +GOW(finite, iFd) +// __finite +GOW(finitef, iFf) +GO(__finitef, iFf) +// finitel // Weak +// __finitel +GOW(floor, dFd) +GOW(floorf, fFf) +// floorl // Weak +GOW(fma, dFddd) +GOW(fmaf, fFfff) +// fmal // Weak +GOW(fmax, dFdd) +GOW(fmaxf, fFff) +// fmaxl // Weak +GOW(fmin, dFdd) +GOW(fminf, fFff) +// fminl // Weak +GOW(fmod, dFdd) +GOW(fmodf, fFff) +// __fmodf_finite +// __fmod_finite +#ifdef HAVE_LD80BITS +GOW(fmodl, DFDD) +#else +GO2(fmodl, KFKK, fmod) +#endif +GO(__fpclassify, iFd) +GO(__fpclassifyf, iFf) +GOW(frexp, dFdp) +GOW(frexpf, fFfp) +#ifdef HAVE_LD80BITS +GOW(frexpl, DFDp) +#else +GO2(frexpl, KFKp, frexp) +#endif +// gamma // Weak +// gammaf // Weak +// __gammaf_r_finite +// gammal // Weak +// __gamma_r_finite +// __gmon_start__ // Weak +GOW(hypot, dFdd) +GOW(hypotf, fFff) +GOM(__hypotf_finite, fFff) +GOM(__hypot_finite, dFdd) +// hypotl // Weak +GOW(ilogb, iFd) +GOW(ilogbf, iFf) +// ilogbl // Weak +// __issignaling +// __issignalingf +// _ITM_deregisterTMCloneTable // Weak +// _ITM_registerTMCloneTable // Weak +GO(j0, dFd) +GO(j0f, fFf) +// __j0f_finite +// __j0_finite +// j0l +GO(j1, dFd) +GO(j1f, fFf) +// __j1f_finite +// __j1_finite +// j1l +GO(jn, dFid) +GO(jnf, fFif) +// __jnf_finite +// __jn_finite +// jnl +GOW(ldexp, dFdi) +GOW(ldexpf, fFfi) +#ifdef HAVE_LD80BITS +GOW(ldexpl, DFD) +#else +GO2(ldexpl, KFK, ldexp) +#endif +GOW(lgamma, dFd) +GOW(lgammaf, fFf) +GOW(lgammaf_r, fFfp) +// __lgammaf_r_finite +#ifdef HAVE_LD80BITS +GOW(lgammal, DFD) +#else +GO2(lgammal, KFK, lgamma) +#endif +#ifdef HAVE_LD80BITS +GOW(lgammal_r, DFDp) +#else +GO2(lgammal_r, KFKp, lgamma_r) +#endif +GOW(lgamma_r, dFdp) +// __lgamma_r_finite +DATAV(_LIB_VERSION, 8) +GOW(llrint, IFd) +GOW(llrintf, IFf) +// llrintl // Weak +GOW(llround, IFd) +GOW(llroundf, IFf) +// llroundl // Weak +GOW(log, dFd) +GOW(log10, dFd) +GOW(log10f, fFf) +GOM(__log10f_finite, fFf) +GOM(__log10_finite, dFd) +// log10l // Weak +GOW(log1p, dFd) +GOW(log1pf, fFf) +// log1pl // Weak +GOW(log2, dFd) +GOW(log2f, fFf) +GOM(__log2f_finite, fFf) +GOM(__log2_finite, dFd) +// log2l // Weak +GOW(logb, dFd) +GOW(logbf, fFf) +// logbl // Weak +GOW(logf, fFf) +GOM(__logf_finite, fFf) +GOM(__log_finite, dFd) +#ifdef HAVE_LD80BITS +GOW(logl, DFD) +#else +GO2(logl, KFK, log) +#endif +GOW(lrint, iFd) +GOW(lrintf, iFf) +// lrintl // Weak +GOW(lround, iFd) +GOW(lroundf, iFf) +// lroundl // Weak +// matherr // Weak +GOW(modf, dFdp) +GOW(modff, fFfp) +// modfl // Weak +// nan // Weak +// nanf // Weak +// nanl // Weak +GOW(nearbyint, dFd) +GOW(nearbyintf, fFf) +// nearbyintl // Weak +GOW(nextafter, dFdd) +GOW(nextafterf, fFff) +// nextafterl // Weak +GOW(nexttoward, dFdd) +GOW(nexttowardf, fFff) +// nexttowardl // Weak +GOW(pow, dFdd) +GOW(pow10, dFd) +GOW(pow10f, fFf) +#ifdef HAVE_LD80BITS +GOW(pow10l, DFD) +#else +GOW(pow10l, KFK) +#endif +GOW(powf, fFff) +GOM(__powf_finite, fFff) +GOM(__pow_finite, dFdd) +#ifdef HAVE_LD80BITS +GOW(powl, DFDD) +#else +GO2(powl, KFKK, pow) +#endif +GOW(remainder, dFdd) +GOW(remainderf, fFff) +// __remainderf_finite +// __remainder_finite +// remainderl // Weak +GOW(remquo, dFddp) +GOW(remquof, fFffp) +// remquol // Weak +GOW(rint, dFd) +GOW(rintf, fFf) +// rintl // Weak +GOW(round, dFd) +GOW(roundf, fFf) +// roundl // Weak +// scalb // Weak +// scalbf // Weak +// __scalbf_finite +// __scalb_finite +// scalbl // Weak +GOW(scalbln, dFdi) +GOW(scalblnf, fFfi) +// scalblnl // Weak +GOW(scalbn, dFdi) +GOW(scalbnf, fFfi) +// scalbnl // Weak +// __signbit +// __signbitf +DATAB(signgam, 8) +// significand // Weak +// significandf // Weak +// significandl // Weak +GOW(sin, dFd) +GOW(sincos, vFdpp) +GOW(sincosf, vFfpp) +// sincosl // Weak +GOW(sinf, fFf) +GOW(sinh, dFd) +GOW(sinhf, fFf) +GOM(__sinhf_finite, fFf) +GOM(__sinh_finite, dFd) +// sinhl // Weak +// sinl // Weak +GOW(sqrt, dFd) +GOW(sqrtf, fFf) +GOM(__sqrtf_finite, fFf) +GOM(__sqrt_finite, dFd) +// sqrtl // Weak +GO(tan, dFd) +GOW(tanf, fFf) +GOW(tanh, dFd) +GOW(tanhf, fFf) +// tanhl // Weak +// tanl // Weak +GOW(tgamma, dFd) +GOW(tgammaf, fFf) +#ifdef HAVE_LD80BITS +GOW(tgammal, DFD) +#else +GO2(tgammal, KFK, tgamma) +#endif +GOW(trunc, dFd) +GOW(truncf, fFf) +// truncl // Weak +GO(y0, dFd) +GO(y0f, fFf) +// __y0f_finite +// __y0_finite +// y0l +GO(y1, dFd) +GO(y1f, fFf) +// __y1f_finite +// __y1_finite +// y1l +GO(yn, dFid) +GO(ynf, fFif) +// __ynf_finite +// __yn_finite +// ynl diff --git a/src/wrapped/wrappedlibpthread_private.h b/src/wrapped/wrappedlibpthread_private.h index 4ec52dc4..fcace575 100755 --- a/src/wrapped/wrappedlibpthread_private.h +++ b/src/wrapped/wrappedlibpthread_private.h @@ -78,9 +78,9 @@ GO(pthread_equal, iFLL) //GOM(__pthread_initialize, vFv) // doesn't exist anymore... // __pthread_initialize_minimal GO(pthread_join, iFLp) -//GOM(__pthread_key_create, iFEpp) -//GOM(pthread_key_create, iFEpp) -//GO(pthread_key_delete, iFu) +GOM(__pthread_key_create, iFEpp) +GOM(pthread_key_create, iFEpp) +GO(pthread_key_delete, iFu) //GO(pthread_kill, iFEpi) // pthread_kill_other_threads_np //GO(__pthread_mutexattr_destroy, iFp) |