diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-03-02 10:51:27 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-03-02 10:51:27 +0100 |
| commit | be92787329b59cf0f2202ca7623055372df0d90f (patch) | |
| tree | 0f446cd46ffe2299926d8ccc971d95dfaacd9b18 /src/libtools | |
| parent | 26201d7e705714cd8ecca3fa28f51e819f9eb520 (diff) | |
| download | box64-be92787329b59cf0f2202ca7623055372df0d90f.tar.gz box64-be92787329b59cf0f2202ca7623055372df0d90f.zip | |
Preparing auxval handling
Diffstat (limited to 'src/libtools')
| -rwxr-xr-x | src/libtools/auxval.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/libtools/auxval.c b/src/libtools/auxval.c new file mode 100755 index 00000000..a038f2dd --- /dev/null +++ b/src/libtools/auxval.c @@ -0,0 +1,59 @@ +#include <stdio.h> +#include <string.h> + +#include <stdlib.h> +#include <stdio.h> +#include <stdint.h> +#include <signal.h> +#include <errno.h> +#include <string.h> +#include <unistd.h> +#include <syscall.h> +#include <stddef.h> +#include <stdarg.h> +#include <fts.h> + +#include "box64context.h" +#include "debug.h" +//#include "x64emu.h" +//#include "emu/x64emu_private.h" +#include "box64stack.h" +#include "auxval.h" + +static uintptr_t* auxval_start = NULL; + +int init_auxval(int argc, const char **argv, const char **env) { + // auxval vector is after envs... + while(*env) + env++; + auxval_start = (uintptr_t*)(env+1); + return 0; +} + +#ifdef BUILD_LIB +__attribute__((section(".init_array"))) static void *init_auxval_constructor = &init_auxval; +#endif + +unsigned long real_getauxval(unsigned long type) +{ + if(!auxval_start) + return 0; + uintptr_t* p = auxval_start; + while(*p) { + if(*p == type) + return p[1]; + p+=2; + } + return 0; +} + +//EXPORT unsigned long my_getauxval(x64emu_t* emu, unsigned long type) +//{ +// uintptr_t* p = emu->context->auxval_start; +// while(*p) { +// if(*p == type) +// return p[1]; +// p+=2; +// } +// return 0; +//} \ No newline at end of file |