Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPetr Bred <bredpetr@gmail.com>2017-07-03 19:24:13 +0300
committerJan Kotas <jkotas@microsoft.com>2017-07-03 19:24:13 +0300
commit8345e61491258854d4b1e7424db013b448436c51 (patch)
treeb0b35222565153e6191ffd79283c6596fd7d3c02 /src
parenta8531bb64e6634a4b645ee0ca60b30a93067d293 (diff)
Fix RhpPInvoke asm helper for arm (#4021)
- correct access to tls global variable in arm thumb Signed-off-by: Petr Bred <bredpetr@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/Native/Runtime/arm/PInvoke.S63
-rw-r--r--src/Native/Runtime/unix/unixasmmacrosarm.inc15
2 files changed, 41 insertions, 37 deletions
diff --git a/src/Native/Runtime/arm/PInvoke.S b/src/Native/Runtime/arm/PInvoke.S
index aa7574ec3..56422d453 100644
--- a/src/Native/Runtime/arm/PInvoke.S
+++ b/src/Native/Runtime/arm/PInvoke.S
@@ -8,18 +8,6 @@
.syntax unified
.thumb
-.macro INLINE_GET_TLS_VAR Var, trashReg
- ldr r0, =\Var(tlsgd)
- bl __tls_get_addr@PLT
- ldr \trashReg, =\Var(gottpoff)
- add r0, \trashReg
-.endmacro
-
-.macro INLINE_GETTHREAD trashReg
- // Inlined version of call C_FUNC(RhpGetThread)
- INLINE_GET_TLS_VAR tls_CurrentThread, \trashReg
-.endmacro
-
//
// RhpPInvoke
//
@@ -29,47 +17,48 @@
// The codegenerator must treat the callsite of this helper as GC triggering and generate the GC info for it.
// Also, the codegenerator must ensure that there are no live GC references in callee saved registers.
//
-NESTED_ENTRY RhpPInvoke, _TEXT, NoHandler
- PROLOG_PUSH "{r4-r7,lr}"
- str lr, [r0, #OFFSETOF__PInvokeTransitionFrame__m_RIP]
- str r7, [r0, #OFFSETOF__PInvokeTransitionFrame__m_FramePointer]
- str sp, [r0, #OFFSETOF__PInvokeTransitionFrame__m_PreservedRegs]
+NESTED_ENTRY RhpPInvoke, _TEXT, NoHandler
+ str lr, [r0, #OFFSETOF__PInvokeTransitionFrame__m_RIP]
+ str r7, [r0, #OFFSETOF__PInvokeTransitionFrame__m_FramePointer]
+ str sp, [r0, #OFFSETOF__PInvokeTransitionFrame__m_PreservedRegs]
- mov r5, r0
- // R0 = GetThread(), R6 - Trash Register
- INLINE_GETTHREAD r6
- str r0, [r5, #OFFSETOF__PInvokeTransitionFrame__m_pThread]
- str r5, [r0, #OFFSETOF__Thread__m_pTransitionFrame]
+ PROLOG_PUSH "{r5,lr}"
- ldr r6, =C_FUNC(RhpTrapThreads)
- ldr r6, [r6]
- cbnz r6, LOCAL_LABEL(InvokeRareTrapThread)
+ mov r5, r0
+ // get TLS global variable address
+ INLINE_GETTHREAD
+ str r0, [r5, #OFFSETOF__PInvokeTransitionFrame__m_pThread]
+ str r5, [r0, #OFFSETOF__Thread__m_pTransitionFrame]
+ ldr r3, =C_FUNC(RhpTrapThreads)
+ ldr r3, [r3]
+ cbnz r3, LOCAL_LABEL(InvokeRareTrapThread)
- EPILOG_POP "{r4-r7,pc}"
+ EPILOG_POP "{r5,pc}"
LOCAL_LABEL(InvokeRareTrapThread):
- b C_FUNC(RhpWaitForSuspend2)
+ EPILOG_POP "{r5,lr}"
+ b C_FUNC(RhpWaitForSuspend2)
NESTED_END RhpPInvoke, _TEXT
+
//
// RhpPInvokeReturn
//
// IN: R0: address of pinvoke frame
//
LEAF_ENTRY RhpPInvokeReturn, _TEXT
- ldr r3, [r0, #OFFSETOF__PInvokeTransitionFrame__m_pThread]
-
- mov r2, #0
- str r2, [r3, #OFFSETOF__Thread__m_pTransitionFrame]
+ ldr r3, [r0, #OFFSETOF__PInvokeTransitionFrame__m_pThread]
- ldr r3, =C_FUNC(RhpTrapThreads)
- ldr r3, [r3]
- cbnz r3, LOCAL_LABEL(ReturnRareTrapThread)
+ mov r2, #0
+ str r2, [r3, #OFFSETOF__Thread__m_pTransitionFrame]
- bx lr
+ ldr r3, =C_FUNC(RhpTrapThreads)
+ ldr r3, [r3]
+ cbnz r3, LOCAL_LABEL(ReturnRareTrapThread)
+ bx lr
LOCAL_LABEL(ReturnRareTrapThread):
- // passing transition frame pointer in r0
- b C_FUNC(RhpWaitForGC2)
+ // passing transition frame pointer in r0
+ b C_FUNC(RhpWaitForGC2)
LEAF_END RhpPInvokeReturn, _TEXT
diff --git a/src/Native/Runtime/unix/unixasmmacrosarm.inc b/src/Native/Runtime/unix/unixasmmacrosarm.inc
index 01b20bc2f..32e269c9e 100644
--- a/src/Native/Runtime/unix/unixasmmacrosarm.inc
+++ b/src/Native/Runtime/unix/unixasmmacrosarm.inc
@@ -170,3 +170,18 @@ C_FUNC(\Name):
bl C_FUNC(NYI_Assert)
.endm
#endif
+
+// thumb with PIC version
+.macro INLINE_GET_TLS_VAR Var
+ ldr r0, 2f
+1:
+ add r0, pc, r0
+ bl __tls_get_addr(PLT)
+2:
+ .4byte \Var(TLSGD) + (. - 1b - 4)
+.endm
+
+.macro INLINE_GETTHREAD
+ // Inlined version of call C_FUNC(RhpGetThread)
+ INLINE_GET_TLS_VAR tls_CurrentThread
+.endm