git: 8d3f27908b69 - stable/13 - stand/efi: Pass --no-dynamic-linker to ld.bfd >= 2.34.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 11 May 2022 00:30:04 UTC
The branch stable/13 has been updated by jhb:

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

commit 8d3f27908b69d47f4e669d8fe424c79f6da33880
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-02-02 20:18:43 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-05-11 00:06:26 +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
    
    (cherry picked from commit 8bd5e2f15cc9756e7d6b7feb43ec47f18a38e2bf)
---
 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 39dc4f8e70ad..6ed777727552 100644
--- a/stand/efi/boot1/Makefile
+++ b/stand/efi/boot1/Makefile
@@ -65,6 +65,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