Page MenuHomeFreeBSD

linker: Recognize SHT_INIT_ARRAY sections as constructor sections
ClosedPublic

Authored by markj on Jul 14 2026, 11:09 PM.
Tags
None
Referenced Files
F167615677: D58245.diff
Sun, Aug 23, 4:30 AM
Unknown Object (File)
Fri, Aug 21, 3:07 PM
Unknown Object (File)
Mon, Aug 17, 9:22 PM
Unknown Object (File)
Mon, Aug 17, 8:47 PM
Unknown Object (File)
Sun, Aug 16, 5:45 AM
Unknown Object (File)
Thu, Aug 13, 10:44 PM
Unknown Object (File)
Thu, Aug 13, 8:30 PM
Unknown Object (File)
Mon, Aug 10, 1:54 AM
Subscribers

Details

Summary

We do this already for ET_REL files, but it was missed here. Note that
this function operates only on dynamically loaded files, not on
preloaded files.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib added inline comments.
sys/kern/link_elf.c
1311

In theory there could be both init and initarray

This revision is now accepted and ready to land.Jul 15 2026, 1:35 PM
sys/kern/link_elf.c
1311

My motivation is really just to handle a specific case where .init_array is added by KASAN. We are not executing constructors for the kernel since for some reason we rely on the loader to pass them down in module metadata.