From 2644cdd6fd3d3477290b0ea550c29e7bb8368efa Mon Sep 17 00:00:00 2001 From: Geoff Norton Date: Wed, 4 Feb 2015 22:26:11 -0800 Subject: [PATCH] Fixup labels for osx assembler / linker --- src/debug/ee/amd64/dbghelpers.S | 4 ++-- src/vm/amd64/jithelpers_fast.S | 4 ++-- src/vm/amd64/theprestubamd64.S | 2 +- src/vm/amd64/unixasmhelpers.S | 6 +++--- src/vm/amd64/unixasmmacros.inc | 32 +++++++++++++++++++++++++++-- src/vm/amd64/virtualcallstubamd64.S | 8 ++++++-- 6 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/debug/ee/amd64/dbghelpers.S b/src/debug/ee/amd64/dbghelpers.S index f6523121751a..de3c56f2f641 100644 --- a/src/debug/ee/amd64/dbghelpers.S +++ b/src/debug/ee/amd64/dbghelpers.S @@ -17,7 +17,7 @@ NESTED_ENTRY FuncEvalHijack, _TEXT, FuncEvalHijackPersonalityRoutine END_PROLOGUE mov [rsp], rdi - call FuncEvalHijackWorker + PLATFORM_CALL FuncEvalHijackWorker // // The following nop is crucial. It is important that the OS *not* recognize @@ -67,7 +67,7 @@ NESTED_ENTRY ExceptionHijack, _TEXT, ExceptionHijackPersonalityRoutine mov [rsp + 18h], rax // DD Hijack primitive already set the stack. So just make the call now. - call ExceptionHijackWorker + PLATFORM_CALL ExceptionHijackWorker // // The following nop is crucial. It is important that the OS *not* recognize diff --git a/src/vm/amd64/jithelpers_fast.S b/src/vm/amd64/jithelpers_fast.S index 4d92a6112bd5..6b2dddc1a3df 100644 --- a/src/vm/amd64/jithelpers_fast.S +++ b/src/vm/amd64/jithelpers_fast.S @@ -21,7 +21,7 @@ LEAF_ENTRY JIT_WriteBarrier, _TEXT #ifdef _DEBUG // In debug builds, this just contains jump to the debug version of the write barrier by default - jmp JIT_WriteBarrier_Debug + PLATFORM_JMP JIT_WriteBarrier_Debug #endif // Do the move into the GC . It is correct to take an AV here, the EH code @@ -104,7 +104,7 @@ LEAF_ENTRY JIT_CheckedWriteBarrier, _TEXT cmp rdi, [rax] jnb NotInHeap - jmp JIT_WriteBarrier + PLATFORM_CALL JIT_WriteBarrier NotInHeap: // See comment above about possible AV diff --git a/src/vm/amd64/theprestubamd64.S b/src/vm/amd64/theprestubamd64.S index 784837e86732..eee4fdec6c88 100644 --- a/src/vm/amd64/theprestubamd64.S +++ b/src/vm/amd64/theprestubamd64.S @@ -15,7 +15,7 @@ NESTED_ENTRY ThePreStub, _TEXT, ProcessCLRException // lea rdi, [rsp + __PWTB_TransitionBlock] // pTransitionBlock* mov rsi, METHODDESC_REGISTER - call PreStubWorker + PLATFORM_CALL PreStubWorker EPILOG_WITH_TRANSITION_BLOCK_TAILCALL TAILJMP_RAX diff --git a/src/vm/amd64/unixasmhelpers.S b/src/vm/amd64/unixasmhelpers.S index 4aebe3ca63a7..cd52e1e20ae7 100644 --- a/src/vm/amd64/unixasmhelpers.S +++ b/src/vm/amd64/unixasmhelpers.S @@ -27,7 +27,7 @@ LEAF_ENTRY PrecodeFixupThunk, _TEXT lea METHODDESC_REGISTER,[rax+r11*8] // Tail call to prestub - jmp ThePreStub + PLATFORM_CALL ThePreStub LEAF_END PrecodeFixupThunk, _TEXT @@ -116,7 +116,7 @@ NESTED_ENTRY NDirectImportThunk, _TEXT, Handler // Call NDirectImportWorker w/ the NDirectMethodDesc* // mov rdi, METHODDESC_REGISTER - call NDirectImportWorker + PLATFORM_CALL NDirectImportWorker RESTORE_FLOAT_ARGUMENT_REGISTERS 0 @@ -163,7 +163,7 @@ NESTED_ENTRY JIT_RareDisableHelper, _TEXT, Handler // Second float return register movdqa [rsp+0x10], xmm1 - call JIT_RareDisableHelperWorker + PLATFORM_CALL JIT_RareDisableHelperWorker movdqa xmm0, [rsp] movdqa xmm1, [rsp+0x10] diff --git a/src/vm/amd64/unixasmmacros.inc b/src/vm/amd64/unixasmmacros.inc index cc9cc30f6609..f2b997f04e0c 100644 --- a/src/vm/amd64/unixasmmacros.inc +++ b/src/vm/amd64/unixasmmacros.inc @@ -24,26 +24,50 @@ .byte 0xE0 .endm +.macro PLATFORM_JMP Name +#if defined(__APPLE__) + jmp _\Name +#else + jmp _\Name +#endif +.endm + +.macro PLATFORM_CALL Name +#if defined(__APPLE__) + call _\Name +#else + call \Name +#endif +.endm + .macro PATCH_LABEL Name +#if defined(__APPLE__) + .global _\Name +_\Name: +#else .global \Name \Name: +#endif .endm .macro LEAF_ENTRY Name, Section #if defined(__APPLE__) .global _\Name + .text +_\Name: #else .global \Name .type \Name, %function -#endif \Name: +#endif .endm .macro LEAF_END_MARKED Name, Section -\Name\()_End: #if defined(__APPLE__) +_\Name\()_End: .global _\Name\()_End #else +\Name\()_End: .global \Name\()_End .size \Name, .-\Name #endif @@ -54,7 +78,11 @@ .endm .macro PREPARE_EXTERNAL_VAR Name, HelperReg +#if defined(__APPLE__) + mov \HelperReg, [rip + _\Name@GOTPCREL] +#else mov \HelperReg, [rip + \Name@GOTPCREL] +#endif .endm .macro push_nonvol_reg Register diff --git a/src/vm/amd64/virtualcallstubamd64.S b/src/vm/amd64/virtualcallstubamd64.S index 6b382421e6c4..a54a0cdd44be 100644 --- a/src/vm/amd64/virtualcallstubamd64.S +++ b/src/vm/amd64/virtualcallstubamd64.S @@ -36,7 +36,7 @@ NESTED_ENTRY ResolveWorkerAsmStub, _TEXT, Handler and rcx, 7 // flags sub rsi, rcx // indirection cell - call VSD_ResolveWorker + PLATFORM_CALL VSD_ResolveWorker EPILOG_WITH_TRANSITION_BLOCK_TAILCALL TAILJMP_RAX @@ -69,7 +69,7 @@ MainLoop_RWCLAS: cmp r10, [rax+08h] // compare our DispatchToken with one in the ResolveCacheElem jne MainLoop_RWCLAS Success_RWCLAS: - PREPARE_EXTERNAL_VAR CHAIN_SUCCESS_COUNTER, rsi + PREPARE_EXTERNAL_VAR g_dispatch_cache_chain_success_counter, rsi sub qword ptr [rsi],1 // decrement success counter jl Promote_RWCLAS mov rax, [rax+10h] // get the ImplTarget @@ -85,6 +85,10 @@ Fail_RWCLAS: pop rsi // Restore the original saved rdx value push r10 // pass the DispatchToken or ResolveCacheElem to promote to ResolveWorkerAsmStub +#if defined(__APPLE__) + jmp _ResolveWorkerAsmStub +#else jmp ResolveWorkerAsmStub +#endif LEAF_END ResolveWorkerChainLookupAsmStub, _TEXT