mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
ELF: make sure stack is always 16 byte aligned
This commit is contained in:
+5
-1
@@ -118,7 +118,11 @@ static void* stacksetup(char** argv, char** env, auxv64_list auxv){
|
|||||||
char* argdatastart = STACK_TOP - argdatasize;
|
char* argdatastart = STACK_TOP - argdatasize;
|
||||||
char* envdatastart = argdatastart - envdatasize;
|
char* envdatastart = argdatastart - envdatasize;
|
||||||
|
|
||||||
auxv64_list* auxvstart = (void*)(((uintptr_t)envdatastart & (~0xF)) - sizeof(auxv));
|
// if the final stack address wouldn't be 16 byte aligned (odd stack entry count), align it
|
||||||
|
|
||||||
|
int alignment = ((argc+1) + (envc+1) + 1) & 1 ? 8 : 0;
|
||||||
|
|
||||||
|
auxv64_list* auxvstart = (void*)(((uintptr_t)envdatastart & (~0xF)) - sizeof(auxv)) + alignment;
|
||||||
|
|
||||||
// count + 1 because of a null entry
|
// count + 1 because of a null entry
|
||||||
char** envstart = (void*)auxvstart - (envc + 1)*sizeof(char*);
|
char** envstart = (void*)auxvstart - (envc + 1)*sizeof(char*);
|
||||||
|
|||||||
Reference in New Issue
Block a user