about summary refs log tree commit diff stats
path: root/src/libtools
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-03-02 10:51:27 +0100
committerptitSeb <sebastien.chev@gmail.com>2021-03-02 10:51:27 +0100
commitbe92787329b59cf0f2202ca7623055372df0d90f (patch)
tree0f446cd46ffe2299926d8ccc971d95dfaacd9b18 /src/libtools
parent26201d7e705714cd8ecca3fa28f51e819f9eb520 (diff)
downloadbox64-be92787329b59cf0f2202ca7623055372df0d90f.tar.gz
box64-be92787329b59cf0f2202ca7623055372df0d90f.zip
Preparing auxval handling
Diffstat (limited to 'src/libtools')
-rwxr-xr-xsrc/libtools/auxval.c59
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