Ensure that we call memcpy from the PLT on linux
authorGeoff Norton <grompf@gmail.com>
Thu, 12 Feb 2015 01:26:34 +0000 (17:26 -0800)
committerGeoff Norton <grompf@gmail.com>
Thu, 12 Feb 2015 01:26:34 +0000 (17:26 -0800)
src/vm/amd64/crthelpers.S
src/vm/amd64/unixasmmacros.inc

index 78fdea8..4cec104 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Copyright (c) Microsoft. All rights reserved.
 // Copyright (c) Geoff Norton. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information. 
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 //
 
 .intel_syntax noprefix
@@ -13,7 +13,7 @@
 // It is IMPORANT that the exception handling code is able to find these guys
 // on the stack, but on non-windows platforms we can just defer to the platform
 // implementation.
-// 
+//
 
 LEAF_ENTRY JIT_MemSet, _TEXT
         test rdx, rdx
@@ -21,7 +21,7 @@ LEAF_ENTRY JIT_MemSet, _TEXT
 
         cmp  byte ptr [rdi], 0
 
-        jmp  C_FUNC(memset)
+        jmp  C_PLTFUNC(memset)
 
 Exit_MemSet:
         ret
@@ -35,7 +35,7 @@ LEAF_ENTRY JIT_MemCpy, _TEXT
         cmp  byte ptr [rdi], 0
         cmp  byte ptr [rsi], 0
 
-        jmp  C_FUNC(memcpy)
+        jmp  C_PLTFUNC(memset)
 
 Exit_MemCpy:
         ret
index 79d2ea5..3b8ad52 100644 (file)
@@ -1,15 +1,15 @@
 //
 // Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information. 
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
 //
 
 #define INVALIDGCVALUE -0x33333333 // 0CCCCCCCDh - the assembler considers it to be a signed integer constant
 
-.macro NOP_3_BYTE 
+.macro NOP_3_BYTE
         nop dword ptr [rax]
 .endm
 
-.macro NOP_2_BYTE 
+.macro NOP_2_BYTE
         xchg ax, ax
 .endm
 
 #define C_FUNC(name) name
 #endif
 
+#if defined(__APPLE__)
+#define C_PLTFUNC(name) _##name
+#else
+#define C_PLTFUNC(name) name@PLT
+#endif
+
 .macro PATCH_LABEL Name
         .global C_FUNC(\Name)
 C_FUNC(\Name):
@@ -126,7 +132,7 @@ C_FUNC(\Name\()_End):
 //       this one gives an "unknown directive" error
 //
 //        .savexmm128 \Reg, \Offset
-    
+
         ___STACK_ADJUSTMENT_FORBIDDEN = 1
 
 .endm
@@ -134,7 +140,7 @@ C_FUNC(\Name\()_End):
 .macro restore_xmm128 Reg, ofs
         __Offset = \ofs
         movdqa          \Reg, [rsp + __Offset]
-.endm 
+.endm
 
 .macro POP_CALLEE_SAVED_REGISTERS
 
@@ -205,7 +211,7 @@ C_FUNC(\Name\()_End):
 // CalleeSavedRegisters::r13
 // CalleeSavedRegisters::r12
 // CalleeSavedRegisters::rbp
-// CalleeSavedRegisters::rbx 
+// CalleeSavedRegisters::rbx
 // ArgumentRegisters::r9
 // ArgumentRegisters::r8
 // ArgumentRegisters::rcx
@@ -258,7 +264,7 @@ C_FUNC(\Name\()_End):
         push_nonvol_reg r12
         push_nonvol_reg rbp
         push_nonvol_reg rbx
-        
+
         // ArgumentRegisters
         PUSH_ARGUMENT_REGISTERS
 
@@ -279,12 +285,12 @@ C_FUNC(\Name\()_End):
 
         alloc_stack     __PWTB_StackAlloc
         SAVE_FLOAT_ARGUMENT_REGISTERS __PWTB_FloatArgumentRegisters
-        
+
         END_PROLOGUE
 
 .endm
 
-.macro EPILOG_WITH_TRANSITION_BLOCK_TAILCALL 
+.macro EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
 
         RESTORE_FLOAT_ARGUMENT_REGISTERS __PWTB_FloatArgumentRegisters
         lea rsp,        [rsp + __PWTB_StackAlloc]