diff options
author | Cary Coutant <ccoutant@google.com> | 2010-12-09 23:19:50 +0000 |
---|---|---|
committer | Cary Coutant <ccoutant@google.com> | 2010-12-09 23:19:50 +0000 |
commit | 83e17bd5ed3c2586f558202172bf9f52ac80650c (patch) | |
tree | 3e1249454b28872800852006958bd7e5e27c2705 /gold | |
parent | f9bbfb18bec91f344bcc74343ad77c8a0e49ed4e (diff) | |
download | gdb-83e17bd5ed3c2586f558202172bf9f52ac80650c.zip gdb-83e17bd5ed3c2586f558202172bf9f52ac80650c.tar.gz gdb-83e17bd5ed3c2586f558202172bf9f52ac80650c.tar.bz2 |
* layout.cc (Layout::layout_gnu_stack): Add warnings for executable
stack.
* layout.h (Layout::layout_gnu_stack): Add pointer to Object
parameter; change all callers.
* object.cc (Sized_relobj::do_layout): Adjust call to layout_gnu_stack.
* options.h (warn_execstack): New option.
Diffstat (limited to 'gold')
-rw-r--r-- | gold/ChangeLog | 9 | ||||
-rw-r--r-- | gold/layout.cc | 20 | ||||
-rw-r--r-- | gold/layout.h | 3 | ||||
-rw-r--r-- | gold/object.cc | 2 | ||||
-rw-r--r-- | gold/options.h | 4 |
5 files changed, 33 insertions, 5 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index 7a5c36c..5febda7 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,12 @@ +2010-12-09 Cary Coutant <ccoutant@google.com> + + * layout.cc (Layout::layout_gnu_stack): Add warnings for executable + stack. + * layout.h (Layout::layout_gnu_stack): Add pointer to Object + parameter; change all callers. + * object.cc (Sized_relobj::do_layout): Adjust call to layout_gnu_stack. + * options.h (warn_execstack): New option. + 2010-12-07 Doug Kwan <dougkwan@google.com> * arm.cc (Target_arm::Scan::get_reference_flags): Treat R_ARM_PREL31 diff --git a/gold/layout.cc b/gold/layout.cc index 52120cc..9bf9a9f 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -1344,15 +1344,29 @@ Layout::expected_segment_count() const // object. On some targets that will force an executable stack. void -Layout::layout_gnu_stack(bool seen_gnu_stack, uint64_t gnu_stack_flags) +Layout::layout_gnu_stack(bool seen_gnu_stack, uint64_t gnu_stack_flags, + const Object* obj) { if (!seen_gnu_stack) - this->input_without_gnu_stack_note_ = true; + { + this->input_without_gnu_stack_note_ = true; + if (parameters->options().warn_execstack() + && parameters->target().is_default_stack_executable()) + gold_warning(_("%s: missing .note.GNU-stack section" + " implies executable stack"), + obj->name().c_str()); + } else { this->input_with_gnu_stack_note_ = true; if ((gnu_stack_flags & elfcpp::SHF_EXECINSTR) != 0) - this->input_requires_executable_stack_ = true; + { + this->input_requires_executable_stack_ = true; + if (parameters->options().warn_execstack() + || parameters->options().is_stack_executable()) + gold_warning(_("%s: requires executable stack"), + obj->name().c_str()); + } } } diff --git a/gold/layout.h b/gold/layout.h index 6e817ca..cfbb9f0 100644 --- a/gold/layout.h +++ b/gold/layout.h @@ -470,7 +470,8 @@ class Layout // .note.GNU-stack section. GNU_STACK_FLAGS is the section flags // from that section if there was one. void - layout_gnu_stack(bool seen_gnu_stack, uint64_t gnu_stack_flags); + layout_gnu_stack(bool seen_gnu_stack, uint64_t gnu_stack_flags, + const Object*); // Add an Output_section_data to the layout. This is used for // special sections like the GOT section. ORDER is where the diff --git a/gold/object.cc b/gold/object.cc index bde89f6..466d26f 100644 --- a/gold/object.cc +++ b/gold/object.cc @@ -1429,7 +1429,7 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, } if (!is_gc_pass_two) - layout->layout_gnu_stack(seen_gnu_stack, gnu_stack_flags); + layout->layout_gnu_stack(seen_gnu_stack, gnu_stack_flags, this); // When doing a relocatable link handle the reloc sections at the // end. Garbage collection and Identical Code Folding is not diff --git a/gold/options.h b/gold/options.h index 7a694a9..8f240f0 100644 --- a/gold/options.h +++ b/gold/options.h @@ -1035,6 +1035,10 @@ class General_options DEFINE_bool(warn_constructors, options::TWO_DASHES, '\0', false, N_("Ignored"), N_("Ignored")); + DEFINE_bool(warn_execstack, options::TWO_DASHES, '\0', false, + N_("Warn if the stack is executable"), + N_("Do not warn if the stack is executable (default)")); + DEFINE_bool(warn_mismatch, options::TWO_DASHES, '\0', true, NULL, N_("Don't warn about mismatched input files")); |