[GOLD] PowerPC relaxation corner case
[platform/upstream/binutils.git] / gold / powerpc.cc
index 0442e56..2319789 100644 (file)
@@ -2399,6 +2399,14 @@ class Stub_control
   output_section()
   { return output_section_; }
 
+  void
+  set_output_and_owner(Output_section* o,
+                      const Output_section::Input_section* i)
+  {
+    this->output_section_ = o;
+    this->owner_ = i;
+  }
+
  private:
   typedef enum
   {
@@ -2515,6 +2523,7 @@ Target_powerpc<size, big_endian>::group_sections(Layout* layout,
                {
                  stub_table->init(stub_control.owner(),
                                   stub_control.output_section());
+                 stub_control.set_output_and_owner(*o, &*i);
                  stub_table = NULL;
                }
              if (stub_table == NULL)
@@ -7672,10 +7681,10 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
       break;
     }
   if (status != Powerpc_relocate_functions<size, big_endian>::STATUS_OK
-      && !has_stub_value
-      && !(gsym != NULL
-          && gsym->is_weak_undefined()
-          && is_branch_reloc(r_type)))
+      && (has_stub_value
+         || !(gsym != NULL
+              && gsym->is_weak_undefined()
+              && is_branch_reloc(r_type))))
     {
       gold_error_at_location(relinfo, relnum, rela.get_r_offset(),
                             _("relocation overflow"));