init
This commit is contained in:
99
script/build-glue.sh
Executable file
99
script/build-glue.sh
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
BUILD_MODE="debug"
|
||||
if [[ "${1:-}" == "--release" ]]; then
|
||||
BUILD_MODE="release"
|
||||
fi
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
TARGET_DIR="${ROOT_DIR}/../target/wasm32-unknown-emscripten/${BUILD_MODE}"
|
||||
DIST_DIR="${ROOT_DIR}/test/dist"
|
||||
EMSDK_DIR="${EMSDK:-/Users/libr/Desktop/Life/emsdk}"
|
||||
UNICORN_BUILD_DIR="${UNICORN_BUILD_DIR:-${ROOT_DIR}/../unicorn/build}"
|
||||
NODE_DIST_JS="${DIST_DIR}/anisette_rs.node.js"
|
||||
NODE_DIST_WASM="${DIST_DIR}/anisette_rs.node.wasm"
|
||||
|
||||
|
||||
|
||||
WEB_EXPORTED_FUNCTIONS='["_malloc","_free","_anisette_init_from_blobs","_anisette_is_machine_provisioned","_anisette_start_provisioning","_anisette_end_provisioning","_anisette_request_otp","_anisette_get_cpim_ptr","_anisette_get_cpim_len","_anisette_get_session","_anisette_get_otp_ptr","_anisette_get_otp_len","_anisette_get_mid_ptr","_anisette_get_mid_len","_anisette_last_error_ptr","_anisette_last_error_len","_anisette_fs_write_file","_anisette_idbfs_init","_anisette_idbfs_sync","_anisette_set_identifier","_anisette_set_provisioning_path"]'
|
||||
NODE_EXPORTED_FUNCTIONS='["_malloc","_free","_anisette_init_from_blobs","_anisette_is_machine_provisioned","_anisette_start_provisioning","_anisette_end_provisioning","_anisette_request_otp","_anisette_get_cpim_ptr","_anisette_get_cpim_len","_anisette_get_session","_anisette_get_otp_ptr","_anisette_get_otp_len","_anisette_get_mid_ptr","_anisette_get_mid_len","_anisette_last_error_ptr","_anisette_last_error_len","_anisette_fs_write_file","_anisette_set_identifier","_anisette_set_provisioning_path"]'
|
||||
WEB_EXPORTED_RUNTIME_METHODS='["FS","HEAPU8","UTF8ToString","stringToUTF8","lengthBytesUTF8"]'
|
||||
NODE_EXPORTED_RUNTIME_METHODS='["HEAPU8","UTF8ToString","stringToUTF8","lengthBytesUTF8"]'
|
||||
|
||||
if [[ -f "${EMSDK_DIR}/emsdk_env.sh" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "${EMSDK_DIR}/emsdk_env.sh" >/dev/null
|
||||
else
|
||||
echo "emsdk_env.sh not found at ${EMSDK_DIR}/emsdk_env.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "${DIST_DIR}"
|
||||
|
||||
# if [[ "${SKIP_UNICORN_REBUILD:-0}" != "1" ]]; then
|
||||
# bash "${ROOT_DIR}/test/rebuild-unicorn.sh"
|
||||
# fi
|
||||
|
||||
pushd "${ROOT_DIR}" >/dev/null
|
||||
if [[ "${BUILD_MODE}" == "release" ]]; then
|
||||
cargo build --release --target wasm32-unknown-emscripten
|
||||
else
|
||||
cargo build --target wasm32-unknown-emscripten
|
||||
fi
|
||||
popd >/dev/null
|
||||
|
||||
EMCC_INPUTS=(
|
||||
"${TARGET_DIR}/libanisette_rs.a"
|
||||
"${UNICORN_BUILD_DIR}/libunicorn.a"
|
||||
"${UNICORN_BUILD_DIR}/libunicorn-common.a"
|
||||
"${UNICORN_BUILD_DIR}/libaarch64-softmmu.a"
|
||||
"${UNICORN_BUILD_DIR}/libarm-softmmu.a"
|
||||
)
|
||||
|
||||
for f in "${EMCC_INPUTS[@]}"; do
|
||||
if [[ ! -f "${f}" ]]; then
|
||||
echo "missing input: ${f}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
emcc \
|
||||
"${EMCC_INPUTS[@]}" \
|
||||
-lidbfs.js \
|
||||
-o "${DIST_DIR}/anisette_rs.js" \
|
||||
-sMODULARIZE=1 \
|
||||
-sEXPORT_ES6=1 \
|
||||
-sENVIRONMENT=web \
|
||||
-sWASM=1 \
|
||||
-sALLOW_MEMORY_GROWTH=1 \
|
||||
-sINITIAL_MEMORY=268435456 \
|
||||
-sWASM_BIGINT=1 \
|
||||
-sFORCE_FILESYSTEM=1 \
|
||||
-sASSERTIONS=1 \
|
||||
-sEXPORTED_FUNCTIONS="${WEB_EXPORTED_FUNCTIONS}" \
|
||||
-sEXPORTED_RUNTIME_METHODS="${WEB_EXPORTED_RUNTIME_METHODS}"
|
||||
|
||||
emcc \
|
||||
"${EMCC_INPUTS[@]}" \
|
||||
-o "${NODE_DIST_JS}" \
|
||||
-sMODULARIZE=1 \
|
||||
-sEXPORT_ES6=1 \
|
||||
-sENVIRONMENT=node \
|
||||
-sWASM=1 \
|
||||
-sALLOW_MEMORY_GROWTH=1 \
|
||||
-sINITIAL_MEMORY=268435456 \
|
||||
-sWASM_BIGINT=1 \
|
||||
-sFORCE_FILESYSTEM=0 \
|
||||
-sASSERTIONS=1 \
|
||||
-sEXPORTED_FUNCTIONS="${NODE_EXPORTED_FUNCTIONS}" \
|
||||
-sEXPORTED_RUNTIME_METHODS="${NODE_EXPORTED_RUNTIME_METHODS}"
|
||||
|
||||
echo "glue build done:"
|
||||
echo " ${DIST_DIR}/anisette_rs.js"
|
||||
echo " ${DIST_DIR}/anisette_rs.wasm"
|
||||
echo " ${NODE_DIST_JS}"
|
||||
echo " ${NODE_DIST_WASM}"
|
||||
|
||||
cp "${DIST_DIR}/anisette_rs.js" "${ROOT_DIR}/../../frontend/public/anisette/anisette_rs.js"
|
||||
cp "${DIST_DIR}/anisette_rs.wasm" "${ROOT_DIR}/../../frontend/public/anisette/anisette_rs.wasm"
|
||||
66
script/patches/ffi.inc.c.diff
Normal file
66
script/patches/ffi.inc.c.diff
Normal file
@@ -0,0 +1,66 @@
|
||||
diff --git a/qemu/tcg/ffi.inc.c b/qemu/tcg/ffi.inc.c
|
||||
index f0300a76..68ea4ebc 100644
|
||||
--- a/qemu/tcg/ffi.inc.c
|
||||
+++ b/qemu/tcg/ffi.inc.c
|
||||
@@ -19,6 +19,7 @@ static int debug_info(TCGHelperInfo *info) {
|
||||
printf("sizemask: 0x%x\n", info->sizemask);
|
||||
printf("n_args: %d\n", info->n_args);
|
||||
printf("t0: %lu\n", (uintptr_t)info->func);
|
||||
+ return 0;
|
||||
}
|
||||
|
||||
static uint64_t do_op_call(tcg_target_ulong *regs, tcg_target_ulong t0) {
|
||||
@@ -32,20 +33,50 @@ static uint64_t do_op_call(tcg_target_ulong *regs, tcg_target_ulong t0) {
|
||||
|
||||
// Manual ABI interventions (wasm32 requires very specific conventions for uint64_t)
|
||||
#if TCG_TARGET_REG_BITS == 32
|
||||
- if (info->flags & dh_callflag_void && info->sizemask == 0x10 && info->n_args == 4) {
|
||||
- ((void (*)(uint32_t, uint64_t, uint32_t, uint32_t))t0)(tci_read_reg(regs, TCG_REG_R0), tci_read_reg_ext(regs, TCG_REG_R1), tci_read_reg(regs, TCG_REG_R3), tci_read_reg(regs, TCG_REG_R4));
|
||||
+ if (info->name && strcmp(info->name, "uc_tracecode") == 0) {
|
||||
+ uint64_t trace_addr = tci_read_reg_ext(regs, TCG_REG_R3);
|
||||
+ // printf("ffi wasm32 fastpath: uc_tracecode r0=%u r1=%u r2=%lu addr=0x%llx\n",
|
||||
+ // (unsigned)tci_read_reg(regs, TCG_REG_R0),
|
||||
+ // (unsigned)tci_read_reg(regs, TCG_REG_R1),
|
||||
+ // (unsigned long)tci_read_reg(regs, TCG_REG_R2),
|
||||
+ // (unsigned long long)trace_addr);
|
||||
+ ((void (*)(uint32_t, uint32_t, uintptr_t, uint64_t))t0)(
|
||||
+ tci_read_reg(regs, TCG_REG_R0),
|
||||
+ tci_read_reg(regs, TCG_REG_R1),
|
||||
+ (uintptr_t)tci_read_reg(regs, TCG_REG_R2),
|
||||
+ trace_addr
|
||||
+ );
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (info->flags & dh_callflag_void && info->sizemask == 0x10 && info->n_args == 4) {
|
||||
+ ((void (*)(uint32_t, uint32_t, uint64_t, uint32_t))t0)(
|
||||
+ tci_read_reg(regs, TCG_REG_R0),
|
||||
+ tci_read_reg(regs, TCG_REG_R1),
|
||||
+ tci_read_reg_ext(regs, TCG_REG_R2),
|
||||
+ tci_read_reg(regs, TCG_REG_R4)
|
||||
+ );
|
||||
return 0;
|
||||
} else if (info->sizemask == 0x255 && info->n_args == 4) {
|
||||
return ((uint64_t (*)(uint64_t, uint64_t, uint64_t, uint32_t))t0)(tci_read_reg_ext(regs, TCG_REG_R0), tci_read_reg_ext(regs, TCG_REG_R2), tci_read_reg_ext(regs, TCG_REG_R4), tci_read_reg(regs, TCG_REG_R7));
|
||||
} else if (info->sizemask == 4 && info->n_args == 3) {
|
||||
return ((uint32_t (*)(uint64_t, uint32_t, uint32_t))t0)(tci_read_reg_ext(regs, TCG_REG_R0), tci_read_reg(regs, TCG_REG_R2), tci_read_reg(regs, TCG_REG_R3));
|
||||
} else if ((info->sizemask == 0x15 || info->sizemask == 0x3f) && info->n_args == 2) {
|
||||
- return ((uint64_t (*)(uint64_t, uint64_t))t0)(tci_read_reg_ext(regs, TCG_REG_R0), tci_read_reg(regs, TCG_REG_R2));
|
||||
+ return ((uint64_t (*)(uint64_t, uint64_t))t0)(tci_read_reg_ext(regs, TCG_REG_R0), tci_read_reg_ext(regs, TCG_REG_R2));
|
||||
} else if (info->sizemask == 0x40 && info->n_args == 3) {
|
||||
((void (*)(uintptr_t, uintptr_t, uint64_t))t0)(tci_read_reg(regs, TCG_REG_R0), tci_read_reg(regs, TCG_REG_R1), tci_read_reg_ext(regs, TCG_REG_R2));
|
||||
return 0;
|
||||
} else if (info->sizemask == 0x15 && info->n_args == 3) {
|
||||
return ((uint64_t (*)(uint64_t, uint64_t, uint32_t))t0)(tci_read_reg_ext(regs, TCG_REG_R0), tci_read_reg_ext(regs, TCG_REG_R2), tci_read_reg(regs, TCG_REG_R4));
|
||||
+ } else if (info->sizemask == 0x4 && info->n_args == 1) {
|
||||
+ // helper with arg shape (i64) -> i32, e.g., neon_narrow_u16, neon_narrow_high_u8, iwmmxt_setpsr_nz
|
||||
+ return ((uint32_t (*)(uint64_t))t0)(tci_read_reg_ext(regs, TCG_REG_R0));
|
||||
+ } else if (info->sizemask == 0x4 && info->n_args == 2) {
|
||||
+ // helper with arg shape (env, i64) -> i32, e.g., neon_narrow_sat_u8 (env is ptr)
|
||||
+ return ((uint32_t (*)(uintptr_t, uint64_t))t0)(
|
||||
+ tci_read_reg(regs, TCG_REG_R0),
|
||||
+ tci_read_reg_ext(regs, TCG_REG_R1)
|
||||
+ );
|
||||
}
|
||||
|
||||
for (int i = 1; i < 15; i++) {
|
||||
191
script/patches/ffi.rs.diff
Normal file
191
script/patches/ffi.rs.diff
Normal file
@@ -0,0 +1,191 @@
|
||||
diff --git a/bindings/rust/src/ffi.rs b/bindings/rust/src/ffi.rs
|
||||
index 7f7a205b..d812e8cd 100644
|
||||
--- a/bindings/rust/src/ffi.rs
|
||||
+++ b/bindings/rust/src/ffi.rs
|
||||
@@ -121,9 +121,15 @@ pub unsafe extern "C" fn mmio_read_callback_proxy<D, F>(
|
||||
where
|
||||
F: FnMut(&mut crate::Unicorn<D>, u64, usize) -> u64,
|
||||
{
|
||||
+ if user_data.is_null() {
|
||||
+ return 0;
|
||||
+ }
|
||||
let user_data = &mut *user_data;
|
||||
+ let Some(inner) = user_data.uc.upgrade() else {
|
||||
+ return 0;
|
||||
+ };
|
||||
let mut user_data_uc = Unicorn {
|
||||
- inner: user_data.uc.upgrade().unwrap(),
|
||||
+ inner,
|
||||
};
|
||||
debug_assert_eq!(uc, user_data_uc.get_handle());
|
||||
(user_data.callback)(&mut user_data_uc, offset, size)
|
||||
@@ -138,9 +144,15 @@ pub unsafe extern "C" fn mmio_write_callback_proxy<D, F>(
|
||||
) where
|
||||
F: FnMut(&mut crate::Unicorn<D>, u64, usize, u64),
|
||||
{
|
||||
+ if user_data.is_null() {
|
||||
+ return;
|
||||
+ }
|
||||
let user_data = &mut *user_data;
|
||||
+ let Some(inner) = user_data.uc.upgrade() else {
|
||||
+ return;
|
||||
+ };
|
||||
let mut user_data_uc = Unicorn {
|
||||
- inner: user_data.uc.upgrade().unwrap(),
|
||||
+ inner,
|
||||
};
|
||||
debug_assert_eq!(uc, user_data_uc.get_handle());
|
||||
(user_data.callback)(&mut user_data_uc, offset, size, value);
|
||||
@@ -154,9 +166,15 @@ pub unsafe extern "C" fn code_hook_proxy<D, F>(
|
||||
) where
|
||||
F: FnMut(&mut crate::Unicorn<D>, u64, u32),
|
||||
{
|
||||
+ if user_data.is_null() {
|
||||
+ return;
|
||||
+ }
|
||||
let user_data = &mut *user_data;
|
||||
+ let Some(inner) = user_data.uc.upgrade() else {
|
||||
+ return;
|
||||
+ };
|
||||
let mut user_data_uc = Unicorn {
|
||||
- inner: user_data.uc.upgrade().unwrap(),
|
||||
+ inner,
|
||||
};
|
||||
debug_assert_eq!(uc, user_data_uc.get_handle());
|
||||
(user_data.callback)(&mut user_data_uc, address, size);
|
||||
@@ -170,9 +188,15 @@ pub unsafe extern "C" fn block_hook_proxy<D, F>(
|
||||
) where
|
||||
F: FnMut(&mut crate::Unicorn<D>, u64, u32),
|
||||
{
|
||||
+ if user_data.is_null() {
|
||||
+ return;
|
||||
+ }
|
||||
let user_data = &mut *user_data;
|
||||
+ let Some(inner) = user_data.uc.upgrade() else {
|
||||
+ return;
|
||||
+ };
|
||||
let mut user_data_uc = Unicorn {
|
||||
- inner: user_data.uc.upgrade().unwrap(),
|
||||
+ inner,
|
||||
};
|
||||
debug_assert_eq!(uc, user_data_uc.get_handle());
|
||||
(user_data.callback)(&mut user_data_uc, address, size);
|
||||
@@ -189,9 +213,15 @@ pub unsafe extern "C" fn mem_hook_proxy<D, F>(
|
||||
where
|
||||
F: FnMut(&mut crate::Unicorn<D>, MemType, u64, usize, i64) -> bool,
|
||||
{
|
||||
+ if user_data.is_null() {
|
||||
+ return false;
|
||||
+ }
|
||||
let user_data = &mut *user_data;
|
||||
+ let Some(inner) = user_data.uc.upgrade() else {
|
||||
+ return false;
|
||||
+ };
|
||||
let mut user_data_uc = Unicorn {
|
||||
- inner: user_data.uc.upgrade().unwrap(),
|
||||
+ inner,
|
||||
};
|
||||
debug_assert_eq!(uc, user_data_uc.get_handle());
|
||||
(user_data.callback)(&mut user_data_uc, mem_type, address, size as usize, value)
|
||||
@@ -204,9 +234,15 @@ pub unsafe extern "C" fn intr_hook_proxy<D, F>(
|
||||
) where
|
||||
F: FnMut(&mut crate::Unicorn<D>, u32),
|
||||
{
|
||||
+ if user_data.is_null() {
|
||||
+ return;
|
||||
+ }
|
||||
let user_data = &mut *user_data;
|
||||
+ let Some(inner) = user_data.uc.upgrade() else {
|
||||
+ return;
|
||||
+ };
|
||||
let mut user_data_uc = Unicorn {
|
||||
- inner: user_data.uc.upgrade().unwrap(),
|
||||
+ inner,
|
||||
};
|
||||
debug_assert_eq!(uc, user_data_uc.get_handle());
|
||||
(user_data.callback)(&mut user_data_uc, value);
|
||||
@@ -221,9 +257,15 @@ pub unsafe extern "C" fn insn_in_hook_proxy<D, F>(
|
||||
where
|
||||
F: FnMut(&mut crate::Unicorn<D>, u32, usize) -> u32,
|
||||
{
|
||||
+ if user_data.is_null() {
|
||||
+ return 0;
|
||||
+ }
|
||||
let user_data = &mut *user_data;
|
||||
+ let Some(inner) = user_data.uc.upgrade() else {
|
||||
+ return 0;
|
||||
+ };
|
||||
let mut user_data_uc = Unicorn {
|
||||
- inner: user_data.uc.upgrade().unwrap(),
|
||||
+ inner,
|
||||
};
|
||||
debug_assert_eq!(uc, user_data_uc.get_handle());
|
||||
(user_data.callback)(&mut user_data_uc, port, size)
|
||||
@@ -236,9 +278,15 @@ pub unsafe extern "C" fn insn_invalid_hook_proxy<D, F>(
|
||||
where
|
||||
F: FnMut(&mut crate::Unicorn<D>) -> bool,
|
||||
{
|
||||
+ if user_data.is_null() {
|
||||
+ return false;
|
||||
+ }
|
||||
let user_data = &mut *user_data;
|
||||
+ let Some(inner) = user_data.uc.upgrade() else {
|
||||
+ return false;
|
||||
+ };
|
||||
let mut user_data_uc = Unicorn {
|
||||
- inner: user_data.uc.upgrade().unwrap(),
|
||||
+ inner,
|
||||
};
|
||||
debug_assert_eq!(uc, user_data_uc.get_handle());
|
||||
(user_data.callback)(&mut user_data_uc)
|
||||
@@ -253,9 +301,15 @@ pub unsafe extern "C" fn insn_out_hook_proxy<D, F>(
|
||||
) where
|
||||
F: FnMut(&mut crate::Unicorn<D>, u32, usize, u32),
|
||||
{
|
||||
+ if user_data.is_null() {
|
||||
+ return;
|
||||
+ }
|
||||
let user_data = &mut *user_data;
|
||||
+ let Some(inner) = user_data.uc.upgrade() else {
|
||||
+ return;
|
||||
+ };
|
||||
let mut user_data_uc = Unicorn {
|
||||
- inner: user_data.uc.upgrade().unwrap(),
|
||||
+ inner,
|
||||
};
|
||||
debug_assert_eq!(uc, user_data_uc.get_handle());
|
||||
(user_data.callback)(&mut user_data_uc, port, size, value);
|
||||
@@ -265,9 +319,15 @@ pub unsafe extern "C" fn insn_sys_hook_proxy<D, F>(uc: uc_handle, user_data: *mu
|
||||
where
|
||||
F: FnMut(&mut crate::Unicorn<D>),
|
||||
{
|
||||
+ if user_data.is_null() {
|
||||
+ return;
|
||||
+ }
|
||||
let user_data = &mut *user_data;
|
||||
+ let Some(inner) = user_data.uc.upgrade() else {
|
||||
+ return;
|
||||
+ };
|
||||
let mut user_data_uc = Unicorn {
|
||||
- inner: user_data.uc.upgrade().unwrap(),
|
||||
+ inner,
|
||||
};
|
||||
debug_assert_eq!(uc, user_data_uc.get_handle());
|
||||
(user_data.callback)(&mut user_data_uc);
|
||||
@@ -283,9 +343,15 @@ pub unsafe extern "C" fn tlb_lookup_hook_proxy<D, F>(
|
||||
where
|
||||
F: FnMut(&mut crate::Unicorn<D>, u64, MemType) -> Option<TlbEntry>,
|
||||
{
|
||||
+ if user_data.is_null() {
|
||||
+ return false;
|
||||
+ }
|
||||
let user_data = &mut *user_data;
|
||||
+ let Some(inner) = user_data.uc.upgrade() else {
|
||||
+ return false;
|
||||
+ };
|
||||
let mut user_data_uc = Unicorn {
|
||||
- inner: user_data.uc.upgrade().unwrap(),
|
||||
+ inner,
|
||||
};
|
||||
debug_assert_eq!(uc, user_data_uc.get_handle());
|
||||
let r = (user_data.callback)(&mut user_data_uc, vaddr, mem_type);
|
||||
16
script/patches/translate-all.c.diff
Normal file
16
script/patches/translate-all.c.diff
Normal file
@@ -0,0 +1,16 @@
|
||||
diff --git a/qemu/accel/tcg/translate-all.c b/qemu/accel/tcg/translate-all.c
|
||||
index 0524fefd..9bc1fd39 100644
|
||||
--- a/qemu/accel/tcg/translate-all.c
|
||||
+++ b/qemu/accel/tcg/translate-all.c
|
||||
@@ -862,6 +862,11 @@ static inline void *alloc_code_gen_buffer(struct uc_struct *uc)
|
||||
|
||||
return buf;
|
||||
}
|
||||
+
|
||||
+void free_code_gen_buffer(struct uc_struct *uc)
|
||||
+{
|
||||
+ (void)uc;
|
||||
+}
|
||||
#elif defined(_WIN32)
|
||||
#define COMMIT_COUNT (1024) // Commit 4MB per exception
|
||||
#define CLOSURE_SIZE (4096)
|
||||
54
script/rebuild-unicorn.sh
Executable file
54
script/rebuild-unicorn.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
EMSDK_DIR="${EMSDK:-/Users/libr/Desktop/Life/emsdk}"
|
||||
UNICORN_DIR="${UNICORN_DIR:-${ROOT_DIR}/../unicorn}"
|
||||
UNICORN_BUILD_DIR="${UNICORN_BUILD_DIR:-${UNICORN_DIR}/build}"
|
||||
JOBS="${JOBS:-8}"
|
||||
PATCH_DIR="${PATCH_DIR:-${ROOT_DIR}/script/patches}"
|
||||
|
||||
if [[ ! -d "${UNICORN_DIR}" ]]; then
|
||||
echo "unicorn directory not found: ${UNICORN_DIR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -f "${EMSDK_DIR}/emsdk_env.sh" ]]; then
|
||||
# shellcheck disable=SC1090
|
||||
source "${EMSDK_DIR}/emsdk_env.sh" >/dev/null
|
||||
else
|
||||
echo "emsdk_env.sh not found at ${EMSDK_DIR}/emsdk_env.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if [[ -d "${PATCH_DIR}" ]]; then
|
||||
# for patch_file in "${PATCH_DIR}"/*.diff; do
|
||||
# if [[ ! -f "${patch_file}" ]]; then
|
||||
# continue
|
||||
# fi
|
||||
|
||||
# echo "applying patch: ${patch_file}"
|
||||
# if ! git -C "${UNICORN_DIR}" apply "${patch_file}"; then
|
||||
# echo "skip failed patch: ${patch_file}"
|
||||
# fi
|
||||
# done
|
||||
# fi
|
||||
|
||||
# rm -rf "${UNICORN_BUILD_DIR}"
|
||||
mkdir -p "${UNICORN_BUILD_DIR}"
|
||||
|
||||
pushd "${UNICORN_BUILD_DIR}" >/dev/null
|
||||
emcmake cmake "${UNICORN_DIR}" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DUNICORN_BUILD_TESTS=OFF \
|
||||
-DUNICORN_INSTALL=OFF \
|
||||
-DUNICORN_LEGACY_STATIC_ARCHIVE=ON \
|
||||
-DUNICORN_INTERPRETER=ON \
|
||||
-DUNICORN_ARCH="arm;aarch64" \
|
||||
-DCMAKE_C_COMPILER=emcc \
|
||||
-DCMAKE_C_FLAGS="-DUSE_STATIC_CODE_GEN_BUFFER"
|
||||
cmake --build . -- -j"${JOBS}"
|
||||
popd >/dev/null
|
||||
|
||||
echo "unicorn rebuild done: ${UNICORN_BUILD_DIR}"
|
||||
Reference in New Issue
Block a user