]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* elf64-ppc.c (ppc64_elf_edit_toc): Don't segfault on NULL
authorAlan Modra <amodra@gmail.com>
Tue, 8 Feb 2011 03:00:28 +0000 (03:00 +0000)
committerAlan Modra <amodra@gmail.com>
Tue, 8 Feb 2011 03:00:28 +0000 (03:00 +0000)
local_syms when looking for local symbols in .toc.

bfd/ChangeLog
bfd/elf64-ppc.c

index 2ca6bc60cd6b411a8afafcec3b5043390085a863..074c8bc9b25b4fab69d32528b829d4467a2f3d38 100644 (file)
@@ -1,3 +1,8 @@
+2011-02-08  Alan Modra  <amodra@gmail.com>
+
+       * elf64-ppc.c (ppc64_elf_edit_toc): Don't segfault on NULL
+       local_syms when looking for local symbols in .toc.
+
 2011-02-01  Alan Modra  <amodra@gmail.com>
 
        Backport from mainline
index 846f5d541b6477683cf982b8ba7ca89bd1285c15..4e85e901053e7d30377bb6659eb29597a6ac0263 100644 (file)
@@ -8372,34 +8372,35 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
 
          /* We shouldn't have local or global symbols defined in the TOC,
             but handle them anyway.  */
-         for (sym = local_syms;
-              sym < local_syms + symtab_hdr->sh_info;
-              ++sym)
-           if (sym->st_value != 0
-               && bfd_section_from_elf_index (ibfd, sym->st_shndx) == toc)
-             {
-               unsigned long i;
+         if (local_syms != NULL)
+           for (sym = local_syms;
+                sym < local_syms + symtab_hdr->sh_info;
+                ++sym)
+             if (sym->st_value != 0
+                 && bfd_section_from_elf_index (ibfd, sym->st_shndx) == toc)
+               {
+                 unsigned long i;
 
-               if (sym->st_value > toc->rawsize)
-                 i = toc->rawsize >> 3;
-               else
-                 i = sym->st_value >> 3;
+                 if (sym->st_value > toc->rawsize)
+                   i = toc->rawsize >> 3;
+                 else
+                   i = sym->st_value >> 3;
 
-               if ((skip[i] & (ref_from_discarded | can_optimize)) != 0)
-                 {
-                   if (local_toc_syms)
-                     (*_bfd_error_handler)
-                       (_("%s defined on removed toc entry"),
-                        bfd_elf_sym_name (ibfd, symtab_hdr, sym, NULL));
-                   do
-                     ++i;
-                   while ((skip[i] & (ref_from_discarded | can_optimize)));
-                   sym->st_value = (bfd_vma) i << 3;
-                 }
+                 if ((skip[i] & (ref_from_discarded | can_optimize)) != 0)
+                   {
+                     if (local_toc_syms)
+                       (*_bfd_error_handler)
+                         (_("%s defined on removed toc entry"),
+                          bfd_elf_sym_name (ibfd, symtab_hdr, sym, NULL));
+                     do
+                       ++i;
+                     while ((skip[i] & (ref_from_discarded | can_optimize)));
+                     sym->st_value = (bfd_vma) i << 3;
+                   }
 
-               sym->st_value -= skip[i];
-               symtab_hdr->contents = (unsigned char *) local_syms;
-             }
+                 sym->st_value -= skip[i];
+                 symtab_hdr->contents = (unsigned char *) local_syms;
+               }
 
          /* Adjust any global syms defined in this toc input section.  */
          if (toc_inf.global_toc_syms)