HomeFreeBSD

kern linker: Don't invoke dtors without having invoked ctors

Description

kern linker: Don't invoke dtors without having invoked ctors

I have a kernel module which fails to load because of an unrecognized
relocation type. link_elf_load_file() fails before the module's ctors
are invoked and it calls linker_file_unload(), which causes the module's
dtors to be executed, resulting in a kernel panic.

Add a flag to the linker file to ensure that dtors are not invoked if
unloading due to an error prior to ctors being invoked.

At the moment I only implemented this for link_elf_obj.c since
link_elf.c doesn't invoke dtors, but I refactored link_elf.c to make
them more similar.

Fixes: 9e575fadf491 ("link_elf_obj: Invoke fini callbacks")
Reviewed by: zlei, kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D44559

Details

Provenance
markjAuthored on Mar 31 2024, 6:14 PM
Reviewer
zlei
Differential Revision
D44559: linker: Don't invoke dtors without having invoked ctors
Parents
rG43b4da44118e: ptrace tests: Add a test using PROC_REAP_KILL to kill a traced debuggee
Branches
Unknown
Tags
Unknown