mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-18 08:49:29 +08:00
Add ability to change linker warning messages into errors when reporting executable stacks and/or executable segments.
include * bfdlink.h (struct bfd_link_info): Update descriptions of the 'execstack', 'noexecstack' and 'warn_execstack' fields. Add 'error_exectack' and 'warn_is_error_for_rwx_segments' fields. bfd * elf.c (assign_file_positions_except_relocs): Turn warnings about executable segments into errors if so requested. * elflink.c (bfd_elf_size_dynamic_sections): Turn warnings about executable stacks into errors if so requested. ld * ldlex.h (enum option_values): Add OPTION_ERROR_EXECSTACK, OPTION_NO_ERROR_EXECSTACK, OPTION_WARN_EXECSTACK_OBJECTS, OPTION_ERROR_RWX_SEGMENTS and OPTION_NO_ERROR_RWX_SEGMENTS. (struct ld_option): Add new long options. (parse_args): Parse new long options. (elf_static_list_options): Display the new options. * ld.texi: Document the new command line options. * configure.ac (error-execstack): New configuration option. (error-rwx-segments): New configuration option. * emultempl/elf.em (_before_parse): Initialse the new linkinfo fields. * NEWS: Mention the new features. * config.in: Regenerate. * configure: Regenerate. * testsuite/ld-elf/commonpage2.d: Disable errors for RWX segments and/or executable stacks. * testsuite/ld-elf/elf.exp: Likewise. * testsuite/ld-elf/header.d: Likewise. * testsuite/ld-elf/loadaddr1.d: Likewise. * testsuite/ld-elf/loadaddr2.d: Likewise. * testsuite/ld-elf/maxpage4.d: Likewise. * testsuite/ld-elf/nobits-1.d: Likewise. * testsuite/ld-elf/note-1.d: Likewise. * testsuite/ld-elf/orphan-10.d: Likewise. * testsuite/ld-elf/orphan-11.d: Likewise. * testsuite/ld-elf/orphan-12.d: Likewise. * testsuite/ld-elf/orphan-5.d: Likewise. * testsuite/ld-elf/orphan-7.d: Likewise. * testsuite/ld-elf/orphan-8.d: Likewise. * testsuite/ld-elf/orphan-9.d: Likewise. * testsuite/ld-elf/orphan-region.d: Likewise. * testsuite/ld-elf/orphan.d: Likewise. * testsuite/ld-elf/pr19539.d: Likewise. * testsuite/ld-elf/pr26256-1a.d: Likewise. * testsuite/ld-elf/pr26907.d: Likewise. * testsuite/ld-elf/pr28597.d: Likewise. * testsuite/ld-elf/retain2.d: Likewise. * testsuite/ld-elf/shared.exp: Likewise. * testsuite/ld-elf/size-1.d: Likewise. * testsuite/ld-elf/textaddr7.d: Likewise. * testsuite/ld-elf/warn1.d: Likewise. * testsuite/ld-elf/warn2.d: Likewise. * testsuite/ld-i386/discarded1.d: Likewise. * testsuite/ld-i386/pr19175.d: Likewise. * testsuite/ld-i386/pr19539.d: Likewise. * testsuite/ld-i386/pr23189.d: Likewise. * testsuite/ld-plugin/lto-3r.d: Likewise. * testsuite/ld-plugin/lto-5r.d: Likewise. * testsuite/ld-plugin/lto.exp: Likewise. * testsuite/ld-powerpc/ppc476-shared.d: Likewise. * testsuite/ld-powerpc/ppc476-shared2.d: Likewise. * testsuite/ld-powerpc/pr28827-2.d: Likewise. * testsuite/ld-s390/s390.exp: Likewise. * testsuite/ld-scripts/align2a.d: Likewise. * testsuite/ld-scripts/align2b.d: Likewise. * testsuite/ld-scripts/align5.d: Likewise. * testsuite/ld-scripts/alignof.exp: Likewise. * testsuite/ld-scripts/crossref.exp: Likewise. * testsuite/ld-scripts/defined2.d: Likewise. * testsuite/ld-scripts/defined3.d: Likewise. * testsuite/ld-scripts/defined5.d: Likewise. * testsuite/ld-scripts/pr14962.d: Likewise. * testsuite/ld-scripts/pr18963.d: Likewise. * testsuite/ld-scripts/pr20302.d: Likewise. * testsuite/ld-scripts/print-memory-usage.exp: Likewise. * testsuite/ld-scripts/rgn-at1.d: Likewise. * testsuite/ld-scripts/rgn-at10.d: Likewise. * testsuite/ld-scripts/rgn-at4.d: Likewise. * testsuite/ld-scripts/rgn-at6.d: Likewise. * testsuite/ld-scripts/rgn-at8.d: Likewise. * testsuite/ld-scripts/rgn-at9.d: Likewise. * testsuite/ld-scripts/rgn-over1.d: Likewise. * testsuite/ld-scripts/rgn-over2.d: Likewise. * testsuite/ld-scripts/rgn-over4.d: Likewise. * testsuite/ld-scripts/rgn-over5.d: Likewise. * testsuite/ld-scripts/rgn-over6.d: Likewise. * testsuite/ld-scripts/script.exp: Likewise. * testsuite/ld-scripts/sizeof.exp: Likewise. * testsuite/ld-scripts/sort-file.d: Likewise. * testsuite/ld-x86-64/discarded1.d: Likewise. * testsuite/ld-x86-64/pr19175.d: Likewise. * testsuite/ld-x86-64/pr19539a.d: Likewise. * testsuite/ld-x86-64/pr19539b.d: Likewise. * testsuite/ld-x86-64/pr23189.d: Likewise.
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
2023-11-10 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
* bfdlink.h (struct bfd_link_info): Update descriptions of the
|
||||
'execstack', 'noexecstack' and 'warn_execstack' fields.
|
||||
Add 'error_exectack' and 'warn_is_error_for_rwx_segments' fields.
|
||||
|
||||
2023-10-30 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
* elf/bpf.h (R_BPF_64_NODYLD32): Add a note that this reloc is
|
||||
|
||||
@@ -484,26 +484,49 @@ struct bfd_link_info
|
||||
--dynamic-list command line options. */
|
||||
unsigned int dynamic: 1;
|
||||
|
||||
/* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W|PF_X
|
||||
flags. */
|
||||
/* Set if the "-z execstack" option has been used to request that a
|
||||
PT_GNU_STACK segment should be created with PF_R, PF_W and PF_X
|
||||
flags set.
|
||||
|
||||
Note - if performing a relocatable link then a .note.GNU-stack
|
||||
section will be created instead, if one does not exist already.
|
||||
The section will have the SHF_EXECINSTR flag bit set. */
|
||||
unsigned int execstack: 1;
|
||||
|
||||
/* TRUE if PT_GNU_STACK segment should be created with PF_R|PF_W
|
||||
flags. */
|
||||
/* Set if the "-z noexecstack" option has been used to request that a
|
||||
PT_GNU_STACK segment should be created with PF_R and PF_W flags. Or
|
||||
a non-executable .note.GNU-stack section for relocateable links.
|
||||
|
||||
Note - this flag is not quite orthogonal to execstack, since both
|
||||
of these flags can be 0. In this case a stack segment can still
|
||||
be created, but it will only have the PF_X flag bit set if one or
|
||||
more of the input files contains a .note.GNU-stack section with the
|
||||
SHF_EXECINSTR flag bit set, or if the default behaviour for the
|
||||
architecture is to create executable stacks.
|
||||
|
||||
The execstack and noexecstack flags should never both be 1. */
|
||||
unsigned int noexecstack: 1;
|
||||
|
||||
/* Tri-state variable:
|
||||
0 => do not warn when creating an executable stack.
|
||||
1 => always warn when creating an executable stack.
|
||||
>1 => warn when creating an executable stack if execstack is 0. */
|
||||
1 => always warn when creating an executable stack (for any reason).
|
||||
2 => only warn when an executable stack has been requested an object
|
||||
file and execstack is 0 or noexecstack is 1.
|
||||
3 => not used. */
|
||||
unsigned int warn_execstack: 2;
|
||||
/* TRUE if a warning generated because of warn_execstack should be instead
|
||||
be treated as an error. */
|
||||
unsigned int error_execstack: 1;
|
||||
|
||||
/* TRUE if warnings should not be generated for TLS segments with eXecute
|
||||
/* TRUE if warnings should NOT be generated for TLS segments with eXecute
|
||||
permission or LOAD segments with RWX permissions. */
|
||||
unsigned int no_warn_rwx_segments: 1;
|
||||
/* TRUE if the user gave either --warn-rwx-segments or
|
||||
--no-warn-rwx-segments. */
|
||||
--no-warn-rwx-segments on the linker command line. */
|
||||
unsigned int user_warn_rwx_segments: 1;
|
||||
/* TRUE if warnings generated when no_warn_rwx_segements is 0 should
|
||||
instead be treated as errors. */
|
||||
unsigned int warn_is_error_for_rwx_segments: 1;
|
||||
|
||||
/* TRUE if the stack can be made executable because of the absence of a
|
||||
.note.GNU-stack section in an input file. Note - even if this field
|
||||
|
||||
Reference in New Issue
Block a user