* layout.cc (Layout::layout_gnu_stack): Add warnings for executable
authorCary Coutant <ccoutant@google.com>
Thu, 9 Dec 2010 23:19:50 +0000 (23:19 +0000)
committerCary Coutant <ccoutant@google.com>
Thu, 9 Dec 2010 23:19:50 +0000 (23:19 +0000)
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.

gold/ChangeLog
gold/layout.cc
gold/layout.h
gold/object.cc
gold/options.h

index 7a5c36cf3daaa6b1b419f931023d5f5c0f67e621..5febda7979623362369cc477da1280edd8fa8d43 100644 (file)
@@ -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
index 52120cca54057f9b950e60c17f7190a4b78a5b91..9bf9a9f7325ff9d2d3fc714ec6508343ba58a54d 100644 (file)
@@ -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());
+       }
     }
 }
 
index 6e817cacd3231e9ddd1f27d8fe319366ec9a60c9..cfbb9f0cc2efa2f3e9487116238328973b4cd8cc 100644 (file)
@@ -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
index bde89f68d26480d35493f66734ee370dd4f5a57b..466d26fd2ebc0c7d6240c2113690356d9bc42838 100644 (file)
@@ -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 
index 7a694a95ce918c4bc5a86ed2d29c204e710cc12c..8f240f07d4a8c20934caecd06c29ab1efe9afdc0 100644 (file)
@@ -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"));
 
This page took 0.040125 seconds and 4 git commands to generate.