HomeFreeBSD

linker: Avoid invoking eventhandlers on incompletely loaded files

Description

linker: Avoid invoking eventhandlers on incompletely loaded files

We do not invoke the kld_load eventhandler until after the file is fully
linked, so don't invoke the kld_unload_try or kld_unload event handlers
unless the file is fully linked either.

In my case, the dtrace SDT kld_unload_try handler was running before
relocations were processed against the file, and that caused problems
when sdt_kld_unload_probes() accesses elements of a linker set.

Move the kld_unload handler invocation earlier, to after sysuninits have
been run. This is a bit more consistent with the kld_load handler.

PR: 291238
Reviewed by: imp, emaste, kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D53938

Details

Provenance
markjAuthored on Nov 26 2025, 6:15 PM
Reviewer
imp
Differential Revision
D53938: linker: Avoid invoking eventhandlers on incompletely loaded files
Parents
rG5f529f9e292a: libc: Fix TESTSDIR for new stdbit tests
Branches
Unknown
Tags
Unknown