From 6f477a3ea989f0562514cbcdc282982018c55879 Mon Sep 17 00:00:00 2001
From: midipix <writeonce@midipix.org>
Date: Wed, 28 Feb 2024 07:25:27 +0000
Subject: slbt_ar_create_dlsyms(): obtain symbol information (via nm) as
 needed.

---
 src/arbits/slbt_archive_dlsyms.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

(limited to 'src')

diff --git a/src/arbits/slbt_archive_dlsyms.c b/src/arbits/slbt_archive_dlsyms.c
index 453d4b6..5fd007c 100644
--- a/src/arbits/slbt_archive_dlsyms.c
+++ b/src/arbits/slbt_archive_dlsyms.c
@@ -328,6 +328,8 @@ static int slbt_ar_create_dlsyms_impl(
 	mode_t                            mode)
 {
 	int                               ret;
+	struct slbt_archive_ctx **        actx;
+	struct slbt_exec_ctx *            ectx;
 	struct slbt_archive_meta_impl *   mctx;
 	const struct slbt_driver_ctx *    dctx;
 	struct slbt_fd_ctx                fdctx;
@@ -335,6 +337,7 @@ static int slbt_ar_create_dlsyms_impl(
 
 	mctx = slbt_archive_meta_ictx(arctxv[0]->meta);
 	dctx = mctx->dctx;
+	ectx = 0;
 
 	if (slbt_lib_get_driver_fdctx(dctx,&fdctx) < 0)
 		return SLBT_NESTED_ERROR(dctx);
@@ -349,6 +352,21 @@ static int slbt_ar_create_dlsyms_impl(
 		fdout = fdctx.fdout;
 	}
 
+	for (actx=arctxv; *actx; actx++) {
+		mctx = slbt_archive_meta_ictx((*actx)->meta);
+
+		if (!mctx->syminfo && !ectx)
+			if (slbt_ectx_get_exec_ctx(dctx,&ectx) < 0)
+				return SLBT_NESTED_ERROR(dctx);
+
+		if (!mctx->syminfo)
+			if (slbt_ar_update_syminfo(*actx,ectx) < 0)
+				return SLBT_NESTED_ERROR(dctx);
+	}
+
+	if (ectx)
+		slbt_ectx_free_exec_ctx(ectx);
+
 	ret = slbt_ar_output_dlsyms_impl(
 		fdout,dctx,arctxv,dlunit);
 
-- 
cgit v1.2.3