Commit Graph

9 Commits

Author SHA1 Message Date
Ian Lance Taylor 58142f101d * libbfd.c (bfd_malloc, bfd_realloc): New functions.
(bfd_zmalloc): Return PTR, not char *.  Take size_t, not
	bfd_size_type.
	* libbfd-in.h (bfd_malloc, bfd_realloc): Declare.
	(bfd_zmalloc): Change declaration.
	* libbfd.h: Rebuild.
	* Many files: Use bfd_malloc and bfd_realloc rather than malloc
	and realloc.  Don't set bfd_error_no_memory if they fail.
1995-12-01 19:48:10 +00:00
Ian Lance Taylor a9713b91a7 * opncls.c (bfd_alloc_by_size_t): Set bfd_error_no_memory if
obstack_alloc fails.
	(bfd_alloc_finish): Set bfd_error_no_memory if obstack_finish
	fails.
	* libbfd.c (bfd_zmalloc): Set bfd_error_no_memory if malloc fails.
	* Many files: don't set bfd_error_no_memory if one of the above
	routines fails.
1995-11-29 22:05:37 +00:00
Ian Lance Taylor 2f3508ad05 * Many files: change all bfd_target vectors to be const. Change
all uses of bfd_target * to be const bfd_target *.  Change
	bfd_target_vector and bfd_default_vector arrays to be const
	bfd_target * const *.
1994-06-20 21:55:45 +00:00
Ian Lance Taylor b3cee0a981 * aoutx.h (NAME(aout,canonicalize_reloc)): Don't error out if
section->relocation is NULL; malloc might have returned NULL when
	given a zero size if there were no relocations.
	* bout.c (b_out_canonicalize_reloc): Likewise.
	* coffcode.h (coff_canonicalize_reloc): Likewise.
	* ecoff.c (ecoff_canonicalize_reloc): Likewise.
	* elfcode.h (elf_canonicalize_reloc): Likewise.
	* mipsbsd.c (MY(canonicalize_reloc)): Likewise.
	* i386lynx.c (NAME(lynx,canonicalize_reloc)): Likewise.
	* nlmcode.h (nlm_canonicalize_reloc): Likewise.
	* som.c (som_canonicalize_reloc): Likewise.
	* hp300hpux.c (MY(slurp_reloc_table)): Likewise.  Also, if malloc
	returns NULL, don't report an error if we asked for zero bytes.
	* i386lynx.c (NAME(lynx,slurp_reloc_table)): If malloc returns
	NULL, don't report an error if we asked for zero bytes.
	* nlmcode.h (nlm_slurp_reloc_fixups): Likewise.
1994-04-05 15:32:49 +00:00
Ian Lance Taylor 4002f18a05 Made sure that every call to bfd_read, bfd_write, and bfd_seek
checks the return value and handled bfd_error correctly.  These
	changes are not itemised.
1994-04-04 22:49:04 +00:00
Ian Lance Taylor 5c8444f8f8 Add bfd_free_cached_info support to a.out backends.
* aoutx.h (aout_get_external_symbols): Renamed from
	aout_link_get_symbols.  Read strings even if symbols have been
	read.  Store string size in obj_aout_string_size.
	(NAME(aout,slurp_symbol_table)): Call aout_get_external_symbols to
	read the symbols.  Allocate the cached symbols with malloc, not
	bfd_alloc.
	(NAME(aout,slurp_reloc_table)): Allocate the cached relocs with
	malloc, not bfd_alloc.
	(NAME(aout,bfd_free_cached_info)): New function; free cached
	symbols and relocs.
	* libaout.h (struct aoutdata): Add external_string_size field.
	(obj_aout_external_string_size): New accessor macro.
	(NAME(aout,close_and_cleanup)): Don't declare.
	(NAME(aout,bfd_free_cached_info)): Declare.
	(aout_32_close_and_cleanup): Don't define.
	(aout_64_close_and_cleanup): Don't define.
	* aout-target.h (MY_bfd_free_cached_info): If not already defined,
	define as NAME(aout,free_cached_info).
	(MY_close_and_cleanup): If not already defined, define as
	MY_bfd_free_cached_info.
	* aout-adobe.c (aout_32_close_and_cleanup): Define.
	(aout_32_bfd_free_cached_info): Don't define.
	* bout.c (aout_32_close_and_cleanup): Define.
	(aout_32_bfd_free_cached_info): Don't define.
	* hp300hpux.c (MY_bfd_free_cached_info): Define as bfd_true.
	(MY_close_and_cleanup): Don't define.
	* i386lynx.c (NAME(lynx,slurp_reloc_table)): Allocate the cached
	relocs with malloc, not bfd_alloc.
	* i386os9k.c (aout_32_close_and_cleanup): Define.
	(aout_32_bfd_free_cached_info): Don't define.
1994-04-01 22:08:38 +00:00
Ian Lance Taylor 326e32d7ce 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.
1994-03-30 22:15:07 +00:00
Jeff Law 250578363e * libbfd.c (bfd_read): Set bfd_error as appropriate for a short
read. (bfd_error_system_call or bfd_error_file_truncated).

        * som.c: Do not blindly set bfd_error_system_call after a
        failing bfd_read, bfd_write, or bfd_seek.  In a few places
        (like som_object_p) override the error status set by bfd_read.

        * aix386-core.c, aout-encap,c archive.c, bout.c: Likewise.
        * coff-rs6000.c, coffgen.c ecoff.c, elf.c: Likewise.
        * elf32-hppa.c, elfcode.h, hp300hpux.c, i386lynx.c: Likewise.
        * nlm32-alpha.c, nlm32-i386.c, nlm32-sparc.c: Likewise.

        * som.c: Check return values from several bfd_{seek,read,write}
        calls that we just assumed were not failing.
1994-03-26 18:28:29 +00:00
Stan Shebs 48ee075741 * configure.in: i386lynx_coff_vec requires coff-i386lynx.o.
* coff-i386lynx.c: New file, defines Lynx target vector and name,
	includes coff-i386.c.
	* coff-i386.c (i386coff_vec): Allow redefinition of target vector
	symbol and name, if TARGET_SYM and/or TARGET_NAME are defined.
	* i386lynx.c: Remove coff vector definition entirely.
	(lynx_32_swap_ext_reloc_in): Define.
	(lynx_32_swap_std_reloc_in): Define, get reloc bits in i386
	Lynx-specific way.
	(lynx_32_swap_ext_reloc_out): Define.
	(lynx_32_swap_std_reloc_out): Define.
	(lynx_32_slurp_reloc_table): Define, call Lynx swapping fns.
	(lynx_32_squirt_out_relocs): Define, call Lynx swapping fns.
	(lynx_32_canonicalize_reloc): Define, call Lynx swapping fns.
	(WRITE_HEADERS): Define, call Lynx swapping fns.

	* config/i386-lynx.mt (SELECT_VECS): Remove redundant vector.
1993-10-01 21:42:59 +00:00