diff --git a/src/prehook-arm64-gas.S b/src/prehook-arm64-gas.S index de39edb..c3a7573 100644 --- a/src/prehook-arm64-gas.S +++ b/src/prehook-arm64-gas.S @@ -1,7 +1,13 @@ +#if defined __APPLE__ +#define funchook_hook_caller_asm _funchook_hook_caller_asm +#define funchook_hook_caller _funchook_hook_caller +#endif .arch armv8-a .text .globl funchook_hook_caller_asm +#if defined __linux__ .type funchook_hook_caller_asm, %function +#endif funchook_hook_caller_asm: .cfi_startproc // save frame pointer (x29) and link register (x30). diff --git a/test/libfunchook_test_aarch64_gas.S b/test/libfunchook_test_aarch64_gas.S index 2c0025b..ab1161c 100644 --- a/test/libfunchook_test_aarch64_gas.S +++ b/test/libfunchook_test_aarch64_gas.S @@ -1,3 +1,23 @@ +#ifdef __APPLE__ +#define call_get_val_in_dll _call_get_val_in_dll +#define get_val_in_dll _get_val_in_dll +#define jump_get_val_in_dll _jump_get_val_in_dll +#define arm64_test_adr _arm64_test_adr +#define arm64_test_beq _arm64_test_beq +#define arm64_test_bne _arm64_test_bne +#define arm64_test_cbnz _arm64_test_cbnz +#define arm64_test_cbz _arm64_test_cbz +#define arm64_test_ldr_w _arm64_test_ldr_w +#define arm64_test_ldr_x _arm64_test_ldr_x +#define arm64_test_ldr_s _arm64_test_ldr_s +#define arm64_test_ldr_d _arm64_test_ldr_d +#define arm64_test_ldr_q _arm64_test_ldr_q +#define arm64_test_prfm _arm64_test_prfm +#define arm64_test_ldrsw _arm64_test_ldrsw +#define arm64_test_tbnz _arm64_test_tbnz +#define arm64_test_tbz _arm64_test_tbz +#define test_data _test_data +#endif .arch armv8-a .file "libfunchook_test_aarch64_gas.S" .text @@ -9,7 +29,9 @@ test_data: call_get_val_in_dll: .global call_get_val_in_dll +#ifdef __linux__ .type call_get_val_in_dll, %function +#endif stp x29, x30, [sp, -16]! bl get_val_in_dll ldp x29, x30, [sp], 16 @@ -17,12 +39,16 @@ call_get_val_in_dll: jump_get_val_in_dll: .global jump_get_val_in_dll +#ifdef __linux__ .type jump_get_val_in_dll, %function +#endif b get_val_in_dll arm64_test_adr: .global arm64_test_adr +#ifdef __linux__ .type arm64_test_adr, %function +#endif adr x9, test_data ldr x9, [x9] add x0, x0, x9 @@ -30,7 +56,9 @@ arm64_test_adr: arm64_test_beq: .global arm64_test_beq +#ifdef __linux__ .type arm64_test_beq, %function +#endif adds x0, x0, 1 beq 1f sub x0, x0, 2 @@ -39,7 +67,9 @@ arm64_test_beq: arm64_test_bne: .global arm64_test_bne +#ifdef __linux__ .type arm64_test_bne, %function +#endif adds x0, x0, 1 bne 1f sub x0, x0, 2 @@ -49,7 +79,9 @@ arm64_test_bne: arm64_test_cbnz: .global arm64_test_cbnz +#ifdef __linux__ .type arm64_test_cbnz, %function +#endif cbnz x0, 1f add x0, x0, 2 1: @@ -58,7 +90,9 @@ arm64_test_cbnz: arm64_test_cbz: .global arm64_test_cbz +#ifdef __linux__ .type arm64_test_cbz, %function +#endif cbz x0, 1f add x0, x0, 2 1: @@ -67,21 +101,27 @@ arm64_test_cbz: arm64_test_ldr_w: .global arm64_test_ldr_w +#ifdef __linux__ .type arm64_test_ldr_w, %function +#endif ldr w9, test_data add x0, x0, x9 ret arm64_test_ldr_x: .global arm64_test_ldr_x +#ifdef __linux__ .type arm64_test_ldr_x, %function +#endif ldr x9, test_data add x0, x0, x9 ret arm64_test_ldr_s: .global arm64_test_ldr_s +#ifdef __linux__ .type arm64_test_ldr_s, %function +#endif ldr s16, test_data mov w9, v16.s[0] add x0, x0, x9 @@ -89,7 +129,9 @@ arm64_test_ldr_s: arm64_test_ldr_d: .global arm64_test_ldr_d +#ifdef __linux__ .type arm64_test_ldr_d, %function +#endif ldr d16, test_data mov x9, v16.d[0] add x0, x0, x9 @@ -97,7 +139,9 @@ arm64_test_ldr_d: arm64_test_ldr_q: .global arm64_test_ldr_q +#ifdef __linux__ .type arm64_test_ldr_q, %function +#endif ldr q16, test_data mov x9, v16.d[0] add x0, x0, x9 @@ -107,7 +151,9 @@ arm64_test_ldr_q: arm64_test_prfm: .global arm64_test_prfm +#ifdef __linux__ .type arm64_test_prfm, %function +#endif prfm pldl1keep, test_data ldr x9, test_data add x0, x0, x9 @@ -115,14 +161,18 @@ arm64_test_prfm: arm64_test_ldrsw: .global arm64_test_ldrsw +#ifdef __linux__ .type arm64_test_ldrsw, %function +#endif ldrsw x9, 1f add x0, x0, x9 ret arm64_test_tbnz: .global arm64_test_tbnz +#ifdef __linux__ .type arm64_test_tbnz, %function +#endif tbnz x0, 32, 1f add x0, x0, 2 1: @@ -131,7 +181,9 @@ arm64_test_tbnz: arm64_test_tbz: .global arm64_test_tbz +#ifdef __linux__ .type arm64_test_tbz, %function +#endif tbz x0, 32, 1f add x0, x0, 2 1: