Now fetches argc, argv, env correctly from the host OS.

This commit is contained in:
dtrg 2007-04-23 23:24:03 +00:00
parent 9710c14c93
commit 9b920e59cb

View file

@ -15,6 +15,31 @@
begtext: begtext:
! This code is placed at the beginning of the ELF executable and is the ! This code is placed at the beginning of the ELF executable and is the
! first thing that runs. ! first thing that runs.
!
! On entry, the stack looks like this:
!
! sp+.. NULL
! sp+8+(4*argc) env (X quads)
! sp+4+(4*argc) NULL
! sp+4 argv (argc quads)
! sp argc
!
! The ACK actually expects:
!
! sp+8 argc
! sp+4 argv
! sp env
mov eax, (esp) ! eax = argc
lea ebx, 4(esp) ! ebx = argv
lea ecx, (esp)(eax*4)
add ecx, 12 ! environ
push ecx ! environ
push ebx ! argc
push eax ! argv
push eax ! dummy, representing the return argument
xor ebp, ebp
jmp __m_a_i_n jmp __m_a_i_n