git: aa2cddc0d21d - stable/12 - Link efi programs with -pie rather than -shared

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Fri, 08 Oct 2021 16:09:09 UTC
The branch stable/12 has been updated by kevans:

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

commit aa2cddc0d21d7411121740efdf4d69c1c743ce4b
Author:     Alex Richardson <arichardson@FreeBSD.org>
AuthorDate: 2020-10-12 11:27:08 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2021-10-08 08:12:10 +0000

    Link efi programs with -pie rather than -shared
    
    This was causing build failures in CheriBSD where we were passing -pie
    already by default.
    
    Reviewed By:    andrew
    Differential Revision: https://reviews.freebsd.org/D24787
    
    (cherry picked from commit 253e820a4db794c4c5e39e8e6d6bf2775f25d0cc)
---
 stand/efi/boot1/Makefile  | 2 +-
 stand/efi/loader/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/stand/efi/boot1/Makefile b/stand/efi/boot1/Makefile
index d4ac55598bb7..bf3860f36b5d 100644
--- a/stand/efi/boot1/Makefile
+++ b/stand/efi/boot1/Makefile
@@ -65,7 +65,7 @@ FILES=	${BOOT1}.efi ${BOOT1}.efifat
 FILESMODE_${BOOT1}.efi=	${BINMODE}
 
 LDSCRIPT=	${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE}
-LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared
+LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie
 
 .if ${MACHINE_CPUARCH} == "aarch64"
 CFLAGS+=	-mgeneral-regs-only
diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile
index 6ee613e7bfea..993a869ab13e 100644
--- a/stand/efi/loader/Makefile
+++ b/stand/efi/loader/Makefile
@@ -84,7 +84,7 @@ LINKS+=		${BINDIR}/${LOADER}.efi ${BINDIR}/loader.efi
 .endif
 
 LDSCRIPT=	${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE}
-LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared
+LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie
 
 CLEANFILES+=	loader.efi