diff options
author | Ian Lance Taylor <ian@airs.com> | 1994-03-30 22:15:07 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1994-03-30 22:15:07 +0000 |
commit | 326e32d7ce8a83f59192657c48c9b9980466b939 (patch) | |
tree | a6d893226affe8172c0ad504e14f8aded908d849 /bfd/archive.c | |
parent | 70f42bae0b1b4d71dfa1b0da6a29d1e82053b118 (diff) | |
download | gdb-326e32d7ce8a83f59192657c48c9b9980466b939.zip gdb-326e32d7ce8a83f59192657c48c9b9980466b939.tar.gz gdb-326e32d7ce8a83f59192657c48c9b9980466b939.tar.bz2 |
Wed Mar 30 16:25:41 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
Changes to let BFD return an error indication from
get_symtab_upper_bound, bfd_canonicalize_symtab,
bfd_get_reloc_upper_bound, and bfd_canonicalize_reloc. They now
return long instead of unsigned int, and use -1 to indicate an
error. Along the way, rename get_symtab_upper_bound to
bfd_get_symtab_upper_bound.
* bfd.c (bfd_get_reloc_upper_bound): Return long, and -1 on
errors.
(bfd_canonicalize_reloc): Likewise.
* syms.c (bfd_get_symtab_upper_bound): Renamed from
get_symtab_upper_bound.
* targets.c (bfd_target): Renamed _get_symtab_upper_bound to
_bfd_get_symtab_upper_bound, and changed it and
_bfd_canonicalize_symtab and _get_reloc_upper_bound and
_bfd_canonicalize_reloc to all return long.
* aoutx.h (NAME(aout,get_symtab)): Return long, and -1 on errors.
(NAME(aout,canonicalize_reloc)): Likewise.
(NAME(aout,get_reloc_upper_bound)): Likewise.
(NAME(aout,get_symtab_upper_bound)): Likewise.
* bout.c (b_out_canonicalize_reloc): Likewise.
(b_out_get_reloc_upper_bound): Likewise.
* coffcode.h (coff_canonicalize_reloc): Likewise.
* coffgen.c (coff_get_symtab_upper_bound): Likewise.
(coff_get_symtab): Likewise.
(coff_get_reloc_upper_bound): Likewise.
* ecoff.c (ecoff_get_symtab_upper_bound): Likewise.
(ecoff_get_symtab): Likewise.
(ecoff_canonicalize_reloc): Likewise.
* elfcode.h (elf_get_symtab_upper_bound): Likewise.
(elf_get_reloc_upper_bound): Likewise.
(elf_canonicalize_reloc): Likewise.
(elf_get_symtab): Likewise.
* hp300hpux.c (MY(get_symtab)): Likewise.
(MY(get_symtab_upper_bound)): Likewise.
(MY(canonicalize_reloc)): Likewise.
* i386lynx.c (NAME(lynx,canonicalize_reloc)): Likewise.
* ieee.c (ieee_slurp_external_symbols): Change return type to
boolean. Check for errors from get_symbol.
(ieee_slurp_symbol_table): Change return type to boolean. Check
for errors from ieee_slurp_external_symbols.
(ieee_get_symtab_upper_bound): Return long, and -1 on errors.
(ieee_get_symtab): Likewise.
(ieee_get_reloc_upper_bound): Likewise.
(ieee_canonicalize_reloc): Likewise.
* mipsbsd.c (MY(canonicalize_reloc)): Likewise.
* nlmcode.h (nlm_get_symtab_upper_bound): Likewise.
(nlm_get_symtab): Likewise.
(nlm_get_reloc_upper_bound): Likewise.
(nlm_canonicalize_reloc): Likewise.
* oasys.c (oasys_get_symtab_upper_bound): Likewise.
(oasys_get_symtab): Likewise.
(oasys_get_reloc_upper_bound): Likewise.
(oasys_canonicalize_reloc): Likewise.
* som.c (som_get_symtab_upper_bound): Likewise.
(som_get_symtab): Likewise.
(som_get_reloc_upper_bound): Likewise.
(som_canonicalize_reloc): Likewise.
* srec.c (srec_get_symtab_upper_bound): Likewise.
(srec_get_symtab): Likewise.
(srec_get_reloc_upper_bound): Define as bfd_0l.
(srec_canonicalize_reloc): Likewise.
* tekhex.c (tekhex_get_symtab): Return long, and -1 on errors.
(tekhex_get_symtab_upper_bound): Likewise.
(tekhex_get_reloc_upper_bound): Define as bfd_0l.
(tekhex_canonicalize_reloc): Likewise.
* libaout.h (NAME(aout,get_symtab_upper_bound)): Change
declaration to return long.
(NAME(aout,get_symtab)): Likewise.
(NAME(aout,canonicalize_reloc)): Likewise.
(NAME(aout,get_reloc_upper_bound)): Likewise.
* libcoff-in.h (coff_get_symtab_upper_bound): Likewise.
(coff_get_symtab): Likewise.
(coff_get_reloc_upper_bound): Likewise.
* libecoff.h (ecoff_get_symtab_upper_bound): Likewise.
(ecoff_get_symtab): Likewise.
(ecoff_canonicalize_reloc): Likewise.
* libelf.h (bfd_elf32_get_symtab_upper_bound): Likewise.
(bfd_elf32_get_symtab): Likewise.
(bfd_elf32_get_reloc_upper_bound): Likewise.
(bfd_elf32_canonicalize_reloc): Likewise.
(bfd_elf64_get_symtab_upper_bound): Likewise.
(bfd_elf64_get_symtab): Likewise.
(bfd_elf64_get_reloc_upper_bound): Likewise.
(bfd_elf64_canonicalize_reloc): Likewise.
* libnlm.h (nlmNAME(get_symtab_upper_bound)): Likewise.
(nlmNAME(get_symtab)): Likewise.
(nlmNAME(get_reloc_upper_bound)): Likewise.
(nlmNAME(canonicalize_reloc)): Likewise.
* archive.c (compute_and_write_armap): Use error_return and
no_memory_return labels rather than freeing information in various
places. Change storage, symcount and src_count to long. Check
errors from bfd_get_symtab_upper_bound and
bfd_canonicalize_symtab.
* bout.c (b_out_relax_section): Change reloc_size to long. Check
for errors from bfd_get_reloc_upper_bound and
bfd_canonicalize_reloc.
(b_out_get_relocated_section_contents): Likewise.
* coff-alpha.c (alpha_ecoff_get_relocated_section_contents):
Likewise.
* elf32-mips.c: Likewise.
* elf32-hppa.c (hppa_elf_stub_finish): Likewise.
(hppa_look_for_stubs_in_section): Check for errors from
bfd_get_symtab_upper_bound, bfd_canonicalize_symtab, and
bfd_canonicalize_reloc.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Check for errors
from bfd_get_symtab_upper_bound and bfd_canonicalize_symtab.
* linker.c (generic_link_read_symbols): Likewise.
(_bfd_generic_final_link): Check for errors from
bfd_get_reloc_upper_bound and bfd_canonicalize_reloc.
* reloc.c (bfd_generic_get_relocated_section_contents): Likewise.
* reloc16.c (bfd_coff_reloc16_relax_section): Likewise.
(bfd_coff_reloc16_get_relocated_section_contents): Likewise.
* libbfd.c (bfd_0l): New function.
* libbfd-in.h (bfd_0l): Declare.
* aix386-core.c: Change get_symtab_upper_bound, get_symtab,
get_reloc_upper_bound, and canonicalize_reloc to use bfd_0l rather
than bfd_0u.
* cisco-core.c, hppabsd-core.c, hpux-core.c: Likewise.
* irix-core.c, osf-core.c, ptrace-core.c, trad-core.c: Likewise.
* bfd-in2.h: Rebuilt.
* libbfd.h: Rebuilt.
* libcoff.h: Rebuilt.
* nlm32-sparc.c (nlm_sparc_read_reloc): Remove unused variables
temp and name.
Diffstat (limited to 'bfd/archive.c')
-rw-r--r-- | bfd/archive.c | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/bfd/archive.c b/bfd/archive.c index 50421ca..88e6dfa 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -1596,15 +1596,15 @@ compute_and_write_armap (arch, elength) bfd *arch; unsigned int elength; { - char *first_name; + char *first_name = NULL; bfd *current; file_ptr elt_no = 0; - struct orl *map; + struct orl *map = NULL; int orl_max = 1024; /* fine initial default */ int orl_count = 0; int stridx = 0; /* string index */ asymbol **syms = NULL; - unsigned int syms_max = 0; + long syms_max = 0; boolean ret; /* Dunno if this is the best place for this info... */ @@ -1614,20 +1614,13 @@ compute_and_write_armap (arch, elength) map = (struct orl *) malloc (orl_max * sizeof (struct orl)); if (map == NULL) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + goto no_memory_return; /* We put the symbol names on the arch obstack, and then discard them when done. */ first_name = bfd_alloc (arch, 1); if (first_name == NULL) - { - free (map); - bfd_set_error (bfd_error_no_memory); - return false; - } + goto no_memory_return; /* Drop all the files called __.SYMDEF, we're going to make our own */ @@ -1643,11 +1636,14 @@ compute_and_write_armap (arch, elength) if ((bfd_check_format (current, bfd_object) == true) && ((bfd_get_file_flags (current) & HAS_SYMS))) { - unsigned int storage; - unsigned int symcount; - unsigned int src_count; + long storage; + long symcount; + long src_count; + + storage = bfd_get_symtab_upper_bound (current); + if (storage < 0) + goto error_return; - storage = get_symtab_upper_bound (current); if (storage != 0) { if (storage > syms_max) @@ -1655,16 +1651,13 @@ compute_and_write_armap (arch, elength) if (syms_max > 0) free (syms); syms_max = storage; - syms = (asymbol **) malloc (syms_max); + syms = (asymbol **) malloc ((size_t) syms_max); if (syms == NULL) - { - free (map); - bfd_release (arch, first_name); - bfd_set_error (bfd_error_no_memory); - return false; - } + goto no_memory_return; } symcount = bfd_canonicalize_symtab (current, syms); + if (symcount < 0) + goto error_return; /* Now map over all the symbols, picking out the ones we want */ for (src_count = 0; src_count < symcount; src_count++) @@ -1689,14 +1682,7 @@ compute_and_write_armap (arch, elength) realloc ((PTR) map, orl_max * sizeof (struct orl))); if (new_map == (struct orl *) NULL) - { - free_and_quit: - free (syms); - free (map); - bfd_release (arch, first_name); - bfd_set_error (bfd_error_no_memory); - return false; - } + goto no_memory_return; map = new_map; } @@ -1706,10 +1692,10 @@ compute_and_write_armap (arch, elength) bfd_alloc (arch, sizeof (char *))); if (map[orl_count].name == NULL) - goto free_and_quit; + goto no_memory_return; *(map[orl_count].name) = bfd_alloc (arch, namelen + 1); if (*(map[orl_count].name) == NULL) - goto free_and_quit; + goto no_memory_return; strcpy (*(map[orl_count].name), syms[src_count]->name); (map[orl_count]).pos = (file_ptr) current; (map[orl_count]).namidx = stridx; @@ -1728,10 +1714,25 @@ compute_and_write_armap (arch, elength) if (syms_max > 0) free (syms); - free (map); - bfd_release (arch, first_name); + if (map != NULL) + free (map); + if (first_name != NULL) + bfd_release (arch, first_name); return ret; + + no_memory_return: + bfd_set_error (bfd_error_no_memory); + + error_return: + if (syms_max > 0) + free (syms); + if (map != NULL) + free (map); + if (first_name != NULL) + bfd_release (arch, first_name); + + return false; } boolean |