change startup code to call munmap()/munmap_text() to map out

own 0-pages.
This commit is contained in:
Ben Gras 2009-09-21 14:41:47 +00:00
parent 1c217d038c
commit da8360c0a3

View file

@ -1,3 +1,4 @@
#
! This is the C run-time start-off routine. It's job is to take the
! arguments as put on the stack by EXEC, and to parse them and set them up the
! way _main expects them.
@ -6,6 +7,8 @@
! simplistic. We simply check for some magic value, but there is no other
! way.
#include <sys/vm_i386.h>
.sect .text; .sect .rom; .sect .data; .sect .bss
.define begtext, begdata, begbss
@ -19,6 +22,7 @@ begdata:
begbss:
.define crtso, __penviron, __penvp, __fpu_present
.define __minix_datastart, __minix_mainjump, __minix_unmapzero
.extern _main, _exit
.sect .text
crtso:
@ -49,6 +53,12 @@ crtso:
smsw ax
testb al, 0x4 ! EM bit in MSW
setz (__fpu_present) ! True if not set
jmp __minix_mainjump
.align I386_PAGE_SIZE
__minix_mainjump:
! unmap zero pages
call __minix_unmapzero
call _main ! main(argc, argv, envp)
@ -57,10 +67,27 @@ crtso:
hlt ! force a trap if exit fails
__minix_unmapzero:
! unmap 0-page code
push I386_PAGE_SIZE
push crtso
call _munmap_text ! munmap_text(crtso, I386_PAGE_SIZE)
add esp, 8
! unmap 0-page data
push I386_PAGE_SIZE
push romstart
call _munmap ! munmap(romstart, I386_PAGE_SIZE)
add esp, 8
ret
.sect .rom
.data4 0 ! Separate I&D: *NULL == 0
! Also keeps the first string in the
! program from appearing at location 0!
romstart:
.space I386_PAGE_SIZE
__minix_datastart:
.space 4
.sect .data
__penviron:
.data4 __penvp ! Pointer to environ, or hidden pointer