From: Ben Gras Date: Mon, 21 Sep 2009 14:41:47 +0000 (+0000) Subject: change startup code to call munmap()/munmap_text() to map out X-Git-Tag: v3.1.5~131 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=da8360c0a3dae8694394986f19e97e86cf64fba4;p=minix.git change startup code to call munmap()/munmap_text() to map out own 0-pages. --- diff --git a/lib/i386/rts/crtso.s b/lib/i386/rts/crtso.s index a43c74a3c..c78cab14a 100755 --- a/lib/i386/rts/crtso.s +++ b/lib/i386/rts/crtso.s @@ -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 + .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