* elf32-m68hc1x.h (struct m68hc11_elf_link_hash_table): Remove
authorStephane Carrez <stcarrez@nerim.fr>
Sat, 6 Sep 2003 21:09:40 +0000 (21:09 +0000)
committerStephane Carrez <stcarrez@nerim.fr>
Sat, 6 Sep 2003 21:09:40 +0000 (21:09 +0000)
all_local_syms member.
* elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Use bfd_elf_get_elf_syms
to get the local symbols.

bfd/ChangeLog
bfd/elf32-m68hc1x.c
bfd/elf32-m68hc1x.h

index 5b463bf61c1a71ac14268443ca5c76652bc85dc1..1e4df13b40a20adf9610c9e35fa69a303c6c8293 100644 (file)
@@ -1,3 +1,10 @@
+2003-09-06  Stephane Carrez  <stcarrez@nerim.fr>
+
+       * elf32-m68hc1x.h (struct m68hc11_elf_link_hash_table): Remove
+       all_local_syms member.
+       * elf32-m68hc1x.c (elf32_m68hc11_size_stubs): Use bfd_elf_get_elf_syms
+       to get the local symbols.
+
 2003-09-06  Stephane Carrez  <stcarrez@nerim.fr>
 
        * elf32-m68hc12.c (elf32_m68hc12_special_sections): New for hc11.
index b31fc7b454b6cae20a7bfe9b8d5ce6af06030283..8d71cb659e6f5f6196804c71d85cee598e13a16b 100644 (file)
@@ -367,76 +367,29 @@ elf32_m68hc11_size_stubs (output_bfd, stub_bfd, info, add_stub_section)
        input_bfd = input_bfd->link_next, bfd_indx++)
     {
       Elf_Internal_Shdr *symtab_hdr;
-      Elf_Internal_Shdr *shndx_hdr;
-      Elf_Internal_Sym *isym;
-      Elf32_External_Sym *extsyms, *esym, *end_sy;
-      Elf_External_Sym_Shndx *shndx_buf, *shndx;
-      bfd_size_type sec_size;
 
       /* We'll need the symbol table in a second.  */
       symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
       if (symtab_hdr->sh_info == 0)
        continue;
 
-      /* We need an array of the local symbols attached to the input bfd.
-        Unfortunately, we're going to have to read & swap them in.  */
-      sec_size = symtab_hdr->sh_info;
-      sec_size *= sizeof (Elf_Internal_Sym);
-      local_syms = (Elf_Internal_Sym *) bfd_malloc (sec_size);
+      /* We need an array of the local symbols attached to the input bfd.  */
+      local_syms = (Elf_Internal_Sym *) symtab_hdr->contents;
+      if (local_syms == NULL)
+       {
+         local_syms = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
+                                            symtab_hdr->sh_info, 0,
+                                            NULL, NULL, NULL);
+         /* Cache them for elf_link_input_bfd.  */
+         symtab_hdr->contents = (unsigned char *) local_syms;
+       }
       if (local_syms == NULL)
-       goto error_ret_free_local;
-
-      all_local_syms[bfd_indx] = local_syms;
-      sec_size = symtab_hdr->sh_info;
-      sec_size *= sizeof (Elf32_External_Sym);
-
-      /* Get the cached copy.  */
-      if (symtab_hdr->contents != NULL)
-        extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
-      else
-        {
-          /* Go get them off disk.  */
-          bfd_size_type amt = symtab_hdr->sh_size;
-          extsyms = (Elf32_External_Sym *) bfd_malloc (amt);
-          if (extsyms == NULL)
-            goto error_ret_free_local;
-
-          if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
-              || bfd_bread ((PTR) extsyms, amt, input_bfd) != amt)
-            {
-            error_ret_free_ext_syms:
-              free (extsyms);
-              goto error_ret_free_local;
-            }
-        }
-      shndx_buf = NULL;
-      shndx_hdr = &elf_tdata (input_bfd)->symtab_shndx_hdr;
-      if (shndx_hdr->sh_size != 0)
         {
-          bfd_size_type amt;
-
-          amt = symtab_hdr->sh_info * sizeof (Elf_External_Sym_Shndx);
-          shndx_buf = (Elf_External_Sym_Shndx *) bfd_malloc (amt);
-          if (shndx_buf == NULL)
-            goto error_ret_free_ext_syms;
-          if (bfd_seek (input_bfd, shndx_hdr->sh_offset, SEEK_SET) != 0
-              || bfd_bread ((PTR) shndx_buf, amt, input_bfd) != amt)
-            {
-              free (shndx_buf);
-              goto error_ret_free_ext_syms;
-            }
-          shndx_hdr->contents = (PTR) shndx_buf;
+          free (all_local_syms);
+         return FALSE;
         }
 
-      /* Swap the local symbols in.  */
-      for (esym = extsyms, end_sy = esym + symtab_hdr->sh_info,
-            isym = local_syms, shndx = shndx_buf;
-          esym < end_sy;
-          esym++, isym++, shndx = (shndx ? shndx + 1 : NULL))
-       bfd_elf32_swap_symbol_in (input_bfd, esym, shndx, isym);
-
-      /* Now we can free the external symbols.  */
-      free (shndx_buf);
+      all_local_syms[bfd_indx] = local_syms;
     }
 
   for (input_bfd = info->input_bfds, bfd_indx = 0;
@@ -608,11 +561,11 @@ elf32_m68hc11_size_stubs (output_bfd, stub_bfd, info, add_stub_section)
 
       bfd_hash_traverse (htab->stub_hash_table, htab->size_one_stub, htab);
     }
-  free (htab->all_local_syms);
+  free (all_local_syms);
   return TRUE;
 
  error_ret_free_local:
-  free (htab->all_local_syms);
+  free (all_local_syms);
   return FALSE;
 }
 
index e70c172c37dac75e0a26486ed753072eed4c4776..c5e937282b1728fb23b19c029c5a8e919f74f2e5 100644 (file)
@@ -118,7 +118,6 @@ struct m68hc11_elf_link_hash_table
   unsigned int bfd_count;
   int top_index;
   asection **input_list;
-  Elf_Internal_Sym **all_local_syms;
 
   /* Small local sym to section mapping cache.  */
   struct sym_sec_cache sym_sec;