kldinfo: utility to display module objects deps and version info

From: Ruslan Zalata <rz_at_fabmicro.ru>
Date: Fri, 25 Sep 2026 01:13:15 UTC
Hello All!

Playing with FreeBSD kernels, hacking driver code and debugging issues 
on laptops sometimes require knowledge of what KObjs are stored in 
kernel module file, their dependencies and, what's more important, for 
what version of kernel a particular module is built! Remember recent 
vboxdrv.ko version mismatch issue ?

Getting FreeBSD kernel module version info is a bit hacky. One of the 
ways involves using "nm" or "readelf" to get a list of special symbols, 
namely "_depend_on_" and "_version", then using "objdump" to get to 
.data section, then using "hexdump" to extract and fine-print version 
info. One also needs to write a script to glue these tools together, 
otherwise it's too easy make a mistake and get wrong data. After some 
time of struggling with this issue, I wrote mine in C, called "kldinfo". 
:-)

This as simple as a nail "kldinfo" utility behaves like "kldload", but 
instead of loading module it dumps list of objects it finds in module 
file along with their corresponding version and dependency info.

I propose to include "kldinfo" in FreeBSD base along with the other 
"kld*" utils. Note, a similar utility called "modinfo" has been present 
in most Linux distros for decades. I think we should have it in FreeBSD 
too. ;-) If that is ok, I will upload source code for review to 
Phabricator.

Repo: https://github.com/pointcheck/kldinfo.git

PS:

The code is fully written by hand, no LLMs have been involved.

-- 
Regards,
Ruslan