Added ARM32 support

This commit is contained in:
alejo committed 2026-11-03 15:22:24 -03:00
1 parent df792729ef
commit 1212cb9dbe
36 files changed
+2381 -783

No files matched your search

@@ -2,7 +2,7 @@
* @file Plugin.cpp
* @brief PluginV1 -- "before your edit". See PluginV2/src/Plugin.cpp for
* "after"; the two deliberately export the identical set of names
* (minus plugin_legacy_feature, removed in V2) so HotReloadContext can
* (minus plugin_legacy_feature, removed in V2) so Context can
* line them up. See ../Shared/PluginApi.h for what each export is
* there to demonstrate (and for the documentation of every function
* defined here).
@@ -24,7 +24,16 @@ int plugin_legacy_feature(int input)
return input;
}
#if defined(__GNUC__) || defined(__clang__)
#if defined(__arm__) || defined(_M_ARM)
// See Shared/PluginApi.h's doc comment on plugin_tiny_function for why ARM32 needs this, rather
// than the plain empty body every other architecture uses below.
__asm__(
".global plugin_tiny_function\n"
".type plugin_tiny_function, %function\n"
"plugin_tiny_function:\n"
"\tbx lr\n"
".size plugin_tiny_function, . - plugin_tiny_function\n");
#elif defined(__GNUC__) || defined(__clang__)
void plugin_tiny_function(void)
{
}
@@ -26,7 +26,16 @@ int plugin_new_feature(int input)
return result;
}
#if defined(__GNUC__) || defined(__clang__)
#if defined(__arm__) || defined(_M_ARM)
// See Shared/PluginApi.h's doc comment on plugin_tiny_function for why ARM32 needs this, rather
// than the plain empty body every other architecture uses below.
__asm__(
".global plugin_tiny_function\n"
".type plugin_tiny_function, %function\n"
"plugin_tiny_function:\n"
"\tbx lr\n"
".size plugin_tiny_function, . - plugin_tiny_function\n");
#elif defined(__GNUC__) || defined(__clang__)
void plugin_tiny_function(void)
{
}
@@ -67,6 +67,19 @@ extern "C"
* and the library can only estimate one from the distance to the next
* export. MSVC has no equivalent per-function override this demo could
* apply, so this one only exists on GCC/Clang.
*
* ARM32 needs a different implementation underneath this same
* declaration (see PluginV1/src/Plugin.cpp): an ordinary empty C++
* body there, even with patchable-function-entry overridden to zero,
* still picks up an unoptimized build's full frame-pointer prologue
* and epilogue -- confirmed directly, 8 bytes on this architecture at
* `-O0`, tying this library's own ARM-state jump size exactly rather
* than falling safely under it. A single hand-written `bx lr`, at file
* scope rather than inside a C++ function body (sidestepping a
* separate GCC quirk: an asm statement inside a naked function body
* is followed by an unconditional extra NOP, confirmed directly),
* reliably stays under every ARM32 jump size this library ever
* writes, in both instruction sets, at every optimization level.
*/
__attribute__((patchable_function_entry(0))) void plugin_tiny_function(void);
#endif