- Timestamp:
- Sep 17, 2010, 2:49:06 AM (15 years ago)
- Location:
- trunk/emx
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/emx/Makefile.kmk
r3658 r3664 236 236 # 237 237 # ldstub 238 # 238 # 239 if 0 239 240 ldstub_TEMPLATE = usr.bin.alp 240 241 ldstub_SOURCES = \ 241 242 src/ld/ldstub.asm \ 242 243 src/ld/ldstub.def 243 ldstub_LDFLAGS = -nostdlib -s -Wl,-O,Option,-O,alignment=1244 ldstub_LDFLAGS = -nostdlib -s #-Wl,-O,Option,-O,alignment=1 244 245 ldstub_LIBS = os2 end 246 else 247 ldstub_TEMPLATE = usr.bin.nasm 248 ldstub_SOURCES = \ 249 src/ld/ldstub-nasm.asm \ 250 src/ld/ldstub.def 251 ldstub_LDFLAGS = -nostdlib -s 252 ldstub_LIBS = os2 253 endif 245 254 ldstub_EXESUFF = 246 255 -
trunk/emx/src/ld/ldstub-nasm.asm
r3660 r3664 1 1 ; $Id$ 2 2 ; 3 ; Micro stub for <app> -> <app>.exe forwarding 3 ; Micro stub for <app> -> <app>.exe forwarding, nasm version. 4 4 ; 5 5 ; Build Instructions: 6 6 ; Stantard version: 7 ; alp ldstub.asm 8 ; ilink /pmtype:vio /ALIGN:1 /OUT:ldstub.bin ldstub.obj ldstub.def os2386.lib 9 ; 10 ; Microversion: 11 ; alp -D:MICRO=1 ldstub.asm 12 ; ilink /pmtype:vio /ALIGN:1 /OUT:ldstub.bin ldstub.obj ldstub.def os2386.lib 7 ; nasm -f obj -o ldstub-nasm.o ldstub-nasm.asm 8 ; ilink /pmtype:vio /ALIGN:1 /OUT:ldstub.bin ldstub-nasm.obj ldstub.def os2386.lib 13 9 ; 14 10 ; OVERLAY may be defined for execv()/spawnv(OVERLAY,..) is to be emulated. … … 23 19 ; 24 20 25 .486 21 22 ;******************************************************************************* 23 ;* Global Variables * 24 ;******************************************************************************* 25 extern DosExecPgm 26 extern DosQueryModuleName 27 28 29 ;******************************************************************************* 30 ;* Segment definitions * 31 ;******************************************************************************* 32 segment TEXT32 public align=1 use32 FLAT class=CODE FLAT 33 segment STACK32 stack align=16 use32 class=STACK FLAT 34 26 35 27 36 ;******************************************************************************* 28 37 ;* Structures and Typedefs * 29 38 ;******************************************************************************* 30 RESULTCODES STRUC 31 resc_codeTerminate DD ? 32 resc_codeResult DD ? 33 RESULTCODES ENDS 39 segment TEXT32 ; works around warning and dummy 'text' segment. 40 struc RESC 41 .codeTerminate resd 1 42 .codeResult resd 1 43 endstruc 34 44 35 extrn DosExecPgm:near36 extrn DosQueryModuleName:near37 38 39 DATA32 segment use32 para public 'DATA'40 DATA32 ends41 42 BSS32 segment use32 para public 'BSS'43 ; buffer for modifying the executable name44 achNewExeName db 260 dup(?)45 padding db 8 dup(?) ; safety precaution.46 47 ; DosExecPgm result buffer.48 res RESULTCODES <?,?>49 BSS32 ends50 51 STACK32 segment use32 para stack 'STACK'52 dd 1800h dup(?) ; size doesn't matter as DosExecPgm uses thunk stack in any case. :/53 STACK32 ends54 55 ifndef MICRO56 DGROUP group DATA32, BSS32, STACK3257 else58 DGROUP group TEXT32, DATA32, BSS32, STACK3259 endif60 61 62 ifndef MICRO63 TEXT32 segment use32 para public 'CODE'64 else65 TEXT32 segment use32 para public 'DATA'66 endif67 45 68 46 ; Program startup registers are defined as follows. … … 85 63 ; @remark I don't care about cleaning up arguments as the leave does so. 86 64 ; 65 segment TEXT32 87 66 start: 88 ASSUME ss:FLAT, ds:FLAT, es:FLAT, fs:nothing, gs:nothing 89 push ebp 90 mov ebp, esp 67 ..start: 68 BITS 32 69 enter 260 + 4 + RESC_size, 0 70 %define achNewExeName ebp - 260 - RESC_size - 4 71 %define res ebp - RESC_size 91 72 92 73 ; … … 95 76 ; ULONG DosQueryModuleName(HMODULE hmod, ULONG ulNameLength, PCHAR pNameBuf); 96 77 ; 97 push offset FLAT:achNewExeName ; pNameBuf 98 push size achNewExeName ; ulNameLength 99 push dword ptr [ebp+8] ; hmod 78 lea ebx, [achNewExeName] 79 push ebx ; pNameBuf 80 push 260 ; ulNameLength 81 push dword [ebp+8] ; hmod 100 82 call DosQueryModuleName 101 83 or eax, eax 102 jz modname_ok 103 104 ; this ain't supposed to happen 105 mov edx, [ebp+4] 106 int 3 84 jnz .exec_failed ; this ain't supposed to happen 107 85 108 modname_ok:109 86 ; 110 87 ; Append .EXE to the module name. … … 112 89 xor ecx, ecx 113 90 dec ecx 114 mov edi, offset FLAT:achNewExeName91 mov edi, ebx ; achNewExeName 115 92 repne scasb 116 mov dword ptr[edi-1], 'EXE.'117 mov dword ptr [edi+3], 093 mov dword [edi-1], 'EXE.' 94 mov dword [edi+3], esi ; esi = 0 at this point. 118 95 119 96 ; … … 128 105 ; PCSZ pName); 129 106 ; 130 xor ecx, ecx131 push offset FLAT:achNewExeName ; pName132 push offset FLAT:res; pRes133 push dword ptr [ebp + 10h]; pEnv134 push dword ptr [ebp + 14h]; pArg135 ifdef OVERLAY107 push ebx ; pName (achNewExeName) 108 lea edi, [res] 109 push edi ; pRes 110 push dword [ebp + 10h] ; pEnv 111 push dword [ebp + 14h] ; pArg 112 %ifdef OVERLAY 136 113 push 1 ; execFlag = EXEC_ASYNC 137 else138 push e cx; execFlag = EXEC_SYNC = 0139 endif140 push e cx; cbObjname141 push e cx; pObjname114 %else 115 push esi ; execFlag = EXEC_SYNC = 0 116 %endif 117 push esi ; cbObjname 118 push esi ; pObjname 142 119 call DosExecPgm 143 120 or eax, eax 144 jz exec_success121 jz .exec_success 145 122 146 exec_failed:147 mov eax, 07fh148 jmp done123 .exec_failed: 124 mov eax, byte 07fh 125 jmp .done 149 126 150 exec_success:151 ifndef OVERLAY127 .exec_success: 128 %ifndef OVERLAY 152 129 ; 153 130 ; Retrieve the result code. 154 131 ; 155 mov eax, res.resc_codeResult 156 mov edx, res.resc_codeTerminate 157 or edx, edx 158 jz done 132 mov eax, [res + RESC.codeResult] 133 cmp [res + RESC.codeTerminate], esi 134 jz .done 159 135 160 136 ; … … 162 138 ; We shouldn't return 0 when we trap, crash or is killed. 163 139 ; 164 mov eax, 0ffh165 endif140 mov eax, byte 0ffh 141 %endif 166 142 167 143 168 done:144 .done: 169 145 leave 170 ret 171 TEXT32 ends 146 ret 172 147 173 end start174 148 149 ; for emxomfld 150 ABSOLUTE 0 151 global WEAK$ZERO 152 WEAK$ZERO: 153
Note:
See TracChangeset
for help on using the changeset viewer.