* m32c-desc.c: Regenerated.
[deliverable/binutils-gdb.git] / bfd / elf32-m32r.c
index d29a7d3621c0979112fd50a9f8be2e044789f971..82ed13c881deb4bc7e0bf462014cb799009ab47d 100644 (file)
@@ -877,7 +877,21 @@ static reloc_howto_type m32r_elf_howto_table[] =
          0,                     /* dst_mask */
          FALSE),                /* pcrel_offset */
 
-  EMPTY_HOWTO (45),
+  /* A 32 bit PC relative relocation.  */
+  HOWTO (R_M32R_REL32,         /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        TRUE,                  /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield, /* complain_on_overflow */
+        bfd_elf_generic_reloc,/* special_function */
+        "R_M32R_REL32",                /* name */
+        FALSE,                 /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        TRUE),                 /* pcrel_offset */
+
   EMPTY_HOWTO (46),
   EMPTY_HOWTO (47),
 
@@ -1193,6 +1207,7 @@ static const struct m32r_reloc_map m32r_reloc_map[] =
   { BFD_RELOC_M32R_SDA16, R_M32R_SDA16_RELA },
   { BFD_RELOC_VTABLE_INHERIT, R_M32R_RELA_GNU_VTINHERIT },
   { BFD_RELOC_VTABLE_ENTRY, R_M32R_RELA_GNU_VTENTRY },
+  { BFD_RELOC_32_PCREL, R_M32R_REL32 },
 
   { BFD_RELOC_M32R_GOT24, R_M32R_GOT24 },
   { BFD_RELOC_M32R_26_PLTREL, R_M32R_26_PLTREL },
@@ -1740,7 +1755,7 @@ m32r_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
 /* Copy the extra info we tack onto an elf_link_hash_entry.  */
 
 static void
