The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=45f9f6ebacff41a70673fdbc305a442afff13494
commit 45f9f6ebacff41a70673fdbc305a442afff13494 Author: Warner Losh <[email protected]> AuthorDate: 2026-07-10 04:05:46 +0000 Commit: Warner Losh <[email protected]> CommitDate: 2026-07-10 04:14:51 +0000 kldxref: Add -m filag to print info about modules in one file kldxref -m <file> will print the same data that the '-d' flag produces, except restrict the output to one file. This should be the full path to the file, and the directory name to process is omitted. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D57902 --- usr.sbin/kldxref/kldxref.8 | 7 ++++++- usr.sbin/kldxref/kldxref.c | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/usr.sbin/kldxref/kldxref.8 b/usr.sbin/kldxref/kldxref.8 index 1704847592cd..c292a2338cb7 100644 --- a/usr.sbin/kldxref/kldxref.8 +++ b/usr.sbin/kldxref/kldxref.8 @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 25, 2023 +.Dd June 27, 2026 .Dt KLDXREF 8 .Os .Sh NAME @@ -35,6 +35,8 @@ .Op Fl Rdv .Op Fl f Ar hintsfile .Ar path ... +.Nm +.Fl m Ar module .Sh DESCRIPTION The .Nm @@ -67,6 +69,9 @@ output. .It Fl f Ar hintsfile Specify a different name for the hints files than .Pa linker.hints . +.It Fl m Ar module +Print information about the modules in the file +.Ar module . .It Fl v Operate in verbose mode. .El diff --git a/usr.sbin/kldxref/kldxref.c b/usr.sbin/kldxref/kldxref.c index eed754e1e730..260a0baa6405 100644 --- a/usr.sbin/kldxref/kldxref.c +++ b/usr.sbin/kldxref/kldxref.c @@ -764,13 +764,13 @@ main(int argc, char *argv[]) { FTS *ftsp; FTSENT *p; - char *dot = NULL; + char *dot = NULL, *module = NULL; int opt, fts_options; struct stat sb; fts_options = FTS_PHYSICAL; - while ((opt = getopt(argc, argv, "Rdf:v")) != -1) { + while ((opt = getopt(argc, argv, "Rdf:m:v")) != -1) { switch (opt) { case 'd': /* no hint file, only print on stdout */ dflag = true; @@ -778,6 +778,10 @@ main(int argc, char *argv[]) case 'f': /* use this name instead of linker.hints */ xref_file = optarg; break; + case 'm': + module = optarg; + dflag = true; + break; case 'v': verbose++; break; @@ -789,11 +793,18 @@ main(int argc, char *argv[]) /* NOTREACHED */ } } - if (argc - optind < 1) + if (argc - optind < (module ? 0 : 1)) usage(); argc -= optind; argv += optind; + if (module) { + if (elf_version(EV_CURRENT) == EV_NONE) + errx(1, "unsupported libelf"); + read_kld(module, module); + exit(0); + } + if (stat(argv[0], &sb) != 0) err(1, "%s", argv[0]); if ((sb.st_mode & S_IFDIR) == 0 && !dflag) {
