git: 799940154c70 - main - rtld: unconditionally generate map file during build

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 29 Feb 2024 01:54:46 UTC
The branch main has been updated by kib:

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

commit 799940154c70597a46627deb4d0b98e174b27b98
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-02-28 00:04:37 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-02-29 00:26:51 +0000

    rtld: unconditionally generate map file during build
    
    It is needed at least to ensure that undesirable code is not linked into
    rtld from libsys/libc, and adding the map file option each time is not
    productive.
    
    Reviewed by:    brooks, emaste
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D44136
---
 libexec/rtld-elf/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile
index fe7e39a6b788..cc40b839024f 100644
--- a/libexec/rtld-elf/Makefile
+++ b/libexec/rtld-elf/Makefile
@@ -73,6 +73,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: