]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Tidy PowerPC gold find_global_entry uses
authorAlan Modra <amodra@gmail.com>
Tue, 28 Apr 2015 07:15:34 +0000 (16:45 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 5 Jun 2015 14:40:15 +0000 (00:10 +0930)
Completely removing the assert probably wasn't the best idea, so
reinstate it for allocated sections.  Also cope with debug info
potentially referring to a missing plt call stub.

And a tidy.  find_global_entry now returns an Address, so make temps
holding the return value of type Address, and compare against
invalid_address.

* powerpc.cc (Target_powerpc::do_dynsym_value): Use Address rather
than unsigned int for find_global_entry result temp.  Compare
against invalid_address.
(Target_powerpc::do_plt_address_for_global): Likewise.
(Target_powerpc::Relocate::relocate): Likewise.  Don't assert
on plt call stub existence for debug info.  Do assert for plt
and global entry stub existence if an alloc section.

gold/ChangeLog
gold/powerpc.cc

index f554ee86044732f053fc5447b55e412b5c6643be..31b189393f626577e40470aeb957fdc29bb4244d 100644 (file)
@@ -1,6 +1,15 @@
 2015-06-05  Alan Modra  <amodra@gmail.com>
 
        Apply from master
+       2015-04-28  Alan Modra  <amodra@gmail.com>
+       * powerpc.cc (Target_powerpc::do_dynsym_value): Use Address rather
+       than unsigned int for find_global_entry result temp.  Compare
+       against invalid_address.
+       (Target_powerpc::do_plt_address_for_global): Likewise.
+       (Target_powerpc::Relocate::relocate): Likewise.  Don't assert
+       on plt call stub existence for debug info.  Do assert for plt
+       and global entry stub existence if an alloc section.
+
        2015-04-28  Alan Modra  <amodra@gmail.com>
        * powerpc.cc (Target_powerpc::Relocate::relocate): Don't assert
        on missing global entry stub due to bogus debug info.
index 3766f727b4154e88b09d3dce61af6f76173c8e9d..22a4a1018ccb09e454077da3d0c3b25b9462a4c1 100644 (file)
@@ -6747,8 +6747,8 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
          && !parameters->options().output_is_position_independent()
          && !is_branch_reloc(r_type))
        {
-         unsigned int off = target->glink_section()->find_global_entry(gsym);
-         if (off != (unsigned int)-1)
+         Address off = target->glink_section()->find_global_entry(gsym);
+         if (off != invalid_address)
            {
              value = target->glink_section()->global_entry_address() + off;
              has_stub_value = true;
@@ -6764,18 +6764,26 @@ Target_powerpc<size, big_endian>::Relocate::relocate(
              if (target->stub_tables().size() != 0)
                stub_table = target->stub_tables()[0];
            }
-         gold_assert(stub_table != NULL);
-         Address off;
-         if (gsym != NULL)
-           off = stub_table->find_plt_call_entry(object, gsym, r_type,
-                                                 rela.get_r_addend());
-         else
-           off = stub_table->find_plt_call_entry(object, r_sym, r_type,
-                                                 rela.get_r_addend());
-         gold_assert(off != invalid_address);
-         value = stub_table->stub_address() + off;
-         has_stub_value = true;
+         if (stub_table != NULL)
+           {
+             Address off;
+             if (gsym != NULL)
+               off = stub_table->find_plt_call_entry(object, gsym, r_type,
+                                                     rela.get_r_addend());
+             else
+               off = stub_table->find_plt_call_entry(object, r_sym, r_type,
+                                                     rela.get_r_addend());
+             if (off != invalid_address)
+               {
+                 value = stub_table->stub_address() + off;
+                 has_stub_value = true;
+               }
+           }
        }
+      // We don't care too much about bogus debug references to
+      // non-local functions, but otherwise there had better be a plt
+      // call stub or global entry stub as appropriate.
+      gold_assert(has_stub_value || !(os->flags() & elfcpp::SHF_ALLOC));
     }
 
   if (r_type == elfcpp::R_POWERPC_GOT16
@@ -8152,8 +8160,8 @@ Target_powerpc<size, big_endian>::do_dynsym_value(const Symbol* gsym) const
     }
   else if (this->abiversion() >= 2)
     {
-      unsigned int off = this->glink_section()->find_global_entry(gsym);
-      if (off != (unsigned int)-1)
+      Address off = this->glink_section()->find_global_entry(gsym);
+      if (off != invalid_address)
        return this->glink_section()->global_entry_address() + off;
     }
   gold_unreachable();
@@ -8202,8 +8210,8 @@ Target_powerpc<size, big_endian>::do_plt_address_for_global(
     }
   else if (this->abiversion() >= 2)
     {
-      unsigned int off = this->glink_section()->find_global_entry(gsym);
-      if (off != (unsigned int)-1)
+      Address off = this->glink_section()->find_global_entry(gsym);
+      if (off != invalid_address)
        return this->glink_section()->global_entry_address() + off;
     }
   gold_unreachable();