Skip to content

Commit be4a3b7

Browse files
authored
fix: #30 BusError when running 32b binary on armv8 with compatibility (#32)
When a 32-bit Android system runs on an ARMv8 device, Android reports to apps that only 32-bit ABIs are supported. As a result, the ARMv7 binary is selected. Although ARMv8 provides a compatibility mode for 32-bit binaries, this mode is stricter than native ARMv7 execution, especially regarding memory alignment and structure layout. The modifications made to the C++ structures in apktool introduced a memory misalignment, which is tolerated on ARMv7 but triggers a BusError on ARMv8 in 32-bit compatibility mode.
1 parent 62222bb commit be4a3b7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

patch.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ sed -i "$ressourcesPattern" "submodules/base/tools/aapt2/ResourcesInternal.proto
2121
git apply "patches/apktool_ibotpeaches.patch"
2222
git apply "patches/protobuf.patch"
2323

24+
# Fix BusError when executing a 32b binary on a armv8 with compatibility mode
25+
git apply "patches/32bsystem_on_armv8.patch"
26+
2427
ln -sf "submodules/googletest" "submodules/boringssl/src/third_party/googletest"

patches/32bsystem_on_armv8.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/submodules/base/libs/androidfw/include/androidfw/ResourceTypes.h b/submodules/base/libs/androidfw/include/androidfw/ResourceTypes.h
2+
index c26489093..7fb0c4e99 100644
3+
--- a/submodules/base/libs/androidfw/include/androidfw/ResourceTypes.h
4+
+++ b/submodules/base/libs/androidfw/include/androidfw/ResourceTypes.h
5+
@@ -505,7 +505,7 @@ struct ResStringPool_span
6+
7+
// The range of characters in the string that this span applies to.
8+
uint32_t firstChar, lastChar;
9+
-};
10+
+} __attribute__((__packed__, aligned(1)));
11+
12+
/**
13+
* Convenience class for accessing data in a ResStringPool resource.

0 commit comments

Comments
 (0)