git: 8bd5e2f15cc9 - main - stand/efi: Pass --no-dynamic-linker to ld.bfd >= 2.34.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 02 Feb 2022 20:19:22 UTC
The branch main has been updated by jhb:

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

commit 8bd5e2f15cc9756e7d6b7feb43ec47f18a38e2bf
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-02-02 20:18:43 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-02-02 20:18:43 +0000

    stand/efi: Pass --no-dynamic-linker to ld.bfd >= 2.34.
    
    ld.bfd in binutils 2.34+ now reports an error in more cases for custom
    ldscripts that do not place PHDRs in a LOAD segment.  However, EFI
    binaries are not dynamic binaries which need PHDRs, so pass
    --no-dynamic-linker to disable this check.
    
    Reviewed by:    imp, emaste
    Differential Revision:  https://reviews.freebsd.org/D34124
---
 stand/efi/boot1/Makefile  | 3 +++
 stand/efi/loader/Makefile | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/stand/efi/boot1/Makefile b/stand/efi/boot1/Makefile
index af03e395b2a5..7e3d762c768d 100644
--- a/stand/efi/boot1/Makefile
+++ b/stand/efi/boot1/Makefile
@@ -67,6 +67,9 @@ FILESMODE_${BOOT1}.efi=	${BINMODE}
 
 LDSCRIPT=	${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE}
 LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie
+.if ${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23400
+LDFLAGS+=	-Wl,--no-dynamic-linker
+.endif
 
 .if ${MACHINE_CPUARCH} == "aarch64"
 CFLAGS+=	-mgeneral-regs-only
diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile
index dd25c940e0e9..1edb5674712e 100644
--- a/stand/efi/loader/Makefile
+++ b/stand/efi/loader/Makefile
@@ -99,6 +99,9 @@ LINKS+=		${BINDIR}/${LOADER}.efi ${BINDIR}/loader.efi
 
 LDSCRIPT=	${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE}
 LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie
+.if ${LINKER_TYPE} == "bfd" && ${LINKER_VERSION} >= 23400
+LDFLAGS+=	-Wl,--no-dynamic-linker
+.endif
 
 CLEANFILES+=	loader.efi