Prefix entrypoints with 0xFF so we can do extra checks.
Add check to ensure we do not read method header from libart.so
Bug: 123510633
Test: m -j40 cts && cts-tradefed run cts \
--test android.jvmti.cts.JvmtiHostTest1927#testJvmti \
--module CtsJvmtiRunTest1927HostTestCases
Change-Id: Ic3e42e3bd4fbda3b11c7e265ed114770139151b9
diff --git a/runtime/arch/arm/asm_support_arm.S b/runtime/arch/arm/asm_support_arm.S
index eeac743..633591d 100644
--- a/runtime/arch/arm/asm_support_arm.S
+++ b/runtime/arch/arm/asm_support_arm.S
@@ -54,7 +54,7 @@
// Common ENTRY declaration code for ARM and thumb, an ENTRY should always be paired with an END.
// Declares the RUNTIME_CURRENT[123] macros that can be used within an ENTRY and will have literals
// generated at END.
-.macro DEF_ENTRY thumb_or_arm, name
+.macro DEF_ENTRY thumb_or_arm, name, alignment
\thumb_or_arm
// Clang ignores .thumb_func and requires an explicit .thumb. Investigate whether we should still
// carry around the .thumb_func.
@@ -64,8 +64,12 @@
.type \name, #function
.hidden \name // Hide this as a global symbol, so we do not incur plt calls.
.global \name
+ // ART-compiled functions have OatQuickMethodHeader but assembly funtions do not.
+ // Prefix the assembly code with 0xFFs, which means there is no method header.
+ .byte 0xFF, 0xFF, 0xFF, 0xFF
// Cache alignment for function entry.
- .balign 16
+ // NB: 0xFF because there is a bug in balign where 0x00 creates nop instructions.
+ .balign \alignment, 0xFF
\name:
.cfi_startproc
.fnstart
@@ -88,12 +92,15 @@
// A thumb2 style ENTRY.
.macro ENTRY name
- DEF_ENTRY .thumb_func, \name
+ DEF_ENTRY .thumb_func, \name, 16
+.endm
+.macro ENTRY_ALIGNED name, alignment
+ DEF_ENTRY .thumb_func, \name, \alignment
.endm
// A ARM style ENTRY.
.macro ARM_ENTRY name
- DEF_ENTRY .arm, \name
+ DEF_ENTRY .arm, \name, 16
.endm
// Terminate an ENTRY and generate GOT_PREL references.