Browse Source

* implement RawThunk for ARM

git-svn-id: trunk@42755 -
svenbarth 6 years ago
parent
commit
7b4cf161aa
1 changed files with 28 additions and 0 deletions
  1. 28 0
      packages/rtl-objpas/src/inc/rtti.pp

+ 28 - 0
packages/rtl-objpas/src/inc/rtti.pp

@@ -891,6 +891,34 @@ asm
 RawThunkEnd:
 end;
 {$endif}
+{$elseif defined(cpuarm)}
+const
+  RawThunkPlaceholderProc = $87658765;
+  RawThunkPlaceholderContext = $43214321;
+
+type
+  TRawThunkProc = PtrUInt;
+  TRawThunkContext = PtrUInt;
+
+procedure RawThunk; assembler; nostackframe;
+asm
+  (* To be compatible with Thumb we first load the function pointer into R0,
+    then move that to R12 which is volatile and then we load the new Self into
+    R0 *)
+  ldr r0, .LProc
+  mov r12, r0
+  ldr r0, .LContext
+{$ifdef CPUARM_HAS_BX}
+  bx r12
+{$else}
+  mov pc, r12
+{$endif}
+.LProc:
+  .long RawThunkPlaceholderProc
+.LContext:
+  .long RawThunkPlaceholderContext
+RawThunkEnd:
+end;
 {$endif}
 
 {$if declared(RawThunk)}