Skip to content

Commit

Permalink
Don't Forget To Dereference Table Pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousTommy committed Feb 4, 2024
1 parent a1e0995 commit d370896
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ Lentry_hook:

// void* x10 = __mach_syscall_table[0-x16]
neg x10, x16 // Convert negative syscall number to positive
lsl x10, x10, #3 // x10 = x9 * 8 (size of a pointer)
add x10, x9, x10
lsl x10, x10, #3 // x10 = syscall_number * 8 (size of a pointer)
add x10, x9, x10 // x10 = __mach_syscall_table + x10
ldr x10, [x10] // x10 = *x10

// x10(...)
blr x10
Expand Down
5 changes: 3 additions & 2 deletions darling/src/libsystem_kernel/emulation/linux/syscalls-table.S
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ Lentry_hook:

// void* x10 = __bsd_syscall_table[x16]
mov x10, x16
lsl x10, x10, #3 // x10 = x9 * 8 (size of a pointer)
add x10, x9, x10
lsl x10, x10, #3 // x10 = syscall_number * 8 (size of a pointer)
add x10, x9, x10 // x10 = __bsd_syscall_table + x10
ldr x10, [x10] // x10 = *x10

// x10(...)
blr x10
Expand Down

0 comments on commit d370896

Please sign in to comment.