diff options
author | Fadi Hanna <fadim@microsoft.com> | 2016-11-15 22:27:43 +0300 |
---|---|---|
committer | Fadi Hanna <fadim@microsoft.com> | 2016-11-15 22:27:43 +0300 |
commit | 4e29f019e860dfcf8ddfee9b47376f76e51af2ae (patch) | |
tree | 72df3fbd434fe317f65f4f33c23b6c048a226d65 /src/Native/Runtime/i386 | |
parent | 691756f86e4def5c8ca13acd3e0c17011d436857 (diff) |
Thunk pool implementation for CoreRT. In CoreRT, the thunk mappings are allocated dynamically in memory using VirtualAlloc. The thunk stubs pages are marked with RX permissions and the thunks data pages are marked with RW permissions.
Refactored some code in ThunkPool.cs to remove from it any knowledge about the thunk sections layout. Thunks layout and allocation become a black box to ThunkPool.cs. All the section layout information is moved to the native component, and section navigation is done by calls to some APIs.
The dynamically allocated thunks pages are enabled by a FEATURE_RX_THUNKS, and only in CoreRT's Full build for now. The portable build doesn't yet support thunks.
[tfs-changeset: 1638131]
Diffstat (limited to 'src/Native/Runtime/i386')
-rw-r--r-- | src/Native/Runtime/i386/ThunkPoolThunks.asm | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/src/Native/Runtime/i386/ThunkPoolThunks.asm b/src/Native/Runtime/i386/ThunkPoolThunks.asm index 27a40ec02..17a6b5cca 100644 --- a/src/Native/Runtime/i386/ThunkPoolThunks.asm +++ b/src/Native/Runtime/i386/ThunkPoolThunks.asm @@ -9,6 +9,8 @@ option casemap:none .code +include AsmMacros.inc + ;; ----------------------------------------------------------------------------------------------------------- ;; standard macros ;; ----------------------------------------------------------------------------------------------------------- @@ -236,40 +238,74 @@ NAMED_READWRITE_DATA_SECTION ThunkData7, ".tkd7" ;; -;; IntPtr _RhpGetThunksBase() +;; IntPtr RhpGetThunksBase() ;; -LEAF_ENTRY _RhpGetThunksBase, _TEXT +FASTCALL_FUNC RhpGetThunksBase, 0 ;; Return the address of the first thunk pool to the caller (this is really the base address) lea eax, [ThunkPool] ret -LEAF_END _RhpGetThunksBase, _TEXT +FASTCALL_ENDFUNC ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; General Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; -;; int _RhpGetNumThunksPerBlock() +;; int RhpGetNumThunksPerBlock() ;; -LEAF_ENTRY _RhpGetNumThunksPerBlock, _TEXT +FASTCALL_FUNC RhpGetNumThunksPerBlock, 0 mov eax, THUNK_POOL_NUM_THUNKS_PER_PAGE ret -LEAF_END _RhpGetNumThunksPerBlock, _TEXT +FASTCALL_ENDFUNC ;; -;; int _RhpGetThunkSize() +;; int RhpGetThunkSize() ;; -LEAF_ENTRY _RhpGetThunkSize, _TEXT +FASTCALL_FUNC RhpGetThunkSize, 0 mov eax, THUNK_CODESIZE ret -LEAF_END _RhpGetThunkSize, _TEXT +FASTCALL_ENDFUNC ;; -;; int _RhpGetNumThunkBlocksPerMapping() +;; int RhpGetNumThunkBlocksPerMapping() ;; -LEAF_ENTRY _RhpGetNumThunkBlocksPerMapping, _TEXT +FASTCALL_FUNC RhpGetNumThunkBlocksPerMapping, 0 mov eax, 8 ret -LEAF_END _RhpGetNumThunkBlocksPerMapping, _TEXT +FASTCALL_ENDFUNC + +;; +;; IntPtr RhpGetNextThunkStubsBlockAddress(IntPtr currentThunkStubsBlockAddress) +;; +FASTCALL_FUNC RhpGetNextThunkStubsBlockAddress, 4 + mov eax, PAGE_SIZE * 2 + add eax, ecx + ret +FASTCALL_ENDFUNC + +;; +;; IntPtr RhpGetThunkDataBlockAddress(IntPtr thunkStubAddress) +;; +FASTCALL_FUNC RhpGetThunkDataBlockAddress, 4 + mov eax, ecx + mov ecx, PAGE_SIZE - 1 + not ecx + and eax, ecx + add eax, PAGE_SIZE + ret +FASTCALL_ENDFUNC + +;; +;; IntPtr RhpGetThunkStubsBlockAddress(IntPtr thunkDataAddress) +;; +FASTCALL_FUNC RhpGetThunkStubsBlockAddress, 4 + mov eax, ecx + mov ecx, PAGE_SIZE - 1 + not ecx + and eax, ecx + sub eax, PAGE_SIZE + ret +FASTCALL_ENDFUNC + end |