Skip to content

fix: support C function mocking on ARM architectures - #70

Open
huiyuexu wants to merge 4 commits into
sinojelly:masterfrom
huiyuexu:fix_arm
Open

fix: support C function mocking on ARM architectures#70
huiyuexu wants to merge 4 commits into
sinojelly:masterfrom
huiyuexu:fix_arm

Conversation

@huiyuexu

@huiyuexu huiyuexu commented Aug 8, 2026

Copy link
Copy Markdown
  • 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.

- 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>
@huiyuexu

huiyuexu commented Aug 8, 2026

Copy link
Copy Markdown
Author

@sinojelly Support C function mocking on ARM architectures, pls check it can be merged into the main branch and suggest releasing a version.

etlom added 3 commits August 15, 2026 09:24
- 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>
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.

2 participants