mirror of
https://github.com/ptitSeb/box64.git
synced 2024-11-24 06:59:53 +00:00
Preparing auxval handling
This commit is contained in:
parent
26201d7e70
commit
be92787329
@ -103,6 +103,7 @@ set(ELFLOADER_SRC
|
||||
"${BOX64_ROOT}/src/elfs/elfloader.c"
|
||||
"${BOX64_ROOT}/src/elfs/elfparser.c"
|
||||
"${BOX64_ROOT}/src/elfs/elfload_dump.c"
|
||||
"${BOX64_ROOT}/src/libtools/auxval.c"
|
||||
"${BOX64_ROOT}/src/tools/box64stack.c"
|
||||
"${BOX64_ROOT}/src/tools/pathcoll.c"
|
||||
"${BOX64_ROOT}/src/tools/fileutils.c"
|
||||
|
13
src/include/auxval.h
Executable file
13
src/include/auxval.h
Executable file
@ -0,0 +1,13 @@
|
||||
#ifndef __AUXVAL_H__
|
||||
#define __AUXVAL_H__
|
||||
|
||||
typedef struct x64emu_s x64emu_t;
|
||||
|
||||
#ifndef BUILD_LIB
|
||||
int init_auxval(int argc, const char **argv, const char **env);
|
||||
#endif
|
||||
|
||||
unsigned long real_getauxval(unsigned long type);
|
||||
//unsigned long my_getauxval(x64emu_t* emu, unsigned long type);
|
||||
|
||||
#endif //__AUXVAL_H__
|
59
src/libtools/auxval.c
Executable file
59
src/libtools/auxval.c
Executable file
@ -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;
|
||||
//}
|
@ -17,6 +17,7 @@
|
||||
#include "elfloader.h"
|
||||
#include "custommem.h"
|
||||
#include "box64stack.h"
|
||||
#include "auxval.h"
|
||||
|
||||
box64context_t *my_context = NULL;
|
||||
int box64_log = LOG_NONE;
|
||||
@ -524,7 +525,7 @@ static void free_contextargv()
|
||||
const char **environ __attribute__((weak)) = NULL;
|
||||
int main(int argc, const char **argv, const char **env) {
|
||||
|
||||
//init_auxval(argc, argv, environ?environ:env);
|
||||
init_auxval(argc, argv, environ?environ:env);
|
||||
// trying to open and load 1st arg
|
||||
if(argc==1) {
|
||||
PrintBox64Version();
|
||||
|
Loading…
Reference in New Issue
Block a user