Skip to content
Open
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
10 changes: 9 additions & 1 deletion src/nix/plthook/plthook_osx.c
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ int plthook_replace(plthook_t *plthook, const char *funcname, void *funcaddr, vo
const char *name;
void **addr;
int rv;
int matches = 0;

if (plthook == NULL) {
set_errmsg("invalid argument: The first argument is null.");
Expand Down Expand Up @@ -1013,7 +1014,12 @@ int plthook_replace(plthook_t *plthook, const char *funcname, void *funcaddr, vo
}
continue;
matched:
if (oldfunc) {
/* A symbol can appear as more than one PLT/lazy-bind entry (observed
on arm64 builds where the classic-bind fallback produces duplicate
stub slots). Patch every matching entry instead of stopping at the
first, since the real call site may resolve through a later one. */
matches++;
if (oldfunc && matches == 1) {
*oldfunc = *addr;
}
if (plthook->readonly_segment) {
Expand All @@ -1028,6 +1034,8 @@ int plthook_replace(plthook_t *plthook, const char *funcname, void *funcaddr, vo
} else {
*addr = funcaddr;
}
}
if (matches > 0) {
return 0;
}
if (rv == EOF) {
Expand Down