ld: Turn on --error-execstack for --warn-execstack --fatal-warnings
Checks
Commit Message
Since --fatal-warnings always turns a warning to an error, turn on
--error-execstack for --warn-execstack --fatal-warnings and override
--no-error-execstack.
PR ld/31299
* lexsup.c (parse_args): Override --no-error-execstack and turn
on --error-execstack for --warn-execstack --fatal-warnings.
* testsuite/ld-elf/elf.exp: Run PR ld/31299 test.
* testsuite/ld-elf/pr31299.error: New file.
---
ld/lexsup.c | 5 +++++
ld/testsuite/ld-elf/elf.exp | 8 ++++++++
ld/testsuite/ld-elf/pr31299.error | 2 ++
3 files changed, 15 insertions(+)
create mode 100644 ld/testsuite/ld-elf/pr31299.error
@@ -1947,6 +1947,11 @@ parse_args (unsigned argc, char **argv)
&& command_line.check_section_addresses < 0)
command_line.check_section_addresses = 0;
+ /* Override --no-error-execstack and turn on --error-execstack for
+ --warn-execstack --fatal-warnings. */
+ if (link_info.warn_execstack && config.fatal_warnings)
+ link_info.error_execstack = 1;
+
if (export_list)
{
struct bfd_elf_version_expr *head = export_list->head.list;
@@ -318,6 +318,14 @@ if { [istarget *-*-*linux*]
{pr29072-b.s} \
{{ld pr29072.b.warn}} \
"pr29072-b.exe"] \
+ [list "PR ld/31299 (error about absent .note.GNU-stack)" \
+ "-e 0 -z stack-size=0x123400 --warn-execstack \
+ --fatal-warnings --no-error-execstack" \
+ "" \
+ "" \
+ {pr29072-b.s} \
+ {{ld pr31299.error}} \
+ "pr31299.exe"] \
]
} else {
run_ld_link_tests [list \
new file mode 100644
@@ -0,0 +1,2 @@
+.*: error: .*\.o: is triggering the generation of an executable stack because it does not have a \.note\.GNU-stack section
+.*: failed to set dynamic section sizes: file format not recognized