mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-12-11 01:22:21 +00:00
Add riscv64 support
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
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_LDFLAGS := -flto -Wl,--icf=all
|
||||
APP_CPPFLAGS := -std=c++23
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <x86_binaries.h>
|
||||
#elif defined(__x86_64__)
|
||||
#include <x86_64_binaries.h>
|
||||
#elif defined(__riscv)
|
||||
#include <riscv64_binaries.h>
|
||||
#else
|
||||
#error Unsupported ABI
|
||||
#endif
|
||||
|
||||
@@ -418,6 +418,9 @@ static void collect_modules(bool open_zygisk) {
|
||||
#elif defined(__x86_64__)
|
||||
info.z32 = openat(modfd, "zygisk/x86.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
|
||||
#error Unsupported ABI
|
||||
#endif
|
||||
|
||||
@@ -313,6 +313,14 @@ static const NativeBridgeRuntimeCallbacks* find_runtime_callbacks(struct _Unwind
|
||||
if (val >= start && val < end)
|
||||
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
|
||||
#error "Unsupported architecture"
|
||||
#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
|
||||
|
||||
LOCAL_CFLAGS := -Wno-unused-but-set-variable
|
||||
ifeq ($(TARGET_ARCH),riscv64)
|
||||
LOCAL_CFLAGS += -DHAVE_REALLOCARRAY
|
||||
endif
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
# libselinux.a
|
||||
|
||||
Reference in New Issue
Block a user