Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jul 2023 23:37:54 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 92053e4f8ae5 - main - share/mk: Pass -znoexecstack to ld.bfd when linking libraries and programs.
Message-ID:  <202307202337.36KNbspb017454@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhb:

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

commit 92053e4f8ae5f6659db7a8fae016f46bb5447bf8
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-07-20 23:36:35 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-07-20 23:37:46 +0000

    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
---
 share/mk/bsd.lib.mk  | 2 ++
 share/mk/bsd.prog.mk | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index dfaf554a3619..a58114af43c4 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -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"
diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
index 6f1079944914..f61331aeaa90 100644
--- a/share/mk/bsd.prog.mk
+++ b/share/mk/bsd.prog.mk
@@ -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"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307202337.36KNbspb017454>