fix: support C function mocking on ARM architectures - #70
Open
huiyuexu wants to merge 4 commits into
Open
Conversation
- select jump code by CPU ISA instead of pointer width - add absolute jump trampolines for AArch64 and ARM32 - support A32 and aligned/halfword-aligned Thumb-2 entries - normalize Thumb function addresses before patching - flush instruction cache after installing and restoring hooks - avoid unaligned address writes in x86 jump generation - add regression coverage for restoring C functions after reset Verified on x86_64, AArch64, ARM32 A32, and ARM32 Thumb-2. All 275 native unit tests pass. Signed-off-by: huiyuexu <xuhuiyue@huawei.com>
Author
|
@sinojelly Support C function mocking on ARM architectures, pls check it can be merged into the main branch and suggest releasing a version. |
- use 4-byte direct AArch64 branches for nearby targets - retain 16-byte absolute jumps for far targets - decode ARM member-function pointers with pointer-sized fields - protect only touched code pages and report hook install failures - add branch-boundary, page-range, and member-pointer tests Verified on x86_64 and AArch64/QEMU. Relevant hook, reset, jump, and page-range tests pass. Signed-off-by: huiyuexu <xuhuiyue@huawei.com>
- resolve non-PIE canonical PLT entries to shared-library functions - pin resolved modules while hooks are active - add nearby trampolines for short AArch64 functions - preserve BTI entries and safely fall back for PAC functions - add lazy and eager cross-DSO regression tests Verified on AArch64/QEMU. Lazy/now binding, short-function, BTI, PAC, hook, and reset cases pass. Signed-off-by: huiyuexu <xuhuiyue@huawei.com>
- parse imported symbol versions from ELF dynamic tables - resolve exact glibc symbol versions with dlvsym - validate ELF table ranges and malformed metadata - cover socket, listen, and pthread rwlock APIs across shared libraries - document the libdl requirement for older glibc Verified on AArch64/QEMU. Versioned system API hook and reset cases pass. The combined branch passes x86_64 279/279, AArch64 287/287, and ARM32 280/280 tests. Signed-off-by: huiyuexu <xuhuiyue@huawei.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Verified on x86_64, AArch64, ARM32 A32, and ARM32 Thumb-2. All 275 native unit tests pass.