Skip to content

Commit 14b660e

Browse files
committed
[BOX32]Improve auxval handling
1 parent 87d74eb commit 14b660e

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/tools/box32stack.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "box64stack.h"
88
#include "box64context.h"
99
#include "elfloader.h"
10+
#include "elfs/elfloader_private.h"
1011
#include "debug.h"
1112
#include "emu/x64emu_private.h"
1213
#include "auxval.h"
@@ -94,19 +95,21 @@ void SetupInitialStack32(x64emu_t *emu)
9495
32: f7fbfb40
9596
33: f7fbf000
9697
*/
98+
elfheader_t* main = my_context->elfs[0];
9799
Push32_32(emu, 0); Push32_32(emu, 0); //AT_NULL(0)=0
98-
//Push32_32(emu, ); Push32_32(emu, 3); //AT_PHDR(3)=address of the PH of the executable
99-
//Push32_32(emu, ); Push32_32(emu, 4); //AT_PHENT(4)=size of PH entry
100-
//Push32_32(emu, ); Push32_32(emu, 5); //AT_PHNUM(5)=number of elf headers
101-
Push32_32(emu, box64_pagesize); Push32_32(emu, 6); //AT_PAGESZ(6)
102-
//Push32_32(emu, real_getauxval(7)); Push32_32(emu, 7); //AT_BASE(7)=ld-2.27.so start (in memory)
103-
Push32_32(emu, 0); Push32_32(emu, 8); //AT_FLAGS(8)=0
104-
Push32_32(emu, R_EIP); Push32_32(emu, 9); //AT_ENTRY(9)=entrypoint
105-
Push32_32(emu, from_ulong(real_getauxval(11))); Push32_32(emu, 11); //AT_UID(11)
106-
Push32_32(emu, from_ulong(real_getauxval(12))); Push32_32(emu, 12); //AT_EUID(12)
107-
Push32_32(emu, from_ulong(real_getauxval(13))); Push32_32(emu, 13); //AT_GID(13)
108-
Push32_32(emu, from_ulong(real_getauxval(14))); Push32_32(emu, 14); //AT_EGID(14)
109-
Push32_32(emu, p_i686); Push32_32(emu, 15); //AT_PLATFORM(15)=&"i686"
100+
Push32_32(emu, main->fileno); Push32_32(emu, 2); //AT_EXECFD=file desciptor of program
101+
Push32_32(emu, (uintptr_t)main->PHEntries._32); Push32_32(emu, 3); //AT_PHDR(3)=address of the PH of the executable
102+
Push32_32(emu, sizeof(Elf32_Phdr)); Push32_32(emu, 4); //AT_PHENT(4)=size of PH entry
103+
Push32_32(emu, main->numPHEntries); Push32_32(emu, 5); //AT_PHNUM(5)=number of elf headers
104+
Push32_32(emu, box64_pagesize); Push32_32(emu, 6); //AT_PAGESZ(6)
105+
//Push32_32(emu, real_getauxval(7)); Push32_32(emu, 7); //AT_BASE(7)=ld-2.27.so start (in memory)
106+
Push32_32(emu, 0); Push32_32(emu, 8); //AT_FLAGS(8)=0
107+
Push32_32(emu, R_EIP); Push32_32(emu, 9); //AT_ENTRY(9)=entrypoint
108+
Push32_32(emu, from_ulong(real_getauxval(11))); Push32_32(emu, 11); //AT_UID(11)
109+
Push32_32(emu, from_ulong(real_getauxval(12))); Push32_32(emu, 12); //AT_EUID(12)
110+
Push32_32(emu, from_ulong(real_getauxval(13))); Push32_32(emu, 13); //AT_GID(13)
111+
Push32_32(emu, from_ulong(real_getauxval(14))); Push32_32(emu, 14); //AT_EGID(14)
112+
Push32_32(emu, p_i686); Push32_32(emu, 15); //AT_PLATFORM(15)=&"i686"
110113
// Push HWCAP:
111114
// FPU: 1<<0 ; VME: 1<<1 ; DE : 1<<2 ; PSE: 1<<3 ; TSC: 1<<4 ; MSR: 1<<5 ; PAE: 1<<6 ; MCE: 1<<7
112115
// CX8: 1<<8 ; APIC:1<<9 ; SEP: 1<<11; MTRR:1<<12; PGE: 1<<13; MCA: 1<<14; CMOV:1<<15

0 commit comments

Comments
 (0)