Fix segfault in ARC linker when generating got entries for local symbols.
authorCupertino Miranda <cmiranda@synopsys.com>
Fri, 22 Jul 2016 14:10:31 +0000 (15:10 +0100)
committerNick Clifton <nickc@redhat.com>
Fri, 22 Jul 2016 14:10:31 +0000 (15:10 +0100)
bfd * arc-got.h (relocate_fix_got_relocs_for_got_info): Handle the case
where there's no elf_link_hash_entry while processing GOT_NORMAL got
entries.

ld * testsuite/ld-arc/got-01.d: New file.
* testsuite/ld-arc/got-01.s: New file.

bfd/ChangeLog
bfd/arc-got.h
ld/ChangeLog
ld/testsuite/ld-arc/got-01.d [new file with mode: 0644]
ld/testsuite/ld-arc/got-01.s [new file with mode: 0644]

index 63daac48ec8629e6043b9143f08e5d104582a4c4..ab92c6ca4d4573ae8e32e8aa90c3a91a88bd8740 100644 (file)
@@ -1,3 +1,9 @@
+2016-07-22  Cupertino Miranda  <cmiranda@synopsys.com>
+
+       * arc-got.h (relocate_fix_got_relocs_for_got_info): Handle the
+       case where there's no elf_link_hash_entry while processing
+       GOT_NORMAL got entries.
+
 2016-07-21  H.J. Lu  <hongjiu.lu@intel.com>
 
        * version.m4 (BFD_VERSION): Set to 2.27.51.
index 00deb01f4b10f5741dfad0ee700383765afc6122..7c3cfd952d2430e583bcb551776ffb25bf2e0f47 100644 (file)
@@ -369,12 +369,21 @@ relocate_fix_got_relocs_for_got_info (struct got_entry **          list_p,
                  = reloc_data->sym_section->output_section->vma
                  + reloc_data->sym_section->output_offset;
 
-               if (h->root.type != bfd_link_hash_undefweak)
+               if (h != NULL
+                   && h->root.type == bfd_link_hash_undefweak)
+                 ARC_DEBUG ("arc_info: PATCHED: NOT_PATCHED "
+                            "@ %#08lx for sym %s in got offset %#lx "
+                            "(is undefweak)\n",
+                            (long) (htab->sgot->output_section->vma
+                                    + htab->sgot->output_offset
+                                    + entry->offset),
+                            symbol_name,
+                            (long) entry->offset);
+               else
                  {
                    bfd_put_32 (output_bfd,
                                reloc_data->sym_value + sec_vma,
                                htab->sgot->contents + entry->offset);
-
                    ARC_DEBUG ("arc_info: PATCHED: %#08lx "
                               "@ %#08lx for sym %s in got offset %#lx\n",
                               (long) (reloc_data->sym_value + sec_vma),
@@ -383,17 +392,6 @@ relocate_fix_got_relocs_for_got_info (struct got_entry **          list_p,
                               symbol_name,
                               (long) entry->offset);
                  }
-               else
-                 {
-                   ARC_DEBUG ("arc_info: PATCHED: NOT_PATCHED "
-                              "@ %#08lx for sym %s in got offset %#lx "
-                              "(is undefweak)\n",
-                              (long) (htab->sgot->output_section->vma
-                                      + htab->sgot->output_offset
-                                      + entry->offset),
-                              symbol_name,
-                              (long) entry->offset);
-                 }
              }
              break;
            default:
index 21105c07d468d325ed985515d602c3db61b996de..728c6b050c8099e0603b10526bcf5628c4873cc6 100644 (file)
@@ -1,3 +1,8 @@
+2016-07-22  Cupertino Miranda  <cmiranda@synopsys.com>
+
+       * testsuite/ld-arc/got-01.d: New file.
+       * testsuite/ld-arc/got-01.s: New file.
+
 2016-07-21  H.J. Lu  <hongjiu.lu@intel.com>
 
        * configure: Regenerated.
diff --git a/ld/testsuite/ld-arc/got-01.d b/ld/testsuite/ld-arc/got-01.d
new file mode 100644 (file)
index 0000000..c34d6a7
--- /dev/null
@@ -0,0 +1,7 @@
+#source: got-01.s
+#as: -mcpu=arc700
+#ld:
+#readelf: -S
+
+There are . section headers, starting at offset 0x[0-9a-f]+:
+#...
diff --git a/ld/testsuite/ld-arc/got-01.s b/ld/testsuite/ld-arc/got-01.s
new file mode 100644 (file)
index 0000000..4e1b406
--- /dev/null
@@ -0,0 +1,5 @@
+        .text
+        .global __start
+__start:
+foo:
+        ld  r0, [pcl, foo@gotpc]