git: 8b84d2da9aac - stable/13 - 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:34 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=8b84d2da9aac3a79be02570f2bc1ed301f03ce8e

commit 8b84d2da9aac3a79be02570f2bc1ed301f03ce8e
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-02-28 23:40:41 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-03-06 07:42:42 +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 def8bb513b3b..4735ad774aa1 100644
--- a/libexec/rtld-elf/Makefile
+++ b/libexec/rtld-elf/Makefile
@@ -75,6 +75,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: