git: 50c64df2a173 - main - Revert "libkldelf: add a private library for kernel/kld-related ELF parsing"

From: Ka Ho Ng <khng_at_FreeBSD.org>
Date: Tue, 08 Oct 2024 19:40:31 UTC
The branch main has been updated by khng:

URL: https://cgit.FreeBSD.org/src/commit/?id=50c64df2a1739dca84c0e3bc795b70e5991b7010

commit 50c64df2a1739dca84c0e3bc795b70e5991b7010
Author:     Ka Ho Ng <khng@FreeBSD.org>
AuthorDate: 2024-10-08 19:40:20 +0000
Commit:     Ka Ho Ng <khng@FreeBSD.org>
CommitDate: 2024-10-08 19:40:20 +0000

    Revert "libkldelf: add a private library for kernel/kld-related ELF parsing"
    
    This reverts commit 0a2cfd653e86ac41c4e6e32a449d133c0ee6d677.
---
 Makefile.inc1                                    | 11 ++---------
 lib/Makefile                                     |  1 -
 lib/libkldelf/Makefile                           | 21 ---------------------
 lib/libkldelf/Makefile.depend                    | 16 ----------------
 share/mk/src.libnames.mk                         |  2 --
 usr.sbin/kldxref/Makefile                        | 13 +++++++++----
 {lib/libkldelf => usr.sbin/kldxref}/ef.c         |  2 +-
 lib/libkldelf/kldelf.h => usr.sbin/kldxref/ef.h  |  6 +++---
 {lib/libkldelf => usr.sbin/kldxref}/ef_aarch64.c |  2 +-
 {lib/libkldelf => usr.sbin/kldxref}/ef_amd64.c   |  2 +-
 {lib/libkldelf => usr.sbin/kldxref}/ef_arm.c     |  2 +-
 {lib/libkldelf => usr.sbin/kldxref}/ef_i386.c    |  2 +-
 {lib/libkldelf => usr.sbin/kldxref}/ef_mips.c    |  2 +-
 {lib/libkldelf => usr.sbin/kldxref}/ef_obj.c     |  2 +-
 {lib/libkldelf => usr.sbin/kldxref}/ef_powerpc.c |  2 +-
 {lib/libkldelf => usr.sbin/kldxref}/ef_riscv.c   |  2 +-
 {lib/libkldelf => usr.sbin/kldxref}/elf.c        |  2 +-
 usr.sbin/kldxref/kldxref.c                       |  2 +-
 18 files changed, 25 insertions(+), 67 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 118e864b69b8..557bbc825625 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -2509,12 +2509,8 @@ ${_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_libkldelf_depend}
