Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
314 changes: 185 additions & 129 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ tests/*/*.log

# GDB
.gdb_history
.idea
.venv
pyproject.toml
uv.lock
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ The tool does not transparently support all features of POSIX shared libraries.
The tool also lacks the following important features:
* symbol versions are not handled at all
* keep fast paths of shims together to reduce I$ pressure
* support for macOS

Finally, there are some minor TODOs in code.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions arch/osx/aarch64/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Arch]
PointerSize = 8
SymbolReloc = R_AARCH64_ABS64, SYMBOLIC, RELATIVE
67 changes: 67 additions & 0 deletions arch/osx/aarch64/table.S.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2018-2025 Yury Gribov
*
* The MIT License (MIT)
*
* Use of this source code is governed by MIT license that can be
* found in the LICENSE.txt file.
*/

#define lr x30
#define ip0 x16

.data
.globl __${lib_suffix}_tramp_table
.private_extern __${lib_suffix}_tramp_table
.p2align 3
__${lib_suffix}_tramp_table:
.zero $table_size

.text

.globl __${lib_suffix}_tramp_resolve
.private_extern __${lib_suffix}_tramp_resolve

.globl __${lib_suffix}_save_regs_and_resolve
.private_extern __${lib_suffix}_save_regs_and_resolve
__${lib_suffix}_save_regs_and_resolve:
.cfi_startproc

#define PUSH_PAIR(reg1, reg2) stp reg1, reg2, [sp, #-16]!; .cfi_adjust_cfa_offset 16; .cfi_rel_offset reg1, 0; .cfi_rel_offset reg2, 8
#define POP_PAIR(reg1, reg2) ldp reg1, reg2, [sp], #16; .cfi_adjust_cfa_offset -16; .cfi_restore reg2; .cfi_restore reg1

#define PUSH_WIDE_PAIR(reg1, reg2) stp reg1, reg2, [sp, #-32]!; .cfi_adjust_cfa_offset 32; .cfi_rel_offset reg1, 0; .cfi_rel_offset reg2, 16
#define POP_WIDE_PAIR(reg1, reg2) ldp reg1, reg2, [sp], #32; .cfi_adjust_cfa_offset -32; .cfi_restore reg2; .cfi_restore reg1

// Save only arguments (and lr)
PUSH_PAIR(x0, x1)
PUSH_PAIR(x2, x3)
PUSH_PAIR(x4, x5)
PUSH_PAIR(x6, x7)
PUSH_PAIR(x8, lr)

ldr x0, [sp, #80] // 16*5

PUSH_WIDE_PAIR(q0, q1)
PUSH_WIDE_PAIR(q2, q3)
PUSH_WIDE_PAIR(q4, q5)
PUSH_WIDE_PAIR(q6, q7)

// Stack is aligned at 16 bytes
bl __${lib_suffix}_tramp_resolve
mov ip0, x0

POP_WIDE_PAIR(q6, q7)
POP_WIDE_PAIR(q4, q5)
POP_WIDE_PAIR(q2, q3)
POP_WIDE_PAIR(q0, q1)

POP_PAIR(x8, lr)
POP_PAIR(x6, x7)
POP_PAIR(x4, x5)
POP_PAIR(x2, x3)
POP_PAIR(x0, x1)

br lr

.cfi_endproc
42 changes: 42 additions & 0 deletions arch/osx/aarch64/trampoline.S.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2018-2025 Yury Gribov
*
* The MIT License (MIT)
*
* Use of this source code is governed by MIT license that can be
* found in the LICENSE.txt file.
*/

.globl _$sym
.p2align 4
#ifndef IMPLIB_EXPORT_SHIMS
.private_extern _$sym
#endif
_$sym:
.cfi_startproc

1:
// Load address via Mach-O PAGE/PAGEOFF directives
adrp ip0, (__${lib_suffix}_tramp_table + $offset)@PAGE
ldr ip0, [ip0, (__${lib_suffix}_tramp_table + $offset)@PAGEOFF]

cbz ip0, 2f

// Fast path
br ip0

2:
// Slow path
mov ip0, #($number & 0xffff)
#if $number > 0xffff
movk ip0, #($number >> 16), lsl #16
#endif
stp ip0, lr, [sp, #-16]!
.cfi_adjust_cfa_offset 16
.cfi_rel_offset lr, 8
bl __${lib_suffix}_save_regs_and_resolve
ldp xzr, lr, [sp], #16
.cfi_adjust_cfa_offset -16
.cfi_restore lr
br ip0
.cfi_endproc
Loading