summaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-05-20 14:59:05 +0930
committerAlan Modra <amodra@gmail.com>2022-05-20 16:11:25 +0930
commitbd7d326debef642c0a98f859807d794d8d68afc7 (patch)
treee590bc7d3c850d6742191d435ada233a4631e50c /ld
parentef5d515048ba13a06815c8fccc420e6e8098da03 (diff)
Tidy warn-execstack handling
Make ld and bfd values consistent by swapping values 0 and 2 in link_info.warn_execstack. This has the benefit of making the value an "extended" boolean, with 0 meaning no warning, 1 meaning warn, other values a conditional warning. Yes, this patch introduces fails on arm/aarch64. Not a problem with this patch but an arm/aarch64 before_parse problem. bfd/ * elflink.c (bfd_elf_size_dynamic_sections): Adjust warn_execstack test. include/ * bfdlink.h (warn_execstack): Swap 0 and 2 meaning. ld/ * configure.ac (DEFAULT_LD_WARN_EXECSTACK): Use values of 0, 1, 2 consistent with link_info.warn_execstack. * ld.texi: Typo fixes. * lexsup.c (parse_args): Adjust setting of link_info.warn_execstack. (elf_static_list_options): Adjust help message conditions. * configure: Regenerate.
Diffstat (limited to 'ld')
-rwxr-xr-xld/configure9
-rw-r--r--ld/configure.ac9
-rw-r--r--ld/ld.texi4
-rw-r--r--ld/lexsup.c6
4 files changed, 13 insertions, 15 deletions
diff --git a/ld/configure b/ld/configure
index b4b0ce14ed..16db825d5a 100755
--- a/ld/configure
+++ b/ld/configure
@@ -15438,12 +15438,14 @@ fi
-ac_default_ld_warn_execstack=unset
+# By default warn when an executable stack is created due to object files
+# requesting such, not when the user specifies -z execstack.
+ac_default_ld_warn_execstack=2
# Check whether --enable-warn-execstack was given.
if test "${enable_warn_execstack+set}" = set; then :
enableval=$enable_warn_execstack; case "${enableval}" in
yes) ac_default_ld_warn_execstack=1 ;;
- no) ac_default_ld_warn_execstack=-1 ;;
+ no) ac_default_ld_warn_execstack=0 ;;
esac
fi
@@ -16997,9 +16999,6 @@ _ACEOF
-if test "${ac_default_ld_warn_execstack}" = unset; then
- ac_default_ld_warn_execstack=0
-fi
cat >>confdefs.h <<_ACEOF
#define DEFAULT_LD_WARN_EXECSTACK $ac_default_ld_warn_execstack
diff --git a/ld/configure.ac b/ld/configure.ac
index 0b29e810dd..01121480c6 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -204,13 +204,15 @@ AC_ARG_ENABLE(separate-code,
esac])
-ac_default_ld_warn_execstack=unset
+# By default warn when an executable stack is created due to object files
+# requesting such, not when the user specifies -z execstack.
+ac_default_ld_warn_execstack=2
AC_ARG_ENABLE(warn-execstack,
AS_HELP_STRING([--enable-warn-execstack],
[enable warnings when creating an executable stack]),
[case "${enableval}" in
yes) ac_default_ld_warn_execstack=1 ;;
- no) ac_default_ld_warn_execstack=-1 ;;
+ no) ac_default_ld_warn_execstack=0 ;;
esac])
ac_default_ld_warn_rwx_segments=unset
@@ -531,9 +533,6 @@ AC_DEFINE_UNQUOTED(DEFAULT_LD_Z_SEPARATE_CODE,
[Define to 1 if you want to enable -z separate-code in ELF linker by default.])
-if test "${ac_default_ld_warn_execstack}" = unset; then
- ac_default_ld_warn_execstack=0
-fi
AC_DEFINE_UNQUOTED(DEFAULT_LD_WARN_EXECSTACK,
$ac_default_ld_warn_execstack,
[Define to 1 if you want to enable --warn-execstack in ELF linker by default.])
diff --git a/ld/ld.texi b/ld/ld.texi
index 8cad847814..a2b162ce5b 100644
--- a/ld/ld.texi
+++ b/ld/ld.texi
@@ -2654,7 +2654,7 @@ object file formats. For formats like COFF or ELF, the linker can not
detect the use of global constructors.
@kindex --warn-execstack
-@cindex warnings, on exectuable stack
+@cindex warnings, on executable stack
@cindex executable stack, warnings on
@item --warn-execstack
@itemx --no-warn-execstack
@@ -2667,7 +2667,7 @@ line option has been used, but this behaviour can be overridden by the
On the other hand the linker will normally warn if the stack is made
executable because one or more of the input files need an execuable
stack and neither of the @command{-z execstack} or @command{-z
-noexecstack} comman line options have been specified. This warning
+noexecstack} command line options have been specified. This warning
can be disabled via the @command{--no-warn-execstack} option.
Note: ELF format input files specify that they need an executable
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 7819047290..82c459adb5 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -927,7 +927,7 @@ parse_args (unsigned argc, char **argv)
link_info.warn_execstack = 1;
break;
case OPTION_NO_WARN_EXECSTACK:
- link_info.warn_execstack = 2;
+ link_info.warn_execstack = 0;
break;
case OPTION_WARN_RWX_SEGMENTS:
link_info.no_warn_rwx_segments = 0;
@@ -2169,14 +2169,14 @@ elf_static_list_options (FILE *file)
-z execstack Mark executable as requiring executable stack\n"));
fprintf (file, _("\
-z noexecstack Mark executable as not requiring executable stack\n"));
-#if DEFAULT_LD_WARN_EXECSTACK > 0
+#if DEFAULT_LD_WARN_EXECSTACK == 1
fprintf (file, _("\
--warn-execstack Generate a warning if the stack is executable (default)\n"));
#else
fprintf (file, _("\
--warn-execstack Generate a warning if the stack is executable\n"));
#endif
-#if DEFAULT_LD_WARN_EXECSTACK < 0
+#if DEFAULT_LD_WARN_EXECSTACK == 0
fprintf (file, _("\
--no-warn-execstack Do not generate a warning if the stack is executable (default)\n"));
#else