Ticket #7287: link-hack.patch
File link-hack.patch, 4.7 KB (added by , 10 years ago) |
---|
-
libs\context\src\asm\fcontext_i386_ms_pe_masm.asm
40 40 ; | fc_mxcsr|fc_x87_cw| | 41 41 ; -------------------------------------------------------------- 42 42 43 43 .386 44 44 .XMM 45 45 .model flat, c 46 _exit PROTO, value:SDWORD 46 _exit PROTO, value:SDWORD 47 47 align_stack PROTO, vp:DWORD 48 48 seh_fcontext PROTO, except:DWORD, frame:DWORD, context:DWORD, dispatch:DWORD 49 49 .code 50 50 51 jump_fcontext PROC EXPORT51 jump_fcontext_impl PROC 52 52 mov ecx, [esp+04h] ; load address of the first fcontext_t arg 53 53 mov [ecx], edi ; save EDI 54 54 mov [ecx+04h], esi ; save ESI 55 55 mov [ecx+08h], ebx ; save EBX 56 56 mov [ecx+0ch], ebp ; save EBP 57 57 … … 104 104 105 105 mov esp, [ecx+010h] ; restore ESP 106 106 mov [esp+04h], eax ; use third arg as first arg in context function 107 107 mov ecx, [ecx+014h] ; fetch the address to return to 108 108 109 109 jmp ecx ; indirect jump to context 110 jump_fcontext ENDP110 jump_fcontext_impl ENDP 111 111 112 make_fcontext PROC EXPORT112 make_fcontext_impl PROC 113 113 mov eax, [esp+04h] ; load address of the fcontext_t arg0 114 114 mov [eax], eax ; save the address of passed context 115 115 mov ecx, [esp+08h] ; load the address of the context function 116 116 mov [eax+014h], ecx ; save the address of the context function 117 117 mov edx, [eax+018h] ; load the stack base 118 118 … … 144 144 145 145 finish: 146 146 xor eax, eax 147 147 push eax ; exit code is zero 148 148 call _exit ; exit application 149 149 hlt 150 make_fcontext ENDP150 make_fcontext_impl ENDP 151 151 END -
libs\context\src\asm\fcontext_x86_64_ms_pe_masm.asm
84 84 85 85 EXTERN _exit:PROC ; standard C library function 86 86 EXTERN align_stack:PROC ; stack alignment 87 87 EXTERN seh_fcontext:PROC ; exception handler 88 88 .code 89 89 90 jump_fcontext PROC EXPORTFRAME:seh_fcontext90 jump_fcontext_impl PROC FRAME:seh_fcontext 91 91 .endprolog 92 92 93 93 mov [rcx], r12 ; save R12 94 94 mov [rcx+08h], r13 ; save R13 95 95 mov [rcx+010h], r14 ; save R14 96 96 mov [rcx+018h], r15 ; save R15 … … 165 165 mov r10, [rdx+048h] ; fetch the address to returned to 166 166 167 167 mov rax, r8 ; use third arg as return value after jump 168 168 mov rcx, r8 ; use third arg as first arg in context function 169 169 170 170 jmp r10 ; indirect jump to caller 171 jump_fcontext ENDP171 jump_fcontext_impl ENDP 172 172 173 make_fcontext PROC EXPORT FRAME; generate function table entry in .pdata and unwind information in E173 make_fcontext_impl PROC FRAME ; generate function table entry in .pdata and unwind information in E 174 174 .endprolog ; .xdata for a function's structured exception handling unwind behavior 175 175 176 176 mov [rcx], rcx ; store the address of current context 177 177 mov [rcx+048h], rdx ; save the address of the function supposed to run 178 178 mov rdx, [rcx+050h] ; load the address where the context stack beginns 179 179 … … 200 200 201 201 finish: 202 202 xor rcx, rcx 203 203 mov [rsp+08h], rcx 204 204 call _exit ; exit application 205 205 hlt 206 make_fcontext ENDP206 make_fcontext_impl ENDP 207 207 END -
libs\context\src\fcontext.cpp
26 26 base = ( char * ) ( ( ( ( uintptr_t) base) - 15) & ~0x0F); 27 27 return base; 28 28 } 29 29 30 30 } 31 31 32 // HACK: GNU linker doesn't understand masm's EXPORT directive. 33 extern "C" 34 intptr_t BOOST_CONTEXT_CALLDECL jump_fcontext_impl( fcontext_t * ofc, fcontext_t const* nfc, intptr_t vp, bool preserve_fpu); 35 extern "C" 36 void BOOST_CONTEXT_CALLDECL make_fcontext_impl( fcontext_t * fc, void (* fn)( intptr_t) ); 37 38 extern "C" BOOST_CONTEXT_DECL 39 intptr_t BOOST_CONTEXT_CALLDECL jump_fcontext( fcontext_t * ofc, fcontext_t const* nfc, intptr_t vp, bool preserve_fpu) 40 { 41 return jump_fcontext_impl(ofc, nfc, vp, preserve_fpu); 42 } 43 44 extern "C" BOOST_CONTEXT_DECL 45 void BOOST_CONTEXT_CALLDECL make_fcontext( fcontext_t * fc, void (* fn)( intptr_t) ) 46 { 47 make_fcontext_impl(fc, fn); 48 } 49 32 50 }} 33 51 34 52 #ifdef BOOST_HAS_ABI_HEADERS 35 53 # include BOOST_ABI_SUFFIX 36 54 #endif