* bfd.c (bfd_error_type, bfd_errmsgs): Add bfd_error_missing_dso.
[binutils-gdb.git] / bfd / elf32-avr.c
index 38e41df48dfd863e3b1317563684e970e49d0669..a2d440129a455dc2b2cac503e9a2c0110c44cdd4 100644 (file)
@@ -672,7 +672,7 @@ elf32_avr_link_hash_table_create (bfd *abfd)
   struct elf32_avr_link_hash_table *htab;
   bfd_size_type amt = sizeof (*htab);
 
-  htab = bfd_malloc (amt);
+  htab = bfd_zmalloc (amt);
   if (htab == NULL)
     return NULL;
 
@@ -690,15 +690,6 @@ elf32_avr_link_hash_table_create (bfd *abfd)
                             sizeof (struct elf32_avr_stub_hash_entry)))
     return NULL;
 
-  htab->stub_bfd = NULL;
-  htab->stub_sec = NULL;
-
-  /* Initialize the address mapping table.  */
-  htab->amt_stub_offsets = NULL;
-  htab->amt_destination_addr = NULL;
-  htab->amt_entry_cnt = 0;
-  htab->amt_max_entry_cnt = 0;
-
   return &htab->etab.root;
 }
 
@@ -717,7 +708,7 @@ elf32_avr_link_hash_table_free (struct bfd_link_hash_table *btab)
     free (htab->amt_destination_addr);
 
   bfd_hash_table_free (&htab->bstab);
-  _bfd_generic_link_hash_table_free (btab);
+  _bfd_elf_link_hash_table_free (btab);
 }
 
 /* Calculates the effective distance of a pc relative jump/call.  */
@@ -1558,7 +1549,7 @@ elf32_avr_relax_delete_bytes (bfd *abfd,
        irel = elf_section_data (isec)->relocs;
        /* PR 12161: Read in the relocs for this section if necessary.  */
        if (irel == NULL)
-        irel = _bfd_elf_link_read_relocs (abfd, isec, NULL, NULL, FALSE);
+         irel = _bfd_elf_link_read_relocs (abfd, isec, NULL, NULL, TRUE);
 
        for (irelend = irel + isec->reloc_count;
             irel < irelend;
@@ -1617,9 +1608,6 @@ elf32_avr_relax_delete_bytes (bfd *abfd,
           /* else...Reference symbol is extern.  No need for adjusting
              the addend.  */
         }
-
-       if (elf_section_data (isec)->relocs == NULL)
-        free (irelend - isec->reloc_count);
      }
   }
 
@@ -1706,8 +1694,8 @@ elf32_avr_relax_section (bfd *abfd,
   struct elf32_avr_link_hash_table *htab;
 
   /* If 'shrinkable' is FALSE, do not shrink by deleting bytes while
-     relaxing. Such shrinking can cause issues for the sections such 
-     as .vectors and .jumptables. Instead the unused bytes should be 
+     relaxing. Such shrinking can cause issues for the sections such
+     as .vectors and .jumptables. Instead the unused bytes should be
      filled with nop instructions. */
   bfd_boolean shrinkable = TRUE;
 
@@ -1878,7 +1866,7 @@ elf32_avr_relax_section (bfd *abfd,
               distance_short_enough = 1;
             /* If shrinkable, then we can check for a range of distance which
                is two bytes farther on both the directions because the call
-               or jump target will be closer by two bytes after the 
+               or jump target will be closer by two bytes after the
                relaxation. */
             else if (shrinkable && ((int) gap >= -4094 && (int) gap <= 4097))
               distance_short_enough = 1;
@@ -1955,7 +1943,7 @@ elf32_avr_relax_section (bfd *abfd,
                                              R_AVR_13_PCREL);
 
                 /* We should not modify the ordering if 'shrinkable' is
-                   FALSE. */ 
+                   FALSE. */
                 if (!shrinkable)
                   {
                     /* Let's insert a nop.  */