|
7 | 7 | #include "box64stack.h" |
8 | 8 | #include "box64context.h" |
9 | 9 | #include "elfloader.h" |
| 10 | +#include "elfs/elfloader_private.h" |
10 | 11 | #include "debug.h" |
11 | 12 | #include "emu/x64emu_private.h" |
12 | 13 | #include "auxval.h" |
@@ -94,19 +95,21 @@ void SetupInitialStack32(x64emu_t *emu) |
94 | 95 | 32: f7fbfb40 |
95 | 96 | 33: f7fbf000 |
96 | 97 | */ |
| 98 | + elfheader_t* main = my_context->elfs[0]; |
97 | 99 | 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" |
110 | 113 | // Push HWCAP: |
111 | 114 | // FPU: 1<<0 ; VME: 1<<1 ; DE : 1<<2 ; PSE: 1<<3 ; TSC: 1<<4 ; MSR: 1<<5 ; PAE: 1<<6 ; MCE: 1<<7 |
112 | 115 | // CX8: 1<<8 ; APIC:1<<9 ; SEP: 1<<11; MTRR:1<<12; PGE: 1<<13; MCA: 1<<14; CMOV:1<<15 |
|
0 commit comments