git: fd5a82ecd2a6 - stable/13 - rtld: unconditionally generate map file during build

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

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

commit fd5a82ecd2a6f51dde00459854f92066b23c3be4
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-02-28 00:04:37 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-03-06 07:42:42 +0000

    rtld: unconditionally generate map file during build
    
    (cherry picked from commit 799940154c70597a46627deb4d0b98e174b27b98)
---
 libexec/rtld-elf/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile
index b95adf82fe9b..def8bb513b3b 100644
--- a/libexec/rtld-elf/Makefile
+++ b/libexec/rtld-elf/Makefile
@@ -69,6 +69,12 @@ SYMBOL_MAPS+=	${RTLD_ELF_DIR}/${RTLD_ARCH}/Symbol.map
 .sinclude "${RTLD_ELF_DIR}/${RTLD_ARCH}/Makefile.inc"
 RTLD_ENTRY?=	.rtld_start
 
+# Always produce the map file so that may be inspected to confirm
+# undesired code is not linked from libsys/libc.
+MAPFILE=	ld-elf.so.1.map
+LDFLAGS+=	-Wl,-Map=${MAPFILE} -Wl,--cref
+CLEANFILES+=	${MAPFILE}
+
 # 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: