]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix powerpc64 segfault caused by zero r_symndx relocs.
authorAlan Modra <amodra@gmail.com>
Wed, 2 Dec 2015 08:19:53 +0000 (18:49 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 10 Dec 2015 13:48:48 +0000 (00:18 +1030)
Fixes a segfault in ppc64_elf_tls_optimize found when testing
R_PPC64_ENTRY, and potential for trouble in other places found by
code inspection.

* elf64-ppc.c (ppc64_elf_tls_optimize): Don't segfault on NULL
symbol section or output section.
(ppc64_elf_edit_toc): Similarly for ld -R objects.
(ppc64_elf_size_stubs): Likewise.

bfd/ChangeLog
bfd/elf64-ppc.c

index 3194cc32f32e18e8825c94890e9fbb9533712ee2..d3a75f5d841a46fa1beb27bac3105f63b5a4f11d 100644 (file)
@@ -1,6 +1,12 @@
 2015-12-10  Alan Modra  <amodra@gmail.com>
 
        Apply from master.
+       2015-12-02  Alan Modra  <amodra@gmail.com>
+       * elf64-ppc.c (ppc64_elf_tls_optimize): Don't segfault on NULL
+       symbol section or output section.
+       (ppc64_elf_edit_toc): Similarly for ld -R objects.
+       (ppc64_elf_size_stubs): Likewise.
+
        2015-11-20  Stefan Teleman  <stefan.teleman@oracle.com>
        PR ld/19260
        * cache.c (bfd_cache_max_open): Avoid using getrlimit on 32-bit
index 42356d8a0b811180bfeeed185d620557e08efcf8..9b5ebcdaffbb36bc3404799c721c285bae1c79d0 100644 (file)
@@ -8391,7 +8391,8 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
                      if (h != NULL
                          && h->root.type == bfd_link_hash_undefweak)
                        ok_tprel = TRUE;
-                     else
+                     else if (sym_sec != NULL
+                              && sym_sec->output_section != NULL)
                        {
                          value += sym_sec->output_offset;
                          value += sym_sec->output_section->vma;
@@ -8952,6 +8953,7 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
                goto error_ret;
 
              if (sym_sec == NULL
+                 || sym_sec->output_section == NULL
                  || discarded_section (sym_sec))
                continue;
 
@@ -12275,7 +12277,9 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
                  if (hash == NULL)
                    {
                      sym_value = sym->st_value;
-                     ok_dest = TRUE;
+                     if (sym_sec != NULL
+                         && sym_sec->output_section != NULL)
+                       ok_dest = TRUE;
                    }
                  else if (hash->elf.root.type == bfd_link_hash_defined
                           || hash->elf.root.type == bfd_link_hash_defweak)