-m32r_elf_copy_indirect_symbol (const struct elf_backend_data *bed,
+m32r_elf_copy_indirect_symbol (struct bfd_link_info *info,
                                struct elf_link_hash_entry *dir,
                                struct elf_link_hash_entry *ind)
 {
@@ -1757,10 +1772,7 @@ m32r_elf_copy_indirect_symbol (const struct elf_backend_data *bed,
           struct elf_m32r_dyn_relocs **pp;
           struct elf_m32r_dyn_relocs *p;
 
-          if (ind->root.type == bfd_link_hash_indirect)
-            abort ();
-
-          /* Add reloc counts against the weak sym to the strong sym
+          /* Add reloc counts against the indirect sym to the direct sym
              list.  Merge any entries against the same section.  */
           for (pp = &eind->dyn_relocs; (p = *pp) != NULL;)
             {
@@ -1784,7 +1796,7 @@ m32r_elf_copy_indirect_symbol (const struct elf_backend_data *bed,
       eind->dyn_relocs = NULL;
     }
 
-  _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
+  _bfd_elf_link_hash_copy_indirect (info, dir, ind);
 }
 
 \f
@@ -1896,6 +1908,13 @@ m32r_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
       return TRUE;
     }
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+                            h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
@@ -2264,7 +2283,8 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
 
       if (s == htab->splt
           || s == htab->sgot
-          || s == htab->sgotplt)
+          || s == htab->sgotplt
+         || s == htab->sdynbss)
         {
           /* Strip this section if we don't need it; see the
              comment below.  */
@@ -2297,6 +2317,9 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
           continue;
         }
 
+      if ((s->flags & SEC_HAS_CONTENTS) == 0)
+       continue;
+
       /* Allocate memory for the section contents.  We use bfd_zalloc
          here in case unused entries are not reclaimed before the
          section's contents are written out.  This should not happen,
@@ -2607,6 +2630,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                               || r_type == R_M32R_HI16_SLO_RELA
                               || r_type == R_M32R_LO16_RELA)
                                  && !h->forced_local)
+                              || r_type == R_M32R_REL32
                               || r_type == R_M32R_10_PCREL_RELA
                               || r_type == R_M32R_18_PCREL_RELA
                               || r_type == R_M32R_26_PCREL_RELA)
@@ -2626,9 +2650,12 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                  else if (sec->output_section == NULL)
                     {
                       (*_bfd_error_handler)
-                        (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
-                         bfd_get_filename (input_bfd), h->root.root.string,
-                         bfd_get_section_name (input_bfd, input_section));
+                        (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+                        input_bfd,
+                        input_section,
+                        (long) rel->r_offset,
+                        howto->name,
+                        h->root.root.string);
 
                       relocation = 0;
                     }
@@ -2850,6 +2877,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
             case R_M32R_16_RELA:
             case R_M32R_24_RELA:
             case R_M32R_32_RELA:
+            case R_M32R_REL32:
             case R_M32R_18_PCREL_RELA:
             case R_M32R_26_PCREL_RELA:
             case R_M32R_HI16_ULO_RELA:
@@ -2858,7 +2886,8 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                   && r_symndx != 0
                   && (input_section->flags & SEC_ALLOC) != 0
                   && ((r_type != R_M32R_18_PCREL_RELA
-                       && r_type != R_M32R_26_PCREL_RELA)
+                       && r_type != R_M32R_26_PCREL_RELA
+                       && r_type != R_M32R_REL32)
                       || (h != NULL
                           && h->dynindx != -1
                           && (! info->symbolic
@@ -2908,7 +2937,8 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
                   if (skip)
                     memset (&outrel, 0, sizeof outrel);
                   else if (r_type == R_M32R_18_PCREL_RELA
-                           || r_type == R_M32R_26_PCREL_RELA)
+                           || r_type == R_M32R_26_PCREL_RELA
+                           || r_type == R_M32R_REL32)
                     {
                       BFD_ASSERT (h != NULL && h->dynindx != -1);
                       outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
@@ -3679,6 +3709,7 @@ m32r_elf_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
        case R_M32R_16_RELA:
        case R_M32R_24_RELA:
        case R_M32R_32_RELA:
+       case R_M32R_REL32:
        case R_M32R_HI16_ULO_RELA:
        case R_M32R_HI16_SLO_RELA:
        case R_M32R_LO16_RELA:
@@ -3700,7 +3731,8 @@ m32r_elf_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED,
                if (p->sec == sec)
                  {
                    if (ELF32_R_TYPE (rel->r_info) == R_M32R_26_PCREL_RELA
-                       || ELF32_R_TYPE (rel->r_info) == R_M32R_26_PCREL_RELA)
+                       || ELF32_R_TYPE (rel->r_info) == R_M32R_26_PCREL_RELA
+                       || ELF32_R_TYPE (rel->r_info) == R_M32R_REL32)
                      p->pc_count -= 1;
                    p->count -= 1;
                    if (p->count == 0)
@@ -3860,6 +3892,7 @@ m32r_elf_check_relocs (bfd *abfd,
         case R_M32R_16_RELA:
         case R_M32R_24_RELA:
         case R_M32R_32_RELA:
+        case R_M32R_REL32:
         case R_M32R_HI16_ULO_RELA:
         case R_M32R_HI16_SLO_RELA:
         case R_M32R_LO16_RELA:
@@ -3895,7 +3928,8 @@ m32r_elf_check_relocs (bfd *abfd,
           if ((info->shared
                && (sec->flags & SEC_ALLOC) != 0
               && ((r_type != R_M32R_26_PCREL_RELA
-                    && r_type != R_M32R_18_PCREL_RELA)
+                    && r_type != R_M32R_18_PCREL_RELA
+                    && r_type != R_M32R_REL32)
                   || (h != NULL
                       && (! info->symbolic
                           || h->root.type == bfd_link_hash_defweak
@@ -3956,6 +3990,7 @@ m32r_elf_check_relocs (bfd *abfd,
               else
                 {
                   asection *s;
+                  void *vpp;
 
                   /* Track dynamic relocs needed for local syms too.  */
                   s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
@@ -3963,8 +3998,8 @@ m32r_elf_check_relocs (bfd *abfd,
                   if (s == NULL)
                     return FALSE;
 
-                  head = ((struct elf_m32r_dyn_relocs **)
-                          &elf_section_data (s)->local_dynrel);
+                 vpp = &elf_section_data (s)->local_dynrel;
+                  head = (struct elf_m32r_dyn_relocs **) vpp;
                 }
 
               p = *head;
@@ -3984,6 +4019,7 @@ m32r_elf_check_relocs (bfd *abfd,
 
               p->count += 1;
               if (ELF32_R_TYPE (rel->r_info) == R_M32R_26_PCREL_RELA
+                 || ELF32_R_TYPE (rel->r_info) == R_M32R_REL32
                   || ELF32_R_TYPE (rel->r_info) == R_M32R_18_PCREL_RELA)
                 p->pc_count += 1;
             }
@@ -4020,24 +4056,6 @@ static const struct bfd_elf_special_section m32r_elf_special_sections[] =
   { NULL,       0,  0, 0,            0 }
 };
 
-static const struct bfd_elf_special_section *
-m32r_elf_get_sec_type_attr (bfd *abfd, asection *sec)
-{
-  const struct bfd_elf_special_section *ssect;
-
-  /* See if this is one of the special sections.  */
-  if (sec->name == NULL)
-    return NULL;
-
-  ssect = _bfd_elf_get_special_section (sec->name,
-                                       m32r_elf_special_sections,
-                                       sec->use_rela_p);
-  if (ssect != NULL)
-    return ssect;
-
-  return _bfd_elf_get_sec_type_attr (abfd, sec);
-}
-
 static bfd_boolean
 m32r_elf_fake_sections (bfd *abfd,
                        Elf_Internal_Shdr *hdr ATTRIBUTE_UNUSED,
@@ -4141,7 +4159,7 @@ m32r_elf_reloc_type_class (const Elf_Internal_Rela *rela)
 #define bfd_elf32_bfd_merge_private_bfd_data   m32r_elf_merge_private_bfd_data
 #define bfd_elf32_bfd_set_private_flags                m32r_elf_set_private_flags
 #define bfd_elf32_bfd_print_private_bfd_data   m32r_elf_print_private_bfd_data
-#define elf_backend_get_sec_type_attr          m32r_elf_get_sec_type_attr
+#define elf_backend_special_sections           m32r_elf_special_sections
 
 #include "elf32-target.h"
 
This page took 0.107928 seconds and 4 git commands to generate.