blob: 1e4b60454b4b18b113ea077995cddc87ebc9a4b0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#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, char **env) {
(void)argc; (void)argv;
// 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;
}
#ifdef BOX32
EXPORT unsigned long my32_getauxval(x64emu_t* emu, unsigned long type)
{
ptr_t* p = (ptr_t*)emu->context->auxval_start;
while(*p) {
if(*p == type)
return p[1];
p+=2;
}
return 0;
}
#endif
EXPORT unsigned long my_getauxval(x64emu_t* emu, unsigned long type)
{
#ifdef BOX32
if(box64_is32bits)
return my32_getauxval(emu, type);
#endif
uintptr_t* p = emu->context->auxval_start;
while(*p) {
if(*p == type)
return p[1];
p+=2;
}
return 0;
}
|