diff options
author | Nick Clifton <nickc@redhat.com> | 2014-03-31 13:14:44 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2014-03-31 13:14:44 +0100 |
commit | 76f0cad6f4e0fdfc4cfeee135b44b6a090919c60 (patch) | |
tree | 8174a9d1b67099b8adbb7ffeedc64c4fea63e962 /ld/emultempl/elf32.em | |
parent | 72c56015dda568cdcce75dc0316aa768f922c2d7 (diff) | |
download | gdb-76f0cad6f4e0fdfc4cfeee135b44b6a090919c60.zip gdb-76f0cad6f4e0fdfc4cfeee135b44b6a090919c60.tar.gz gdb-76f0cad6f4e0fdfc4cfeee135b44b6a090919c60.tar.bz2 |
This is a fix for PR ld/16744 which showed that an object file linked with -r and -z [no]execstack
would not honour the [no]execstack. Fully linked binaries use a special segment to indicate the
state of the stack, but relocatable object files only have sections, and .note.GNU-stack was not
being created.
* emultempl/elf32.em (_after_open): Create a .note.GNU-stack
section when performing a relocatable link with -z [no]execstack
specified.
Diffstat (limited to 'ld/emultempl/elf32.em')
-rw-r--r-- | ld/emultempl/elf32.em | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 7ea5adc..de460a2 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1112,7 +1112,20 @@ gld${EMULATION_NAME}_after_open (void) } if (link_info.relocatable) - return; + { + if (link_info.execstack == ! link_info.noexecstack) + /* PR ld/16744: If "-z [no]execstack" has been specified on the + command line and we are perfoming a relocatable link then no + PT_GNU_STACK segment will be created and so the + linkinfo.[no]execstack values set in _handle_option() will have no + effect. Instead we create a .note.GNU-stack section in much the + same way as the assembler does with its --[no]execstack option. */ + (void) bfd_make_section_with_flags (link_info.input_bfds, + ".note.GNU-stack", + SEC_READONLY | (link_info.execstack ? SEC_CODE : 0)); + + return; + } if (link_info.eh_frame_hdr && !link_info.traditional_format) |