summaryrefslogtreecommitdiff
path: root/bfd/elf32-xstormy16.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2002-07-07 09:10:41 +0000
committerAlan Modra <amodra@bigpond.net.au>2002-07-07 09:10:41 +0000
commit5621f0d7ffa04af5fd362685dff00d3d6acfd9f1 (patch)
tree7e6057d0c6d48e5896826402da5c359dc8473e9d /bfd/elf32-xstormy16.c
parent9afab7719d9020caac002e85299650b75a99f4f9 (diff)
downloadbinutils-redhat-5621f0d7ffa04af5fd362685dff00d3d6acfd9f1.tar.gz
* elf-bfd.h (struct elf_reloc_cookie): Remove locsym_shndx,
change type of locsyms. (bfd_elf_get_elf_syms): Declare. * elf.c (bfd_elf_get_elf_syms): New function. (group_signature): Use bfd_elf_get_elf_syms. (bfd_section_from_r_symndx): Likewise. * elfcode.h (elf_slurp_symbol_table): Likewise. * elflink.h (elf_link_is_defined_archive_symbol): Likewise. (elf_link_add_object_symbols): Likewise. Reorganise to increase locality of various data structures. Properly free internal relocs. (elf_bfd_final_link): Properly free internal relocs. (elf_link_check_versioned_symbol): Use bfd_elf_get_elf_syms. (elf_link_input_bfd): Likewise. (elf_gc_mark): Likewise. Properly free internal relocs. (elf_gc_sweep): Properly free internal relocs. (elf_reloc_symbol_deleted_p): No need to swap syms in. (elf_bfd_discard_info): Use bfd_elf_get_elf_syms. Properly free internal relocs. * elf-m10200.c (mn10200_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free possibly cached info. (mn10200_elf_relax_delete_bytes): Remove symbol swapping code. (mn10200_elf_symbol_address_p): Pass in internal syms. Remove symbol swapping code. (mn10200_elf_get_relocated_section_contents): Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf-m10300.c (mn10300_elf_relax_section): As above for elf-m10200.c. (mn10300_elf_relax_delete_bytes): Likewise. (mn10300_elf_symbol_address_p): Likewise. (mn10300_elf_get_relocated_section_contents): Likewise. * elf32-h8300.c (elf32_h8_relax_section): As above for elf-m10200.c. (elf32_h8_relax_delete_bytes): Likewise. (elf32_h8_symbol_address_p): Likewise. (elf32_h8_get_relocated_section_contents): Likewise. * elf32-m32r.c (m32r_elf_relax_section): As above for elf-m10200.c. (m32r_elf_relax_delete_bytes): Likewise. (m32r_elf_get_relocated_section_contents): Likewise. * elf32-sh.c (sh_elf_reloc_loop): Free section contents using elf_section_data to determine whether cached. (sh_elf_relax_section): As above for elf-m10200.c. (sh_elf_relax_delete_bytes): Likewise. (sh_elf_get_relocated_section_contents): Likewise. * elf32-xstormy16.c (xstormy16_elf_relax_section): As above. * elf64-alpha.c (elf64_alpha_relax_section): As above. Also delay reading of local syms. * elf64-mmix.c (mmix_elf_relax_section): Likewise. * elf64-sh64.c (sh_elf64_get_relocated_section_contents): As above. * elfxx-ia64.c (elfNN_ia64_relax_section): As above. * elfxx-mips.c (_bfd_mips_elf_check_relocs): Properly free internal relocs. * elf32-arm.h (bfd_elf32_arm_process_before_allocation): Properly free internal relocs and section contents. Don't read symbols. * elf32-hppa.c (get_local_syms): Use bfd_elf_get_elf_syms. (elf32_hppa_size_stubs): Don't free local syms. * elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Delay reading of local syms. Use bfd_elf_get_elf_syms. Properly free possibly cached info. * elf32-mips.c (bfd_mips_elf32_create_embedded_relocs): Likewise. * elf64-hppa.c (elf64_hppa_check_relocs): Use bfd_elf_get_elf_syms. * elf64-ppc.c (struct ppc_link_hash_table): Delete bfd_count and all_local_syms. (get_local_syms): Delete function. (edit_opd): Use bfd_elf_get_elf_syms. Free on error exit. Cache on exit. (ppc64_elf_size_stubs): Use bfd_elf_get_elf_syms. Free/cache on exit.
Diffstat (limited to 'bfd/elf32-xstormy16.c')
-rw-r--r--bfd/elf32-xstormy16.c85
1 files changed, 27 insertions, 58 deletions
diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c
index 8f83f31581..ada29d8db4 100644
--- a/bfd/elf32-xstormy16.c
+++ b/bfd/elf32-xstormy16.c
@@ -586,88 +586,51 @@ xstormy16_elf_relax_section (dynobj, splt, info, again)
&relax_plt_data);
/* Likewise for local symbols, though that's somewhat less convenient
- as we have walk the list of input bfds and swap in symbol data. */
+ as we have to walk the list of input bfds and swap in symbol data. */
for (ibfd = info->input_bfds; ibfd ; ibfd = ibfd->link_next)
{
bfd_vma *local_plt_offsets = elf_local_got_offsets (ibfd);
Elf_Internal_Shdr *symtab_hdr;
- Elf_Internal_Shdr *shndx_hdr;
- Elf32_External_Sym *extsyms;
- Elf_External_Sym_Shndx *shndx_buf;
+ Elf_Internal_Sym *isymbuf = NULL;
unsigned int idx;
if (! local_plt_offsets)
continue;
symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
- shndx_hdr = &elf_tdata (ibfd)->symtab_shndx_hdr;
-
- if (symtab_hdr->contents != NULL)
- extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
- else
+ if (symtab_hdr->sh_info != 0)
{
- bfd_size_type amt;
-
- amt = symtab_hdr->sh_info;
- amt *= sizeof (Elf32_External_Sym);
- extsyms = (Elf32_External_Sym *) bfd_malloc (amt);
- if (extsyms == NULL)
+ isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
+ if (isymbuf == NULL)
+ isymbuf = bfd_elf_get_elf_syms (ibfd, symtab_hdr,
+ symtab_hdr->sh_info, 0,
+ NULL, NULL, NULL);
+ if (isymbuf == NULL)
return false;
- if (bfd_seek (ibfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || bfd_bread ((PTR) extsyms, amt, ibfd) != amt)
- {
- error_ret_free_extsyms:
- free (extsyms);
- return false;
- }
- }
-
- shndx_buf = NULL;
- if (shndx_hdr->sh_size != 0)
- {
- bfd_size_type amt;
-
- amt = symtab_hdr->sh_info;
- amt *= sizeof (Elf_External_Sym_Shndx);
- shndx_buf = (Elf_External_Sym_Shndx *) bfd_malloc (amt);
- if (shndx_buf == NULL)
- goto error_ret_free_extsyms;
- if (bfd_seek (ibfd, shndx_hdr->sh_offset, SEEK_SET) != 0
- || bfd_bread ((PTR) shndx_buf, amt, ibfd) != amt)
- {
- free (shndx_buf);
- goto error_ret_free_extsyms;
- }
- shndx_hdr->contents = (bfd_byte *) shndx_buf;
}
for (idx = 0; idx < symtab_hdr->sh_info; ++idx)
{
- Elf_External_Sym_Shndx *shndx;
- Elf_Internal_Sym isym;
+ Elf_Internal_Sym *isym;
asection *tsec;
bfd_vma address;
if (local_plt_offsets[idx] == (bfd_vma) -1)
continue;
- shndx = shndx_buf;
- if (shndx != NULL)
- shndx += idx;
- bfd_elf32_swap_symbol_in (ibfd, (const PTR) (extsyms + idx),
- (const PTR) shndx, &isym);
- if (isym.st_shndx == SHN_UNDEF)
+ isym = &isymbuf[idx];
+ if (isym->st_shndx == SHN_UNDEF)
continue;
- else if (isym.st_shndx == SHN_ABS)
+ else if (isym->st_shndx == SHN_ABS)
tsec = bfd_abs_section_ptr;
- else if (isym.st_shndx == SHN_COMMON)
+ else if (isym->st_shndx == SHN_COMMON)
tsec = bfd_com_section_ptr;
else
- tsec = bfd_section_from_elf_index (ibfd, isym.st_shndx);
+ tsec = bfd_section_from_elf_index (ibfd, isym->st_shndx);
address = (tsec->output_section->vma
+ tsec->output_offset
- + isym.st_value);
+ + isym->st_value);
if (address <= 0xffff)
{
local_plt_offsets[idx] = -1;
@@ -676,11 +639,17 @@ xstormy16_elf_relax_section (dynobj, splt, info, again)
}
}
- if (shndx_buf != NULL)
- free (shndx_buf);
-
- if ((Elf32_External_Sym *) symtab_hdr->contents != extsyms)
- free (extsyms);
+ if (isymbuf != NULL
+ && symtab_hdr->contents != (unsigned char *) isymbuf)
+ {
+ if (! info->keep_memory)
+ free (isymbuf);
+ else
+ {
+ /* Cache the symbols for elf_link_input_bfd. */
+ symtab_hdr->contents = (unsigned char *) isymbuf;
+ }
+ }
}
/* If we changed anything, walk the symbols again to reallocate