From 9c46bdbfb161a06b5a3c0559abb456961ca519f9 Mon Sep 17 00:00:00 2001
From: midipix <writeonce@midipix.org>
Date: Sat, 9 Mar 2024 22:43:23 +0000
Subject: link mode: --disable-shared: also delete the associated .expsyms.a
 archive.

---
 src/internal/slibtool_symlink_impl.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/internal/slibtool_symlink_impl.c b/src/internal/slibtool_symlink_impl.c
index 019d3d6..06751c7 100644
--- a/src/internal/slibtool_symlink_impl.c
+++ b/src/internal/slibtool_symlink_impl.c
@@ -34,6 +34,7 @@ slbt_hidden int slbt_create_symlink(
 	char **		oargv;
 	const char *	slash;
 	char *		ln[5];
+	char *          dot;
 	char *		dotdot;
 	char		tmplnk [PATH_MAX];
 	char		lnkarg [PATH_MAX];
@@ -82,10 +83,22 @@ slbt_hidden int slbt_create_symlink(
 	fdcwd = slbt_driver_fdcwd(dctx);
 
 	/* placeholder? */
-	if (fdevnull)
+	if (fdevnull) {
 		if (unlinkat(fdcwd,lnkname,0) && (errno != ENOENT))
 			return SLBT_SYSTEM_ERROR(dctx,0);
 
+		if ((dot = strrchr(lnkname,'.'))) {
+			if (!strcmp(dot,dctx->cctx->settings.dsosuffix)) {
+				strcpy(dot,".expsyms.a");
+
+				if (unlinkat(fdcwd,lnkname,0) && (errno != ENOENT))
+					return SLBT_SYSTEM_ERROR(dctx,0);
+
+				strcpy(dot,dctx->cctx->settings.dsosuffix);
+			}
+		}
+	}
+
 	if (suffix) {
 		sprintf(alnkarg,"%s%s",lnkname,suffix);
 		lnkname = alnkarg;
-- 
cgit v1.2.3