diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-06-05 15:03:37 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-06-05 15:03:37 +0200 |
| commit | 3bdcae10c8e0ed7b958137124585b0ff594a21fc (patch) | |
| tree | 03073bc8d2d4c27d446c16924122e1982573fd55 /src/wrapped/wrappedlibc.c | |
| parent | 681df1604dd27688fdcc07c7fd1640b3f1bd8a54 (diff) | |
| download | box64-3bdcae10c8e0ed7b958137124585b0ff594a21fc.tar.gz box64-3bdcae10c8e0ed7b958137124585b0ff594a21fc.zip | |
Added a few more wrapped function and improved getopt handling
Diffstat (limited to 'src/wrapped/wrappedlibc.c')
| -rwxr-xr-x | src/wrapped/wrappedlibc.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 3cd8a75b..270066ad 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -36,6 +36,7 @@ #include <spawn.h> #include <fts.h> #include <syslog.h> +#include <getopt.h> #undef LOG_INFO #undef LOG_DEBUG @@ -57,7 +58,7 @@ #include "auxval.h" #include "elfloader.h" #include "bridge.h" - +#include "globalsymbols.h" #define LIBNAME libc const char* libcName = "libc.so.6"; @@ -674,20 +675,12 @@ EXPORT int my___sprintf_chk(x64emu_t* emu, void* buff, int flag, size_t l, void return vsprintf(buff, (const char*)fmt, VARARGS); } -#if 0 -EXPORT int my_asprintf(x64emu_t* emu, void** buff, void * fmt, void * b, va_list V) { - #ifndef NOALIGN - // need to align on arm - myStackAlign((const char*)fmt, b, emu->scratch); +EXPORT int my_asprintf(x64emu_t* emu, void** buff, void * fmt, uint64_t * b) { + myStackAlign(emu, (const char*)fmt, b, emu->scratch, R_EAX, 2); PREPARE_VALIST; - void* f = vasprintf; - return ((iFppp_t)f)(buff, fmt, VARARGS); - #else - return vasprintf((char**)buff, (char*)fmt, V); - #endif + return vasprintf((char**)buff, (char*)fmt, VARARGS); } -EXPORT int my___asprintf(x64emu_t* emu, void** buff, void * fmt, void * b, va_list V) __attribute__((alias("my_asprintf"))); -#endif +EXPORT int my___asprintf(x64emu_t* emu, void** buff, void * fmt, uint64_t * b) __attribute__((alias("my_asprintf"))); EXPORT int my_vasprintf(x64emu_t* emu, char** buff, void* fmt, x64_va_list_t b) { (void)emu; @@ -2061,6 +2054,27 @@ EXPORT int my_mprotect(x64emu_t* emu, void *addr, unsigned long len, int prot) return ret; } +EXPORT int my_getopt(int argc, char* const argv[], const char *optstring) +{ + int ret = getopt(argc, argv, optstring); + my_checkGlobalOpt(); + return ret; +} + +EXPORT int my_getopt_long(int argc, char* const argv[], const char* optstring, const struct option *longopts, int *longindex) +{ + int ret = getopt_long(argc, argv, optstring, longopts, longindex); + my_checkGlobalOpt(); + return ret; +} + +EXPORT int my_getopt_long_only(int argc, char* const argv[], const char* optstring, const struct option *longopts, int *longindex) +{ + int ret = getopt_long_only(argc, argv, optstring, longopts, longindex); + my_checkGlobalOpt(); + return ret; +} + #if 0 typedef struct my_cookie_s { uintptr_t r, w, s, c; |