1/* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef ART_RUNTIME_ARCH_ARM_ASM_SUPPORT_ARM_S_ 18#define ART_RUNTIME_ARCH_ARM_ASM_SUPPORT_ARM_S_ 19 20#include "asm_support_arm.h" 21 22// Define special registers. 23 24// Register holding suspend check count down. 25#define rSUSPEND r4 26// Register holding Thread::Current(). 27#define rSELF r9 28 29.syntax unified 30.arch armv7-a 31.thumb 32 33// Macro to generate the value of Runtime::Current into rDest. As it uses labels 34// then the labels need to be unique. We bind these to the function name in the ENTRY macros. 35.macro RUNTIME_CURRENT name, num, rDest 36 .if .Lruntime_current\num\()_used 37 .error 38 .endif 39 .set .Lruntime_current\num\()_used, 1 40 ldr \rDest, .Lruntime_instance_\name\()_\num @ Load GOT_PREL offset of Runtime::instance_. 41.Lload_got_\name\()_\num\(): 42 add \rDest, pc @ Fixup GOT_PREL address. 43 ldr \rDest, [\rDest] @ Load address of Runtime::instance_. 44 ldr \rDest, [\rDest] @ Load Runtime::instance_. 45.endm 46 47// Common ENTRY declaration code for ARM and thumb, an ENTRY should always be paired with an END. 48// Declares the RUNTIME_CURRENT[123] macros that can be used within an ENTRY and will have literals 49// generated at END. 50.macro DEF_ENTRY thumb_or_arm, name 51 \thumb_or_arm 52// Clang ignores .thumb_func and requires an explicit .thumb. Investigate whether we should still 53// carry around the .thumb_func. 54 .ifc \thumb_or_arm, .thumb_func 55 .thumb 56 .endif 57 .type \name, #function 58 .hidden \name // Hide this as a global symbol, so we do not incur plt calls. 59 .global \name 60 // Cache alignment for function entry. 61 .balign 16 62\name: 63 .cfi_startproc 64 .fnstart 65 // Track whether RUNTIME_CURRENT was used. 66 .set .Lruntime_current1_used, 0 67 .set .Lruntime_current2_used, 0 68 .set .Lruntime_current3_used, 0 69 // The RUNTIME_CURRENT macros that are bound to the \name argument of DEF_ENTRY to ensure 70 // that label names are unique. 71 .macro RUNTIME_CURRENT1 rDest 72 RUNTIME_CURRENT \name, 1, \rDest 73 .endm 74 .macro RUNTIME_CURRENT2 rDest 75 RUNTIME_CURRENT \name, 2, \rDest 76 .endm 77 .macro RUNTIME_CURRENT3 rDest 78 RUNTIME_CURRENT \name, 3, \rDest 79 .endm 80.endm 81 82// A thumb2 style ENTRY. 83.macro ENTRY name 84 DEF_ENTRY .thumb_func, \name 85.endm 86 87// A ARM style ENTRY. 88.macro ARM_ENTRY name 89 DEF_ENTRY .arm, \name 90.endm 91 92// Terminate an ENTRY and generate GOT_PREL references. 93.macro END name 94 // Generate offsets of GOT and Runtime::instance_ used in RUNTIME_CURRENT. 95 .if .Lruntime_current1_used 96 .Lruntime_instance_\name\()_1: 97 .word _ZN3art7Runtime9instance_E(GOT_PREL)-(.Lload_got_\name\()_1+4) 98 .endif 99 .if .Lruntime_current2_used 100 .Lruntime_instance_\name\()_2: 101 .word _ZN3art7Runtime9instance_E(GOT_PREL)-(.Lload_got_\name\()_2+4) 102 .endif 103 .if .Lruntime_current3_used 104 .Lruntime_instance_\name\()_3: 105 .word _ZN3art7Runtime9instance_E(GOT_PREL)-(.Lload_got_\name\()_3+4) 106 .endif 107 // Remove the RUNTIME_CURRENTx macros so they get rebound in the next function entry. 108 .purgem RUNTIME_CURRENT1 109 .purgem RUNTIME_CURRENT2 110 .purgem RUNTIME_CURRENT3 111 .fnend 112 .cfi_endproc 113 .size \name, .-\name 114.endm 115 116// Declare an unimplemented ENTRY that will halt a debugger. 117.macro UNIMPLEMENTED name 118 ENTRY \name 119 bkpt 120 bkpt 121 END \name 122.endm 123 124// Macros to poison (negate) the reference for heap poisoning. 125.macro POISON_HEAP_REF rRef 126#ifdef USE_HEAP_POISONING 127 rsb \rRef, \rRef, #0 128#endif // USE_HEAP_POISONING 129.endm 130 131// Macros to unpoison (negate) the reference for heap poisoning. 132.macro UNPOISON_HEAP_REF rRef 133#ifdef USE_HEAP_POISONING 134 rsb \rRef, \rRef, #0 135#endif // USE_HEAP_POISONING 136.endm 137 138#endif // ART_RUNTIME_ARCH_X86_ASM_SUPPORT_X86_S_ 139