Changeset 2806
- Timestamp:
- Sep 2, 2006, 6:44:18 AM (19 years ago)
- Location:
- trunk/libc
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libc/Makefile.kmk
r2739 r2806 267 267 startupobjs_SOURCES := 268 268 define def_startup 269 $(PATH_TARGET)/crt0$(i).o: src/libc/startup/386/crt0.s | $(call DIRDEP,$(PATH_TARGET)) 270 $(RM) -f $@ $@bj 269 $(PATH_TARGET)/crt0$(i).o: src/libc/startup/os2/x86/crt0.s | $(call DIRDEP,$(PATH_TARGET)) 270 $(RM) -f $$@ $$@bj 271 echo "i=$i" 271 272 gcc -c -Iinclude -x assembler-with-cpp \ 272 273 $(subst wild, -DARGS_WILD, \ … … 275 276 $(subst nofork, -DNOFORK, \ 276 277 $(subst hi, -DHIGHMEM, $i) )))) \ 277 -o $ @ \278 $ <279 $ (eval startupobjs_SOURCES += $(PATH_TARGET)/crt0$(i).o)278 -o $$@ \ 279 $$< 280 $$(eval startupobjs_SOURCES += $(PATH_TARGET)/crt0$(i).o) 280 281 ifeq ($(BUILD_TARGET),os2) 281 282 $(PATH_TARGET)/crt0$(i).obj: $(PATH_TARGET)/crt0$(i).o 282 emxomf -m__text -o $ @$<283 $ (eval startupobjs_SOURCES += $(PATH_TARGET)/crt0$(i).obj)283 emxomf -m__text -o $$@ $$< 284 $$(eval startupobjs_SOURCES += $(PATH_TARGET)/crt0$(i).obj) 284 285 endif 285 286 286 287 ifeq ($(subst resp,,$(subst wild,,$(i))),$(i)) 287 $(PATH_TARGET)/dll0$(i).o: src/libc/startup/ 386/dll0.s | $(call DIRDEP,$(PATH_TARGET))288 $(RM) -f $ @$@bj288 $(PATH_TARGET)/dll0$(i).o: src/libc/startup/os2/x86/dll0.s | $(call DIRDEP,$(PATH_TARGET)) 289 $(RM) -f $$@ $$@bj 289 290 gcc -c -Iinclude -x assembler-with-cpp \ 290 291 $(subst wild, -DARGS_WILD, \ … … 293 294 $(subst nofork, -DNOFORK, \ 294 295 $(subst hi, -DHIGHMEM, $i) )))) \ 295 -o $ @ \296 $ <297 $ (eval startupobjs_SOURCES += $(PATH_TARGET)/dll0$(i).o)296 -o $$@ \ 297 $$< 298 $$(eval startupobjs_SOURCES += $(PATH_TARGET)/dll0$(i).o) 298 299 ifeq ($(BUILD_TARGET),os2) 299 300 $(PATH_TARGET)/dll0$(i).obj: $(PATH_TARGET)/dll0$(i).o 300 emxomf -l__text -o $ @$<301 $ (eval startupobjs_SOURCES += $(PATH_TARGET)/dll0$(i).obj)301 emxomf -l__text -o $$@ $$< 302 $$(eval startupobjs_SOURCES += $(PATH_TARGET)/dll0$(i).obj) 302 303 endif 303 304 endif … … 306 307 # generate 307 308 i:= 308 $(eval $( valuedef_startup))309 $(eval $(def_startup)) 309 310 $(foreach i,\ 310 311 hi \ … … 343 344 \ 344 345 resp \ 345 ,$(eval $( valuedef_startup)))346 ,$(eval $(def_startup))) 346 347 347 348 # binmode -
trunk/libc/include/InnoTekLIBC/fork.h
r2805 r2806 37 37 38 38 /** Current fork module version. */ 39 #define __LIBC_FORK_MODULE_VERSION 0x0001000 039 #define __LIBC_FORK_MODULE_VERSION 0x00010001 40 40 41 41 /** Timeout on waiting semaphore in fork operations */ … … 566 566 * management so multiple LIBC versions can share the same module lists. */ 567 567 __LIBC_PFORKMODULE pNext; 568 /** The module handle. */568 /** The module handle. Added in version 0x00010001 of this structure. */ 569 569 unsigned hmod; 570 570 /** Reserved space to make it 32 byte aligned - must be zero. */ -
trunk/libc/src/libc/startup/os2/x86/crt0.s
r2805 r2806 37 37 * DS = ES = SS = flat data selector. 38 38 * FS = TIB selector. 39 * EFLAGS= ?39 * EFLAGS=undefined 40 40 * 41 41 * @returns exit code to pass to DosExit(1, rc); … … 49 49 .global __text 50 50 __text: 51 /* create stack frame */ 51 /* 52 * Clear DF, create a stack frame, register the exception handler, 53 * and allocate the main argument frame. 54 */ 55 cld 56 push %ebp 52 57 mov %esp, %ebp 58 59 pushl $__libc_Back_exceptionHandler 60 pushl %fs:0 /* tib_pexchain */ 61 mov %esp, %fs:0 62 63 andl 0xfffffff0, %esp /* make sure it's aligned. */ 64 subl $0x10, %esp 65 53 66 54 67 #if !defined(NOFORK) && !defined(NOUNIX) … … 57 70 * register the fork module. If we're forking, this call will never return. 58 71 */ 59 mov 8(%ebp), %eax 60 mov %eax, g_ForkModule_hmod 61 62 pushl $g_ForkModule 63 call ___libc_ForkRegisterModule 64 addl $4, %esp 72 movl 8(%ebp), %eax 73 movl %eax, g_ForkModule_hmod 74 75 movl $g_ForkModule, (%esp) 76 call ___libc_ForkRegisterModule 65 77 #endif 66 78 … … 69 81 * the CRT and get the arguments for main(). 70 82 */ 71 pushl 0 /* the main argument frame */72 pushl 073 pushl 074 83 movl %esp, %ecx 75 84 pushl %ecx /* pMainFrame */ … … 90 99 #endif 91 100 #if defined(ARGS_WILD) 92 # define F 3__LIBC_INIT_FLAGS_EXPAND_WILDCARDS93 #else 94 # define F 3095 #endif 96 pushl (F1+F2+F3+F4)101 # define F4 __LIBC_INIT_FLAGS_EXPAND_WILDCARDS 102 #else 103 # define F4 0 104 #endif 105 pushl $(F1+F2+F3+F4) 97 106 lea 8(%ebp), %edx 98 107 pushl %edx /* pvOS */ … … 100 109 pushl %eax /* hmod */ 101 110 call ___libc_InitExe 102 addl %esp, $0x0c111 addl $0x0c, %esp 103 112 104 113 /* … … 110 119 */ 111 120 call _main 112 addl $0x0c, %esp113 121 114 122 do_exit: … … 139 147 */ 140 148 g_ForkModule: 141 .long 0x0001000 0/* uVersion (__LIBC_FORK_MODULE_VERSION) */149 .long 0x00010001 /* uVersion (__LIBC_FORK_MODULE_VERSION) */ 142 150 .long __atfork_callback /* pfnAtFork */ 143 151 .long ___fork_parent1__ /* papParent1 */ -
trunk/libc/src/libc/startup/os2/x86/dll0.s
r2787 r2806 2 2 /** @file 3 3 * 4 * Standard entry point for dynamic libraries. 5 * This routine gets control right after dynamic library is loaded. 6 * 7 * 8 * Copyright (c) 1992-1998 by Eberhard Mattes 9 * Copyright (c) 2003 InnoTek Systemberatung GmbH 10 * 11 * 12 * This file is part of Innotek LIBC. 13 * 14 * Innotek LIBC is free software; you can redistribute it and/or modify 4 * OS/2 dll0. 5 * 6 * Copyright (c) 2006 knut st. osmundsen <bird@innotek.de> 7 * 8 * 9 * This file is part of kLIBC. 10 * 11 * kLIBC is free software; you can redistribute it and/or modify 15 12 * it under the terms of the GNU Lesser General Public License as published 16 13 * by the Free Software Foundation; either version 2 of the License, or 17 14 * (at your option) any later version. 18 15 * 19 * InnotekLIBC is distributed in the hope that it will be useful,16 * kLIBC is distributed in the hope that it will be useful, 20 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 23 20 * 24 21 * You should have received a copy of the GNU Lesser General Public License 25 * along with InnotekLIBC; if not, write to the Free Software22 * along with kLIBC; if not, write to the Free Software 26 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 27 24 * 28 25 */ 29 26 30 #include <emx/asm386.h> 31 32 .globl __text 33 .globl __data 34 .globl ___data_start 35 .globl ___bss_start 36 37 .text 38 39 27 28 #include <klibc/initterm.h> 29 30 31 32 /** 33 * The OS/2 library entry point. 34 * 35 * We emulate _DLL_InitTerm for EMX and VAC compatibility up to a point. 36 * That is, we don't let the extra termination call on load failure get 37 * to _DLL_InitTerm(). Should a fatal exception arise during init we 38 * will catch it and make the load fail. 39 * 40 * EAX = EBX = ECX = EDX = ESI = EDI = EBP = GS = 0. 41 * CS = flat code selector. 42 * DS = ES = SS = flat data selector. 43 * FS = TIB selector. 44 * EFLAGS=undefined 45 * 46 * 47 * @returns exit code to pass to DosExit(1, rc); 48 * @param hmod [ebp + 8h] The executable module handle. 49 * @param fFlag [ebp + 0ch] Why we're called. 50 * 51 */ 52 .text 53 .global __text 54 __text: 55 /* 56 * Clear DF, create a stack frame, and setup the exception handler. 57 */ 58 cld 59 pushl %ebp 60 movl %esp, %ebp 61 62 pushl $dll0_exception_handler 63 pushl %fs:0 /* tib_pexchain */ 64 movl %esp, %fs:0 65 66 subl $0x1c, %esp 67 68 /* 69 * What are we in for? 70 */ 71 movl 8(%ebp), %eax 72 orl %eax, %eax 73 je dll0_init 74 cmpl $1, %eax 75 je dll0_term 76 jmp return_failure /* something's busted. */ 77 78 79 /* 80 * Initialize the DLL. 81 */ 82 dll0_init: 83 #if !defined(NOFORK) && !defined(NOUNIX) 84 /* 85 * Update g_ForkModule.hmod and call __libc_ForkRegisterModule(&g_ForkModule) to 86 * register the fork module. The return code is < 0 on error, 0 on normal load, > 0 on fork. 87 */ 88 movl 8(%ebp), %eax 89 movl %eax, g_ForkModule_hmod 90 91 movl $g_ForkModule, (%esp) 92 call ___libc_ForkRegisterModule 93 cmpl $0, %eax 94 je dll0_init_not_forking 95 jg return_success /* %eax > 0: we're forking; no init. */ 96 jmp return_failure /* %eax < 0: the call failed. */ 97 dll0_init_not_forking: 98 movb $1, g_fCalledForkRegisterModule 99 #endif 100 101 /* 102 * Call __libc_InitDll(hmod, NULL, fFlags) to initialized the CRT for this DLL. 103 */ 40 104 #if defined(HIGHMEM) 41 # define FLAG_HIGHMEM 1105 # define F1 __LIBC_INIT_FLAGS_MEM_HIGH 42 106 #else 43 #define FLAG_HIGHMEM 0 44 #endif 45 107 # define F1 0 108 #endif 46 109 #if defined(NOUNIX) 47 # define FLAG_NOUNIX 2110 # define F2 __LIBC_INIT_FLAGS_NO_UNIX 48 111 #else 49 #define FLAG_NOUNIX 0 50 #endif 51 52 #if defined(NOFORK) 53 #define FLAG_NOFORK 4 112 # define F2 0 113 #endif 114 #if defined(ARGS_RESP) 115 # define F3 __LIBC_INIT_FLAGS_EXPAND_RESPONSE_FILE 54 116 #else 55 #define FLAG_NOFORK 0 56 #endif 57 58 /* 59 * The DLL Entry Point. 60 */ 61 __text: 62 cmpl $0, 8(%esp) 63 je do_init 64 cmpl $1, 8(%esp) 65 je do_term 66 jmp _DLL_InitTerm 67 68 69 /* 70 * DLL Initialization. 71 */ 72 do_init: 117 # define F3 0 118 #endif 119 #if defined(ARGS_WILD) 120 # define F4 __LIBC_INIT_FLAGS_EXPAND_WILDCARDS 121 #else 122 # define F4 0 123 #endif 124 movl $(F1+F2+F3+F4), 8(%esp) /* fFlags */ 125 movl $0, 4(%esp) /* pvOS */ 126 movl 8(%ebp), %eax 127 movl %eax, (%esp) /* hmod */ 128 call ___libc_InitDll 129 orl %eax, %eax 130 jnz dll0_term_fork_module 131 movb $1, g_fCalledInitDll 132 133 /* 134 * We can now invoke _DLL_InitTerm(hmod, 0). 135 */ 136 movl $0, 4(%esp) /* fFlags = 0 */ 137 movl 8(%ebp), %eax 138 movl %eax, (%esp) /* hmod */ 139 call _DLL_InitTerm 140 orl %eax, %eax 141 jz dll0_term_crt /* it failed. */ 142 movb $1, g_fCalled_DLL_InitTerm 143 144 return_success: 145 movl -8(%ebp), %edx 146 mov %edx, %fs:0 147 148 movl $1, %eax 149 leave 150 ret 151 152 153 /* 154 * DLL Termination / Init Bailout. 155 * 156 * The termination return code is ignored, so we return 'failure' (0) regardless 157 * of we're cleaning up from a failed init or are actually in a real termination call. 158 */ 159 dll0_term: 160 /* 161 * _DLL_InitTerm(hmod, 1). 162 */ 163 cmpb $1, g_fCalled_DLL_InitTerm 164 jnz dll0_term_crt 165 166 movl $1, 4(%esp) /* fFlags = 1 = termination */ 167 movl 8(%ebp), %eax 168 movl %eax, (%esp) /* hmod */ 169 movb $0, g_fCalled_DLL_InitTerm 170 call _DLL_InitTerm 171 172 /* 173 * Call __libc_TermDll(hmod, NULL, fFlags). 174 */ 175 dll0_term_crt: 176 cmpb $1, g_fCalledInitDll 177 jnz dll0_term_fork_module 178 179 movl $(F1+F2+F3+F4), 8(%esp) /* fFlags */ 180 movl $0, 4(%esp) /* pvOS */ 181 movl 8(%ebp), %eax 182 movl %eax, (%esp) /* hmod */ 183 movb $0, g_fCalledInitDll 184 call ___libc_TermDll 185 186 /* 187 * __libc_ForkDeregisterModule($g_ForkModule) 188 */ 189 dll0_term_fork_module: 73 190 #if !defined(NOFORK) && !defined(NOUNIX) 74 pushl $0 75 pushl $ForkModule 191 cmpb $1, g_fCalledForkRegisterModule 192 jnz dll0_term_done 193 194 movl $g_ForkModule, (%esp) 195 movb $0, g_fCalledForkRegisterModule 76 196 call ___libc_ForkRegisterModule 77 addl $8, %esp 78 cmpl $0, %eax 79 je do_init_not_forking 80 jg do_return_success /* we're forking; no init. */ 81 /* else: eax < 0 - failure. */ 82 do_return_failure: 197 198 dll0_term_done: 199 #endif 200 201 return_failure: 202 movl -8(%ebp), %edx 203 mov %edx, %fs:0 204 83 205 xorl %eax, %eax 206 leave 84 207 ret 85 do_return_success: 86 xorl %eax, %eax 87 inc %al 208 209 210 /** 211 * Exception handler. 212 * 213 * @param pXcptRepRec [ebp + 0x08] 214 * @param pXcptRegRec [ebp + 0x0c] 215 * @param pCtx [ebp + 0x10] 216 * @param pvWhatever [ebp + 0x14] 217 */ 218 dll0_exception_handler: 219 cld 220 pushl %ebp 221 mov %esp, %ebp 222 223 /* 224 * Call __libc_InitDllException and let it decide what to do. 225 * It returns 0 if we should continue search the exception handler chain. 226 * It returns -1 if we resume execution. 227 * All other return codes means that we should abort the DLL load. 228 */ 229 pushl 0x14(%ebp) 230 pushl 0x10(%ebp) 231 pushl 0x0c(%ebp) 232 pushl 0x08(%ebp) 233 call ___libc_InitDllException 234 orl %eax, %eax 235 jz dll0_xcpt_return 236 cmp $0xffffffff, %eax 237 je dll0_xcpt_return 238 239 /* 240 * Abort the loading / termination. 241 * We pXcptRegRec as a navigation point to calculate %ebp and %esp. 242 */ 243 mov 0x0c(%ebp), %eax 244 lea 0x08(%eax), %ebp 245 lea -0x14(%eax), %esp 246 jmp dll0_term 247 248 /* 249 * Continue search or execution. 250 */ 251 dll0_xcpt_return: 252 leave 88 253 ret 89 254 90 /* normal dll init. */ 91 do_init_not_forking: 92 #endif 93 /* call __init_dll() */ 94 pushl 4(%esp) 95 pushl $(FLAG_HIGHMEM + FLAG_NOUNIX + FLAG_NOFORK) 96 call ___init_dll 97 add $8, %esp 98 orl %eax, %eax 99 jnz do_return_failure 100 101 /* call _DLL_InitTerm */ 102 cld 103 pushl 8(%esp) 104 pushl 8(%esp) 105 call _DLL_InitTerm 106 add $8, %esp 107 orl %eax, %eax 108 jnz do_return_success 109 110 /* _DLL_InitTerm failed, undo the module registration. */ 255 256 257 /** 258 * __data_start (and __data) marks the start of the data segment. 259 * 260 * By convention required by emxbind, the datasegment starts with 261 * a magic number followed by a pointer to the list of OS/2 DLL 262 * references. When linking OMF this is not used by anyone. 263 */ 264 .data 265 .global ___data_start 266 .global __data 267 ___data_start: 268 __data: 269 .long 0x00ba0bab /* Magic number (error detection). */ 270 .long __os2dll /* List of OS/2 DLL references. */ 271 272 /** Indicates that we've called __libc_InitDll() and should call __libc_TermDll(). */ 273 g_fCalledInitDll: 274 .byte 0 275 /** Indicates that we've called _DLL_InitTerm(,0) and should call _DLL_InitTerm(,1). */ 276 g_fCalled_DLL_InitTerm: 277 .byte 0 278 /** Indicates that we've called __libc_ForkRegisterModule() and should call __libc_ForkDeregisterModule(). */ 279 g_fCalledForkRegisterModule: 280 .byte 0 281 .byte 0 /* alignment */ 282 .long 0 /* alignment */ 283 111 284 #if !defined(NOFORK) && !defined(NOUNIX) 112 pushl $ForkModule 113 call ___libc_ForkRegisterModule 114 addl $4, %esp 115 #endif 116 jmp do_return_failure; 117 118 119 /* 120 * DLL Termination. 121 */ 122 do_term: 123 /* do init term first */ 124 cld 125 pushl 8(%esp) 126 pushl 8(%esp) 127 call _DLL_InitTerm 128 add $8, %esp 129 orl %eax, %eax 130 jnz do_term_dll 131 ret 132 133 do_term_dll: 134 /* call __libc_Back_termDll() */ 135 pushl 4(%esp) 136 pushl $(FLAG_HIGHMEM + FLAG_NOUNIX + FLAG_NOFORK) 137 call ___libc_Back_termDll 138 add $8, %esp 139 140 /* call __libc_ForkDeregisterModule */ 285 /** 286 * The fork module structure. 287 */ 288 g_ForkModule: 289 .long 0x00010001 /* uVersion (__LIBC_FORK_MODULE_VERSION) */ 290 .long __atfork_callback /* pfnAtFork */ 291 .long ___fork_parent1__ /* papParent1 */ 292 .long ___fork_child1__ /* papChild1 */ 293 .long ___data_start /* pvDataSegBase */ 294 .long _end /* pvDataSegEnd */ 295 .long 0x00000000 /* fFlags */ 296 .long 0 /* pNext */ 297 g_ForkModule_hmod: 298 .long 0 /* hmod */ 299 .long 0 /* uReserved[7] */ 300 .long 0 /* uReserved[7] */ 301 .long 0 /* uReserved[7] */ 302 .long 0 /* uReserved[7] */ 303 .long 0 /* uReserved[7] */ 304 .long 0 /* uReserved[7] */ 305 .long 0 /* uReserved[7] */ 306 #endif 307 308 309 /** 310 * __bss_start marks where the BSS segment starts. 311 */ 312 .bss 313 .global ___bss_start 314 ___bss_start: 315 316 317 /** 318 * Start all the a.out SETs the CRT and GCC are making use of. 319 * 320 * _os2dll is used by emxbind/ld for dll imports. 321 * __CTOR_LIST__ and __DTOR_LIST__ are lists of static constructors and destructors. 322 * __crtinit1__ is the list of static crt init routines. 323 * __crtinit2__ is the list of static crt termination routines. 324 * __eh_frame__, __eh_init__ and __eh_term__ are GCC exception handling info. 325 * __fork_parent1__ and __fork_child1__ are lists with fork time callbacks. 326 */ 327 .stabs "__os2dll", 21, 0, 0, 0xffffffff 328 .stabs "___CTOR_LIST__", 21, 0, 0, 0xffffffff 329 .stabs "___DTOR_LIST__", 21, 0, 0, 0xffffffff 330 .stabs "___crtinit1__", 21, 0, 0, 0xffffffff 331 .stabs "___crtexit1__", 21, 0, 0, 0xffffffff 332 .stabs "___eh_frame__", 21, 0, 0, 0xffffffff 333 .stabs "___eh_init__", 21, 0, 0, 0xffffffff 334 .stabs "___eh_term__", 21, 0, 0, 0xffffffff 141 335 #if !defined(NOFORK) && !defined(NOUNIX) 142 pushl $ForkModule 143 call ___libc_ForkDeregisterModule 144 addl $4, %esp 145 #endif 146 jmp do_return_success 147 148 149 .data 150 __data: 151 ___data_start: 152 .long 0xba0bab // Magic number (error detection) 153 .long __os2dll // list of OS/2 DLL references 154 155 .stabs "__os2dll", 21, 0, 0, 0xffffffff 156 .stabs "___CTOR_LIST__", 21, 0, 0, 0xffffffff 157 .stabs "___DTOR_LIST__", 21, 0, 0, 0xffffffff 158 .stabs "___crtinit1__", 21, 0, 0, 0xffffffff 159 .stabs "___crtexit1__", 21, 0, 0, 0xffffffff 160 .stabs "___eh_frame__", 21, 0, 0, 0xffffffff 161 .stabs "___eh_init__", 21, 0, 0, 0xffffffff 162 .stabs "___eh_term__", 21, 0, 0, 0xffffffff 163 #if !defined(NOFORK) && !defined(NOUNIX) 164 .stabs "___fork_parent1__", 21, 0, 0, 0xffffffff 165 .stabs "___fork_child1__", 21, 0, 0, 0xffffffff 166 167 ForkModule: 168 .long 0x00010000 // uVersion (__LIBC_FORK_MODULE_VERSION) 169 .long __atfork_callback // pfnAtFork 170 .long ___fork_parent1__ // papParent1 171 .long ___fork_child1__ // papChild1 172 .long ___data_start // pvDataSegBase 173 .long _end // pvDataSegEnd 174 .long 0 // fFlags 175 .long 0 // pNext 176 .long 0 // uReserved[8] 177 .long 0 // uReserved[8] 178 .long 0 // uReserved[8] 179 .long 0 // uReserved[8] 180 .long 0 // uReserved[8] 181 .long 0 // uReserved[8] 182 .long 0 // uReserved[8] 183 .long 0 // uReserved[8] 184 #endif 185 .stabs "__end",1,0,0,0 /* force libend inclusion for -Zomf. */ 186 187 .bss 188 ___bss_start: 189 336 .stabs "___fork_parent1__", 21, 0, 0, 0xffffffff 337 .stabs "___fork_child1__", 21, 0, 0, 0xffffffff 338 #endif 339 340 341 /** 342 * Add a symbol table entry which drags _end in libend into OMF links. 343 */ 344 .stabs "__end",1,0,0,0 345
Note:
See TracChangeset
for help on using the changeset viewer.