share/mk: Pass -znoexecstack to ld.bfd when linking libraries and programs.

lld assumes -znoexecstack by default whereas ld.bfd still defaults to
-zexecstack in the absence of .note.GNU-stack annotations.  Adding the
flags centrally avoids having to patch various libraries in the tree
as one-offs (e.g. OpenSSL 3 is the current thing generating new
warnings with ld.bfd).

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D41120
This commit is contained in:
John Baldwin 2023-07-20 16:36:35 -07:00
parent 59dc489a7e
commit 92053e4f8a
2 changed files with 4 additions and 0 deletions

View file

@ -95,6 +95,8 @@ LDFLAGS+= -Wl,-zretpolineplt
.warning Retpoline requested but not supported by compiler or linker
.endif
.endif
# LLD sensibly defaults to -znoexecstack, so do the same for BFD
LDFLAGS.bfd+= -Wl,-znoexecstack
# Initialize stack variables on function entry
.if ${MK_INIT_ALL_ZERO} == "yes"

View file

@ -68,6 +68,8 @@ LDFLAGS+= -Wl,-zretpolineplt
.warning Retpoline requested but not supported by compiler or linker
.endif
.endif
# LLD sensibly defaults to -znoexecstack, so do the same for BFD
LDFLAGS.bfd+= -Wl,-znoexecstack
# Initialize stack variables on function entry
.if ${MK_INIT_ALL_ZERO} == "yes"