libkldelf: add a private library for kernel/kld-related ELF parsing

The libkldelf library was originally a part of kldxref(8). It exposed
ELF parsing helpers specialized in parsing KLDs and the kernel
executable. The library can be used to read metadata such as linker_set,
mod_depend, mod_version and PNP match info, and raw data from the ELF.

To promote the reuse of the facilities the ELF parsing code is separated
from kldxref(8) into a new private library.

kldxref(8) is modified to link against the libkldelf library.

Sponsored by:	Juniper Networks, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D46719
This commit is contained in:
Ka Ho Ng
2024-10-08 04:24:07 +00:00
parent 6c711019f2
commit 0a2cfd653e
18 changed files with 67 additions and 25 deletions
+9 -2
View File
@@ -2509,8 +2509,12 @@ ${_bt}-lib/libdwarf: ${_bt_m4_depend}
_bt_libelf_depend=${_bt}-lib/libelf
.endif
_libkldelf= lib/libkldelf
${_bt}-lib/libkldelf: ${_bt_libelf_depend}
_bt_libkldelf_depend=${_bt}-lib/libkldelf
_kldxref= usr.sbin/kldxref
${_bt}-usr.sbin/kldxref: ${_bt_libelf_depend}
${_bt}-usr.sbin/kldxref: ${_bt_libelf_depend} ${_bt_libkldelf_depend}
# flua is required to regenerate syscall files. It first appeared during the
# 13.0-CURRENT cycle, thus needs to be built on -older releases and stable
@@ -2773,6 +2777,7 @@ bootstrap-tools: ${_bt}-links .PHONY
${_cat} \
${_kbdcontrol} \
${_elftoolchain_libs} \
${_libkldelf} \
${_kldxref} \
lib/libopenbsd \
usr.bin/mandoc \
@@ -3216,7 +3221,8 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \
lib/libfigpar \
${_lib_libgssapi} \
lib/libjail \
lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
lib/libkiconv lib/libkldelf lib/libkvm \
lib/liblzma lib/libmd lib/libnv \
lib/libzstd \
${_lib_casper} \
lib/ncurses/tinfo \
@@ -3251,6 +3257,7 @@ _prebuild_libs+= lib/libregex
.endif
lib/libgeom__L: lib/libexpat__L lib/libsbuf__L
lib/libkldelf__L: lib/libelf__L
lib/libkvm__L: lib/libelf__L
.if ${MK_RADIUS_SUPPORT} != "no"