diff options
Diffstat (limited to 'src/wrapped')
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 5 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibctypes.h | 2 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibpthreadtypes.h | 2 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.c | 2 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.h | 1 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibc.c | 98 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibc_private.h | 2 | ||||
| -rw-r--r-- | src/wrapped/wrappedlibpthread_private.h | 2 |
8 files changed, 56 insertions, 58 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index be3f70e4..6c2ca8d8 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -164,6 +164,7 @@ #() cFpp #() wFpi #() iFEi +#() iFEL #() iFEp #() iFwp #() iFii @@ -3944,6 +3945,8 @@ wrappedlibc: - iFip: - fstat - fstat64 +- iFup: + - setrlimit - iFLp: - pthread_getattr_np - iFpi: @@ -4459,6 +4462,8 @@ wrappedlibpthread: - __pthread_register_cancel - __pthread_unregister_cancel - __pthread_unwind_next +- iFL: + - pthread_key_delete - iFp: - __pthread_mutexattr_destroy - __pthread_mutexattr_init diff --git a/src/wrapped/generated/wrappedlibctypes.h b/src/wrapped/generated/wrappedlibctypes.h index bd36a4b3..ff0c659e 100644 --- a/src/wrapped/generated/wrappedlibctypes.h +++ b/src/wrapped/generated/wrappedlibctypes.h @@ -25,6 +25,7 @@ typedef void (*vFpu_t)(void*, uint32_t); typedef void (*vFpp_t)(void*, void*); typedef void (*vFpV_t)(void*, ...); typedef int32_t (*iFip_t)(int32_t, void*); +typedef int32_t (*iFup_t)(uint32_t, void*); typedef int32_t (*iFLp_t)(uintptr_t, void*); typedef int32_t (*iFpi_t)(void*, int32_t); typedef int32_t (*iFpL_t)(void*, uintptr_t); @@ -147,6 +148,7 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void* GO(warnx, vFpV_t) \ GO(fstat, iFip_t) \ GO(fstat64, iFip_t) \ + GO(setrlimit, iFup_t) \ GO(pthread_getattr_np, iFLp_t) \ GO(__sigsetjmp, iFpi_t) \ GO(backtrace, iFpi_t) \ diff --git a/src/wrapped/generated/wrappedlibpthreadtypes.h b/src/wrapped/generated/wrappedlibpthreadtypes.h index 95c1c73e..ad0ad8e2 100644 --- a/src/wrapped/generated/wrappedlibpthreadtypes.h +++ b/src/wrapped/generated/wrappedlibpthreadtypes.h @@ -12,6 +12,7 @@ #endif typedef void (*vFp_t)(void*); +typedef int32_t (*iFL_t)(uintptr_t); typedef int32_t (*iFp_t)(void*); typedef void (*vFpi_t)(void*, int32_t); typedef int32_t (*iFLp_t)(uintptr_t, void*); @@ -30,6 +31,7 @@ typedef int32_t (*iFpppp_t)(void*, void*, void*, void*); GO(__pthread_register_cancel, vFp_t) \ GO(__pthread_unregister_cancel, vFp_t) \ GO(__pthread_unwind_next, vFp_t) \ + GO(pthread_key_delete, iFL_t) \ GO(__pthread_mutexattr_destroy, iFp_t) \ GO(__pthread_mutexattr_init, iFp_t) \ GO(pthread_attr_destroy, iFp_t) \ diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index 7253c4cd..57056891 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -200,6 +200,7 @@ typedef int8_t (*cFpi_t)(void*, int32_t); typedef int8_t (*cFpp_t)(void*, void*); typedef int16_t (*wFpi_t)(void*, int32_t); typedef int32_t (*iFEi_t)(x64emu_t*, int32_t); +typedef int32_t (*iFEL_t)(x64emu_t*, uintptr_t); typedef int32_t (*iFEp_t)(x64emu_t*, void*); typedef int32_t (*iFwp_t)(int16_t, void*); typedef int32_t (*iFii_t)(int32_t, int32_t); @@ -3151,6 +3152,7 @@ void cFpi(x64emu_t *emu, uintptr_t fcn) { cFpi_t fn = (cFpi_t)fcn; R_RAX=fn((voi void cFpp(x64emu_t *emu, uintptr_t fcn) { cFpp_t fn = (cFpp_t)fcn; R_RAX=fn((void*)R_RDI, (void*)R_RSI); } void wFpi(x64emu_t *emu, uintptr_t fcn) { wFpi_t fn = (wFpi_t)fcn; R_RAX=fn((void*)R_RDI, (int32_t)R_RSI); } void iFEi(x64emu_t *emu, uintptr_t fcn) { iFEi_t fn = (iFEi_t)fcn; R_RAX=(int32_t)fn(emu, (int32_t)R_RDI); } +void iFEL(x64emu_t *emu, uintptr_t fcn) { iFEL_t fn = (iFEL_t)fcn; R_RAX=(int32_t)fn(emu, (uintptr_t)R_RDI); } void iFEp(x64emu_t *emu, uintptr_t fcn) { iFEp_t fn = (iFEp_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI); } void iFwp(x64emu_t *emu, uintptr_t fcn) { iFwp_t fn = (iFwp_t)fcn; R_RAX=(int32_t)fn((int16_t)R_RDI, (void*)R_RSI); } void iFii(x64emu_t *emu, uintptr_t fcn) { iFii_t fn = (iFii_t)fcn; R_RAX=(int32_t)fn((int32_t)R_RDI, (int32_t)R_RSI); } diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index ba0ca026..20b01f0b 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -201,6 +201,7 @@ void cFpi(x64emu_t *emu, uintptr_t fnc); void cFpp(x64emu_t *emu, uintptr_t fnc); void wFpi(x64emu_t *emu, uintptr_t fnc); void iFEi(x64emu_t *emu, uintptr_t fnc); +void iFEL(x64emu_t *emu, uintptr_t fnc); void iFEp(x64emu_t *emu, uintptr_t fnc); void iFwp(x64emu_t *emu, uintptr_t fnc); void iFii(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 625ec087..06e68715 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -38,6 +38,7 @@ #include <syslog.h> #include <malloc.h> #include <getopt.h> +#include <sys/resource.h> #include <sys/prctl.h> #include <sys/ptrace.h> #undef LOG_INFO @@ -2454,28 +2455,6 @@ EXPORT void* my___deregister_frame_info(void* a) EXPORT void* my____brk_addr = NULL; -// longjmp / setjmp -typedef struct jump_buff_x64_s { - uint64_t save_rbx; - uint64_t save_rbp; - uint64_t save_r12; - uint64_t save_r13; - uint64_t save_r14; - uint64_t save_r15; - uint64_t save_rsp; - uint64_t save_rip; -} jump_buff_x64_t; - -typedef struct __jmp_buf_tag_s { - jump_buff_x64_t __jmpbuf; - int __mask_was_saved; - #ifdef ANDROID - sigset_t __saved_mask; - #else - __sigset_t __saved_mask; - #endif -} __jmp_buf_tag_t; - void EXPORT my_longjmp(x64emu_t* emu, /*struct __jmp_buf_tag __env[1]*/void *p, int32_t __val) { jump_buff_x64_t *jpbuff = &((__jmp_buf_tag_t*)p)->__jmpbuf; @@ -2627,46 +2606,46 @@ EXPORT void* my_mremap(x64emu_t* emu, void* old_addr, size_t old_size, size_t ne dynarec_log(LOG_DEBUG, "mremap(%p, %lu, %lu, %d, %p)=>", old_addr, old_size, new_size, flags, new_addr); void* ret = mremap(old_addr, old_size, new_size, flags, new_addr); dynarec_log(LOG_DEBUG, "%p\n", ret); - if(ret==(void*)-1) - return ret; // failed... - uint32_t prot = getProtection((uintptr_t)old_addr)&~PROT_CUSTOM; - if(ret==old_addr) { - if(old_size && old_size<new_size) { - setProtection_mmap((uintptr_t)ret+old_size, new_size-old_size, prot); - #ifdef DYNAREC - if(box64_dynarec) - addDBFromAddressRange((uintptr_t)ret+old_size, new_size-old_size); - #endif - } else if(old_size && new_size<old_size) { - freeProtection((uintptr_t)ret+new_size, old_size-new_size); - #ifdef DYNAREC - if(box64_dynarec) - cleanDBFromAddressRange((uintptr_t)ret+new_size, old_size-new_size, 1); + if(ret!=(void*)-1) { + uint32_t prot = getProtection((uintptr_t)old_addr)&~PROT_CUSTOM; + if(ret==old_addr) { + if(old_size && old_size<new_size) { + setProtection_mmap((uintptr_t)ret+old_size, new_size-old_size, prot); + #ifdef DYNAREC + if(box64_dynarec) + addDBFromAddressRange((uintptr_t)ret+old_size, new_size-old_size); + #endif + } else if(old_size && new_size<old_size) { + freeProtection((uintptr_t)ret+new_size, old_size-new_size); + #ifdef DYNAREC + if(box64_dynarec) + cleanDBFromAddressRange((uintptr_t)ret+new_size, old_size-new_size, 1); + #endif + } else if(!old_size) { + setProtection_mmap((uintptr_t)ret, new_size, prot); + #ifdef DYNAREC + if(box64_dynarec) + addDBFromAddressRange((uintptr_t)ret, new_size); + #endif + } + } else { + if(old_size + #ifdef MREMAP_DONTUNMAP + && ((flags&MREMAP_DONTUNMAP)==0) #endif - } else if(!old_size) { - setProtection_mmap((uintptr_t)ret, new_size, prot); + ) { + freeProtection((uintptr_t)old_addr, old_size); + #ifdef DYNAREC + if(box64_dynarec) + cleanDBFromAddressRange((uintptr_t)old_addr, old_size, 1); + #endif + } + setProtection_mmap((uintptr_t)ret, new_size, prot); // should copy the protection from old block #ifdef DYNAREC if(box64_dynarec) addDBFromAddressRange((uintptr_t)ret, new_size); #endif } - } else { - if(old_size - #ifdef MREMAP_DONTUNMAP - && ((flags&MREMAP_DONTUNMAP)==0) - #endif - ) { - freeProtection((uintptr_t)old_addr, old_size); - #ifdef DYNAREC - if(box64_dynarec) - cleanDBFromAddressRange((uintptr_t)old_addr, old_size, 1); - #endif - } - setProtection_mmap((uintptr_t)ret, new_size, prot); // should copy the protection from old block - #ifdef DYNAREC - if(box64_dynarec) - addDBFromAddressRange((uintptr_t)ret, new_size); - #endif } return ret; } @@ -2879,6 +2858,13 @@ EXPORT void* my_malloc(unsigned long size) return calloc(1, size); } +EXPORT int my_setrlimit(x64emu_t* emu, int ressource, const struct rlimit *rlim) +{ + int ret = (ressource==RLIMIT_AS)?0:setrlimit(ressource, rlim); + if(ressource==RLIMIT_AS) printf_log(LOG_DEBUG, " (ignored) RLIMIT_AS, cur=0x%lx, max=0x%lx ", rlim->rlim_cur, rlim->rlim_max); + return ret; +} + #if 0 #ifdef PANDORA #define RENAME_NOREPLACE (1 << 0) diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index ee855e42..f3568219 100644 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -1748,7 +1748,7 @@ GOW(setregid, iFuu) GOW(setresgid, iFuuu) GOW(setresuid, iFuuu) GOW(setreuid, iFuu) -GOW(setrlimit, iFup) +GOWM(setrlimit, iFEup) GOW(setrlimit64, iFup) GO(setrpcent, vFi) GO(setservent, vFi) diff --git a/src/wrapped/wrappedlibpthread_private.h b/src/wrapped/wrappedlibpthread_private.h index c0fd0557..ca356e39 100644 --- a/src/wrapped/wrappedlibpthread_private.h +++ b/src/wrapped/wrappedlibpthread_private.h @@ -135,7 +135,7 @@ GO(pthread_getname_np, iFppL) GO(pthread_join, iFLp) GOM(__pthread_key_create, iFEpp) GOM(pthread_key_create, iFEpp) -GO(pthread_key_delete, iFL) +GOM(pthread_key_delete, iFEL) GO2(pthread_kill@GLIBC_2.2.5, iFEpi, my_pthread_kill_old) GOM(pthread_kill, iFEpi) GO(pthread_kill_other_threads_np, vFv) |