[ARC] Reassign the symbol got information to actual symbol when indirect.
[external/binutils.git] / bfd / elf32-arc.c
index 3e99cab..26e1bd4 100644 (file)
@@ -55,17 +55,20 @@ name_for_global_symbol (struct elf_link_hash_entry *h)
     Elf_Internal_Rela _rel;                                            \
     bfd_byte * _loc;                                                   \
                                                                        \
-    BFD_ASSERT (_htab->srel##SECTION &&_htab->srel##SECTION->contents); \
-    _loc = _htab->srel##SECTION->contents                              \
-      + ((_htab->srel##SECTION->reloc_count)                           \
-        * sizeof (Elf32_External_Rela));                               \
-    _htab->srel##SECTION->reloc_count++;                               \
-    _rel.r_addend = ADDEND;                                            \
-    _rel.r_offset = (_htab->s##SECTION)->output_section->vma           \
-      + (_htab->s##SECTION)->output_offset + OFFSET;                   \
-    BFD_ASSERT ((long) SYM_IDX != -1);                                 \
-    _rel.r_info = ELF32_R_INFO (SYM_IDX, TYPE);                                \
-    bfd_elf32_swap_reloca_out (BFD, &_rel, _loc);                      \
+    if (_htab->dynamic_sections_created == TRUE)                               \
+      {                                                                        \
+       BFD_ASSERT (_htab->srel##SECTION &&_htab->srel##SECTION->contents); \
+       _loc = _htab->srel##SECTION->contents                           \
+         + ((_htab->srel##SECTION->reloc_count)                        \
+            * sizeof (Elf32_External_Rela));                           \
+       _htab->srel##SECTION->reloc_count++;                            \
+       _rel.r_addend = ADDEND;                                         \
+       _rel.r_offset = (_htab->s##SECTION)->output_section->vma        \
+         + (_htab->s##SECTION)->output_offset + OFFSET;                \
+       BFD_ASSERT ((long) SYM_IDX != -1);                              \
+       _rel.r_info = ELF32_R_INFO (SYM_IDX, TYPE);                     \
+       bfd_elf32_swap_reloca_out (BFD, &_rel, _loc);                   \
+      }                                                                        \
   }
 
 
@@ -728,9 +731,11 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
 
        case Tag_ARC_ABI_pic:
          tagname = "PIC";
+         /* fall through */
        case Tag_ARC_ABI_sda:
          if (!tagname)
            tagname = "SDA";
+         /* fall through */
        case Tag_ARC_ABI_tls:
          {
            const char *tagval[] = { "Absent", "MWDT", "GNU" };
@@ -756,9 +761,11 @@ arc_elf_merge_attributes (bfd *ibfd, struct bfd_link_info *info)
 
        case Tag_ARC_ABI_double_size:
          tagname = "Double size";
+         /* fall through */
        case Tag_ARC_ABI_enumsize:
          if (!tagname)
            tagname = "Enum size";
+         /* fall through */
        case Tag_ARC_ABI_exceptions:
          if (!tagname)
            tagname = "ABI exceptions";
@@ -1581,7 +1588,12 @@ elf_arc_relocate_section (bfd *                    output_bfd,
 
          while (h->root.type == bfd_link_hash_indirect
                 || h->root.type == bfd_link_hash_warning)
+         {
+           struct elf_link_hash_entry *h_old = h;
            h = (struct elf_link_hash_entry *) h->root.u.i.link;
+           if (h->got.glist == 0 && h_old->got.glist != h->got.glist)
+             h->got.glist = h_old->got.glist;
+         }
 
          /* TODO: Need to validate what was the intention.  */
          /* BFD_ASSERT ((h->dynindx == -1) || (h->forced_local != 0)); */
@@ -1931,7 +1943,8 @@ elf_arc_check_relocs (bfd *                        abfd,
               and the dynamic linker can not resolve these.  However
               the error should not occur for e.g. debugging or
               non-readonly sections.  */
-           if ((bfd_link_dll (info) && !bfd_link_pie (info))
+           if (h != NULL
+               && (bfd_link_dll (info) && !bfd_link_pie (info))
                && (sec->flags & SEC_ALLOC) != 0
                && (sec->flags & SEC_READONLY) != 0
                && ((sec->flags & SEC_CODE) != 0