+${_bt}-usr.sbin/kldxref: ${_bt_libelf_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
@@ -2777,7 +2773,6 @@ bootstrap-tools: ${_bt}-links .PHONY
     ${_cat} \
     ${_kbdcontrol} \
     ${_elftoolchain_libs} \
-    ${_libkldelf} \
     ${_kldxref} \
     lib/libopenbsd \
     usr.bin/mandoc \
@@ -3221,8 +3216,7 @@ _prebuild_libs=	${_kerberos5_lib_libasn1} \
 		lib/libfigpar \
 		${_lib_libgssapi} \
 		lib/libjail \
-		lib/libkiconv lib/libkldelf lib/libkvm \
-		lib/liblzma lib/libmd lib/libnv \
+		lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
 		lib/libzstd \
 		${_lib_casper} \
 		lib/ncurses/tinfo \
@@ -3257,7 +3251,6 @@ _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"
diff --git a/lib/Makefile b/lib/Makefile
index e4a4aa95a1ef..221eac74ee26 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -66,7 +66,6 @@ SUBDIR=	${SUBDIR_BOOTSTRAP} \
 	libiscsiutil \
 	libjail \
 	libkiconv \
-	libkldelf \
 	libkvm \
 	liblua \
 	liblzma \
diff --git a/lib/libkldelf/Makefile b/lib/libkldelf/Makefile
deleted file mode 100644
index 0d1716f17fca..000000000000
--- a/lib/libkldelf/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-.include <bsd.own.mk>
-
-PACKAGE=	runtime
-LIB=		kldelf
-PRIVATELIB=	yes
-
-SRCS=	ef.c \
-	ef_obj.c \
-	elf.c \
-	ef_aarch64.c \
-	ef_arm.c \
-	ef_amd64.c \
-	ef_i386.c \
-	ef_mips.c \
-	ef_powerpc.c \
-	ef_riscv.c
-WARNS?=	2
-
-LIBADD=	elf
-
-.include <bsd.lib.mk>
diff --git a/lib/libkldelf/Makefile.depend b/lib/libkldelf/Makefile.depend
deleted file mode 100644
index b0aa274151ad..000000000000
--- a/lib/libkldelf/Makefile.depend
+++ /dev/null
@@ -1,16 +0,0 @@
-# Autogenerated - do NOT edit!
-
-DIRDEPS = \
-	include \
-	include/xlocale \
-	lib/${CSU_DIR} \
-	lib/libc \
-	lib/libcompiler_rt \
-	lib/libelf \
-
-
-.include <dirdeps.mk>
-
-.if ${DEP_RELDIR} == ${_DEP_RELDIR}
-# local dependencies - needed for -jN in clean tree
-.endif
diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk
index 092e1b444beb..1e0a04e83fe3 100644
--- a/share/mk/src.libnames.mk
+++ b/share/mk/src.libnames.mk
@@ -27,7 +27,6 @@ _PRIVATELIBS=	\
 		gtest_main \
 		heimipcc \
 		heimipcs \
-		kldelf \
 		ldns \
 		sqlite3 \
 		ssh \
@@ -313,7 +312,6 @@ _DP_bsnmp=	crypto
 .endif
 _DP_geom=	bsdxml sbuf
 _DP_cam=	sbuf
-_DP_kldelf=	elf
 _DP_kvm=	elf
 _DP_casper=	nv
 _DP_cap_dns=	nv
diff --git a/usr.sbin/kldxref/Makefile b/usr.sbin/kldxref/Makefile
index c41517a78904..fc9b0b4215fc 100644
--- a/usr.sbin/kldxref/Makefile
+++ b/usr.sbin/kldxref/Makefile
@@ -1,12 +1,17 @@
 PACKAGE=	runtime
 PROG=	kldxref
 MAN=	kldxref.8
-SRCS=	kldxref.c
-
-CFLAGS+=-I${SRCTOP}/lib/libkldelf
+SRCS=	kldxref.c ef.c ef_obj.c elf.c
+SRCS+=	ef_aarch64.c \
+	ef_arm.c \
+	ef_amd64.c \
+	ef_i386.c \
+	ef_mips.c \
+	ef_powerpc.c \
+	ef_riscv.c
 
 WARNS?=	2
 
-LIBADD=	elf kldelf
+LIBADD=	elf
 
 .include <bsd.prog.mk>
diff --git a/lib/libkldelf/ef.c b/usr.sbin/kldxref/ef.c
similarity index 99%
rename from lib/libkldelf/ef.c
rename to usr.sbin/kldxref/ef.c
index 052798ee31e4..975626e46046 100644
--- a/lib/libkldelf/ef.c
+++ b/usr.sbin/kldxref/ef.c
@@ -41,7 +41,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "kldelf.h"
+#include "ef.h"
 
 #define	MAXSEGS 16
 struct ef_file {
diff --git a/lib/libkldelf/kldelf.h b/usr.sbin/kldxref/ef.h
similarity index 99%
rename from lib/libkldelf/kldelf.h
rename to usr.sbin/kldxref/ef.h
index e0a8cc627ff2..9d3dc1b1b435 100644
--- a/lib/libkldelf/kldelf.h
+++ b/usr.sbin/kldxref/ef.h
@@ -32,8 +32,8 @@
  * SUCH DAMAGE.
  */
 
-#ifndef _KLDELF_H_
-#define _KLDELF_H_
+#ifndef _EF_H_
+#define _EF_H_
 
 #include <sys/linker_set.h>
 #include <stdbool.h>
@@ -312,4 +312,4 @@ int	elf_reloc(struct elf_file *ef, const void *reldata, Elf_Type reltype,
 
 __END_DECLS
 
-#endif /* _KLDELF_H_*/
+#endif /* _EF_H_*/
diff --git a/lib/libkldelf/ef_aarch64.c b/usr.sbin/kldxref/ef_aarch64.c
similarity index 99%
rename from lib/libkldelf/ef_aarch64.c
rename to usr.sbin/kldxref/ef_aarch64.c
index d2db29f22891..b61de3b032ab 100644
--- a/lib/libkldelf/ef_aarch64.c
+++ b/usr.sbin/kldxref/ef_aarch64.c
@@ -31,7 +31,7 @@
 #include <errno.h>
 #include <gelf.h>
 
-#include "kldelf.h"
+#include "ef.h"
 
 /*
  * Apply relocations to the values obtained from the file. `relbase' is the
diff --git a/lib/libkldelf/ef_amd64.c b/usr.sbin/kldxref/ef_amd64.c
similarity index 99%
rename from lib/libkldelf/ef_amd64.c
rename to usr.sbin/kldxref/ef_amd64.c
index 7295835f75b3..fde032dcabc2 100644
--- a/lib/libkldelf/ef_amd64.c
+++ b/usr.sbin/kldxref/ef_amd64.c
@@ -33,7 +33,7 @@
 #include <errno.h>
 #include <gelf.h>
 
-#include "kldelf.h"
+#include "ef.h"
 
 /*
  * Apply relocations to the values obtained from the file. `relbase' is the
diff --git a/lib/libkldelf/ef_arm.c b/usr.sbin/kldxref/ef_arm.c
similarity index 99%
rename from lib/libkldelf/ef_arm.c
rename to usr.sbin/kldxref/ef_arm.c
index 657294dc9fb0..cc5e265f821e 100644
--- a/lib/libkldelf/ef_arm.c
+++ b/usr.sbin/kldxref/ef_arm.c
@@ -34,7 +34,7 @@
 #include <errno.h>
 #include <gelf.h>
 
-#include "kldelf.h"
+#include "ef.h"
 
 /*
  * Apply relocations to the values obtained from the file. `relbase' is the
diff --git a/lib/libkldelf/ef_i386.c b/usr.sbin/kldxref/ef_i386.c
similarity index 99%
rename from lib/libkldelf/ef_i386.c
rename to usr.sbin/kldxref/ef_i386.c
index ae571e2d50f2..962ed2bc0664 100644
--- a/lib/libkldelf/ef_i386.c
+++ b/usr.sbin/kldxref/ef_i386.c
@@ -33,7 +33,7 @@
 #include <errno.h>
 #include <gelf.h>
 
-#include "kldelf.h"
+#include "ef.h"
 
 /*
  * Apply relocations to the values obtained from the file. `relbase' is the
diff --git a/lib/libkldelf/ef_mips.c b/usr.sbin/kldxref/ef_mips.c
similarity index 99%
rename from lib/libkldelf/ef_mips.c
rename to usr.sbin/kldxref/ef_mips.c
index 99790e11a9c3..e4aeedb5c08b 100644
--- a/lib/libkldelf/ef_mips.c
+++ b/usr.sbin/kldxref/ef_mips.c
@@ -36,7 +36,7 @@
 #include <errno.h>
 #include <gelf.h>
 
-#include "kldelf.h"
+#include "ef.h"
 
 /*
  * Apply relocations to the values obtained from the file. `relbase' is the
diff --git a/lib/libkldelf/ef_obj.c b/usr.sbin/kldxref/ef_obj.c
similarity index 99%
rename from lib/libkldelf/ef_obj.c
rename to usr.sbin/kldxref/ef_obj.c
index e09bd036b71e..ac83137cd394 100644
--- a/lib/libkldelf/ef_obj.c
+++ b/usr.sbin/kldxref/ef_obj.c
@@ -43,7 +43,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "kldelf.h"
+#include "ef.h"
 
 typedef struct {
 	GElf_Addr	addr;
diff --git a/lib/libkldelf/ef_powerpc.c b/usr.sbin/kldxref/ef_powerpc.c
similarity index 99%
rename from lib/libkldelf/ef_powerpc.c
rename to usr.sbin/kldxref/ef_powerpc.c
index 33f09c0d69ef..f72cc1d85e20 100644
--- a/lib/libkldelf/ef_powerpc.c
+++ b/usr.sbin/kldxref/ef_powerpc.c
@@ -33,7 +33,7 @@
 #include <errno.h>
 #include <gelf.h>
 
-#include "kldelf.h"
+#include "ef.h"
 
 /*
  * Apply relocations to the values obtained from the file. `relbase' is the
diff --git a/lib/libkldelf/ef_riscv.c b/usr.sbin/kldxref/ef_riscv.c
similarity index 99%
rename from lib/libkldelf/ef_riscv.c
rename to usr.sbin/kldxref/ef_riscv.c
index bda04bb2c39a..46b9b66bee58 100644
--- a/lib/libkldelf/ef_riscv.c
+++ b/usr.sbin/kldxref/ef_riscv.c
@@ -36,7 +36,7 @@
 #include <errno.h>
 #include <gelf.h>
 
-#include "kldelf.h"
+#include "ef.h"
 
 /*
  * Apply relocations to the values obtained from the file. `relbase' is the
diff --git a/lib/libkldelf/elf.c b/usr.sbin/kldxref/elf.c
similarity index 99%
rename from lib/libkldelf/elf.c
rename to usr.sbin/kldxref/elf.c
index da319ffc6c98..f98c39b69c0b 100644
--- a/lib/libkldelf/elf.c
+++ b/usr.sbin/kldxref/elf.c
@@ -44,7 +44,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "kldelf.h"
+#include "ef.h"
 
 SET_DECLARE(elf_reloc, struct elf_reloc_data);
 
diff --git a/usr.sbin/kldxref/kldxref.c b/usr.sbin/kldxref/kldxref.c
index eed754e1e730..6bb0469a9ff5 100644
--- a/usr.sbin/kldxref/kldxref.c
+++ b/usr.sbin/kldxref/kldxref.c
@@ -51,7 +51,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <kldelf.h>
+#include "ef.h"
 
 #define	MAXRECSIZE	(64 << 10)	/* 64k */
 #define check(val)	if ((error = (val)) != 0) break