* elf64-ppc.c (edit_opd): Correct test for discarded sections.
[deliverable/binutils-gdb.git] / bfd / elf64-ppc.c
index bf2a6d795f3e3103cba0a20221655c1e0d4fcee1..37b30e6278adc599ef9b9a8948cc76e988641c81 100644 (file)
@@ -3675,12 +3675,16 @@ edit_opd (obfd, info)
              break;
            }
 
-         if (sym_sec->output_section == bfd_abs_section_ptr)
-           {
-             /* OK, we've found a function that's excluded from the
-                link.  */
-             need_edit = true;
-           }
+         /* opd entries are always for functions defined in the
+            current input bfd.  If the symbol isn't defined in the
+            input bfd, then we won't be using the function in this
+            bfd;  It must be defined in a linkonce section in another
+            bfd, or is weak.  It's also possible that we are
+            discarding the function due to a linker script /DISCARD/,
+            which we test for via the output_section.  */
+         if (sym_sec->owner != ibfd
+             || sym_sec->output_section == bfd_abs_section_ptr)
+           need_edit = true;
 
          offset += 24;
        }
@@ -3754,7 +3758,8 @@ edit_opd (obfd, info)
                                                              sym->st_shndx);
                    }
 
-                 skip = sym_sec->output_section == bfd_abs_section_ptr;
+                 skip = (sym_sec->owner != ibfd
+                         || sym_sec->output_section == bfd_abs_section_ptr);
                  if (skip)
                    {
                      if (h != NULL)
This page took 0.024604 seconds and 4 git commands to generate.