Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update arm64 assembly to link/build on apple silicon mac #54

Closed
wants to merge 1 commit into from

Conversation

redthing1
Copy link

@redthing1 redthing1 commented Apr 5, 2024

This updates the arm64 assembly code, to resolve the issues brought up here.

Trying to build it from the original source here results in the assembler complaining:

/code/funchook/src/prehook-arm64-gas.S:4:2: error: unknown directive
 .type funchook_hook_caller_asm, %function
 ^

This is because the assembler for arm64 mac doesn't support that directive. Additionally, the naming of symbols defined in assembly is different.
I made a copy of the aarch64 asm files and fixed the syntax, so that it properly builds and links for arm64 mac. I also ran the tests with these results:

*** Skip tests changing executable compiled by Xcode 11.0 or upper on macOS. ***
[1] test_funchook_int: get_val_in_dll
[2] test_funchook_int: call_get_val_in_dll
[3] test_funchook_int: jump_get_val_in_dll
[4] test_funchook_uint64: arm64_test_adr
[5] test_funchook_uint64: arm64_test_beq
[6] test_funchook_uint64: arm64_test_bne
[7] test_funchook_uint64: arm64_test_cbnz
[8] test_funchook_uint64: arm64_test_cbz
[9] test_funchook_uint64: arm64_test_ldr_w
[10] test_funchook_uint64: arm64_test_ldr_x
[11] test_funchook_uint64: arm64_test_ldrsw
[12] test_funchook_uint64: arm64_test_ldr_s
[13] test_funchook_uint64: arm64_test_ldr_d
[14] test_funchook_uint64: arm64_test_ldr_q
[15] test_funchook_uint64: arm64_test_prfm
[16] test_funchook_uint64: arm64_test_tbnz
[17] test_funchook_uint64: arm64_test_tbz
[18] test_hook_open_and_fopen
ERROR: failed to install open and fopen hooks. (Failed to unprotect memory 0x180ecc000 (size=16384, prot=read,write) <- 0x180ececa4 (size=8, error=Permission denied))
[19] test_hook_many_funcs
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
[20] test_prehook: func_info
[21] test_prehook: long_args
[22] test_prehook: double_args
[23] test_prehook: mixed_args
[24] test_prehook: fastcall_args
[25] test_cpp: thiscall
[26] test_cpp: exception in prehook
1 of 26 tests are failed.
ERROR

@kubo
Copy link
Owner

kubo commented Apr 6, 2024

Thanks for your contribution.

I fixed it by another way.
See a9fc560, which uses C-preprocessor.

@kubo kubo closed this Apr 6, 2024
@redthing1
Copy link
Author

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants