From c1c99c0a37dc11ae373da9d4f1c2684adc52f915 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 22 Jun 2019 17:12:01 -0700 Subject: [PATCH] ARM: Page-align instruction tables --- include/mgba-util/common.h | 2 ++ src/arm/isa-arm.c | 2 +- src/arm/isa-thumb.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/mgba-util/common.h b/include/mgba-util/common.h index e268dbad5..c5fd76ac5 100644 --- a/include/mgba-util/common.h +++ b/include/mgba-util/common.h @@ -218,6 +218,7 @@ typedef intptr_t ssize_t; #define ATTRIBUTE_UNUSED #define ATTRIBUTE_FORMAT(X, Y, Z) #define ATTRIBUTE_NOINLINE +#define ATTRIBUTE_ALIGN // Adapted from https://stackoverflow.com/a/2390626 #define _CONSTRUCTOR(FN, PRE) \ static void FN(void); \ @@ -232,6 +233,7 @@ typedef intptr_t ssize_t; #define ATTRIBUTE_UNUSED __attribute__((unused)) #define ATTRIBUTE_FORMAT(X, Y, Z) __attribute__((format(X, Y, Z))) #define ATTRIBUTE_NOINLINE __attribute__((noinline)) +#define ATTRIBUTE_ALIGN(X) __attribute__((aligned(X))) #define CONSTRUCTOR(FN) static __attribute__((constructor)) void FN(void) #endif diff --git a/src/arm/isa-arm.c b/src/arm/isa-arm.c index ae8d61820..644208531 100644 --- a/src/arm/isa-arm.c +++ b/src/arm/isa-arm.c @@ -738,6 +738,6 @@ DEFINE_INSTRUCTION_ARM(MSRRI, DEFINE_INSTRUCTION_ARM(SWI, cpu->irqh.swi32(cpu, opcode & 0xFFFFFF)) -const ARMInstruction _armTable[0x1000] = { +ATTRIBUTE_ALIGN(4096) const ARMInstruction _armTable[0x1000] = { DECLARE_ARM_EMITTER_BLOCK(_ARMInstruction) }; diff --git a/src/arm/isa-thumb.c b/src/arm/isa-thumb.c index ede7ba368..0d7f66f2f 100644 --- a/src/arm/isa-thumb.c +++ b/src/arm/isa-thumb.c @@ -400,6 +400,6 @@ DEFINE_INSTRUCTION_THUMB(BX, DEFINE_INSTRUCTION_THUMB(SWI, cpu->irqh.swi16(cpu, opcode & 0xFF)) -const ThumbInstruction _thumbTable[0x400] = { +ATTRIBUTE_ALIGN(4096) const ThumbInstruction _thumbTable[0x400] = { DECLARE_THUMB_EMITTER_BLOCK(_ThumbInstruction) };