mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-25 02:55:33 +00:00
Add riscv64 support
This commit is contained in:
parent
e9694c6195
commit
a07b9315a5
@ -27,7 +27,7 @@ android {
|
|||||||
versionName = Config.version
|
versionName = Config.version
|
||||||
versionCode = Config.versionCode
|
versionCode = Config.versionCode
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
|
abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64", "riscv64")
|
||||||
debugSymbolLevel = "FULL"
|
debugSymbolLevel = "FULL"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
build.py
3
build.py
@ -68,12 +68,13 @@ if shutil.which("ccache") is not None:
|
|||||||
cpu_count = multiprocessing.cpu_count()
|
cpu_count = multiprocessing.cpu_count()
|
||||||
os_name = platform.system().lower()
|
os_name = platform.system().lower()
|
||||||
|
|
||||||
archs = ["armeabi-v7a", "x86", "arm64-v8a", "x86_64"]
|
archs = ["armeabi-v7a", "x86", "arm64-v8a", "x86_64", "riscv64"]
|
||||||
triples = [
|
triples = [
|
||||||
"armv7a-linux-androideabi",
|
"armv7a-linux-androideabi",
|
||||||
"i686-linux-android",
|
"i686-linux-android",
|
||||||
"aarch64-linux-android",
|
"aarch64-linux-android",
|
||||||
"x86_64-linux-android",
|
"x86_64-linux-android",
|
||||||
|
"riscv64-linux-android",
|
||||||
]
|
]
|
||||||
default_targets = ["magisk", "magiskinit", "magiskboot", "magiskpolicy", "busybox"]
|
default_targets = ["magisk", "magiskinit", "magiskboot", "magiskpolicy", "busybox"]
|
||||||
support_targets = default_targets + ["resetprop"]
|
support_targets = default_targets + ["resetprop"]
|
||||||
|
@ -229,32 +229,16 @@ fun Project.setupApp() {
|
|||||||
|
|
||||||
val syncLibs by tasks.registering(Sync::class) {
|
val syncLibs by tasks.registering(Sync::class) {
|
||||||
into("src/main/jniLibs")
|
into("src/main/jniLibs")
|
||||||
into("armeabi-v7a") {
|
for (abi in arrayOf("armeabi-v7a", "x86", "arm64-v8a", "x86_64", "riscv64")) {
|
||||||
from(rootProject.file("native/out/armeabi-v7a")) {
|
into(abi) {
|
||||||
include("busybox", "magiskboot", "magiskinit", "magiskpolicy", "magisk")
|
from(rootProject.file("native/out/$abi")) {
|
||||||
rename { "lib$it.so" }
|
include("busybox", "magiskboot", "magiskinit", "magiskpolicy", "magisk")
|
||||||
}
|
rename { "lib$it.so" }
|
||||||
}
|
}
|
||||||
into("x86") {
|
|
||||||
from(rootProject.file("native/out/x86")) {
|
|
||||||
include("busybox", "magiskboot", "magiskinit", "magiskpolicy", "magisk")
|
|
||||||
rename { "lib$it.so" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
into("arm64-v8a") {
|
|
||||||
from(rootProject.file("native/out/arm64-v8a")) {
|
|
||||||
include("busybox", "magiskboot", "magiskinit", "magiskpolicy", "magisk")
|
|
||||||
rename { "lib$it.so" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
into("x86_64") {
|
|
||||||
from(rootProject.file("native/out/x86_64")) {
|
|
||||||
include("busybox", "magiskboot", "magiskinit", "magiskpolicy", "magisk")
|
|
||||||
rename { "lib$it.so" }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onlyIf {
|
onlyIf {
|
||||||
if (inputs.sourceFiles.files.size != 20)
|
if (inputs.sourceFiles.files.size != 25)
|
||||||
throw StopExecutionException("Please build binaries first! (./build.py binary)")
|
throw StopExecutionException("Please build binaries first! (./build.py binary)")
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ android {
|
|||||||
"B_MAGISK=1", "B_INIT=1", "B_BOOT=1", "B_POLICY=1",
|
"B_MAGISK=1", "B_INIT=1", "B_BOOT=1", "B_POLICY=1",
|
||||||
"B_PRELOAD=1", "B_PROP=1", "B_CRT0=1"
|
"B_PRELOAD=1", "B_PROP=1", "B_CRT0=1"
|
||||||
)
|
)
|
||||||
|
abiFilters("armeabi-v7a", "arm64-v8a", "x86", "x86_64", "riscv64")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
APP_BUILD_SCRIPT := src/Android.mk
|
APP_BUILD_SCRIPT := src/Android.mk
|
||||||
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
|
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 riscv64
|
||||||
APP_CFLAGS := -Wall -Oz -fomit-frame-pointer -flto
|
APP_CFLAGS := -Wall -Oz -fomit-frame-pointer -flto
|
||||||
APP_LDFLAGS := -flto -Wl,--icf=all
|
APP_LDFLAGS := -flto -Wl,--icf=all
|
||||||
APP_CPPFLAGS := -std=c++23
|
APP_CPPFLAGS := -std=c++23
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include <x86_binaries.h>
|
#include <x86_binaries.h>
|
||||||
#elif defined(__x86_64__)
|
#elif defined(__x86_64__)
|
||||||
#include <x86_64_binaries.h>
|
#include <x86_64_binaries.h>
|
||||||
|
#elif defined(__riscv)
|
||||||
|
#include <riscv64_binaries.h>
|
||||||
#else
|
#else
|
||||||
#error Unsupported ABI
|
#error Unsupported ABI
|
||||||
#endif
|
#endif
|
||||||
|
@ -418,6 +418,9 @@ static void collect_modules(bool open_zygisk) {
|
|||||||
#elif defined(__x86_64__)
|
#elif defined(__x86_64__)
|
||||||
info.z32 = openat(modfd, "zygisk/x86.so", O_RDONLY | O_CLOEXEC);
|
info.z32 = openat(modfd, "zygisk/x86.so", O_RDONLY | O_CLOEXEC);
|
||||||
info.z64 = openat(modfd, "zygisk/x86_64.so", O_RDONLY | O_CLOEXEC);
|
info.z64 = openat(modfd, "zygisk/x86_64.so", O_RDONLY | O_CLOEXEC);
|
||||||
|
#elif defined(__riscv)
|
||||||
|
info.z32 = -1;
|
||||||
|
info.z64 = openat(modfd, "zygisk/riscv64.so", O_RDONLY | O_CLOEXEC);
|
||||||
#else
|
#else
|
||||||
#error Unsupported ABI
|
#error Unsupported ABI
|
||||||
#endif
|
#endif
|
||||||
|
@ -313,6 +313,14 @@ static const NativeBridgeRuntimeCallbacks* find_runtime_callbacks(struct _Unwind
|
|||||||
if (val >= start && val < end)
|
if (val >= start && val < end)
|
||||||
return reinterpret_cast<const NativeBridgeRuntimeCallbacks*>(val);
|
return reinterpret_cast<const NativeBridgeRuntimeCallbacks*>(val);
|
||||||
}
|
}
|
||||||
|
#elif defined(__riscv)
|
||||||
|
// x8-x9, x18-x27 callee-saved registers
|
||||||
|
for (int i : {8, 9, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27}) {
|
||||||
|
auto val = static_cast<uintptr_t>(_Unwind_GetGR(ctx, i));
|
||||||
|
ZLOGV("x%d = %p\n", i, reinterpret_cast<void *>(val));
|
||||||
|
if (val >= start && val < end)
|
||||||
|
return reinterpret_cast<const NativeBridgeRuntimeCallbacks*>(val);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#error "Unsupported architecture"
|
#error "Unsupported architecture"
|
||||||
#endif
|
#endif
|
||||||
|
3
native/src/external/Android.mk
vendored
3
native/src/external/Android.mk
vendored
@ -215,6 +215,9 @@ LOCAL_SRC_FILES := \
|
|||||||
selinux/libsepol/cil/src/cil_write_ast.c
|
selinux/libsepol/cil/src/cil_write_ast.c
|
||||||
|
|
||||||
LOCAL_CFLAGS := -Wno-unused-but-set-variable
|
LOCAL_CFLAGS := -Wno-unused-but-set-variable
|
||||||
|
ifeq ($(TARGET_ARCH),riscv64)
|
||||||
|
LOCAL_CFLAGS += -DHAVE_REALLOCARRAY
|
||||||
|
endif
|
||||||
include $(BUILD_STATIC_LIBRARY)
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
|
|
||||||
# libselinux.a
|
# libselinux.a
|
||||||
|
@ -58,7 +58,7 @@ for file in lib*.so; do
|
|||||||
mv "$file" "${file:3:${#file}-6}"
|
mv "$file" "${file:3:${#file}-6}"
|
||||||
done
|
done
|
||||||
|
|
||||||
if $IS64BIT; then
|
if [ -e "/system/bin/linker" ]; then
|
||||||
unzip -oj magisk.apk "lib/$ABI32/libmagisk.so"
|
unzip -oj magisk.apk "lib/$ABI32/libmagisk.so"
|
||||||
mv libmagisk.so magisk32
|
mv libmagisk.so magisk32
|
||||||
chmod 755 magisk32
|
chmod 755 magisk32
|
||||||
|
@ -494,11 +494,7 @@ remove_system_su() {
|
|||||||
api_level_arch_detect() {
|
api_level_arch_detect() {
|
||||||
API=$(grep_get_prop ro.build.version.sdk)
|
API=$(grep_get_prop ro.build.version.sdk)
|
||||||
ABI=$(grep_get_prop ro.product.cpu.abi)
|
ABI=$(grep_get_prop ro.product.cpu.abi)
|
||||||
if [ "$ABI" = "x86" ]; then
|
if [ "$ABI" = "arm64-v8a" ]; then
|
||||||
ARCH=x86
|
|
||||||
ABI32=x86
|
|
||||||
IS64BIT=false
|
|
||||||
elif [ "$ABI" = "arm64-v8a" ]; then
|
|
||||||
ARCH=arm64
|
ARCH=arm64
|
||||||
ABI32=armeabi-v7a
|
ABI32=armeabi-v7a
|
||||||
IS64BIT=true
|
IS64BIT=true
|
||||||
@ -506,11 +502,18 @@ api_level_arch_detect() {
|
|||||||
ARCH=x64
|
ARCH=x64
|
||||||
ABI32=x86
|
ABI32=x86
|
||||||
IS64BIT=true
|
IS64BIT=true
|
||||||
else
|
elif [ "$ABI" = "armeabi-v7a" ]; then
|
||||||
ARCH=arm
|
ARCH=arm
|
||||||
ABI=armeabi-v7a
|
|
||||||
ABI32=armeabi-v7a
|
ABI32=armeabi-v7a
|
||||||
IS64BIT=false
|
IS64BIT=false
|
||||||
|
elif [ "$ABI" = "x86" ]; then
|
||||||
|
ARCH=x86
|
||||||
|
ABI32=x86
|
||||||
|
IS64BIT=false
|
||||||
|
elif [ "$ABI" = "riscv64" ]; then
|
||||||
|
ARCH=riscv64
|
||||||
|
ABI32=riscv32
|
||||||
|
IS64BIT=true
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user