From d3b9bdb3ba6fe02b28fdbf51023e9cb21c471f2a Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sat, 16 Feb 2013 16:06:30 +0100 Subject: [PATCH] Provide envp to the main function. --- libc/x64/crt1.s | 2 ++ libc/x86/crt1.s | 1 + 2 files changed, 3 insertions(+) diff --git a/libc/x64/crt1.s b/libc/x64/crt1.s index 33d9e82d..2834d109 100644 --- a/libc/x64/crt1.s +++ b/libc/x64/crt1.s @@ -39,12 +39,14 @@ _start: # Prepare signals, memory allocation, stdio and such. pushq %rsi pushq %rdi + pushq %rcx call initialize_standard_library # Run the global constructors. call _init # Run main + popq %rdx # Note! envp is now %rdx (previously %rcx) popq %rdi popq %rsi call main diff --git a/libc/x86/crt1.s b/libc/x86/crt1.s index a7e777b5..1d7be001 100644 --- a/libc/x86/crt1.s +++ b/libc/x86/crt1.s @@ -37,6 +37,7 @@ _start: movl %ecx, environ # envp # Arguments for main + push %ecx # envp push %ebx # argv push %eax # argc