git: 3cce838c60fc - stable/14 - rtld: use generated map file to check for some leaks from libc into rtld

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 07 Mar 2024 00:35:00 UTC
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=3cce838c60fcda9aacf249d1172bff7f78c4bf3b

commit 3cce838c60fcda9aacf249d1172bff7f78c4bf3b
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-02-28 23:40:41 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-03-07 00:34:34 +0000

    rtld: use generated map file to check for some leaks from libc into rtld
    
    (cherry picked from commit 5db5c6c87a75f8b1871f021726fc4697253ae5cf)
---
 libexec/rtld-elf/Makefile | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile
index cc40b839024f..37c3840538d5 100644
--- a/libexec/rtld-elf/Makefile
+++ b/libexec/rtld-elf/Makefile
@@ -79,6 +79,25 @@ MAPFILE=	ld-elf.so.1.map
 LDFLAGS+=	-Wl,-Map=${MAPFILE} -Wl,--cref
 CLEANFILES+=	${MAPFILE}
 
+afterbuild:
+	@if grep __libsys_interposing ${MAPFILE} >/dev/null ; then \
+		echo "libsys_interposing leaked" 1>&2 ; \
+		exit 1 ; \
+	fi
+	@if grep __libc_interposing ${MAPFILE} >/dev/null ; then \
+		echo "libc_interposing leaked" 1>&2 ; \
+		exit 1 ; \
+	fi
+	@if grep xlocale ${MAPFILE} >/dev/null ; then \
+		echo "xlocale leaked" 1>&2 ; \
+		exit 1 ; \
+	fi
+	@if grep fprintf ${MAPFILE} >/dev/null ; then \
+		echo "stdio leaked" 1>&2 ; \
+		exit 1 ; \
+	fi
+
+
 # Since moving rtld-elf to /libexec, we need to create a symlink.
 # Fixup the existing binary that's there so we can symlink over it.
 beforeinstall: