mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-11-28 14:30:48 +00:00
Make all callers of malloc or realloc (including via obstacks)
check the result for NULL. Most set bfd_error to no_memory and return in that case; a few are harder to fix, and are marked with "FIXME <return type>". * elf32-hppa.c (hppa_elf_build_arg_reloc_stub hppa_elf_build_long_branch_stub): Check bfd_make_empty_symbol return. * linker.c (_bfd_generic_link_output_symbols _bfd_generic_link_write_global_symbol): Ditto * section.c (bfd_make_section_anyway): Ditto. * tekhex.c (find_chunk tekhex_mkobject): Check bfd_alloc. (first_phase): Ditto. FIXME void (tekhex_make_empty_symbol): Check bfd_zalloc. * sunos.c (sunos_read_dynamic_info): Check bfd_zalloc. (MY(read_dynamic_symbols) MY(read_dynamic_relocs)): Check bfd_alloc. * stringhash.c (_bfd_stringtab_hash_newfunc): Check bfd_hash_allocate. * srec.c: Indent. (fillup_symbols): Check bfd_alloc. FIXME void (srec_mkobject srec_get_section_contents srec_set_section_contents): Check bfd_alloc. (srec_make_empty_symbol): Check bfd_zalloc. * som.c (hppa_som_gen_reloc_type): Check bfd_alloc_by_size_t. (make_unique_section): Check bfd_alloc. (som_new_section_hook): Check bfd_zalloc. (bfd_som_attach_aux_hdr): Ditto. FIXME void * rs6000-core.c (rs6000coff_core_p): Check bfd_zalloc. * osf-core.c (osf_core_make_empty_symbol): Check bfd_zalloc. (osf_core_core_file_p): Check bfd_alloc. * oasys.c (oasys_slurp_symbol_table oasys_archive_p oasys_mkobject oasys_object_p oasys_new_section_hook oasys_set_section_contents): Check bfd_alloc. (oasys_slurp_section_data): Check bfd_zalloc and bfd_alloc. (oasys_make_empty_symbol): Check bfd_zalloc. * nlmcode.h (nlm_make_empty_symbol): Check bfd_zalloc. (nlm_slurp_symbol_table): Check bfd_zalloc and bfd_alloc. * nlm32-sparc.c (nlm_sparc_read_import): Check bfd_alloc. * nlm32-i386.c (nlm_i386_read_import): Check bfd_alloc. * nlm32-alpha.c (nlm_alpha_read_import): Check bfd_alloc. * linker.c (_bfd_link_hash_newfunc (generic_link_hash_newfunc (archive_hash_newfunc (_bfd_generic_link_add_one_symbol): Check bfd_hash_allocate. (_bfd_generic_final_link (_bfd_generic_link_output_symbols (default_indirect_link_order): Check bfd_alloc. (bfd_new_link_order): Check bfd_alloc_by_size_t. * irix-core.c (irix_core_make_empty_symbol): Check bfd_zalloc. * ieee.c: Indent. (read_id get_symbol get_section_entry ieee_archive_p ieee_object_p ieee_slurp_section_data ieee_new_section_hook): Check bfd_alloc. (do_one): Check bfd_alloc. Return a boolean. (ieee_slurp_section_data): Check it. (init_for_output): Check bfd_alloc. Return a boolean. (ieee_set_section_contents): Check it. (do_with_relocs): Check bfd_alloc. Return a boolean. (ieee_bfd_debug_info_accumulate): Ditto. FIXME void. (ieee_mkobject): Check bfd_zalloc. (ieee_make_empty_symbol): Check bfd_zmalloc. * hpux-core.c (hpux_core_make_empty_symbol): Check bfd_zalloc. * hppabsd-core.c (hppabsd_core_make_empty_symbol): Check bfd_zalloc. (hppabsd_core_core_file_p): Check bfd_zalloc. * hp300hpux.c (MY(slurp_symbol_table)): Check bfd_alloc. * elfcode.h (elf_new_section_hook): Check bfd_alloc. (bfd_section_from_phdr): Ditto. (write_relocs): Ditto. FIXME void (elf_map_symbols assign_section_numbers map_program_segments): Ditto. Return a boolean. (swap_out_syms): Ditto. Check elf_map_symbols. (elf_slurp_symbol_table): Check bfd_zalloc. (elf_slurp_reloca_table): Check bfd_alloc. (elf_slurp_reloc_table): Ditto. (elf_compute_section_file_positions): Check assign_section_numbers. (assign_file_positions_except_relocs): Return a boolean. Check map_program_segments. (elf_compute_section_file_positions): Check it. * elf32-mips.c (mips_elf_final_link): Check bfd_alloc. * elf32-hppa.c (hppa_elf_stub_branch_reloc): Check bfd_zmalloc and realloc. (hppa_elf_stub_reloc): Ditto. (hppa_elf_build_arg_reloc_stub): Check bfd_zalloc. (hppa_elf_build_long_branch_stub): Ditto. (elf32_hppa_backend_symbol_table_processing): Ditto. * ecoff.c (ecoff_set_symbol_info): Check bfd_alloc. Return a boolean. (ecoff_slurp_symbol_table): Check it. (ecoff_slurp_armap): Check bfd_alloc. (ecoff_write_armap): Check bfd_zalloc. (ecoff_link_hash_newfunc): Check bfd_hash_allocate and _bfd_link_hash_newfunc. (ecoff_link_add_externals): Check bfd_alloc. * ctor.c (bfd_constructor_entry): Check bfd_alloc. * coffgen.c (coff_real_object_p): Check bfd_alloc. (coff_renumber_symbols): Check bfd_alloc_by_size_t. Return a boolean. (coff_write_symbol): Check bfd_alloc. FIXME int (coff_write_linenumbers): Check bfd_alloc. Return a boolean. (coff_section_symbol): Check bfd_alloc_by_size_t. (coff_get_normalized_symtab): Check bfd_alloc. (coff_bfd_make_debug_symbol): Check bfd_zalloc. * libcoff-in.h: Change decls of coff_renumber_symbols, coff_write_linenumbers. * libcoff.h: Rebuilt. * coffcode.h (coff_write_object_contents): Check coff_renumber_symbols, coff_write_linenumbers. * coffcode.h: Indent. (coff_add_missing_symbols): Check bfd_alloc_by_size_t. Return a boolean. (coff_write_object_contents): Check it. * coff-alpha.c (alpha_relocate_section): Check bfd_alloc. * coff-mips.c (mips_relocate_section): Ditto. * archive.c (bfd_slurp_bsd_armap_f2): Check bfd_alloc value. (do_slurp_bsd_armap): Ditto. (compute_and_write_armap): Check bfd_realloc value. * aoutx.h (translate_from_native_sym_flags): Check bfd_alloc return value. Return boolean value. (NAME(aout,make_empty_symbol)): Check bfd_zalloc return value. (NAME(aout,slurp_symbol_table)): Check bf_alloc and bfd_zalloc return value. (add_to_stringtab): Ditto. FIXME void (aout_link_hash_newfunc): Check bfd_hash_allocate return value. (aout_link_add_symbols): Check bfd_alloc value. (translate_symbol_table): Check translate_from_native_sym_flags. * hp300hpux.c (MY(slurp_symbol_table)): Ditto. * aoutx.h (aout_link_hash_newfunc): Check _bfd_link_hash_newfunc. * opncls.c (bfd_zalloc bfd_realloc): Check result of bfd_alloc. * opncls.c (obstack_chunk_alloc): Define as malloc, not bfd_xmalloc_by_size_t. (_bfd_new_bfd): Check obstack_begin for 0 return. * ieee.c (obstack_chunk_alloc): Define as malloc, not bfd_xmalloc_by_size_t. (ieee_archive_p): Check obstack_begin for 0 return and obstack_finish for NULL return. * hash.c (obstack_chunk_alloc): Define as malloc, not bfd_xmalloc_by_size_t. (bfd_hash_table_init_n): Check obstack_begin for 0 return and obstack_finish for NULL return. (bfd_hash_lookup): Check obstack_alloc for NULL return. * ecofflink.c (obstack_chunk_alloc): Define as malloc, not bfd_xmalloc_by_size_t. bfd_ecoff_debug_accumulate bfd_ecoff_debug_accumulate_other): Check obstack_alloc. (add_file_shuffle add_memory_shuffle): Check obstack_alloc for NULL return. Return boolean, not void. (bfd_ecoff_debug_init): Check obstack_begin for 0 return. (bfd_ecoff_debug_accumulate): Check add_file_shuffle and add_memory_shuffle return. (string_hash_newfunc): Check bfd_hash_allocate and bfd_hash_newfunc. (bfd_ecoff_debug_accumulate): Check bfd_alloc. (ecoff_add_string): Check add_memory_shuffle return. * libbfd-in.h (xmalloc, bfd_xmalloc, bfd_xmalloc_by_size_t): Remove decls. * libbfd.h: Rebuilt.
This commit is contained in:
parent
704bbd0dc3
commit
9783e04a64
189
bfd/ChangeLog
189
bfd/ChangeLog
@ -1,3 +1,192 @@
|
||||
Tue Feb 8 08:57:31 1994 David J. Mackenzie (djm@thepub.cygnus.com)
|
||||
|
||||
Make all callers of malloc or realloc (including via obstacks)
|
||||
check the result for NULL. Most set bfd_error to no_memory and
|
||||
return in that case; a few are harder to fix, and are marked
|
||||
with "FIXME <return type>".
|
||||
|
||||
* elf32-hppa.c (hppa_elf_build_arg_reloc_stub
|
||||
hppa_elf_build_long_branch_stub): Check bfd_make_empty_symbol return.
|
||||
* linker.c (_bfd_generic_link_output_symbols
|
||||
_bfd_generic_link_write_global_symbol): Ditto
|
||||
* section.c (bfd_make_section_anyway): Ditto.
|
||||
|
||||
* tekhex.c (find_chunk tekhex_mkobject): Check bfd_alloc.
|
||||
(first_phase): Ditto. FIXME void
|
||||
(tekhex_make_empty_symbol): Check bfd_zalloc.
|
||||
|
||||
* sunos.c (sunos_read_dynamic_info): Check bfd_zalloc.
|
||||
(MY(read_dynamic_symbols) MY(read_dynamic_relocs)): Check bfd_alloc.
|
||||
|
||||
* stringhash.c (_bfd_stringtab_hash_newfunc): Check bfd_hash_allocate.
|
||||
|
||||
* srec.c: Indent.
|
||||
(fillup_symbols): Check bfd_alloc. FIXME void
|
||||
(srec_mkobject srec_get_section_contents
|
||||
srec_set_section_contents): Check bfd_alloc.
|
||||
(srec_make_empty_symbol): Check bfd_zalloc.
|
||||
|
||||
* som.c (hppa_som_gen_reloc_type): Check bfd_alloc_by_size_t.
|
||||
(make_unique_section): Check bfd_alloc.
|
||||
(som_new_section_hook): Check bfd_zalloc.
|
||||
(bfd_som_attach_aux_hdr): Ditto. FIXME void
|
||||
|
||||
* rs6000-core.c (rs6000coff_core_p): Check bfd_zalloc.
|
||||
|
||||
* osf-core.c (osf_core_make_empty_symbol): Check bfd_zalloc.
|
||||
(osf_core_core_file_p): Check bfd_alloc.
|
||||
|
||||
* oasys.c (oasys_slurp_symbol_table oasys_archive_p
|
||||
oasys_mkobject oasys_object_p oasys_new_section_hook
|
||||
oasys_set_section_contents): Check bfd_alloc.
|
||||
(oasys_slurp_section_data): Check bfd_zalloc and bfd_alloc.
|
||||
(oasys_make_empty_symbol): Check bfd_zalloc.
|
||||
|
||||
* nlmcode.h (nlm_make_empty_symbol): Check bfd_zalloc.
|
||||
(nlm_slurp_symbol_table): Check bfd_zalloc and bfd_alloc.
|
||||
|
||||
* nlm32-sparc.c (nlm_sparc_read_import): Check bfd_alloc.
|
||||
|
||||
* nlm32-i386.c (nlm_i386_read_import): Check bfd_alloc.
|
||||
|
||||
* nlm32-alpha.c (nlm_alpha_read_import): Check bfd_alloc.
|
||||
|
||||
* linker.c (_bfd_link_hash_newfunc
|
||||
(generic_link_hash_newfunc
|
||||
(archive_hash_newfunc
|
||||
(_bfd_generic_link_add_one_symbol): Check bfd_hash_allocate.
|
||||
(_bfd_generic_final_link
|
||||
(_bfd_generic_link_output_symbols
|
||||
(default_indirect_link_order): Check bfd_alloc.
|
||||
(bfd_new_link_order): Check bfd_alloc_by_size_t.
|
||||
|
||||
* irix-core.c (irix_core_make_empty_symbol): Check bfd_zalloc.
|
||||
|
||||
* ieee.c: Indent.
|
||||
(read_id get_symbol get_section_entry ieee_archive_p ieee_object_p
|
||||
ieee_slurp_section_data ieee_new_section_hook): Check bfd_alloc.
|
||||
(do_one): Check bfd_alloc. Return a boolean.
|
||||
(ieee_slurp_section_data): Check it.
|
||||
(init_for_output): Check bfd_alloc. Return a boolean.
|
||||
(ieee_set_section_contents): Check it.
|
||||
(do_with_relocs): Check bfd_alloc. Return a boolean.
|
||||
(ieee_bfd_debug_info_accumulate): Ditto. FIXME void.
|
||||
(ieee_mkobject): Check bfd_zalloc.
|
||||
(ieee_make_empty_symbol): Check bfd_zmalloc.
|
||||
|
||||
* hpux-core.c (hpux_core_make_empty_symbol): Check
|
||||
bfd_zalloc.
|
||||
|
||||
* hppabsd-core.c (hppabsd_core_make_empty_symbol): Check
|
||||
bfd_zalloc.
|
||||
(hppabsd_core_core_file_p): Check bfd_zalloc.
|
||||
|
||||
* hp300hpux.c (MY(slurp_symbol_table)): Check bfd_alloc.
|
||||
|
||||
* elfcode.h (elf_new_section_hook): Check bfd_alloc.
|
||||
(bfd_section_from_phdr): Ditto.
|
||||
(write_relocs): Ditto. FIXME void
|
||||
(elf_map_symbols assign_section_numbers map_program_segments):
|
||||
Ditto. Return a boolean.
|
||||
(swap_out_syms): Ditto. Check elf_map_symbols.
|
||||
(elf_slurp_symbol_table): Check bfd_zalloc.
|
||||
(elf_slurp_reloca_table): Check bfd_alloc.
|
||||
(elf_slurp_reloc_table): Ditto.
|
||||
(elf_compute_section_file_positions): Check assign_section_numbers.
|
||||
(assign_file_positions_except_relocs): Return a boolean.
|
||||
Check map_program_segments.
|
||||
(elf_compute_section_file_positions): Check it.
|
||||
|
||||
* elf32-mips.c (mips_elf_final_link): Check bfd_alloc.
|
||||
|
||||
* elf32-hppa.c (hppa_elf_stub_branch_reloc): Check bfd_zmalloc and
|
||||
realloc.
|
||||
(hppa_elf_stub_reloc): Ditto.
|
||||
(hppa_elf_build_arg_reloc_stub): Check bfd_zalloc.
|
||||
(hppa_elf_build_long_branch_stub): Ditto.
|
||||
(elf32_hppa_backend_symbol_table_processing): Ditto.
|
||||
|
||||
* ecoff.c (ecoff_set_symbol_info): Check bfd_alloc. Return a boolean.
|
||||
(ecoff_slurp_symbol_table): Check it.
|
||||
(ecoff_slurp_armap): Check bfd_alloc.
|
||||
(ecoff_write_armap): Check bfd_zalloc.
|
||||
(ecoff_link_hash_newfunc): Check bfd_hash_allocate and
|
||||
_bfd_link_hash_newfunc.
|
||||
(ecoff_link_add_externals): Check bfd_alloc.
|
||||
|
||||
* ctor.c (bfd_constructor_entry): Check bfd_alloc.
|
||||
|
||||
* coffgen.c (coff_real_object_p): Check bfd_alloc.
|
||||
(coff_renumber_symbols): Check bfd_alloc_by_size_t. Return a boolean.
|
||||
(coff_write_symbol): Check bfd_alloc. FIXME int
|
||||
(coff_write_linenumbers): Check bfd_alloc. Return a boolean.
|
||||
(coff_section_symbol): Check bfd_alloc_by_size_t.
|
||||
(coff_get_normalized_symtab): Check bfd_alloc.
|
||||
(coff_bfd_make_debug_symbol): Check bfd_zalloc.
|
||||
* libcoff-in.h: Change decls of coff_renumber_symbols,
|
||||
coff_write_linenumbers.
|
||||
* libcoff.h: Rebuilt.
|
||||
* coffcode.h (coff_write_object_contents): Check
|
||||
coff_renumber_symbols, coff_write_linenumbers.
|
||||
|
||||
* coffcode.h: Indent.
|
||||
(coff_add_missing_symbols): Check bfd_alloc_by_size_t. Return a
|
||||
boolean.
|
||||
(coff_write_object_contents): Check it.
|
||||
|
||||
* coff-alpha.c (alpha_relocate_section): Check bfd_alloc.
|
||||
* coff-mips.c (mips_relocate_section): Ditto.
|
||||
|
||||
* archive.c (bfd_slurp_bsd_armap_f2): Check bfd_alloc value.
|
||||
(do_slurp_bsd_armap): Ditto.
|
||||
(compute_and_write_armap): Check bfd_realloc value.
|
||||
|
||||
* aoutx.h (translate_from_native_sym_flags): Check bfd_alloc
|
||||
return value. Return boolean value.
|
||||
(NAME(aout,make_empty_symbol)): Check bfd_zalloc return value.
|
||||
(NAME(aout,slurp_symbol_table)): Check bf_alloc and bfd_zalloc
|
||||
return value.
|
||||
(add_to_stringtab): Ditto. FIXME void
|
||||
(aout_link_hash_newfunc): Check bfd_hash_allocate return value.
|
||||
(aout_link_add_symbols): Check bfd_alloc value.
|
||||
(translate_symbol_table): Check translate_from_native_sym_flags.
|
||||
* hp300hpux.c (MY(slurp_symbol_table)): Ditto.
|
||||
* aoutx.h (aout_link_hash_newfunc): Check _bfd_link_hash_newfunc.
|
||||
|
||||
* opncls.c (bfd_zalloc bfd_realloc): Check result of bfd_alloc.
|
||||
|
||||
* opncls.c (obstack_chunk_alloc): Define as malloc, not
|
||||
bfd_xmalloc_by_size_t.
|
||||
(_bfd_new_bfd): Check obstack_begin for 0 return.
|
||||
|
||||
* ieee.c (obstack_chunk_alloc): Define as malloc, not
|
||||
bfd_xmalloc_by_size_t.
|
||||
(ieee_archive_p): Check obstack_begin for 0 return and
|
||||
obstack_finish for NULL return.
|
||||
|
||||
* hash.c (obstack_chunk_alloc): Define as malloc, not
|
||||
bfd_xmalloc_by_size_t.
|
||||
(bfd_hash_table_init_n): Check obstack_begin for 0 return and
|
||||
obstack_finish for NULL return.
|
||||
(bfd_hash_lookup): Check obstack_alloc for NULL return.
|
||||
|
||||
* ecofflink.c (obstack_chunk_alloc): Define as malloc, not
|
||||
bfd_xmalloc_by_size_t.
|
||||
bfd_ecoff_debug_accumulate
|
||||
bfd_ecoff_debug_accumulate_other): Check obstack_alloc.
|
||||
(add_file_shuffle add_memory_shuffle): Check obstack_alloc for
|
||||
NULL return. Return boolean, not void.
|
||||
(bfd_ecoff_debug_init): Check obstack_begin for 0 return.
|
||||
(bfd_ecoff_debug_accumulate): Check add_file_shuffle
|
||||
and add_memory_shuffle return.
|
||||
(string_hash_newfunc): Check bfd_hash_allocate and bfd_hash_newfunc.
|
||||
(bfd_ecoff_debug_accumulate): Check bfd_alloc.
|
||||
(ecoff_add_string): Check add_memory_shuffle return.
|
||||
|
||||
* libbfd-in.h (xmalloc, bfd_xmalloc, bfd_xmalloc_by_size_t):
|
||||
Remove decls.
|
||||
* libbfd.h: Rebuilt.
|
||||
|
||||
Fri Feb 11 15:35:32 1994 Stu Grossman (grossman at cygnus.com)
|
||||
|
||||
* configure.host: Add Lynx/rs6000 support.
|
||||
|
86
bfd/aoutx.h
86
bfd/aoutx.h
@ -1,5 +1,5 @@
|
||||
/* BFD semi-generic back-end for a.out binaries.
|
||||
Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
@ -452,7 +452,7 @@ DEFUN(NAME(aout,some_aout_object_p),(abfd, execp, callback_to_real_object_p),
|
||||
#ifdef THIS_IS_ONLY_DOCUMENTATION
|
||||
/* The common code can't fill in these things because they depend
|
||||
on either the start address of the text segment, the rounding
|
||||
up of virtual addersses between segments, or the starting file
|
||||
up of virtual addresses between segments, or the starting file
|
||||
position of the text segment -- all of which varies among different
|
||||
versions of a.out. */
|
||||
|
||||
@ -1083,7 +1083,7 @@ DEFUN(NAME(aout,set_section_contents),(abfd, section, location, offset, count),
|
||||
/* Only in their own functions for ease of debugging; when sym flags have
|
||||
stabilised these should be inlined into their (single) caller */
|
||||
|
||||
static void
|
||||
static boolean
|
||||
DEFUN (translate_from_native_sym_flags, (sym_pointer, cache_ptr, abfd),
|
||||
struct external_nlist *sym_pointer AND
|
||||
aout_symbol_type * cache_ptr AND
|
||||
@ -1100,8 +1100,14 @@ DEFUN (translate_from_native_sym_flags, (sym_pointer, cache_ptr, abfd),
|
||||
char *copy = bfd_alloc (abfd, strlen (cache_ptr->symbol.name) + 1);
|
||||
asection *section;
|
||||
asection *into_section;
|
||||
|
||||
arelent_chain *reloc = (arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
|
||||
|
||||
if (!copy || !reloc)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
strcpy (copy, cache_ptr->symbol.name);
|
||||
|
||||
/* Make sure that this bfd has a section with the right contructor
|
||||
@ -1130,7 +1136,8 @@ DEFUN (translate_from_native_sym_flags, (sym_pointer, cache_ptr, abfd),
|
||||
cache_ptr->type = N_BSS;
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
bfd_error = bad_value;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Build a relocation pointing into the constuctor section
|
||||
@ -1292,10 +1299,10 @@ DEFUN (translate_from_native_sym_flags, (sym_pointer, cache_ptr, abfd),
|
||||
}
|
||||
if (cache_ptr->symbol.section == 0)
|
||||
abort ();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static boolean
|
||||
DEFUN(translate_to_native_sym_flags,(sym_pointer, cache_ptr, abfd),
|
||||
struct external_nlist *sym_pointer AND
|
||||
@ -1384,6 +1391,11 @@ DEFUN(NAME(aout,make_empty_symbol),(abfd),
|
||||
{
|
||||
aout_symbol_type *new =
|
||||
(aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
|
||||
if (!new)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
new->symbol.the_bfd = abfd;
|
||||
|
||||
return &new->symbol;
|
||||
@ -1429,7 +1441,8 @@ translate_symbol_table (abfd, in, ext, count, str, strsize, dynamic)
|
||||
in->type = bfd_h_get_8 (abfd, ext->e_type);
|
||||
in->symbol.udata = 0;
|
||||
|
||||
translate_from_native_sym_flags (ext, in, abfd);
|
||||
if (!translate_from_native_sym_flags (ext, in, abfd))
|
||||
return false;
|
||||
|
||||
if (dynamic)
|
||||
in->symbol.flags |= BSF_DYNAMIC;
|
||||
@ -1489,7 +1502,12 @@ DEFUN(NAME(aout,slurp_symbol_table),(abfd),
|
||||
* sizeof (aout_symbol_type))));
|
||||
|
||||
/* Don't allocate on the obstack, so we can free it easily. */
|
||||
syms = (struct external_nlist *) bfd_xmalloc(symbol_size);
|
||||
syms = (struct external_nlist *) malloc(symbol_size);
|
||||
if (!strings || !cached || !syms)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET);
|
||||
if (bfd_read ((PTR)syms, 1, symbol_size, abfd) != symbol_size)
|
||||
{
|
||||
@ -1823,6 +1841,11 @@ add_to_stringtab (abfd, str, tab)
|
||||
add_it:
|
||||
entry = (struct stringtab_entry *)
|
||||
bfd_alloc_by_size_t (abfd, sizeof (struct stringtab_entry));
|
||||
if (!entry)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
|
||||
entry->less = entry->greater = 0;
|
||||
entry->hash = hashval;
|
||||
@ -2806,14 +2829,19 @@ aout_link_hash_newfunc (entry, table, string)
|
||||
if (ret == (struct aout_link_hash_entry *) NULL)
|
||||
ret = ((struct aout_link_hash_entry *)
|
||||
bfd_hash_allocate (table, sizeof (struct aout_link_hash_entry)));
|
||||
if (ret == (struct aout_link_hash_entry *) NULL)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return (struct bfd_hash_entry *) ret;
|
||||
}
|
||||
|
||||
/* Call the allocation method of the superclass. */
|
||||
ret = ((struct aout_link_hash_entry *)
|
||||
_bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
|
||||
table, string));
|
||||
|
||||
/* Set local fields. */
|
||||
ret->indx = -1;
|
||||
if (ret)
|
||||
/* Set local fields. */
|
||||
ret->indx = -1;
|
||||
|
||||
return (struct bfd_hash_entry *) ret;
|
||||
}
|
||||
@ -2827,7 +2855,12 @@ NAME(aout,link_hash_table_create) (abfd)
|
||||
struct aout_link_hash_table *ret;
|
||||
|
||||
ret = ((struct aout_link_hash_table *)
|
||||
bfd_xmalloc (sizeof (struct aout_link_hash_table)));
|
||||
malloc (sizeof (struct aout_link_hash_table)));
|
||||
if (ret == (struct aout_link_hash_table *) NULL)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return (struct bfd_link_hash_table *) NULL;
|
||||
}
|
||||
if (! _bfd_link_hash_table_init (&ret->root, abfd,
|
||||
aout_link_hash_newfunc))
|
||||
{
|
||||
@ -2952,11 +2985,16 @@ aout_link_get_symbols (abfd)
|
||||
|
||||
count = exec_hdr (abfd)->a_syms / EXTERNAL_NLIST_SIZE;
|
||||
|
||||
/* We allocate using bfd_xmalloc to make the values easy to free
|
||||
/* We allocate using malloc to make the values easy to free
|
||||
later on. If we put them on the obstack it might not be possible
|
||||
to free them. */
|
||||
syms = ((struct external_nlist *)
|
||||
bfd_xmalloc ((size_t) count * EXTERNAL_NLIST_SIZE));
|
||||
malloc ((size_t) count * EXTERNAL_NLIST_SIZE));
|
||||
if (syms == (struct external_nlist *) NULL)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
|
||||
|| (bfd_read ((PTR) syms, 1, exec_hdr (abfd)->a_syms, abfd)
|
||||
@ -2969,7 +3007,12 @@ aout_link_get_symbols (abfd)
|
||||
!= BYTES_IN_WORD))
|
||||
return false;
|
||||
stringsize = GET_WORD (abfd, string_chars);
|
||||
strings = (char *) bfd_xmalloc ((size_t) stringsize);
|
||||
strings = (char *) malloc ((size_t) stringsize);
|
||||
if (strings == NULL)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Skip space for the string count in the buffer for convenience
|
||||
when using indexes. */
|
||||
@ -3155,6 +3198,11 @@ aout_link_add_symbols (abfd, info)
|
||||
bfd_alloc (abfd,
|
||||
((size_t) sym_count
|
||||
* sizeof (struct aout_link_hash_entry *))));
|
||||
if (!sym_hash)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
obj_aout_sym_hashes (abfd) = sym_hash;
|
||||
|
||||
p = obj_aout_external_syms (abfd);
|
||||
@ -3857,6 +3905,14 @@ aout_link_write_other_symbol (h, data)
|
||||
if (h->root.written)
|
||||
return true;
|
||||
|
||||
h->root.written = true;
|
||||
|
||||
if (finfo->info->strip == strip_all
|
||||
|| (finfo->info->strip == strip_some
|
||||
&& bfd_hash_lookup (finfo->info->keep_hash, h->root.root.string,
|
||||
false, false) == NULL))
|
||||
return true;
|
||||
|
||||
output_bfd = finfo->output_bfd;
|
||||
|
||||
switch (h->root.type)
|
||||
|
@ -754,6 +754,11 @@ do_slurp_bsd_armap (abfd)
|
||||
ardata->symdefs = (carsym *) bfd_alloc (abfd,
|
||||
(ardata->symdef_count
|
||||
* sizeof (carsym)));
|
||||
if (!ardata->symdefs)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (counter = 0, set = ardata->symdefs;
|
||||
counter < ardata->symdef_count;
|
||||
@ -985,6 +990,11 @@ bfd_slurp_bsd_armap_f2 (abfd)
|
||||
ardata->symdefs = (carsym *) bfd_alloc (abfd,
|
||||
(ardata->symdef_count
|
||||
* BSD_SYMDEF_SIZE));
|
||||
if (!ardata->symdefs)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (counter = 0, set = ardata->symdefs;
|
||||
counter < ardata->symdef_count;
|
||||
|
@ -1323,6 +1323,11 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
bfd_alloc (input_bfd,
|
||||
(NUM_RELOC_SECTIONS
|
||||
* sizeof (asection *))));
|
||||
if (!symndx_to_section)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
symndx_to_section[RELOC_SECTION_NONE] = NULL;
|
||||
symndx_to_section[RELOC_SECTION_TEXT] =
|
||||
@ -1456,12 +1461,15 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
not currently implemented. */
|
||||
|
||||
/* I believe that the LITERAL reloc will only apply to a ldq
|
||||
instruction, so check my assumption. */
|
||||
BFD_ASSERT (((bfd_get_32 (input_bfd,
|
||||
contents + r_vaddr - input_section->vma)
|
||||
>> 26)
|
||||
& 0x3f)
|
||||
== 0x29);
|
||||
or ldl instruction, so check my assumption. */
|
||||
{
|
||||
unsigned long insn;
|
||||
|
||||
insn = bfd_get_32 (input_bfd,
|
||||
contents + r_vaddr - input_section->vma);
|
||||
BFD_ASSERT (((insn >> 26) & 0x3f) == 0x29
|
||||
|| ((insn >> 26) & 0x3f) == 0x28);
|
||||
}
|
||||
|
||||
relocatep = true;
|
||||
addend = ecoff_data (input_bfd)->gp - gp;
|
||||
|
@ -796,6 +796,11 @@ mips_relocate_section (output_bfd, info, input_bfd, input_section,
|
||||
bfd_alloc (input_bfd,
|
||||
(NUM_RELOC_SECTIONS
|
||||
* sizeof (asection *))));
|
||||
if (!symndx_to_section)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
symndx_to_section[RELOC_SECTION_NONE] = NULL;
|
||||
symndx_to_section[RELOC_SECTION_TEXT] =
|
||||
@ -1166,10 +1171,10 @@ static const struct ecoff_backend_data mips_ecoff_backend_data =
|
||||
{
|
||||
/* COFF backend structure. */
|
||||
{
|
||||
(void (*) PARAMS ((bfd *,PTR,int,int,PTR))) bfd_void, /* aux_in */
|
||||
(void (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR))) bfd_void, /* aux_in */
|
||||
(void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_in */
|
||||
(void (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_in */
|
||||
(unsigned (*) PARAMS ((bfd *,PTR,int,int,PTR))) bfd_void, /* aux_out */
|
||||
(unsigned (*) PARAMS ((bfd *,PTR,int,int,int,int,PTR)))bfd_void,/*aux_out*/
|
||||
(unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* sym_out */
|
||||
(unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* lineno_out */
|
||||
(unsigned (*) PARAMS ((bfd *,PTR,PTR))) bfd_void, /* reloc_out */
|
||||
|
1859
bfd/coffcode.h
1859
bfd/coffcode.h
File diff suppressed because it is too large
Load Diff
175
bfd/coffgen.c
175
bfd/coffgen.c
@ -1,5 +1,5 @@
|
||||
/* Support for the generic parts of COFF, for BFD.
|
||||
Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
@ -132,6 +132,11 @@ DEFUN(coff_real_object_p,(abfd, nscns, internal_f, internal_a),
|
||||
scnhsz = bfd_coff_scnhsz (abfd);
|
||||
readsize = nscns * scnhsz;
|
||||
external_sections = (char *)bfd_alloc(abfd, readsize);
|
||||
if (!external_sections)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (bfd_read((PTR)external_sections, 1, readsize, abfd) != readsize) {
|
||||
goto fail;
|
||||
@ -420,7 +425,7 @@ struct internal_syment *syment)
|
||||
do that here too.
|
||||
|
||||
*/
|
||||
void
|
||||
boolean
|
||||
DEFUN(coff_renumber_symbols,(bfd_ptr),
|
||||
bfd *bfd_ptr)
|
||||
{
|
||||
@ -444,6 +449,11 @@ DEFUN(coff_renumber_symbols,(bfd_ptr),
|
||||
newsyms = (asymbol **) bfd_alloc_by_size_t (bfd_ptr,
|
||||
sizeof (asymbol *)
|
||||
* (symbol_count + 1));
|
||||
if (!newsyms)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
bfd_ptr->outsymbols = newsyms;
|
||||
for (i = 0; i < symbol_count; i++)
|
||||
if (symbol_ptr_ptr[i]->section != &bfd_und_section)
|
||||
@ -485,6 +495,7 @@ DEFUN(coff_renumber_symbols,(bfd_ptr),
|
||||
}
|
||||
}
|
||||
obj_conv_table_size (bfd_ptr) = native_index;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -493,42 +504,59 @@ DEFUN(coff_renumber_symbols,(bfd_ptr),
|
||||
|
||||
*/
|
||||
void
|
||||
DEFUN(coff_mangle_symbols,(bfd_ptr),
|
||||
bfd *bfd_ptr)
|
||||
coff_mangle_symbols (bfd_ptr)
|
||||
bfd *bfd_ptr;
|
||||
{
|
||||
unsigned int symbol_count = bfd_get_symcount(bfd_ptr);
|
||||
unsigned int symbol_count = bfd_get_symcount (bfd_ptr);
|
||||
asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols;
|
||||
unsigned int symbol_index;
|
||||
|
||||
for (symbol_index = 0; symbol_index < symbol_count; symbol_index++)
|
||||
{
|
||||
coff_symbol_type *coff_symbol_ptr =
|
||||
coff_symbol_from(bfd_ptr, symbol_ptr_ptr[symbol_index]);
|
||||
{
|
||||
coff_symbol_type *coff_symbol_ptr =
|
||||
coff_symbol_from (bfd_ptr, symbol_ptr_ptr[symbol_index]);
|
||||
|
||||
if (coff_symbol_ptr && coff_symbol_ptr->native) {
|
||||
if (coff_symbol_ptr && coff_symbol_ptr->native)
|
||||
{
|
||||
int i;
|
||||
combined_entry_type *s = coff_symbol_ptr->native;
|
||||
|
||||
for (i = 0; i < s->u.syment.n_numaux ; i++) {
|
||||
combined_entry_type *a = s + i + 1;
|
||||
if (a->fix_tag) {
|
||||
a->u.auxent.x_sym.x_tagndx.l =
|
||||
a->u.auxent.x_sym.x_tagndx.p->offset;
|
||||
a->fix_tag = 0;
|
||||
if (s->fix_value)
|
||||
{
|
||||
/* FIXME: We should use a union here. */
|
||||
s->u.syment.n_value =
|
||||
((combined_entry_type *) s->u.syment.n_value)->offset;
|
||||
s->fix_value = 0;
|
||||
}
|
||||
if (a->fix_end) {
|
||||
a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l =
|
||||
a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p->offset;
|
||||
a->fix_end = 0;
|
||||
|
||||
for (i = 0; i < s->u.syment.n_numaux ; i++)
|
||||
{
|
||||
combined_entry_type *a = s + i + 1;
|
||||
if (a->fix_tag)
|
||||
{
|
||||
a->u.auxent.x_sym.x_tagndx.l =
|
||||
a->u.auxent.x_sym.x_tagndx.p->offset;
|
||||
a->fix_tag = 0;
|
||||
}
|
||||
if (a->fix_end)
|
||||
{
|
||||
a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l =
|
||||
a->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p->offset;
|
||||
a->fix_end = 0;
|
||||
}
|
||||
if (a->fix_scnlen)
|
||||
{
|
||||
a->u.auxent.x_csect.x_scnlen.l =
|
||||
a->u.auxent.x_csect.x_scnlen.p->offset;
|
||||
a->fix_scnlen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int string_size;
|
||||
static bfd_size_type string_size;
|
||||
static bfd_size_type debug_string_size;
|
||||
static asection *debug_string_section;
|
||||
|
||||
static void
|
||||
DEFUN(coff_fix_symbol_name,(abfd, symbol, native),
|
||||
@ -569,17 +597,50 @@ DEFUN(coff_fix_symbol_name,(abfd, symbol, native),
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* NOT A C_FILE SYMBOL */
|
||||
if (name_length <= SYMNMLEN) {
|
||||
{ /* NOT A C_FILE SYMBOL */
|
||||
if (name_length <= SYMNMLEN)
|
||||
{
|
||||
/* This name will fit into the symbol neatly */
|
||||
strncpy(native->u.syment._n._n_name, symbol->name, SYMNMLEN);
|
||||
}
|
||||
else {
|
||||
else if (! bfd_coff_symname_in_debug (abfd, &native->u.syment))
|
||||
{
|
||||
native->u.syment._n._n_n._n_offset = string_size + 4;
|
||||
native->u.syment._n._n_n._n_zeroes = 0;
|
||||
string_size += name_length + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
long filepos;
|
||||
bfd_byte buf[2];
|
||||
|
||||
/* This name should be written into the .debug section. For
|
||||
some reason each name is preceded by a two byte length
|
||||
and also followed by a null byte. FIXME: We assume that
|
||||
the .debug section has already been created, and that it
|
||||
is large enough. */
|
||||
if (debug_string_section == (asection *) NULL)
|
||||
debug_string_section = bfd_get_section_by_name (abfd, ".debug");
|
||||
filepos = bfd_tell (abfd);
|
||||
bfd_put_16 (abfd, name_length + 1, buf);
|
||||
if (! bfd_set_section_contents (abfd,
|
||||
debug_string_section,
|
||||
(PTR) buf,
|
||||
(file_ptr) debug_string_size,
|
||||
(bfd_size_type) 2)
|
||||
|| ! bfd_set_section_contents (abfd,
|
||||
debug_string_section,
|
||||
(PTR) symbol->name,
|
||||
(file_ptr) debug_string_size + 2,
|
||||
(bfd_size_type) name_length + 1))
|
||||
abort ();
|
||||
if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
|
||||
abort ();
|
||||
native->u.syment._n._n_n._n_offset = debug_string_size + 2;
|
||||
native->u.syment._n._n_n._n_zeroes = 0;
|
||||
debug_string_size += name_length + 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define set_index(symbol, idx) ((symbol)->udata =(PTR) (idx))
|
||||
@ -625,6 +686,11 @@ unsigned int written)
|
||||
|
||||
symesz = bfd_coff_symesz (abfd);
|
||||
buf = bfd_alloc (abfd, symesz);
|
||||
if (!buf)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
bfd_coff_swap_sym_out(abfd, &native->u.syment, buf);
|
||||
bfd_write(buf, 1, symesz, abfd);
|
||||
bfd_release (abfd, buf);
|
||||
@ -636,6 +702,11 @@ unsigned int written)
|
||||
|
||||
auxesz = bfd_coff_auxesz (abfd);
|
||||
buf = bfd_alloc (abfd, auxesz);
|
||||
if (!buf)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
for (j = 0; j < native->u.syment.n_numaux; j++)
|
||||
{
|
||||
bfd_coff_swap_aux_out(abfd,
|
||||
@ -785,7 +856,7 @@ DEFUN(coff_write_symbols,(abfd),
|
||||
asymbol **p;
|
||||
|
||||
string_size = 0;
|
||||
|
||||
debug_string_size = 0;
|
||||
|
||||
/* Seek to the right place */
|
||||
bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET);
|
||||
@ -833,9 +904,10 @@ DEFUN(coff_write_symbols,(abfd),
|
||||
(c_symbol->native->u.syment.n_sclass == C_FILE)) ?
|
||||
FILNMLEN : SYMNMLEN;
|
||||
|
||||
if (name_length > maxlen) {
|
||||
if (name_length > maxlen
|
||||
&& ! bfd_coff_symname_in_debug (abfd,
|
||||
&c_symbol->native->u.syment))
|
||||
bfd_write((PTR) (q->name), 1, name_length + 1, abfd);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -848,9 +920,15 @@ DEFUN(coff_write_symbols,(abfd),
|
||||
bfd_h_put_32 (abfd, size, buffer);
|
||||
bfd_write((PTR) buffer, 1, sizeof (buffer), abfd);
|
||||
}
|
||||
|
||||
BFD_ASSERT (debug_string_size == 0
|
||||
|| (debug_string_section != (asection *) NULL
|
||||
&& (BFD_ALIGN (debug_string_size,
|
||||
1 << debug_string_section->alignment_power)
|
||||
== bfd_section_size (abfd, debug_string_section))));
|
||||
}
|
||||
|
||||
void
|
||||
boolean
|
||||
DEFUN(coff_write_linenumbers,(abfd),
|
||||
bfd *abfd)
|
||||
{
|
||||
@ -860,6 +938,11 @@ DEFUN(coff_write_linenumbers,(abfd),
|
||||
|
||||
linesz = bfd_coff_linesz (abfd);
|
||||
buff = bfd_alloc (abfd, linesz);
|
||||
if (!buff)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return;
|
||||
}
|
||||
for (s = abfd->sections; s != (asection *) NULL; s = s->next) {
|
||||
if (s->lineno_count) {
|
||||
asymbol **q = abfd->outsymbols;
|
||||
@ -893,6 +976,7 @@ DEFUN(coff_write_linenumbers,(abfd),
|
||||
}
|
||||
}
|
||||
bfd_release (abfd, buff);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
@ -925,6 +1009,11 @@ coff_section_symbol (abfd, name)
|
||||
};
|
||||
struct foo *f;
|
||||
f = (struct foo *) bfd_alloc_by_size_t (abfd, sizeof (*f));
|
||||
if (!f)
|
||||
{
|
||||
bfd_error = no_error;
|
||||
return NULL;
|
||||
}
|
||||
memset ((char *) f, 0, sizeof (*f));
|
||||
coff_symbol_from (abfd, sym)->native = csym = f->e;
|
||||
}
|
||||
@ -1106,11 +1195,21 @@ bfd *abfd)
|
||||
}
|
||||
|
||||
internal = (combined_entry_type *)bfd_alloc(abfd, size);
|
||||
if (!internal)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
internal_end = internal + bfd_get_symcount(abfd);
|
||||
|
||||
symesz = bfd_coff_symesz (abfd);
|
||||
raw_size = bfd_get_symcount(abfd) * symesz;
|
||||
raw = bfd_alloc(abfd,raw_size);
|
||||
if (!raw)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET) == -1
|
||||
|| bfd_read(raw, raw_size, 1, abfd) != raw_size) {
|
||||
@ -1131,8 +1230,10 @@ bfd *abfd)
|
||||
|
||||
unsigned int i;
|
||||
bfd_coff_swap_sym_in(abfd, (PTR)raw_src, (PTR)&internal_ptr->u.syment);
|
||||
internal_ptr->fix_value = 0;
|
||||
internal_ptr->fix_tag = 0;
|
||||
internal_ptr->fix_end = 0;
|
||||
internal_ptr->fix_scnlen = 0;
|
||||
symbol_ptr = internal_ptr;
|
||||
|
||||
for (i = 0;
|
||||
@ -1142,8 +1243,10 @@ bfd *abfd)
|
||||
internal_ptr++;
|
||||
raw_src += symesz;
|
||||
|
||||
internal_ptr->fix_value = 0;
|
||||
internal_ptr->fix_tag = 0;
|
||||
internal_ptr->fix_end = 0;
|
||||
internal_ptr->fix_scnlen = 0;
|
||||
bfd_coff_swap_aux_in(abfd, (PTR) raw_src,
|
||||
symbol_ptr->u.syment.n_type,
|
||||
symbol_ptr->u.syment.n_sclass,
|
||||
@ -1212,6 +1315,8 @@ bfd *abfd)
|
||||
internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring;
|
||||
internal_ptr->u.syment._n._n_n._n_zeroes = 0;
|
||||
}
|
||||
else if (internal_ptr->u.syment._n._n_n._n_offset == 0)
|
||||
internal_ptr->u.syment._n._n_n._n_offset = (long int) "";
|
||||
else if (!bfd_coff_symname_in_debug(abfd, &internal_ptr->u.syment)) {
|
||||
/* Long name already. Point symbol at the string in the table. */
|
||||
if (string_table == NULL) {
|
||||
@ -1259,6 +1364,7 @@ DEFUN (coff_make_empty_symbol, (abfd),
|
||||
bfd_error = no_memory;
|
||||
return (NULL);
|
||||
} /* on error */
|
||||
memset (new, 0, sizeof *new);
|
||||
new->symbol.section = 0;
|
||||
new->native = 0;
|
||||
new->lineno = (alent *) NULL;
|
||||
@ -1282,6 +1388,11 @@ coff_bfd_make_debug_symbol (abfd, ptr, sz)
|
||||
} /* on error */
|
||||
/* @@ This shouldn't be using a constant multiplier. */
|
||||
new->native = (combined_entry_type *) bfd_zalloc (abfd, sizeof (combined_entry_type) * 10);
|
||||
if (!new->native)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return (NULL);
|
||||
} /* on error */
|
||||
new->symbol.section = &bfd_debug_section;
|
||||
new->lineno = (alent *) NULL;
|
||||
new->done_lineno = false;
|
||||
|
14
bfd/ctor.c
14
bfd/ctor.c
@ -95,7 +95,7 @@ INTERNAL_FUNCTION
|
||||
bfd_constructor_entry
|
||||
|
||||
SYNOPSIS
|
||||
void bfd_constructor_entry(bfd *abfd,
|
||||
boolean bfd_constructor_entry(bfd *abfd,
|
||||
asymbol **symbol_ptr_ptr,
|
||||
CONST char*type);
|
||||
|
||||
@ -109,10 +109,13 @@ DESCRIPTION
|
||||
have one, and grow a relocation table for the entry points as
|
||||
they accumulate.
|
||||
|
||||
Return <<true>> if successful, <<false>> if out of memory.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
void DEFUN(bfd_constructor_entry,(abfd, symbol_ptr_ptr, type),
|
||||
boolean
|
||||
DEFUN(bfd_constructor_entry,(abfd, symbol_ptr_ptr, type),
|
||||
bfd *abfd AND
|
||||
asymbol **symbol_ptr_ptr AND
|
||||
CONST char *type)
|
||||
@ -130,6 +133,11 @@ void DEFUN(bfd_constructor_entry,(abfd, symbol_ptr_ptr, type),
|
||||
{
|
||||
arelent_chain *reloc = (arelent_chain *)bfd_alloc(abfd,
|
||||
sizeof(arelent_chain));
|
||||
if (!reloc)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* reloc->relent.section = (asection *)NULL;*/
|
||||
reloc->relent.addend = 0;
|
||||
@ -143,5 +151,5 @@ void DEFUN(bfd_constructor_entry,(abfd, symbol_ptr_ptr, type),
|
||||
rel_section->_cooked_size += sizeof(int *);
|
||||
rel_section->reloc_count++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
63
bfd/ecoff.c
63
bfd/ecoff.c
@ -46,7 +46,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
static int ecoff_get_magic PARAMS ((bfd *abfd));
|
||||
static boolean ecoff_slurp_symbolic_header PARAMS ((bfd *abfd));
|
||||
static void ecoff_set_symbol_info PARAMS ((bfd *abfd, SYMR *ecoff_sym,
|
||||
static boolean ecoff_set_symbol_info PARAMS ((bfd *abfd, SYMR *ecoff_sym,
|
||||
asymbol *asym, int ext,
|
||||
asymbol **indirect_ptr_ptr));
|
||||
static void ecoff_emit_aggregate PARAMS ((bfd *abfd, char *string,
|
||||
@ -831,7 +831,7 @@ ecoff_make_empty_symbol (abfd)
|
||||
|
||||
/* Set the BFD flags and section for an ECOFF symbol. */
|
||||
|
||||
static void
|
||||
static boolean
|
||||
ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, indirect_ptr_ptr)
|
||||
bfd *abfd;
|
||||
SYMR *ecoff_sym;
|
||||
@ -859,7 +859,7 @@ ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, indirect_ptr_ptr)
|
||||
asym->flags = BSF_DEBUGGING;
|
||||
asym->section = &bfd_und_section;
|
||||
*indirect_ptr_ptr = NULL;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ECOFF_IS_STAB (ecoff_sym)
|
||||
@ -869,7 +869,7 @@ ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, indirect_ptr_ptr)
|
||||
asym->section = &bfd_ind_section;
|
||||
/* Pass this symbol on to the next call to this function. */
|
||||
*indirect_ptr_ptr = asym;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Most symbol types are just for debugging. */
|
||||
@ -885,12 +885,12 @@ ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, indirect_ptr_ptr)
|
||||
if (ECOFF_IS_STAB (ecoff_sym))
|
||||
{
|
||||
asym->flags = BSF_DEBUGGING;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
asym->flags = BSF_DEBUGGING;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ext)
|
||||
@ -1042,6 +1042,11 @@ ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, indirect_ptr_ptr)
|
||||
char *copy;
|
||||
|
||||
copy = (char *) bfd_alloc (abfd, strlen (name) + 1);
|
||||
if (!copy)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
strcpy (copy, name);
|
||||
section = bfd_make_section (abfd, copy);
|
||||
}
|
||||
@ -1049,6 +1054,11 @@ ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, indirect_ptr_ptr)
|
||||
/* Build a reloc pointing to this constructor. */
|
||||
reloc_chain =
|
||||
(arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
|
||||
if (!reloc_chain)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
reloc_chain->relent.sym_ptr_ptr =
|
||||
bfd_get_section (asym)->symbol_ptr_ptr;
|
||||
reloc_chain->relent.address = section->_raw_size;
|
||||
@ -1079,6 +1089,7 @@ ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, indirect_ptr_ptr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Read an ECOFF symbol table. */
|
||||
@ -1136,8 +1147,9 @@ ecoff_slurp_symbol_table (abfd)
|
||||
(*swap_ext_in) (abfd, (PTR) eraw_src, &internal_esym);
|
||||
internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ssext
|
||||
+ internal_esym.asym.iss);
|
||||
ecoff_set_symbol_info (abfd, &internal_esym.asym,
|
||||
&internal_ptr->symbol, 1, &indirect_ptr);
|
||||
if (!ecoff_set_symbol_info (abfd, &internal_esym.asym,
|
||||
&internal_ptr->symbol, 1, &indirect_ptr))
|
||||
return false;
|
||||
/* The alpha uses a negative ifd field for section symbols. */
|
||||
if (internal_esym.ifd >= 0)
|
||||
internal_ptr->fdr = (ecoff_data (abfd)->debug_info.fdr
|
||||
@ -1171,8 +1183,9 @@ ecoff_slurp_symbol_table (abfd)
|
||||
internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ss
|
||||
+ fdr_ptr->issBase
|
||||
+ internal_sym.iss);
|
||||
ecoff_set_symbol_info (abfd, &internal_sym,
|
||||
&internal_ptr->symbol, 0, &indirect_ptr);
|
||||
if (!ecoff_set_symbol_info (abfd, &internal_sym,
|
||||
&internal_ptr->symbol, 0, &indirect_ptr))
|
||||
return false;
|
||||
internal_ptr->fdr = fdr_ptr;
|
||||
internal_ptr->local = true;
|
||||
internal_ptr->native = (PTR) lraw_src;
|
||||
@ -3047,6 +3060,12 @@ ecoff_slurp_armap (abfd)
|
||||
symdef_ptr = ((struct symdef *)
|
||||
bfd_alloc (abfd,
|
||||
ardata->symdef_count * sizeof (struct symdef)));
|
||||
if (!symdef_ptr)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
ardata->symdefs = (carsym *) symdef_ptr;
|
||||
|
||||
raw_ptr = raw_armap + 4;
|
||||
@ -3158,6 +3177,11 @@ ecoff_write_armap (abfd, elength, map, orl_count, stridx)
|
||||
return false;
|
||||
|
||||
hashtable = (bfd_byte *) bfd_zalloc (abfd, symdefsize);
|
||||
if (!hashtable)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
current = abfd->archive_head;
|
||||
last_elt = current;
|
||||
@ -3308,15 +3332,23 @@ ecoff_link_hash_newfunc (entry, table, string)
|
||||
if (ret == (struct ecoff_link_hash_entry *) NULL)
|
||||
ret = ((struct ecoff_link_hash_entry *)
|
||||
bfd_hash_allocate (table, sizeof (struct ecoff_link_hash_entry)));
|
||||
if (ret == (struct ecoff_link_hash_entry *) NULL)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Call the allocation method of the superclass. */
|
||||
ret = ((struct ecoff_link_hash_entry *)
|
||||
_bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
|
||||
table, string));
|
||||
|
||||
/* Set local fields. */
|
||||
ret->indx = -1;
|
||||
ret->abfd = NULL;
|
||||
if (ret)
|
||||
{
|
||||
/* Set local fields. */
|
||||
ret->indx = -1;
|
||||
ret->abfd = NULL;
|
||||
}
|
||||
memset (&ret->esym, 0, sizeof ret->esym);
|
||||
|
||||
return (struct bfd_hash_entry *) ret;
|
||||
@ -3710,6 +3742,11 @@ ecoff_link_add_externals (abfd, info, external_ext, ssext)
|
||||
sym_hash = ((struct ecoff_link_hash_entry **)
|
||||
bfd_alloc (abfd,
|
||||
ext_count * sizeof (struct bfd_link_hash_entry *)));
|
||||
if (!sym_hash)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
ecoff_data (abfd)->sym_hashes = sym_hash;
|
||||
|
||||
ext_ptr = (char *) external_ext;
|
||||
|
153
bfd/ecofflink.c
153
bfd/ecofflink.c
@ -41,7 +41,7 @@ static boolean ecoff_write_symhdr PARAMS ((bfd *, struct ecoff_debug_info *,
|
||||
file_ptr where));
|
||||
|
||||
/* Obstack allocation and deallocation routines. */
|
||||
#define obstack_chunk_alloc bfd_xmalloc_by_size_t
|
||||
#define obstack_chunk_alloc malloc
|
||||
#define obstack_chunk_free free
|
||||
|
||||
/* The minimum amount of data to allocate. */
|
||||
@ -115,14 +115,22 @@ string_hash_newfunc (entry, table, string)
|
||||
if (ret == (struct string_hash_entry *) NULL)
|
||||
ret = ((struct string_hash_entry *)
|
||||
bfd_hash_allocate (table, sizeof (struct string_hash_entry)));
|
||||
if (ret == (struct string_hash_entry *) NULL)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Call the allocation method of the superclass. */
|
||||
ret = ((struct string_hash_entry *)
|
||||
bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
|
||||
|
||||
/* Initialize the local fields. */
|
||||
ret->val = -1;
|
||||
ret->next = NULL;
|
||||
if (ret)
|
||||
{
|
||||
/* Initialize the local fields. */
|
||||
ret->val = -1;
|
||||
ret->next = NULL;
|
||||
}
|
||||
|
||||
return (struct bfd_hash_entry *) ret;
|
||||
}
|
||||
@ -197,12 +205,12 @@ struct accumulate
|
||||
|
||||
/* Add a file entry to a shuffle list. */
|
||||
|
||||
static void add_file_shuffle PARAMS ((struct accumulate *,
|
||||
static boolean add_file_shuffle PARAMS ((struct accumulate *,
|
||||
struct shuffle **,
|
||||
struct shuffle **, bfd *, file_ptr,
|
||||
unsigned long));
|
||||
|
||||
static void
|
||||
static boolean
|
||||
add_file_shuffle (ainfo, head, tail, input_bfd, offset, size)
|
||||
struct accumulate *ainfo;
|
||||
struct shuffle **head;
|
||||
@ -222,11 +230,16 @@ add_file_shuffle (ainfo, head, tail, input_bfd, offset, size)
|
||||
(*tail)->size += size;
|
||||
if ((*tail)->size > ainfo->largest_file_shuffle)
|
||||
ainfo->largest_file_shuffle = (*tail)->size;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
n = (struct shuffle *) obstack_alloc (&ainfo->memory,
|
||||
sizeof (struct shuffle));
|
||||
if (!n)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
n->next = NULL;
|
||||
n->size = size;
|
||||
n->filep = true;
|
||||
@ -239,16 +252,17 @@ add_file_shuffle (ainfo, head, tail, input_bfd, offset, size)
|
||||
*tail = n;
|
||||
if (size > ainfo->largest_file_shuffle)
|
||||
ainfo->largest_file_shuffle = size;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Add a memory entry to a shuffle list. */
|
||||
|
||||
static void add_memory_shuffle PARAMS ((struct accumulate *,
|
||||
struct shuffle **head,
|
||||
struct shuffle **tail,
|
||||
bfd_byte *data, unsigned long size));
|
||||
static boolean add_memory_shuffle PARAMS ((struct accumulate *,
|
||||
struct shuffle **head,
|
||||
struct shuffle **tail,
|
||||
bfd_byte *data, unsigned long size));
|
||||
|
||||
static void
|
||||
static boolean
|
||||
add_memory_shuffle (ainfo, head, tail, data, size)
|
||||
struct accumulate *ainfo;
|
||||
struct shuffle **head;
|
||||
@ -260,6 +274,11 @@ add_memory_shuffle (ainfo, head, tail, data, size)
|
||||
|
||||
n = (struct shuffle *) obstack_alloc (&ainfo->memory,
|
||||
sizeof (struct shuffle));
|
||||
if (!n)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
n->next = NULL;
|
||||
n->size = size;
|
||||
n->filep = false;
|
||||
@ -269,6 +288,7 @@ add_memory_shuffle (ainfo, head, tail, data, size)
|
||||
if (*tail != (struct shuffle *) NULL)
|
||||
(*tail)->next = n;
|
||||
*tail = n;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Initialize the FDR hash table. This returns a handle which is then
|
||||
@ -284,7 +304,12 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info)
|
||||
{
|
||||
struct accumulate *ainfo;
|
||||
|
||||
ainfo = (struct accumulate *) bfd_xmalloc (sizeof (struct accumulate));
|
||||
ainfo = (struct accumulate *) malloc (sizeof (struct accumulate));
|
||||
if (!ainfo)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
if (! bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc,
|
||||
1021))
|
||||
return NULL;
|
||||
@ -319,7 +344,11 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info)
|
||||
output_debug->symbolic_header.issMax = 1;
|
||||
}
|
||||
|
||||
obstack_begin (&ainfo->memory, 4050);
|
||||
if (!obstack_begin (&ainfo->memory, 4050))
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (PTR) ainfo;
|
||||
}
|
||||
@ -447,7 +476,13 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
|
||||
|
||||
sz = (input_symhdr->crfd + input_symhdr->ifdMax) * external_rfd_size;
|
||||
rfd_out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
|
||||
add_memory_shuffle (ainfo, &ainfo->rfd, &ainfo->rfd_end, rfd_out, sz);
|
||||
if (!input_debug->ifdmap || !rfd_out)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
if (!add_memory_shuffle (ainfo, &ainfo->rfd, &ainfo->rfd_end, rfd_out, sz))
|
||||
return false;
|
||||
|
||||
copied = 0;
|
||||
|
||||
@ -537,7 +572,13 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
|
||||
information. */
|
||||
sz = copied * external_fdr_size;
|
||||
fdr_out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
|
||||
add_memory_shuffle (ainfo, &ainfo->fdr, &ainfo->fdr_end, fdr_out, sz);
|
||||
if (!fdr_out)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
if (!add_memory_shuffle (ainfo, &ainfo->fdr, &ainfo->fdr_end, fdr_out, sz))
|
||||
return false;
|
||||
for (fdr_ptr = fdr_start, i = 0;
|
||||
fdr_ptr < fdr_end;
|
||||
fdr_ptr += fdr_add, i++)
|
||||
@ -569,7 +610,13 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
|
||||
fgotfilename = false;
|
||||
sz = fdr.csym * external_sym_size;
|
||||
sym_out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
|
||||
add_memory_shuffle (ainfo, &ainfo->sym, &ainfo->sym_end, sym_out, sz);
|
||||
if (!sym_out)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
if (!add_memory_shuffle (ainfo, &ainfo->sym, &ainfo->sym_end, sym_out, sz))
|
||||
return false;
|
||||
lraw_src = ((bfd_byte *) input_debug->external_sym
|
||||
+ fdr.isymBase * input_swap->external_sym_size);
|
||||
lraw_end = lraw_src + fdr.csym * input_swap->external_sym_size;
|
||||
@ -658,10 +705,11 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
|
||||
/* Copy the information that does not need swapping. */
|
||||
if (fdr.cbLine > 0)
|
||||
{
|
||||
add_file_shuffle (ainfo, &ainfo->line, &ainfo->line_end,
|
||||
if (!add_file_shuffle (ainfo, &ainfo->line, &ainfo->line_end,
|
||||
input_bfd,
|
||||
input_symhdr->cbLineOffset + fdr.cbLineOffset,
|
||||
fdr.cbLine);
|
||||
fdr.cbLine))
|
||||
return false;
|
||||
fdr.ilineBase = output_symhdr->ilineMax;
|
||||
fdr.cbLineOffset = output_symhdr->cbLine;
|
||||
output_symhdr->ilineMax += fdr.cline;
|
||||
@ -669,11 +717,12 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
|
||||
}
|
||||
if (fdr.caux > 0)
|
||||
{
|
||||
add_file_shuffle (ainfo, &ainfo->aux, &ainfo->aux_end,
|
||||
if (!add_file_shuffle (ainfo, &ainfo->aux, &ainfo->aux_end,
|
||||
input_bfd,
|
||||
(input_symhdr->cbAuxOffset
|
||||
+ fdr.iauxBase * sizeof (union aux_ext)),
|
||||
fdr.caux * sizeof (union aux_ext));
|
||||
fdr.caux * sizeof (union aux_ext)))
|
||||
return false;
|
||||
fdr.iauxBase = output_symhdr->iauxMax;
|
||||
output_symhdr->iauxMax += fdr.caux;
|
||||
}
|
||||
@ -689,10 +738,11 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
|
||||
}
|
||||
else if (fdr.cbSs > 0)
|
||||
{
|
||||
add_file_shuffle (ainfo, &ainfo->ss, &ainfo->ss_end,
|
||||
if (!add_file_shuffle (ainfo, &ainfo->ss, &ainfo->ss_end,
|
||||
input_bfd,
|
||||
input_symhdr->cbSsOffset + fdr.issBase,
|
||||
fdr.cbSs);
|
||||
fdr.cbSs))
|
||||
return false;
|
||||
fdr.issBase = output_symhdr->issMax;
|
||||
output_symhdr->issMax += fdr.cbSs;
|
||||
}
|
||||
@ -704,18 +754,24 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
|
||||
the information will suffice. */
|
||||
BFD_ASSERT (external_pdr_size == input_swap->external_pdr_size);
|
||||
if (fdr.cpd > 0)
|
||||
add_file_shuffle (ainfo, &ainfo->pdr, &ainfo->pdr_end,
|
||||
input_bfd,
|
||||
(input_symhdr->cbPdOffset
|
||||
+ fdr.ipdFirst * external_pdr_size),
|
||||
fdr.cpd * external_pdr_size);
|
||||
{
|
||||
if (!add_file_shuffle (ainfo, &ainfo->pdr, &ainfo->pdr_end,
|
||||
input_bfd,
|
||||
(input_symhdr->cbPdOffset
|
||||
+ fdr.ipdFirst * external_pdr_size),
|
||||
fdr.cpd * external_pdr_size))
|
||||
return false;
|
||||
}
|
||||
BFD_ASSERT (external_opt_size == input_swap->external_opt_size);
|
||||
if (fdr.copt > 0)
|
||||
add_file_shuffle (ainfo, &ainfo->opt, &ainfo->opt_end,
|
||||
input_bfd,
|
||||
(input_symhdr->cbOptOffset
|
||||
+ fdr.ioptBase * external_opt_size),
|
||||
fdr.copt * external_opt_size);
|
||||
{
|
||||
if (!add_file_shuffle (ainfo, &ainfo->opt, &ainfo->opt_end,
|
||||
input_bfd,
|
||||
(input_symhdr->cbOptOffset
|
||||
+ fdr.ioptBase * external_opt_size),
|
||||
fdr.copt * external_opt_size))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -734,7 +790,13 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
|
||||
end = in + fdr.cpd * insz;
|
||||
sz = fdr.cpd * outsz;
|
||||
out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
|
||||
add_memory_shuffle (ainfo, &ainfo->pdr, &ainfo->pdr_end, out, sz);
|
||||
if (!out)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
if (!add_memory_shuffle (ainfo, &ainfo->pdr, &ainfo->pdr_end, out, sz))
|
||||
return false;
|
||||
for (; in < end; in += insz, out += outsz)
|
||||
{
|
||||
PDR pdr;
|
||||
@ -751,7 +813,13 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
|
||||
end = in + fdr.copt * insz;
|
||||
sz = fdr.copt * outsz;
|
||||
out = (bfd_byte *) obstack_alloc (&ainfo->memory, sz);
|
||||
add_memory_shuffle (ainfo, &ainfo->opt, &ainfo->opt_end, out, sz);
|
||||
if (!out)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
if (!add_memory_shuffle (ainfo, &ainfo->opt, &ainfo->opt_end, out, sz))
|
||||
return false;
|
||||
for (; in < end; in += insz, out += outsz)
|
||||
{
|
||||
OPTR opt;
|
||||
@ -810,8 +878,9 @@ ecoff_add_string (ainfo, info, debug, fdr, string)
|
||||
len = strlen (string);
|
||||
if (info->relocateable)
|
||||
{
|
||||
add_memory_shuffle (ainfo, &ainfo->ss, &ainfo->ss_end, (PTR) string,
|
||||
len + 1);
|
||||
if (!add_memory_shuffle (ainfo, &ainfo->ss, &ainfo->ss_end, (PTR) string,
|
||||
len + 1))
|
||||
return -1;
|
||||
ret = symhdr->issMax;
|
||||
symhdr->issMax += len + 1;
|
||||
fdr->cbSs += len + 1;
|
||||
@ -921,6 +990,11 @@ bfd_ecoff_debug_accumulate_other (handle, output_bfd, output_debug,
|
||||
|
||||
external_sym = (PTR) obstack_alloc (&ainfo->memory,
|
||||
output_swap->external_sym_size);
|
||||
if (!external_sym)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
(*swap_sym_out) (output_bfd, &internal_sym, external_sym);
|
||||
add_memory_shuffle (ainfo, &ainfo->sym, &ainfo->sym_end,
|
||||
external_sym, output_swap->external_sym_size);
|
||||
@ -936,6 +1010,11 @@ bfd_ecoff_debug_accumulate_other (handle, output_bfd, output_debug,
|
||||
it only applies to aux fields and there are none. */
|
||||
external_fdr = (PTR) obstack_alloc (&ainfo->memory,
|
||||
output_swap->external_fdr_size);
|
||||
if (!external_fdr)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
(*output_swap->swap_fdr_out) (output_bfd, &fdr, external_fdr);
|
||||
add_memory_shuffle (ainfo, &ainfo->fdr, &ainfo->fdr_end,
|
||||
external_fdr, output_swap->external_fdr_size);
|
||||
|
@ -485,10 +485,10 @@ hppa_elf_gen_reloc_type (abfd, base_type, format, field)
|
||||
int i;
|
||||
|
||||
final_types = (elf32_hppa_reloc_type **) bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type *) * 2);
|
||||
BFD_ASSERT (final_types != 0);
|
||||
BFD_ASSERT (final_types != 0); /* FIXME */
|
||||
|
||||
finaltype = (elf32_hppa_reloc_type *) bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type));
|
||||
BFD_ASSERT (finaltype != 0);
|
||||
BFD_ASSERT (finaltype != 0); /* FIXME */
|
||||
|
||||
final_types[0] = finaltype;
|
||||
final_types[1] = NULL;
|
||||
@ -1090,10 +1090,10 @@ hppa_elf_gen_reloc_type (abfd, base_type, format, field)
|
||||
case R_HPPA_COMPLEX_PCREL_CALL:
|
||||
case R_HPPA_COMPLEX_ABS_CALL:
|
||||
final_types = (elf32_hppa_reloc_type **) bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type *) * 6);
|
||||
BFD_ASSERT (final_types != 0);
|
||||
BFD_ASSERT (final_types != 0); /* FIXME */
|
||||
|
||||
finaltype = (elf32_hppa_reloc_type *) bfd_alloc_by_size_t (abfd, sizeof (elf32_hppa_reloc_type) * 5);
|
||||
BFD_ASSERT (finaltype != 0);
|
||||
BFD_ASSERT (finaltype != 0); /* FIXME */
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
final_types[i] = &finaltype[i];
|
||||
@ -1747,6 +1747,11 @@ elf_hppa_tc_symbol (abfd, symbolP, sym_idx)
|
||||
return;
|
||||
|
||||
symextP = (symext_chainS *) bfd_alloc (abfd, sizeof (symext_chainS) * 2);
|
||||
if (!symextP)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
|
||||
symextP[0].entry = ELF32_HPPA_SX_WORD (HPPA_SXT_SYMNDX, sym_idx);
|
||||
symextP[0].next = &symextP[1];
|
||||
@ -1808,6 +1813,11 @@ elf_hppa_tc_make_sections (abfd, ignored)
|
||||
bfd_set_section_alignment (abfd, symextn_sec, 2);
|
||||
}
|
||||
symextn_contents = (symext_entryS *) bfd_alloc (abfd, size);
|
||||
if (!symextn_contents)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
|
||||
for (i = 0, symextP = symext_rootP; symextP; symextP = symextP->next, ++i)
|
||||
symextn_contents[i] = symextP->entry;
|
||||
@ -1965,7 +1975,7 @@ new_stub (abfd, stub_sec, link_info)
|
||||
else
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
bfd_perror ("new_stub");
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
|
||||
return stub;
|
||||
@ -2031,7 +2041,7 @@ add_stub_by_name(abfd, stub_sec, sym, link_info)
|
||||
else
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
bfd_perror("add_stub_by_name");
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
}
|
||||
|
||||
@ -2141,8 +2151,8 @@ type_of_mismatch (caller_bits, callee_bits, type)
|
||||
}
|
||||
|
||||
#define CURRENT_STUB_OFFSET(entry) \
|
||||
((int)(entry)->stub_desc->stub_secp \
|
||||
- (int)(entry)->stub_desc->stub_contents - 4)
|
||||
((char *)(entry)->stub_desc->stub_secp \
|
||||
- (char *)(entry)->stub_desc->stub_contents - 4)
|
||||
|
||||
static boolean stubs_finished = false;
|
||||
|
||||
@ -2275,13 +2285,18 @@ hppa_elf_stub_branch_reloc (stub_desc, /* the bfd */
|
||||
stub_desc->stub_sec->relocation = (arelent *) realloc (stub_desc->stub_sec->relocation,
|
||||
size);
|
||||
}
|
||||
if (!stub_desc->stub_sec->relocation)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
}
|
||||
|
||||
/* Fill in the details. */
|
||||
relent.address = offset;
|
||||
relent.addend = 0;
|
||||
relent.sym_ptr_ptr = (asymbol **) bfd_zalloc (stub_desc->this_bfd, sizeof (asymbol *));
|
||||
BFD_ASSERT (relent.sym_ptr_ptr);
|
||||
BFD_ASSERT (relent.sym_ptr_ptr); /* FIXME */
|
||||
|
||||
relent.sym_ptr_ptr[0] = target_sym;
|
||||
relent.howto = bfd_reloc_type_lookup (stub_desc->this_bfd, R_HPPA_PCREL_CALL_17);
|
||||
@ -2325,6 +2340,11 @@ hppa_elf_stub_reloc (stub_desc, /* the bfd */
|
||||
stub_desc->stub_sec->relocation = (arelent *) realloc (stub_desc->stub_sec->relocation,
|
||||
size);
|
||||
}
|
||||
if (!stub_desc->stub_sec->relocation)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
}
|
||||
|
||||
rela_hdr = &elf_section_data(stub_desc->stub_sec)->rel_hdr;
|
||||
@ -2334,7 +2354,7 @@ hppa_elf_stub_reloc (stub_desc, /* the bfd */
|
||||
relent.address = offset;
|
||||
relent.addend = 0;
|
||||
relent.sym_ptr_ptr = (asymbol **) bfd_zalloc (stub_desc->this_bfd, sizeof (asymbol *));
|
||||
BFD_ASSERT (relent.sym_ptr_ptr);
|
||||
BFD_ASSERT (relent.sym_ptr_ptr); /* FIXME */
|
||||
|
||||
relent.sym_ptr_ptr[0] = target_sym;
|
||||
relent.howto = bfd_reloc_type_lookup (stub_desc->this_bfd, type);
|
||||
@ -2407,7 +2427,12 @@ hppa_elf_build_arg_reloc_stub (abfd, output_bfd, link_info, reloc_entry,
|
||||
if (!stub_desc->stub_contents)
|
||||
{
|
||||
stub_desc->allocated_size = STUB_BUFFER_INCR;
|
||||
stub_desc->stub_contents = (char *) bfd_xmalloc (STUB_BUFFER_INCR);
|
||||
stub_desc->stub_contents = (char *) malloc (STUB_BUFFER_INCR);
|
||||
if (!stub_desc->stub_contents)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else if ((stub_desc->allocated_size - stub_desc->real_size) < STUB_MAX_SIZE)
|
||||
{
|
||||
@ -2435,6 +2460,11 @@ hppa_elf_build_arg_reloc_stub (abfd, output_bfd, link_info, reloc_entry,
|
||||
change the relocation type? */
|
||||
reloc_entry->sym_ptr_ptr = (asymbol **) bfd_zalloc (stub_desc->this_bfd,
|
||||
sizeof (asymbol *));
|
||||
if (!reloc_entry->sym_ptr_ptr)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
reloc_entry->sym_ptr_ptr[0] = stub_sym;
|
||||
if (reloc_entry->howto->type != R_HPPA_PLABEL_32
|
||||
&& (get_opcode(insn) == BLE
|
||||
@ -2446,10 +2476,20 @@ hppa_elf_build_arg_reloc_stub (abfd, output_bfd, link_info, reloc_entry,
|
||||
{
|
||||
/* Create a new symbol to point to this stub. */
|
||||
stub_sym = bfd_make_empty_symbol (abfd);
|
||||
if (!stub_sym)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
stub_sym->name = bfd_zalloc (abfd, strlen (stub_sym_name) + 1);
|
||||
if (!stub_sym->name)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
strcpy ((char *) stub_sym->name, stub_sym_name);
|
||||
stub_sym->value
|
||||
= (int) stub_desc->stub_secp - (int) stub_desc->stub_contents;
|
||||
= (char *) stub_desc->stub_secp - (char *) stub_desc->stub_contents;
|
||||
stub_sym->section = stub_sec;
|
||||
stub_sym->flags = BSF_LOCAL | BSF_FUNCTION;
|
||||
stub_entry = add_stub_by_name (abfd, stub_sec, stub_sym, link_info);
|
||||
@ -2459,6 +2499,11 @@ hppa_elf_build_arg_reloc_stub (abfd, output_bfd, link_info, reloc_entry,
|
||||
relocation to be the internal use only stub R_HPPA_STUB_CALL_17. */
|
||||
reloc_entry->sym_ptr_ptr = (asymbol **) bfd_zalloc (stub_desc->this_bfd,
|
||||
sizeof (asymbol *));
|
||||
if (!reloc_entry->sym_ptr_ptr)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
reloc_entry->sym_ptr_ptr[0] = stub_sym;
|
||||
if (reloc_entry->howto->type != R_HPPA_PLABEL_32
|
||||
&& (get_opcode (insn) == BLE
|
||||
@ -2929,6 +2974,11 @@ hppa_elf_build_long_branch_stub (abfd, output_bfd, link_info, reloc_entry,
|
||||
FIXME. Is there a need to change the relocation type too? */
|
||||
reloc_entry->sym_ptr_ptr = (asymbol **) bfd_zalloc (stub_desc->this_bfd,
|
||||
sizeof (asymbol *));
|
||||
if (!reloc_entry->sym_ptr_ptr)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
reloc_entry->sym_ptr_ptr[0] = stub_sym;
|
||||
reloc_entry->howto = bfd_reloc_type_lookup (abfd, R_HPPA_STUB_CALL_17);
|
||||
}
|
||||
@ -2936,10 +2986,20 @@ hppa_elf_build_long_branch_stub (abfd, output_bfd, link_info, reloc_entry,
|
||||
{
|
||||
/* We will need to allocate a new stub. */
|
||||
stub_sym = bfd_make_empty_symbol (abfd);
|
||||
if (!stub_sym)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
stub_sym->name = bfd_zalloc (abfd, strlen (stub_sym_name) + 1);
|
||||
if (!stub_sym->name)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
strcpy ((char *) stub_sym->name, stub_sym_name);
|
||||
stub_sym->value
|
||||
= (int) stub_desc->stub_secp - (int) stub_desc->stub_contents;
|
||||
= (char *) stub_desc->stub_secp - (char *) stub_desc->stub_contents;
|
||||
stub_sym->section = stub_sec;
|
||||
stub_sym->flags = BSF_LOCAL | BSF_FUNCTION;
|
||||
stub_entry = add_stub_by_name (abfd, stub_sec, stub_sym, link_info);
|
||||
@ -2950,6 +3010,11 @@ hppa_elf_build_long_branch_stub (abfd, output_bfd, link_info, reloc_entry,
|
||||
FIXME. Is there a need to change the relocation type too? */
|
||||
reloc_entry->sym_ptr_ptr = (asymbol **) bfd_zalloc (stub_desc->this_bfd,
|
||||
sizeof (asymbol *));
|
||||
if (!reloc_entry->sym_ptr_ptr)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
reloc_entry->sym_ptr_ptr[0] = stub_sym;
|
||||
reloc_entry->howto = bfd_reloc_type_lookup (abfd, R_HPPA_STUB_CALL_17);
|
||||
|
||||
@ -3458,6 +3523,11 @@ elf32_hppa_backend_symbol_table_processing (abfd, esyms,symcnt)
|
||||
/* allocate a buffer of the appropriate size for the symextn section */
|
||||
|
||||
symextn_hdr->contents = bfd_zalloc(abfd,symextn_hdr->sh_size);
|
||||
if (!symextn_hdr->contents)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
symextn_hdr->size = symextn_hdr->sh_size;
|
||||
|
||||
/* read in the symextn section */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* MIPS-specific support for 32-bit ELF
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
Copyright 1993, 1994 Free Software Foundation, Inc.
|
||||
|
||||
Most of the information added by Ian Lance Taylor, Cygnus Support,
|
||||
<ian@cygnus.com>.
|
||||
@ -1061,6 +1061,7 @@ mips_elf_read_ecoff_info (abfd, section, debug)
|
||||
return false; \
|
||||
}
|
||||
|
||||
READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, PTR);
|
||||
READ (line, cbLineOffset, cbLine, sizeof (unsigned char), unsigned char *);
|
||||
READ (external_dnr, cbDnOffset, idnMax, swap->external_dnr_size, PTR);
|
||||
READ (external_pdr, cbPdOffset, ipdMax, swap->external_pdr_size, PTR);
|
||||
@ -1072,7 +1073,8 @@ mips_elf_read_ecoff_info (abfd, section, debug)
|
||||
READ (ssext, cbSsExtOffset, issExtMax, sizeof (char), char *);
|
||||
READ (external_fdr, cbFdOffset, ifdMax, swap->external_fdr_size, PTR);
|
||||
READ (external_rfd, cbRfdOffset, crfd, swap->external_rfd_size, PTR);
|
||||
READ (external_ext, cbExtOffset, iextMax, swap->external_ext_size, PTR);
|
||||
|
||||
debug->fdr = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1084,6 +1086,8 @@ mips_elf_get_extr (sym, esym)
|
||||
asymbol *sym;
|
||||
EXTR *esym;
|
||||
{
|
||||
const struct ecoff_debug_swap *swap;
|
||||
|
||||
if (sym->flags & BSF_SECTION_SYM)
|
||||
return false;
|
||||
|
||||
@ -1103,7 +1107,11 @@ mips_elf_get_extr (sym, esym)
|
||||
return true;
|
||||
}
|
||||
|
||||
*esym = *((elf_symbol_type *) sym)->tc_data.mips_extr;
|
||||
swap = (get_elf_backend_data (bfd_asymbol_bfd (sym))
|
||||
->elf_backend_ecoff_debug_swap);
|
||||
(*swap->swap_ext_in) (bfd_asymbol_bfd (sym),
|
||||
((elf_symbol_type *) sym)->tc_data.mips_extr,
|
||||
esym);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1140,6 +1148,7 @@ mips_elf_final_link (abfd, info)
|
||||
const struct ecoff_debug_swap *swap
|
||||
= get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
|
||||
HDRR *symhdr = &debug.symbolic_header;
|
||||
PTR mdebug_handle = NULL;
|
||||
|
||||
abfd->outsymbols = (asymbol **) NULL;
|
||||
abfd->symcount = 0;
|
||||
@ -1152,6 +1161,7 @@ mips_elf_final_link (abfd, info)
|
||||
return false;
|
||||
|
||||
/* Accumulate the global symbols. */
|
||||
wginfo.info = info;
|
||||
wginfo.output_bfd = abfd;
|
||||
wginfo.psymalloc = &outsymalloc;
|
||||
_bfd_generic_link_hash_traverse (_bfd_generic_hash_table (info),
|
||||
@ -1167,7 +1177,10 @@ mips_elf_final_link (abfd, info)
|
||||
secpp = &abfd->sections;
|
||||
while (*secpp != NULL)
|
||||
{
|
||||
if ((*secpp)->_raw_size == 0
|
||||
if (((*secpp)->_raw_size == 0
|
||||
&& strcmp ((*secpp)->name, ".data") != 0
|
||||
&& strcmp ((*secpp)->name, ".text") != 0
|
||||
&& strcmp ((*secpp)->name, ".bss") != 0)
|
||||
|| strcmp ((*secpp)->name, ".options") == 0
|
||||
|| strncmp ((*secpp)->name, ".gptab", 6) == 0)
|
||||
{
|
||||
@ -1182,6 +1195,8 @@ mips_elf_final_link (abfd, info)
|
||||
information. We don't write out the information until we have
|
||||
set the section sizes, because the ELF backend only assigns space
|
||||
in the file once. */
|
||||
reginfo_sec = NULL;
|
||||
mdebug_sec = NULL;
|
||||
for (o = abfd->sections; o != (asection *) NULL; o = o->next)
|
||||
{
|
||||
if (strcmp (o->name, ".reginfo") == 0)
|
||||
@ -1258,18 +1273,22 @@ mips_elf_final_link (abfd, info)
|
||||
|
||||
/* We accumulate the debugging information itself in the
|
||||
debug_info structure. */
|
||||
debug.line = debug.line_end = NULL;
|
||||
debug.external_dnr = debug.external_dnr_end = NULL;
|
||||
debug.external_pdr = debug.external_pdr_end = NULL;
|
||||
debug.external_sym = debug.external_sym_end = NULL;
|
||||
debug.external_opt = debug.external_opt_end = NULL;
|
||||
debug.external_aux = debug.external_aux_end = NULL;
|
||||
debug.ss = debug.ss_end = NULL;
|
||||
debug.line = NULL;
|
||||
debug.external_dnr = NULL;
|
||||
debug.external_pdr = NULL;
|
||||
debug.external_sym = NULL;
|
||||
debug.external_opt = NULL;
|
||||
debug.external_aux = NULL;
|
||||
debug.ss = NULL;
|
||||
debug.ssext = debug.ssext_end = NULL;
|
||||
debug.external_fdr = debug.external_fdr_end = NULL;
|
||||
debug.external_rfd = debug.external_rfd_end = NULL;
|
||||
debug.external_fdr = NULL;
|
||||
debug.external_rfd = NULL;
|
||||
debug.external_ext = debug.external_ext_end = NULL;
|
||||
|
||||
mdebug_handle = bfd_ecoff_debug_init (abfd, &debug, swap, info);
|
||||
if (mdebug_handle == (PTR) NULL)
|
||||
return false;
|
||||
|
||||
for (p = o->link_order_head;
|
||||
p != (struct bfd_link_order *) NULL;
|
||||
p = p->next)
|
||||
@ -1282,6 +1301,10 @@ mips_elf_final_link (abfd, info)
|
||||
if (p->type != bfd_indirect_link_order)
|
||||
continue;
|
||||
|
||||
#ifndef alloca
|
||||
alloca (0);
|
||||
#endif
|
||||
|
||||
input_section = p->u.indirect.section;
|
||||
input_bfd = input_section->owner;
|
||||
|
||||
@ -1308,9 +1331,8 @@ mips_elf_final_link (abfd, info)
|
||||
return false;
|
||||
|
||||
if (! (bfd_ecoff_debug_accumulate
|
||||
(abfd, &debug, swap,
|
||||
input_bfd, &input_debug, input_swap,
|
||||
info->relocateable)))
|
||||
(mdebug_handle, abfd, &debug, swap, input_bfd,
|
||||
&input_debug, input_swap, info)))
|
||||
return false;
|
||||
|
||||
/* Loop through the external symbols. For each one with
|
||||
@ -1355,15 +1377,21 @@ mips_elf_final_link (abfd, info)
|
||||
if (elf_sym->tc_data.mips_extr != NULL)
|
||||
continue;
|
||||
|
||||
elf_sym->tc_data.mips_extr =
|
||||
(EXTR *) bfd_alloc (abfd, sizeof (EXTR));
|
||||
if (ext.ifd != -1)
|
||||
{
|
||||
BFD_ASSERT (ext.ifd
|
||||
< input_debug.symbolic_header.ifdMax);
|
||||
ext.ifd = input_debug.ifdmap[ext.ifd];
|
||||
}
|
||||
|
||||
ext.ifd += input_debug.ifdbase;
|
||||
*elf_sym->tc_data.mips_extr = ext;
|
||||
(*input_swap->swap_ext_out) (input_bfd, &ext,
|
||||
(PTR) eraw_src);
|
||||
elf_sym->tc_data.mips_extr = (PTR) eraw_src;
|
||||
}
|
||||
}
|
||||
|
||||
/* Free up the information we just read. */
|
||||
/* Free up the information we just read, except for the
|
||||
external symbols which we may have pointers to. */
|
||||
free (input_debug.line);
|
||||
free (input_debug.external_dnr);
|
||||
free (input_debug.external_pdr);
|
||||
@ -1374,7 +1402,6 @@ mips_elf_final_link (abfd, info)
|
||||
free (input_debug.ssext);
|
||||
free (input_debug.external_fdr);
|
||||
free (input_debug.external_rfd);
|
||||
free (input_debug.external_ext);
|
||||
}
|
||||
|
||||
/* Build the external symbol information. */
|
||||
@ -1418,7 +1445,12 @@ mips_elf_final_link (abfd, info)
|
||||
input_bfd = input_section->owner;
|
||||
relsize = bfd_get_reloc_upper_bound (input_bfd,
|
||||
input_section);
|
||||
relocs = (arelent **) bfd_xmalloc (relsize);
|
||||
relocs = (arelent **) malloc (relsize);
|
||||
if (!relocs)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
reloc_count =
|
||||
bfd_canonicalize_reloc (input_bfd, input_section,
|
||||
relocs,
|
||||
@ -1434,6 +1466,11 @@ mips_elf_final_link (abfd, info)
|
||||
bfd_alloc (abfd,
|
||||
(o->reloc_count
|
||||
* sizeof (arelent *))));
|
||||
if (!o->orelocation)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
/* Reset the count so that it can be used as an index
|
||||
when putting in the output relocs. */
|
||||
o->reloc_count = 0;
|
||||
@ -1461,8 +1498,12 @@ mips_elf_final_link (abfd, info)
|
||||
(file_ptr) 0, (bfd_size_type) 0);
|
||||
BFD_ASSERT (abfd->output_has_begun);
|
||||
}
|
||||
if (! bfd_ecoff_write_debug (abfd, &debug, swap, mdebug_sec->filepos))
|
||||
if (! bfd_ecoff_write_accumulated_debug (mdebug_handle, abfd, &debug,
|
||||
swap, info,
|
||||
mdebug_sec->filepos))
|
||||
return false;
|
||||
|
||||
bfd_ecoff_debug_free (mdebug_handle, abfd, &debug, swap, info);
|
||||
}
|
||||
|
||||
/* Handle all the link order information for the sections. */
|
||||
|
112
bfd/elfcode.h
112
bfd/elfcode.h
@ -132,7 +132,7 @@ static boolean elf_slurp_symbol_table PARAMS ((bfd *, asymbol **));
|
||||
static int elf_symbol_from_bfd_symbol PARAMS ((bfd *,
|
||||
struct symbol_cache_entry **));
|
||||
|
||||
static void elf_map_symbols PARAMS ((bfd *));
|
||||
static boolean elf_map_symbols PARAMS ((bfd *));
|
||||
static boolean swap_out_syms PARAMS ((bfd *));
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -412,7 +412,7 @@ DEFUN (bfd_add_to_strtab, (abfd, ss, str),
|
||||
/* should this be using obstacks? */
|
||||
ss->tab = realloc (ss->tab, ss->length + ln);
|
||||
|
||||
BFD_ASSERT (ss->tab != 0);
|
||||
BFD_ASSERT (ss->tab != 0); /* FIXME */
|
||||
strcpy (ss->tab + ss->length, str);
|
||||
ss->nentries++;
|
||||
ss->length += ln;
|
||||
@ -437,7 +437,7 @@ DEFUN (bfd_add_2_to_strtab, (abfd, ss, str, str2),
|
||||
else
|
||||
ss->tab = malloc (ln);
|
||||
|
||||
BFD_ASSERT (ss->tab != 0);
|
||||
BFD_ASSERT (ss->tab != 0); /* FIXME */
|
||||
strcpy (ss->tab + ss->length, str);
|
||||
strcpy (ss->tab + ss->length + strlen (str), str2);
|
||||
ss->nentries++;
|
||||
@ -596,8 +596,8 @@ DEFUN (bfd_section_from_shdr, (abfd, shindex),
|
||||
newsect->flags = SEC_HAS_CONTENTS;
|
||||
hdr->rawdata = (PTR) newsect;
|
||||
newsect->_raw_size = hdr->sh_size;
|
||||
newsect->alignment_power = 0;
|
||||
newsect->vma = 0;
|
||||
newsect->alignment_power = bfd_log2 (hdr->sh_addralign);
|
||||
newsect->vma = hdr->sh_addr;
|
||||
newsect->filepos = hdr->sh_offset;
|
||||
|
||||
if (hdr->sh_flags & SHF_ALLOC)
|
||||
@ -710,6 +710,11 @@ DEFUN (elf_new_section_hook, (abfd, sec),
|
||||
struct bfd_elf_section_data *sdata;
|
||||
|
||||
sdata = (struct bfd_elf_section_data *) bfd_alloc (abfd, sizeof (*sdata));
|
||||
if (!sdata)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
sec->used_by_bfd = (PTR) sdata;
|
||||
memset (sdata, 0, sizeof (*sdata));
|
||||
return true;
|
||||
@ -753,6 +758,11 @@ DEFUN (bfd_section_from_phdr, (abfd, hdr, index),
|
||||
(hdr->p_memsz > hdr->p_filesz));
|
||||
sprintf (namebuf, split ? "segment%da" : "segment%d", index);
|
||||
name = bfd_alloc (abfd, strlen (namebuf) + 1);
|
||||
if (!name)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
strcpy (name, namebuf);
|
||||
newsect = bfd_make_section (abfd, name);
|
||||
newsect->vma = hdr->p_vaddr;
|
||||
@ -779,6 +789,11 @@ DEFUN (bfd_section_from_phdr, (abfd, hdr, index),
|
||||
{
|
||||
sprintf (namebuf, "segment%db", index);
|
||||
name = bfd_alloc (abfd, strlen (namebuf) + 1);
|
||||
if (!name)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
strcpy (name, namebuf);
|
||||
newsect = bfd_make_section (abfd, name);
|
||||
newsect->vma = hdr->p_vaddr + hdr->p_filesz;
|
||||
@ -1149,6 +1164,11 @@ write_relocs (abfd, sec, xxx)
|
||||
|
||||
rela_hdr->sh_size = rela_hdr->sh_entsize * sec->reloc_count;
|
||||
rela_hdr->contents = (void *) bfd_alloc (abfd, rela_hdr->sh_size);
|
||||
if (!rela_hdr->contents)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
|
||||
/* orelocation has the data, reloc_count has the count... */
|
||||
if (use_rela_p)
|
||||
@ -1378,7 +1398,7 @@ sym_is_global (abfd, sym)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static boolean
|
||||
DEFUN (elf_map_symbols, (abfd), bfd * abfd)
|
||||
{
|
||||
int symcount = bfd_get_symcount (abfd);
|
||||
@ -1414,11 +1434,20 @@ DEFUN (elf_map_symbols, (abfd), bfd * abfd)
|
||||
sect_syms = (asymbol **) bfd_zalloc (abfd, max_index * sizeof (asymbol *));
|
||||
elf_section_syms (abfd) = sect_syms;
|
||||
|
||||
BFD_ASSERT (sect_syms != 0);
|
||||
if (sect_syms != 0)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (asect = abfd->sections; asect; asect = asect->next)
|
||||
{
|
||||
asymbol *sym = bfd_make_empty_symbol (abfd);
|
||||
if (!sym)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
sym->the_bfd = abfd;
|
||||
sym->name = asect->name;
|
||||
sym->value = asect->vma;
|
||||
@ -1442,6 +1471,11 @@ DEFUN (elf_map_symbols, (abfd), bfd * abfd)
|
||||
else
|
||||
syms = (asymbol **) bfd_alloc (abfd,
|
||||
(num_sections + 1) * sizeof (asymbol *));
|
||||
if (!syms)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (asect = abfd->sections; asect; asect = asect->next)
|
||||
{
|
||||
@ -1455,6 +1489,11 @@ DEFUN (elf_map_symbols, (abfd), bfd * abfd)
|
||||
|
||||
elf_sym_extra (abfd) = sym_extra
|
||||
= (Elf_Sym_Extra *) bfd_alloc (abfd, symcount * sizeof (Elf_Sym_Extra));
|
||||
if (!sym_extra)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Identify and classify all of the symbols. */
|
||||
for (idx = 0; idx < symcount; idx++)
|
||||
@ -1478,17 +1517,19 @@ DEFUN (elf_map_symbols, (abfd), bfd * abfd)
|
||||
|
||||
elf_num_locals (abfd) = num_locals;
|
||||
elf_num_globals (abfd) = num_globals;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void assign_section_numbers ();
|
||||
static void assign_file_positions_except_relocs ();
|
||||
static boolean assign_section_numbers ();
|
||||
static boolean assign_file_positions_except_relocs ();
|
||||
|
||||
static boolean
|
||||
DEFUN (elf_compute_section_file_positions, (abfd), bfd * abfd)
|
||||
{
|
||||
bfd_map_over_sections (abfd, elf_fake_sections, 0);
|
||||
|
||||
assign_section_numbers (abfd);
|
||||
if (!assign_section_numbers (abfd))
|
||||
return false;
|
||||
|
||||
bfd_map_over_sections (abfd, elf_make_sections, 0);
|
||||
|
||||
@ -1497,7 +1538,8 @@ DEFUN (elf_compute_section_file_positions, (abfd), bfd * abfd)
|
||||
if (swap_out_syms (abfd) == false)
|
||||
return false;
|
||||
|
||||
assign_file_positions_except_relocs (abfd);
|
||||
if (!assign_file_positions_except_relocs (abfd))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1531,7 +1573,7 @@ static const Elf_Internal_Shdr null_shdr;
|
||||
too. The link/info pointers for the standard section types are filled
|
||||
in here too, while we're at it. (Link pointers for .stab sections are
|
||||
not filled in here.) */
|
||||
static void
|
||||
static boolean
|
||||
assign_section_numbers (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
@ -1573,6 +1615,11 @@ assign_section_numbers (abfd)
|
||||
indices. */
|
||||
i_shdrp = (Elf_Internal_Shdr **)
|
||||
bfd_alloc (abfd, section_number * sizeof (Elf_Internal_Shdr *));
|
||||
if (!i_shdrp)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
elf_elfsections(abfd) = i_shdrp;
|
||||
for (i = 0; i < section_number; i++)
|
||||
i_shdrp[i] = 0;
|
||||
@ -1595,6 +1642,7 @@ assign_section_numbers (abfd)
|
||||
for (i = 0; i < section_number; i++)
|
||||
if (i_shdrp[i] == 0)
|
||||
abort ();
|
||||
return true;
|
||||
}
|
||||
|
||||
static INLINE file_ptr
|
||||
@ -1645,7 +1693,7 @@ struct seg_info {
|
||||
struct seg_info *next;
|
||||
};
|
||||
|
||||
static void
|
||||
static boolean
|
||||
map_program_segments (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
@ -1708,6 +1756,11 @@ map_program_segments (abfd)
|
||||
{
|
||||
struct seg_info *s;
|
||||
s = (struct seg_info *) bfd_alloc (abfd, sizeof (struct seg_info));
|
||||
if (!s)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
s->next = seg;
|
||||
seg = s;
|
||||
}
|
||||
@ -1787,6 +1840,11 @@ map_program_segments (abfd)
|
||||
}
|
||||
phdr = (Elf_Internal_Phdr*) bfd_alloc (abfd,
|
||||
n_segs * sizeof (Elf_Internal_Phdr));
|
||||
if (!phdr)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
elf_tdata (abfd)->phdr = phdr;
|
||||
while (seg)
|
||||
{
|
||||
@ -1810,9 +1868,10 @@ map_program_segments (abfd)
|
||||
i_ehdrp->e_phnum = n_segs;
|
||||
}
|
||||
elf_write_phdrs (abfd, i_ehdrp, elf_tdata (abfd)->phdr, i_ehdrp->e_phnum);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
static boolean
|
||||
assign_file_positions_except_relocs (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
@ -1912,7 +1971,8 @@ assign_file_positions_except_relocs (abfd)
|
||||
if (exec_p)
|
||||
{
|
||||
elf_tdata (abfd)->next_file_pos = off;
|
||||
map_program_segments (abfd);
|
||||
if (!map_program_segments (abfd))
|
||||
return false;
|
||||
off = elf_tdata (abfd)->next_file_pos;
|
||||
|
||||
/* Section headers. */
|
||||
@ -1932,6 +1992,7 @@ assign_file_positions_except_relocs (abfd)
|
||||
}
|
||||
}
|
||||
elf_tdata (abfd)->next_file_pos = off;
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean
|
||||
@ -2048,7 +2109,8 @@ static boolean
|
||||
swap_out_syms (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
elf_map_symbols (abfd);
|
||||
if (!elf_map_symbols (abfd))
|
||||
return false;
|
||||
|
||||
/* Dump out the symtabs. */
|
||||
{
|
||||
@ -2079,6 +2141,11 @@ swap_out_syms (abfd)
|
||||
|
||||
outbound_syms = (Elf_External_Sym *)
|
||||
bfd_alloc (abfd, (1 + symcount) * sizeof (Elf_External_Sym));
|
||||
if (!outbound_syms)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
/* now generate the data (for "contents") */
|
||||
{
|
||||
/* Fill in zeroth symbol and swap it out. */
|
||||
@ -2527,7 +2594,7 @@ DEFUN (elf_slurp_symbol_table, (abfd, symptrs),
|
||||
|
||||
/* Temporarily allocate room for the raw ELF symbols. */
|
||||
x_symp = (Elf_External_Sym *) malloc (symcount * sizeof (Elf_External_Sym));
|
||||
if (!x_symp)
|
||||
if (!symbase || !x_symp)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
@ -2705,6 +2772,12 @@ DEFUN (elf_slurp_reloca_table, (abfd, asect, symbols),
|
||||
bfd_seek (abfd, asect->rel_filepos, SEEK_SET);
|
||||
native_relocs = (Elf_External_Rela *)
|
||||
bfd_alloc (abfd, asect->reloc_count * sizeof (Elf_External_Rela));
|
||||
if (!native_relocs)
|
||||
if (!reloc_cache)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
bfd_read ((PTR) native_relocs,
|
||||
sizeof (Elf_External_Rela), asect->reloc_count, abfd);
|
||||
|
||||
@ -2847,6 +2920,11 @@ DEFUN (elf_slurp_reloc_table, (abfd, asect, symbols),
|
||||
bfd_seek (abfd, asect->rel_filepos, SEEK_SET);
|
||||
native_relocs = (Elf_External_Rel *)
|
||||
bfd_alloc (abfd, asect->reloc_count * sizeof (Elf_External_Rel));
|
||||
if (!native_relocs)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
bfd_read ((PTR) native_relocs,
|
||||
sizeof (Elf_External_Rel), asect->reloc_count, abfd);
|
||||
|
||||
|
34
bfd/hash.c
34
bfd/hash.c
@ -1,22 +1,22 @@
|
||||
/* hash.c -- hash table routines for BFD
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 94 Free Software Foundation, Inc.
|
||||
Written by Steve Chamberlain <sac@cygnus.com>
|
||||
|
||||
This file is part of GLD, the Gnu Linker.
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
GLD is free software; you can redistribute it and/or modify
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GLD is distributed in the hope that it will be useful,
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GLD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
@ -290,7 +290,7 @@ SUBSUBSECTION
|
||||
*/
|
||||
|
||||
/* Obstack allocation and deallocation routines. */
|
||||
#define obstack_chunk_alloc xmalloc
|
||||
#define obstack_chunk_alloc malloc
|
||||
#define obstack_chunk_free free
|
||||
|
||||
/* The default number of entries to use when creating a hash table. */
|
||||
@ -309,9 +309,18 @@ bfd_hash_table_init_n (table, newfunc, size)
|
||||
unsigned int alloc;
|
||||
|
||||
alloc = size * sizeof (struct bfd_hash_entry *);
|
||||
obstack_begin (&table->memory, alloc);
|
||||
if (!obstack_begin (&table->memory, alloc))
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
table->table = ((struct bfd_hash_entry **)
|
||||
obstack_alloc (&table->memory, alloc));
|
||||
if (!table->table)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
memset ((PTR) table->table, 0, alloc);
|
||||
table->size = size;
|
||||
table->newfunc = newfunc;
|
||||
@ -388,6 +397,11 @@ bfd_hash_lookup (table, string, create, copy)
|
||||
char *new;
|
||||
|
||||
new = (char *) obstack_alloc (&table->memory, len + 1);
|
||||
if (!new)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return (struct bfd_hash_entry *) NULL;
|
||||
}
|
||||
strcpy (new, string);
|
||||
string = new;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* BFD backend for hp-ux 9000/300
|
||||
Copyright (C) 1990-1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990, 1991, 1994 Free Software Foundation, Inc.
|
||||
Written by Glenn Engel.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
@ -28,7 +28,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
Support for the 9000/[34]00 has several limitations.
|
||||
1. Shared libraries are not supported.
|
||||
2. The output format from this bfd is not usable by native tools.
|
||||
3. Core files are not supported (yet).
|
||||
|
||||
The primary motivation for writing this bfd was to allow use of
|
||||
gdb and gcc for host based debugging and not to mimic the hp-ux tools
|
||||
@ -126,10 +125,17 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
/***********************************************/
|
||||
/* provide overrides for routines in this file */
|
||||
/***********************************************/
|
||||
#define MY_get_symtab MY(get_symtab)
|
||||
#define MY_get_symtab_upper_bound MY(get_symtab_upper_bound)
|
||||
#define MY_canonicalize_reloc MY(canonicalize_reloc)
|
||||
#define MY_write_object_contents MY(write_object_contents)
|
||||
/* these don't use MY because that causes problems within JUMP_TABLE
|
||||
(CAT winds up being expanded recursively, which ANSI C compilers
|
||||
will not do). */
|
||||
#define MY_get_symtab hp300hpux_get_symtab
|
||||
#define MY_get_symtab_upper_bound hp300hpux_get_symtab_upper_bound
|
||||
#define MY_canonicalize_reloc hp300hpux_canonicalize_reloc
|
||||
#define MY_write_object_contents hp300hpux_write_object_contents
|
||||
|
||||
#define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
|
||||
#define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#define MY_bfd_final_link _bfd_generic_final_link
|
||||
|
||||
#define hp300hpux_write_syms aout_32_write_syms
|
||||
|
||||
@ -167,6 +173,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#define HP_RLENGTH_ALIGN 0x03
|
||||
|
||||
#define NAME(x,y) CAT3(hp300hpux,_32_,y)
|
||||
#define ARCH_SIZE 32
|
||||
#include "aoutx.h"
|
||||
|
||||
/* Since the hpux symbol table has nlist elements interspersed with
|
||||
@ -232,6 +239,8 @@ DEFUN(MY(callback),(abfd),
|
||||
return abfd->xvec;
|
||||
}
|
||||
|
||||
extern boolean aout_32_write_syms PARAMS ((bfd *abfd));
|
||||
|
||||
static boolean
|
||||
DEFUN(MY(write_object_contents),(abfd),
|
||||
bfd *abfd)
|
||||
@ -272,7 +281,19 @@ DEFUN(MY(write_object_contents),(abfd),
|
||||
bfd_seek (abfd, 0L, false);
|
||||
bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd);
|
||||
|
||||
/* Now write out reloc info, followed by syms and strings */
|
||||
/* Write out the symbols, and then the relocs. We must write out
|
||||
the symbols first so that we know the symbol indices. */
|
||||
|
||||
if (bfd_get_symcount (abfd) != 0)
|
||||
{
|
||||
/* Skip the relocs to where we want to put the symbols. */
|
||||
if (bfd_seek (abfd, (file_ptr) N_DRELOFF (*execp) + execp->a_drsize,
|
||||
SEEK_SET) != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! MY(write_syms) (abfd))
|
||||
return false;
|
||||
|
||||
if (bfd_get_symcount (abfd) != 0)
|
||||
{
|
||||
@ -284,7 +305,6 @@ DEFUN(MY(write_object_contents),(abfd),
|
||||
if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) return false;
|
||||
}
|
||||
|
||||
MY(write_syms)(abfd);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -340,7 +360,7 @@ DEFUN(convert_sym_type,(sym_pointer, cache_ptr, abfd),
|
||||
break;
|
||||
|
||||
default:
|
||||
printf ("unknown symbol type encountered: %x", name_type);
|
||||
fprintf (stderr, "unknown symbol type encountered: %x", name_type);
|
||||
}
|
||||
if (name_type & HP_SYMTYPE_EXTERNAL)
|
||||
new_type |= N_EXT;
|
||||
@ -462,6 +482,11 @@ DEFUN(MY(slurp_symbol_table),(abfd),
|
||||
|
||||
strings = (char *) bfd_alloc(abfd,
|
||||
symbol_bytes + SYM_EXTRA_BYTES);
|
||||
if (!strings)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
syms = (struct external_nlist *) (strings + SYM_EXTRA_BYTES);
|
||||
bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET);
|
||||
if (bfd_read ((PTR)syms, symbol_bytes, 1, abfd) != symbol_bytes)
|
||||
@ -489,6 +514,11 @@ DEFUN(MY(slurp_symbol_table),(abfd),
|
||||
cached = (aout_symbol_type *)
|
||||
bfd_zalloc(abfd, (bfd_size_type)(bfd_get_symcount (abfd) *
|
||||
sizeof(aout_symbol_type)));
|
||||
if (!cached)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* as we march thru the hp symbol table, convert it into a list of
|
||||
null terminated strings to hold the symbol names. Make sure any
|
||||
@ -515,7 +545,8 @@ DEFUN(MY(slurp_symbol_table),(abfd),
|
||||
|
||||
cache_save = *cache_ptr;
|
||||
convert_sym_type(sym_pointer, cache_ptr, abfd);
|
||||
translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd);
|
||||
if (!translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd))
|
||||
return false;
|
||||
|
||||
/********************************************************/
|
||||
/* for hpux, the 'lenght' value indicates the length of */
|
||||
@ -560,8 +591,9 @@ DEFUN(MY(slurp_symbol_table),(abfd),
|
||||
strings += length+10;
|
||||
cache_ptr2->type &= ~HP_SECONDARY_SYMBOL; /* clear secondary */
|
||||
convert_sym_type(sym_pointer, cache_ptr2, abfd);
|
||||
translate_from_native_sym_flags (sym_pointer, cache_ptr2,
|
||||
abfd);
|
||||
if (!translate_from_native_sym_flags (sym_pointer, cache_ptr2,
|
||||
abfd))
|
||||
return false;
|
||||
}
|
||||
|
||||
/* skip over the embedded symbol. */
|
||||
@ -618,8 +650,8 @@ DEFUN(MY(swap_std_reloc_in), (abfd, bytes, cache_ptr, symbols),
|
||||
case HP_RSEGMENT_NOOP:
|
||||
break;
|
||||
default:
|
||||
printf
|
||||
("illegal relocation segment type: %x\n", (bytes->r_type[0]));
|
||||
fprintf (stderr, "illegal relocation segment type: %x\n",
|
||||
(bytes->r_type[0]));
|
||||
}
|
||||
|
||||
switch (bytes->r_length[0])
|
||||
@ -634,7 +666,7 @@ DEFUN(MY(swap_std_reloc_in), (abfd, bytes, cache_ptr, symbols),
|
||||
r_length = 2;
|
||||
break;
|
||||
default:
|
||||
printf("illegal relocation length: %x\n",bytes->r_length[0] );
|
||||
fprintf (stderr, "illegal relocation length: %x\n",bytes->r_length[0] );
|
||||
r_length = 0;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,8 @@ hppabsd_core_make_empty_symbol (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
|
||||
new->the_bfd = abfd;
|
||||
if (new)
|
||||
new->the_bfd = abfd;
|
||||
return new;
|
||||
}
|
||||
|
||||
@ -165,6 +166,11 @@ hppabsd_core_core_file_p (abfd)
|
||||
|
||||
coredata = (struct hppabsd_core_struct *)
|
||||
bfd_zalloc (abfd, sizeof (struct hppabsd_core_struct));
|
||||
if (!coredata)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Make the core data and available via the tdata part of the BFD. */
|
||||
abfd->tdata.hppabsd_core_data = coredata;
|
||||
@ -234,7 +240,7 @@ hppabsd_core_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
#define hppabsd_core_close_and_cleanup bfd_generic_close_and_cleanup
|
||||
#define hppabsd_core_set_section_contents (boolean (*) PARAMS \
|
||||
((bfd *abfd, asection *section, PTR data, file_ptr offset, \
|
||||
bfd_size_type count))) bfd_false
|
||||
bfd_size_type count))) bfd_generic_set_section_contents
|
||||
#define hppabsd_core_get_section_contents \
|
||||
bfd_generic_get_section_contents
|
||||
#define hppabsd_core_new_section_hook (boolean (*) PARAMS \
|
||||
@ -288,9 +294,10 @@ swap_abort ()
|
||||
abort ();
|
||||
}
|
||||
|
||||
#define NO_GET ((bfd_vma (*) PARAMS (( bfd_byte *))) swap_abort )
|
||||
#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
|
||||
#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
|
||||
#define NO_SIGNED_GET ((bfd_signed_vma (*) PARAMS ((bfd_byte *))) swap_abort )
|
||||
#define NO_SIGNED_GET \
|
||||
((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
|
||||
|
||||
bfd_target hppabsd_core_vec =
|
||||
{
|
||||
|
4491
bfd/ieee.c
4491
bfd/ieee.c
File diff suppressed because it is too large
Load Diff
112
bfd/linker.c
112
bfd/linker.c
@ -1,22 +1,22 @@
|
||||
/* linker.c -- BFD linker routines
|
||||
Copyright 1993 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 94 Free Software Foundation, Inc.
|
||||
Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support
|
||||
|
||||
This file is part of BFD
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
GLD is free software; you can redistribute it and/or modify
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GLD is distributed in the hope that it will be useful,
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GLD; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
@ -443,15 +443,23 @@ _bfd_link_hash_newfunc (entry, table, string)
|
||||
if (ret == (struct bfd_link_hash_entry *) NULL)
|
||||
ret = ((struct bfd_link_hash_entry *)
|
||||
bfd_hash_allocate (table, sizeof (struct bfd_link_hash_entry)));
|
||||
if (ret == (struct bfd_link_hash_entry *) NULL)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Call the allocation method of the superclass. */
|
||||
ret = ((struct bfd_link_hash_entry *)
|
||||
bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
|
||||
|
||||
/* Initialize the local fields. */
|
||||
ret->type = bfd_link_hash_new;
|
||||
ret->written = false;
|
||||
ret->next = NULL;
|
||||
if (ret)
|
||||
{
|
||||
/* Initialize the local fields. */
|
||||
ret->type = bfd_link_hash_new;
|
||||
ret->written = false;
|
||||
ret->next = NULL;
|
||||
}
|
||||
|
||||
return (struct bfd_hash_entry *) ret;
|
||||
}
|
||||
@ -549,14 +557,22 @@ generic_link_hash_newfunc (entry, table, string)
|
||||
if (ret == (struct generic_link_hash_entry *) NULL)
|
||||
ret = ((struct generic_link_hash_entry *)
|
||||
bfd_hash_allocate (table, sizeof (struct generic_link_hash_entry)));
|
||||
if (ret == (struct generic_link_hash_entry *) NULL)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Call the allocation method of the superclass. */
|
||||
ret = ((struct generic_link_hash_entry *)
|
||||
_bfd_link_hash_newfunc ((struct bfd_hash_entry *) ret,
|
||||
table, string));
|
||||
|
||||
/* Set local fields. */
|
||||
ret->sym = NULL;
|
||||
if (ret)
|
||||
{
|
||||
/* Set local fields. */
|
||||
ret->sym = NULL;
|
||||
}
|
||||
|
||||
return (struct bfd_hash_entry *) ret;
|
||||
}
|
||||
@ -570,7 +586,12 @@ _bfd_generic_link_hash_table_create (abfd)
|
||||
struct generic_link_hash_table *ret;
|
||||
|
||||
ret = ((struct generic_link_hash_table *)
|
||||
bfd_xmalloc (sizeof (struct generic_link_hash_table)));
|
||||
malloc (sizeof (struct generic_link_hash_table)));
|
||||
if (!ret)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return (struct bfd_link_hash_table *) NULL;
|
||||
}
|
||||
if (! _bfd_link_hash_table_init (&ret->root, abfd,
|
||||
generic_link_hash_newfunc))
|
||||
{
|
||||
@ -683,13 +704,21 @@ archive_hash_newfunc (entry, table, string)
|
||||
if (ret == (struct archive_hash_entry *) NULL)
|
||||
ret = ((struct archive_hash_entry *)
|
||||
bfd_hash_allocate (table, sizeof (struct archive_hash_entry)));
|
||||
if (ret == (struct archive_hash_entry *) NULL)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Call the allocation method of the superclass. */
|
||||
ret = ((struct archive_hash_entry *)
|
||||
bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
|
||||
|
||||
/* Initialize the local fields. */
|
||||
ret->defs = (struct archive_list *) NULL;
|
||||
if (ret)
|
||||
{
|
||||
/* Initialize the local fields. */
|
||||
ret->defs = (struct archive_list *) NULL;
|
||||
}
|
||||
|
||||
return (struct bfd_hash_entry *) ret;
|
||||
}
|
||||
@ -1405,6 +1434,11 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value,
|
||||
sub = ((struct bfd_link_hash_entry *)
|
||||
bfd_hash_allocate (&info->hash->table,
|
||||
sizeof (struct bfd_link_hash_entry)));
|
||||
if (!sub)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
*sub = *h;
|
||||
h->type = bfd_link_hash_warning;
|
||||
h->u.i.link = sub;
|
||||
@ -1452,6 +1486,7 @@ _bfd_generic_final_link (abfd, info)
|
||||
return false;
|
||||
|
||||
/* Accumulate the global symbols. */
|
||||
wginfo.info = info;
|
||||
wginfo.output_bfd = abfd;
|
||||
wginfo.psymalloc = &outsymalloc;
|
||||
_bfd_generic_link_hash_traverse (_bfd_generic_hash_table (info),
|
||||
@ -1482,7 +1517,12 @@ _bfd_generic_final_link (abfd, info)
|
||||
input_bfd = input_section->owner;
|
||||
relsize = bfd_get_reloc_upper_bound (input_bfd,
|
||||
input_section);
|
||||
relocs = (arelent **) bfd_xmalloc (relsize);
|
||||
relocs = (arelent **) malloc ((size_t) relsize);
|
||||
if (!relocs)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
reloc_count =
|
||||
bfd_canonicalize_reloc (input_bfd, input_section,
|
||||
relocs,
|
||||
@ -1498,6 +1538,11 @@ _bfd_generic_final_link (abfd, info)
|
||||
bfd_alloc (abfd,
|
||||
(o->reloc_count
|
||||
* sizeof (arelent *))));
|
||||
if (!o->orelocation)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
/* Reset the count so that it can be used as an index
|
||||
when putting in the output relocs. */
|
||||
o->reloc_count = 0;
|
||||
@ -1572,6 +1617,11 @@ _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc)
|
||||
|
||||
symsize = get_symtab_upper_bound (input_bfd);
|
||||
input_bfd->outsymbols = (asymbol **) bfd_alloc (input_bfd, symsize);
|
||||
if (!input_bfd->outsymbols)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
input_bfd->symcount = bfd_canonicalize_symtab (input_bfd,
|
||||
input_bfd->outsymbols);
|
||||
|
||||
@ -1589,6 +1639,8 @@ _bfd_generic_link_output_symbols (output_bfd, input_bfd, info, psymalloc)
|
||||
asymbol *newsym;
|
||||
|
||||
newsym = bfd_make_empty_symbol (input_bfd);
|
||||
if (!newsym)
|
||||
return false;
|
||||
newsym->name = input_bfd->filename;
|
||||
newsym->value = 0;
|
||||
newsym->flags = BSF_LOCAL | BSF_FILE;
|
||||
@ -1767,6 +1819,14 @@ _bfd_generic_link_write_global_symbol (h, data)
|
||||
if (h->root.written)
|
||||
return true;
|
||||
|
||||
h->root.written = true;
|
||||
|
||||
if (wginfo->info->strip == strip_all
|
||||
|| (wginfo->info->strip == strip_some
|
||||
&& bfd_hash_lookup (wginfo->info->keep_hash, h->root.root.string,
|
||||
false, false) == NULL))
|
||||
return true;
|
||||
|
||||
if (h->sym != (asymbol *) NULL)
|
||||
{
|
||||
sym = h->sym;
|
||||
@ -1775,6 +1835,8 @@ _bfd_generic_link_write_global_symbol (h, data)
|
||||
else
|
||||
{
|
||||
sym = bfd_make_empty_symbol (wginfo->output_bfd);
|
||||
if (!sym)
|
||||
return false;
|
||||
sym->name = h->root.root.string;
|
||||
sym->flags = 0;
|
||||
}
|
||||
@ -1820,8 +1882,6 @@ _bfd_generic_link_write_global_symbol (h, data)
|
||||
abort ();
|
||||
}
|
||||
|
||||
h->root.written = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1836,6 +1896,11 @@ bfd_new_link_order (abfd, section)
|
||||
|
||||
new = ((struct bfd_link_order *)
|
||||
bfd_alloc_by_size_t (abfd, sizeof (struct bfd_link_order)));
|
||||
if (!new)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new->type = bfd_undefined_link_order;
|
||||
new->offset = 0;
|
||||
@ -1948,6 +2013,11 @@ default_indirect_link_order (output_bfd, info, output_section, link_order)
|
||||
|
||||
symsize = get_symtab_upper_bound (input_bfd);
|
||||
input_bfd->outsymbols = (asymbol **) bfd_alloc (input_bfd, symsize);
|
||||
if (!input_bfd->outsymbols)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
input_bfd->symcount = bfd_canonicalize_symtab (input_bfd,
|
||||
input_bfd->outsymbols);
|
||||
}
|
||||
@ -1957,6 +2027,8 @@ default_indirect_link_order (output_bfd, info, output_section, link_order)
|
||||
contents = (bfd_get_relocated_section_contents
|
||||
(output_bfd, info, link_order, contents, info->relocateable,
|
||||
bfd_get_outsymbols (input_bfd)));
|
||||
if (!contents)
|
||||
return false;
|
||||
|
||||
/* Output the section contents. */
|
||||
if (! bfd_set_section_contents (output_bfd, output_section, (PTR) contents,
|
||||
|
@ -96,6 +96,7 @@ nlm_alpha_write_prefix (abfd)
|
||||
bfd_error = system_call_error;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* How to process the various reloc types. */
|
||||
@ -469,13 +470,13 @@ nlm_alpha_read_reloc (abfd, sym, secp, rel)
|
||||
rel->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
|
||||
rel->addend = 0;
|
||||
}
|
||||
else if (r_symndx == RELOC_SECTION_TEXT)
|
||||
else if (r_symndx == ALPHA_RELOC_SECTION_TEXT)
|
||||
{
|
||||
rel->sym_ptr_ptr = code_sec->symbol_ptr_ptr;
|
||||
BFD_ASSERT (bfd_get_section_vma (abfd, code_sec) == 0);
|
||||
rel->addend = 0;
|
||||
}
|
||||
else if (r_symndx == RELOC_SECTION_DATA)
|
||||
else if (r_symndx == ALPHA_RELOC_SECTION_DATA)
|
||||
{
|
||||
rel->sym_ptr_ptr = data_sec->symbol_ptr_ptr;
|
||||
rel->addend = - bfd_get_section_vma (abfd, data_sec);
|
||||
@ -573,14 +574,23 @@ nlm_alpha_read_reloc (abfd, sym, secp, rel)
|
||||
break;
|
||||
|
||||
case ALPHA_R_NW_RELOC:
|
||||
/* If this is SETGP, we set the addend to 0. Otherwise we set
|
||||
the addend to the size of the .lita section (this is
|
||||
r_symndx) plus 1. We have already set the address of the
|
||||
reloc to r_vaddr. */
|
||||
if (r_size == ALPHA_R_NW_RELOC_SETGP)
|
||||
gp_value = r_vaddr;
|
||||
{
|
||||
gp_value = r_vaddr;
|
||||
rel->addend = 0;
|
||||
}
|
||||
else if (r_size == ALPHA_R_NW_RELOC_LITA)
|
||||
lita_address = r_vaddr;
|
||||
{
|
||||
lita_address = r_vaddr;
|
||||
rel->addend = r_symndx + 1;
|
||||
}
|
||||
else
|
||||
BFD_ASSERT (0);
|
||||
rel->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
|
||||
rel->addend = r_size;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -628,6 +638,11 @@ nlm_alpha_read_import (abfd, sym)
|
||||
}
|
||||
sym -> symbol.the_bfd = abfd;
|
||||
sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
|
||||
if (!sym -> symbol.name)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd)
|
||||
!= symlength)
|
||||
{
|
||||
@ -645,6 +660,11 @@ nlm_alpha_read_import (abfd, sym)
|
||||
rcount = bfd_h_get_32 (abfd, temp);
|
||||
nlm_relocs = ((struct nlm_relent *)
|
||||
bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
|
||||
if (!nlm_relocs)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
sym -> relocs = nlm_relocs;
|
||||
sym -> rcnt = 0;
|
||||
while (sym -> rcnt < rcount)
|
||||
@ -680,52 +700,72 @@ nlm_alpha_write_import (abfd, sec, rel)
|
||||
sym = *rel->sym_ptr_ptr;
|
||||
|
||||
/* Get values for the relocation fields. */
|
||||
r_vaddr = bfd_get_section_vma (abfd, sec) + rel->address;
|
||||
if (bfd_get_section (sym) == &bfd_und_section)
|
||||
r_type = rel->howto->type;
|
||||
if (r_type != ALPHA_R_NW_RELOC)
|
||||
{
|
||||
r_extern = 1;
|
||||
r_symndx = 0;
|
||||
r_vaddr = bfd_get_section_vma (abfd, sec) + rel->address;
|
||||
if ((sec->flags & SEC_CODE) == 0)
|
||||
r_vaddr += bfd_section_size (abfd,
|
||||
bfd_get_section_by_name (abfd,
|
||||
NLM_CODE_NAME));
|
||||
if (bfd_get_section (sym) == &bfd_und_section)
|
||||
{
|
||||
r_extern = 1;
|
||||
r_symndx = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
r_extern = 0;
|
||||
if (bfd_get_section_flags (abfd, bfd_get_section (sym)) & SEC_CODE)
|
||||
r_symndx = ALPHA_RELOC_SECTION_TEXT;
|
||||
else
|
||||
r_symndx = ALPHA_RELOC_SECTION_DATA;
|
||||
}
|
||||
r_offset = 0;
|
||||
r_size = 0;
|
||||
|
||||
switch (r_type)
|
||||
{
|
||||
case ALPHA_R_LITUSE:
|
||||
case ALPHA_R_GPDISP:
|
||||
r_symndx = rel->addend;
|
||||
break;
|
||||
|
||||
case ALPHA_R_OP_STORE:
|
||||
r_size = rel->addend & 0xff;
|
||||
r_offset = (rel->addend >> 8) & 0xff;
|
||||
break;
|
||||
|
||||
case ALPHA_R_OP_PUSH:
|
||||
case ALPHA_R_OP_PSUB:
|
||||
case ALPHA_R_OP_PRSHIFT:
|
||||
r_vaddr = rel->addend;
|
||||
break;
|
||||
|
||||
case ALPHA_R_IGNORE:
|
||||
r_vaddr = rel->address;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
r_extern = 0;
|
||||
if (bfd_get_section_flags (abfd, bfd_get_section (sym)) & SEC_CODE)
|
||||
r_symndx = RELOC_SECTION_TEXT;
|
||||
else
|
||||
r_symndx = RELOC_SECTION_DATA;
|
||||
}
|
||||
r_type = rel->howto->type;
|
||||
r_offset = 0;
|
||||
r_size = 0;
|
||||
|
||||
switch (r_type)
|
||||
{
|
||||
case ALPHA_R_LITUSE:
|
||||
case ALPHA_R_GPDISP:
|
||||
r_symndx = rel->addend;
|
||||
break;
|
||||
|
||||
case ALPHA_R_OP_STORE:
|
||||
r_size = rel->addend & 0xff;
|
||||
r_offset = (rel->addend >> 8) & 0xff;
|
||||
break;
|
||||
|
||||
case ALPHA_R_OP_PUSH:
|
||||
case ALPHA_R_OP_PSUB:
|
||||
case ALPHA_R_OP_PRSHIFT:
|
||||
r_vaddr = rel->addend;
|
||||
break;
|
||||
|
||||
case ALPHA_R_IGNORE:
|
||||
/* r_type == ALPHA_R_NW_RELOC */
|
||||
r_vaddr = rel->address;
|
||||
break;
|
||||
|
||||
case ALPHA_R_NW_RELOC:
|
||||
r_size = rel->addend;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
if (rel->addend == 0)
|
||||
{
|
||||
r_symndx = 0;
|
||||
r_size = ALPHA_R_NW_RELOC_SETGP;
|
||||
}
|
||||
else
|
||||
{
|
||||
r_symndx = rel->addend - 1;
|
||||
r_size = ALPHA_R_NW_RELOC_LITA;
|
||||
}
|
||||
r_extern = 0;
|
||||
r_offset = 0;
|
||||
}
|
||||
|
||||
/* Swap out the relocation fields. */
|
||||
@ -800,13 +840,14 @@ nlm_alpha_get_public_offset (abfd, sym)
|
||||
static boolean
|
||||
nlm_alpha_write_external (abfd, count, sym, relocs)
|
||||
bfd *abfd;
|
||||
bfd_vma count;
|
||||
bfd_size_type count;
|
||||
asymbol *sym;
|
||||
struct reloc_and_sec *relocs;
|
||||
{
|
||||
int i;
|
||||
bfd_byte len;
|
||||
unsigned char temp[NLM_TARGET_LONG_SIZE];
|
||||
arelent r;
|
||||
|
||||
len = strlen (sym->name);
|
||||
if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
|
||||
@ -816,13 +857,28 @@ nlm_alpha_write_external (abfd, count, sym, relocs)
|
||||
return false;
|
||||
}
|
||||
|
||||
bfd_put_32 (abfd, count, temp);
|
||||
bfd_put_32 (abfd, count + 2, temp);
|
||||
if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
|
||||
{
|
||||
bfd_error = system_call_error;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* The first two relocs for each external symbol are the .lita
|
||||
address and the GP value. */
|
||||
r.sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
|
||||
r.howto = &nlm32_alpha_nw_howto;
|
||||
|
||||
r.address = nlm_alpha_backend_data (abfd)->lita_address;
|
||||
r.addend = nlm_alpha_backend_data (abfd)->lita_size + 1;
|
||||
if (nlm_alpha_write_import (abfd, (asection *) NULL, &r) == false)
|
||||
return false;
|
||||
|
||||
r.address = nlm_alpha_backend_data (abfd)->gp;
|
||||
r.addend = 0;
|
||||
if (nlm_alpha_write_import (abfd, (asection *) NULL, &r) == false)
|
||||
return false;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (nlm_alpha_write_import (abfd, relocs[i].sec,
|
||||
@ -842,6 +898,7 @@ static const struct nlm_backend_data nlm32_alpha_backend =
|
||||
sizeof (struct nlm32_alpha_external_prefix_header),
|
||||
bfd_arch_alpha,
|
||||
0,
|
||||
true, /* no uninitialized data permitted by Alpha NetWare. */
|
||||
nlm_alpha_backend_object_p,
|
||||
nlm_alpha_write_prefix,
|
||||
nlm_alpha_read_reloc,
|
||||
@ -853,6 +910,7 @@ static const struct nlm_backend_data nlm32_alpha_backend =
|
||||
nlm_swap_fixed_header_in,
|
||||
nlm_swap_fixed_header_out,
|
||||
nlm_alpha_write_external,
|
||||
0, /* write_export */
|
||||
};
|
||||
|
||||
#define TARGET_LITTLE_NAME "nlm32-alpha"
|
||||
|
@ -363,6 +363,11 @@ nlm_i386_read_import (abfd, sym)
|
||||
}
|
||||
sym -> symbol.the_bfd = abfd;
|
||||
sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
|
||||
if (!sym -> symbol.name)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd)
|
||||
!= symlength)
|
||||
{
|
||||
@ -380,6 +385,11 @@ nlm_i386_read_import (abfd, sym)
|
||||
rcount = bfd_h_get_32 (abfd, temp);
|
||||
nlm_relocs = ((struct nlm_relent *)
|
||||
bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
|
||||
if (!nlm_relocs)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
sym -> relocs = nlm_relocs;
|
||||
sym -> rcnt = 0;
|
||||
while (sym -> rcnt < rcount)
|
||||
@ -444,6 +454,7 @@ static const struct nlm_backend_data nlm32_i386_backend =
|
||||
0, /* optional_prefix_size */
|
||||
bfd_arch_i386,
|
||||
0,
|
||||
false,
|
||||
0, /* backend_object_p */
|
||||
0, /* write_prefix_func */
|
||||
nlm_i386_read_reloc,
|
||||
@ -455,6 +466,7 @@ static const struct nlm_backend_data nlm32_i386_backend =
|
||||
nlm_swap_fixed_header_in,
|
||||
nlm_swap_fixed_header_out,
|
||||
nlm_i386_write_external,
|
||||
0, /* write_export */
|
||||
};
|
||||
|
||||
#define TARGET_LITTLE_NAME "nlm32-i386"
|
||||
|
@ -173,7 +173,7 @@ nlm_sparc_write_reloc (abfd, sec, rel)
|
||||
arelent *rel;
|
||||
{
|
||||
bfd_vma val;
|
||||
struct nlm32_sparc_reloc_ext tmp_reloc = {0};
|
||||
struct nlm32_sparc_reloc_ext tmp_reloc;
|
||||
int index;
|
||||
int type = -1;
|
||||
reloc_howto_type *tmp;
|
||||
@ -283,6 +283,11 @@ nlm_sparc_read_import (abfd, sym)
|
||||
}
|
||||
sym -> symbol.the_bfd = abfd;
|
||||
sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
|
||||
if (!sym -> symbol.name)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Then read in the symbol
|
||||
@ -304,6 +309,11 @@ nlm_sparc_read_import (abfd, sym)
|
||||
|
||||
nlm_relocs = ((struct nlm_relent *)
|
||||
bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
|
||||
if (!nlm_relocs)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
sym -> relocs = nlm_relocs;
|
||||
sym -> rcnt = 0;
|
||||
while (sym -> rcnt < rcount)
|
||||
|
118
bfd/nlmcode.h
118
bfd/nlmcode.h
@ -111,14 +111,11 @@ DEFUN (nlm_object_p, (abfd), bfd * abfd)
|
||||
|
||||
/* Read in the fixed length portion of the NLM header in external format. */
|
||||
|
||||
x_fxdhdr = alloca (nlm_fixed_header_size (abfd));
|
||||
x_fxdhdr = (PTR) alloca (nlm_fixed_header_size (abfd));
|
||||
|
||||
if (bfd_read ((PTR) x_fxdhdr, nlm_fixed_header_size (abfd), 1, abfd) !=
|
||||
nlm_fixed_header_size (abfd))
|
||||
{
|
||||
bfd_error = system_call_error;
|
||||
goto got_no_match;
|
||||
}
|
||||
goto got_wrong_format_error;
|
||||
|
||||
/* Allocate an instance of the nlm_obj_tdata structure and hook it up to
|
||||
the tdata pointer in the bfd. */
|
||||
@ -561,7 +558,7 @@ DEFUN (nlm_swap_auxiliary_headers_in, (abfd),
|
||||
}
|
||||
else if (strncmp (tempstr, "CoPyRiGhT=", 10) == 0)
|
||||
{
|
||||
if (bfd_read ((PTR) &nlm_copyright_header (abfd)->stamp,
|
||||
if (bfd_read ((PTR) nlm_copyright_header (abfd)->stamp,
|
||||
sizeof (nlm_copyright_header (abfd)->stamp),
|
||||
1, abfd)
|
||||
!= sizeof (nlm_copyright_header (abfd)->stamp))
|
||||
@ -859,7 +856,8 @@ nlm_make_empty_symbol (abfd)
|
||||
nlm_symbol_type *new;
|
||||
|
||||
new = (nlm_symbol_type *) bfd_zalloc (abfd, sizeof (nlm_symbol_type));
|
||||
new->symbol.the_bfd = abfd;
|
||||
if (new)
|
||||
new->symbol.the_bfd = abfd;
|
||||
return &new->symbol;
|
||||
}
|
||||
|
||||
@ -964,6 +962,11 @@ nlm_slurp_symbol_table (abfd)
|
||||
|
||||
sym = ((nlm_symbol_type *)
|
||||
bfd_zalloc (abfd, totsymcount * sizeof (nlm_symbol_type)));
|
||||
if (!sym)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
nlm_set_symbols (abfd, sym);
|
||||
|
||||
/* We use the bfd's symcount directly as the control count, so that early
|
||||
@ -982,6 +985,11 @@ nlm_slurp_symbol_table (abfd)
|
||||
}
|
||||
sym -> symbol.the_bfd = abfd;
|
||||
sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
|
||||
if (!sym -> symbol.name)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd)
|
||||
!= symlength)
|
||||
{
|
||||
@ -1048,6 +1056,11 @@ nlm_slurp_symbol_table (abfd)
|
||||
}
|
||||
sym -> symbol.the_bfd = abfd;
|
||||
sym -> symbol.name = bfd_alloc (abfd, symlength + 1);
|
||||
if (!sym -> symbol.name)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
if (bfd_read ((PTR) sym -> symbol.name, symlength, 1, abfd)
|
||||
!= symlength)
|
||||
{
|
||||
@ -1399,6 +1412,15 @@ nlm_compute_section_file_positions (abfd)
|
||||
nlm_set_text_low (abfd, text_low);
|
||||
nlm_set_data_low (abfd, data_low);
|
||||
|
||||
if (nlm_no_uninitialized_data (abfd))
|
||||
{
|
||||
/* This NetWare format does not use uninitialized data. We must
|
||||
increase the size of the data section. We will never wind up
|
||||
writing those file locations, so they will remain zero. */
|
||||
data += bss;
|
||||
bss = 0;
|
||||
}
|
||||
|
||||
text_ptr = BFD_ALIGN (sofar, 1 << text_align);
|
||||
data_ptr = BFD_ALIGN (text_ptr + text, 1 << data_align);
|
||||
other_ptr = BFD_ALIGN (data_ptr + data, 1 << other_align);
|
||||
@ -1465,8 +1487,17 @@ nlm_compute_section_file_positions (abfd)
|
||||
add += size;
|
||||
add = BFD_ALIGN (add, 1 << bss_sec->alignment_power);
|
||||
}
|
||||
nlm_fixed_header (abfd)->uninitializedDataSize += add;
|
||||
bss_sec->_raw_size += add;
|
||||
if (add != 0)
|
||||
{
|
||||
if (nlm_no_uninitialized_data (abfd))
|
||||
{
|
||||
/* We could handle this case, but so far it hasn't been
|
||||
necessary. */
|
||||
abort ();
|
||||
}
|
||||
nlm_fixed_header (abfd)->uninitializedDataSize += add;
|
||||
bss_sec->_raw_size += add;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1530,9 +1561,17 @@ nlm_external_reloc_compare (p1, p2)
|
||||
{
|
||||
const struct reloc_and_sec *r1 = (const struct reloc_and_sec *) p1;
|
||||
const struct reloc_and_sec *r2 = (const struct reloc_and_sec *) p2;
|
||||
int cmp;
|
||||
|
||||
return strcmp ((*r1->rel->sym_ptr_ptr)->name,
|
||||
(*r2->rel->sym_ptr_ptr)->name);
|
||||
cmp = strcmp ((*r1->rel->sym_ptr_ptr)->name,
|
||||
(*r2->rel->sym_ptr_ptr)->name);
|
||||
if (cmp != 0)
|
||||
return cmp;
|
||||
|
||||
/* We sort by address within symbol to make the sort more stable and
|
||||
increase the chances that different hosts will generate bit for
|
||||
bit equivalent results. */
|
||||
return (int) (r1->rel->address - r2->rel->address);
|
||||
}
|
||||
|
||||
/* Write out an NLM file. We write out the information in this order:
|
||||
@ -1574,7 +1613,7 @@ nlm_write_object_contents (abfd)
|
||||
asymbol **sym_ptr_ptr;
|
||||
file_ptr last;
|
||||
boolean (*write_prefix_func) PARAMS ((bfd *));
|
||||
unsigned char *fixed_header = alloca (nlm_fixed_header_size (abfd));
|
||||
unsigned char *fixed_header = (unsigned char *) alloca (nlm_fixed_header_size (abfd));
|
||||
|
||||
if (abfd->output_has_begun == false
|
||||
&& nlm_compute_section_file_positions (abfd) == false)
|
||||
@ -1705,7 +1744,7 @@ nlm_write_object_contents (abfd)
|
||||
BFD_ASSERT (i == external_reloc_count);
|
||||
|
||||
/* Sort the external relocs by name. */
|
||||
qsort (external_relocs, external_reloc_count,
|
||||
qsort ((PTR) external_relocs, (size_t) external_reloc_count,
|
||||
sizeof (struct reloc_and_sec), nlm_external_reloc_compare);
|
||||
|
||||
/* Write out the external relocs. */
|
||||
@ -1745,10 +1784,13 @@ nlm_write_object_contents (abfd)
|
||||
if (sym_ptr_ptr != (asymbol **) NULL)
|
||||
{
|
||||
bfd_vma (*get_public_offset_func) PARAMS ((bfd *, asymbol *));
|
||||
boolean (*write_export_func) PARAMS ((bfd*, asymbol *, bfd_vma));
|
||||
|
||||
asymbol **sym_end;
|
||||
|
||||
nlm_fixed_header (abfd)->publicsOffset = bfd_tell (abfd);
|
||||
get_public_offset_func = nlm_get_public_offset_func (abfd);
|
||||
write_export_func = nlm_write_export_func (abfd);
|
||||
c = 0;
|
||||
sym_end = sym_ptr_ptr + bfd_get_symcount (abfd);
|
||||
for (; sym_ptr_ptr < sym_end; sym_ptr_ptr++)
|
||||
@ -1766,15 +1808,6 @@ nlm_write_object_contents (abfd)
|
||||
|
||||
++c;
|
||||
|
||||
len = strlen (sym->name);
|
||||
if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd)
|
||||
!= sizeof (bfd_byte))
|
||||
|| bfd_write (sym->name, len, 1, abfd) != len)
|
||||
{
|
||||
bfd_error = system_call_error;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (get_public_offset_func)
|
||||
{
|
||||
/* Most backends can use the code below, but
|
||||
@ -1804,13 +1837,30 @@ nlm_write_object_contents (abfd)
|
||||
}
|
||||
}
|
||||
|
||||
put_word (abfd, offset, temp);
|
||||
if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
|
||||
if (write_export_func)
|
||||
{
|
||||
bfd_error = system_call_error;
|
||||
return false;
|
||||
if ((*write_export_func) (abfd, sym, offset) == false)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
len = strlen (sym->name);
|
||||
if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd)
|
||||
!= sizeof (bfd_byte))
|
||||
|| bfd_write (sym->name, len, 1, abfd) != len)
|
||||
{
|
||||
bfd_error = system_call_error;
|
||||
return false;
|
||||
}
|
||||
|
||||
put_word (abfd, offset, temp);
|
||||
if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
|
||||
{
|
||||
bfd_error = system_call_error;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
nlm_fixed_header (abfd)->numberOfPublics = c;
|
||||
|
||||
/* Write out the debugging records. The NLM conversion program
|
||||
@ -1849,16 +1899,18 @@ nlm_write_object_contents (abfd)
|
||||
|
||||
++c;
|
||||
|
||||
offset = sym->value;
|
||||
offset = bfd_asymbol_value (sym);
|
||||
sec = sym->section;
|
||||
if (sec->flags & SEC_CODE)
|
||||
type = 1;
|
||||
else if (sec->flags & SEC_DATA)
|
||||
type = 0;
|
||||
else if (sec->flags & SEC_ALLOC)
|
||||
{
|
||||
offset -= nlm_get_text_low (abfd);
|
||||
type = 1;
|
||||
}
|
||||
else if (sec->flags & (SEC_DATA | SEC_ALLOC))
|
||||
{
|
||||
/* SEC_ALLOC is for the .bss section. */
|
||||
offset -= nlm_get_data_low (abfd);
|
||||
type = 0;
|
||||
offset += nlm_fixed_header (abfd)->dataImageSize;
|
||||
}
|
||||
else
|
||||
type = 2;
|
||||
|
89
bfd/oasys.c
89
bfd/oasys.c
@ -33,6 +33,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
#define offsetof(type, identifier) (size_t) &(((type *) 0)->identifier)
|
||||
#endif
|
||||
|
||||
static boolean oasys_write_sections PARAMS ((bfd *));
|
||||
|
||||
/* Read in all the section data and relocation stuff too */
|
||||
PROTO(static boolean,oasys_slurp_section_data,(bfd *CONST abfd));
|
||||
|
||||
@ -99,7 +101,11 @@ DEFUN(oasys_slurp_symbol_table,(abfd),
|
||||
#else
|
||||
data->strings = bfd_alloc(abfd, data->symbol_string_length);
|
||||
#endif
|
||||
|
||||
if (!data->symbols || !data->strings)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
|
||||
dest_defined = data->symbols + abfd->symcount -1;
|
||||
|
||||
@ -267,9 +273,14 @@ DEFUN(oasys_archive_p,(abfd),
|
||||
oasys_module_info_type *module =
|
||||
(oasys_module_info_type*)
|
||||
bfd_alloc(abfd, sizeof(oasys_module_info_type) * header.mod_count);
|
||||
|
||||
oasys_module_table_type record;
|
||||
|
||||
if (!ar || !module)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
abfd->tdata.oasys_ar_data = ar;
|
||||
ar->module = module;
|
||||
ar->module_count = header.mod_count;
|
||||
@ -292,6 +303,11 @@ DEFUN(oasys_archive_p,(abfd),
|
||||
record.sect_count = bfd_h_get_32(abfd, record_ext.sect_count);
|
||||
|
||||
module[i].name = bfd_alloc(abfd,33);
|
||||
if (!module[i].name)
|
||||
{
|
||||
bfd_error = no_error;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(module[i].name, record_ext.mod_name, 33);
|
||||
filepos +=
|
||||
@ -313,6 +329,11 @@ DEFUN(oasys_archive_p,(abfd),
|
||||
record.module_name_size = bfd_h_get_32(abfd, record_ext.mod_name_length);
|
||||
|
||||
module[i].name = bfd_alloc(abfd,record.module_name_size + 1);
|
||||
if (!module[i].name)
|
||||
{
|
||||
bfd_error = no_error;
|
||||
return NULL;
|
||||
}
|
||||
bfd_read((PTR)module[i].name, 1, record.module_name_size, abfd);
|
||||
module[i].name[record.module_name_size] = 0;
|
||||
filepos +=
|
||||
@ -338,7 +359,7 @@ DEFUN(oasys_mkobject,(abfd),
|
||||
{
|
||||
|
||||
abfd->tdata.oasys_obj_data = (oasys_data_type*)bfd_alloc(abfd, sizeof(oasys_data_type));
|
||||
return true;
|
||||
return abfd->tdata.oasys_obj_data ? true : false;
|
||||
}
|
||||
|
||||
#define MAX_SECS 16
|
||||
@ -391,6 +412,11 @@ DEFUN(oasys_object_p,(abfd),
|
||||
goto fail;
|
||||
}
|
||||
buffer = bfd_alloc(abfd, 3);
|
||||
if (!buffer)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
goto fail;
|
||||
}
|
||||
section_number= record.section.relb & RELOCATION_SECT_BITS;
|
||||
sprintf(buffer,"%u", section_number);
|
||||
s = bfd_make_section(abfd,buffer);
|
||||
@ -548,6 +574,11 @@ DEFUN(oasys_slurp_section_data,(abfd),
|
||||
if (per->initialized == false)
|
||||
{
|
||||
per->data = (bfd_byte *) bfd_zalloc(abfd, section->_raw_size);
|
||||
if (!per->data)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
per->reloc_tail_ptr = (oasys_reloc_type **)&(section->relocation);
|
||||
per->had_vma = false;
|
||||
per->initialized = true;
|
||||
@ -607,6 +638,11 @@ DEFUN(oasys_slurp_section_data,(abfd),
|
||||
(oasys_reloc_type *)
|
||||
bfd_alloc(abfd,
|
||||
sizeof(oasys_reloc_type));
|
||||
if (!r)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
*(per->reloc_tail_ptr) = r;
|
||||
per->reloc_tail_ptr = &r->next;
|
||||
r->next= (oasys_reloc_type *)NULL;
|
||||
@ -648,6 +684,11 @@ DEFUN(oasys_slurp_section_data,(abfd),
|
||||
(oasys_reloc_type *)
|
||||
bfd_alloc(abfd,
|
||||
sizeof(oasys_reloc_type));
|
||||
if (!r)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
*(per->reloc_tail_ptr) = r;
|
||||
per->reloc_tail_ptr = &r->next;
|
||||
r->next= (oasys_reloc_type *)NULL;
|
||||
@ -704,10 +745,6 @@ DEFUN(oasys_slurp_section_data,(abfd),
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern bfd_error_vector_type bfd_error_vector;
|
||||
|
||||
static boolean
|
||||
DEFUN(oasys_new_section_hook,(abfd, newsect),
|
||||
bfd *abfd AND
|
||||
@ -715,6 +752,11 @@ DEFUN(oasys_new_section_hook,(abfd, newsect),
|
||||
{
|
||||
newsect->used_by_bfd = (PTR)
|
||||
bfd_alloc(abfd, sizeof(oasys_per_section_type));
|
||||
if (!newsect->used_by_bfd)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
oasys_per_section( newsect)->data = (bfd_byte *)NULL;
|
||||
oasys_per_section(newsect)->section = newsect;
|
||||
oasys_per_section(newsect)->offset = 0;
|
||||
@ -897,9 +939,9 @@ DEFUN(oasys_write_syms, (abfd),
|
||||
|
||||
|
||||
/* Write a section header for each section */
|
||||
static void
|
||||
DEFUN(oasys_write_sections, (abfd),
|
||||
bfd *CONST abfd)
|
||||
static boolean
|
||||
oasys_write_sections (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
asection *s;
|
||||
static oasys_section_record_type out;
|
||||
@ -907,8 +949,8 @@ DEFUN(oasys_write_sections, (abfd),
|
||||
for (s = abfd->sections; s != (asection *)NULL; s = s->next) {
|
||||
if (!isdigit(s->name[0]))
|
||||
{
|
||||
bfd_error_vector.nonrepresentable_section(abfd,
|
||||
s->name);
|
||||
bfd_error = nonrepresentable_section;
|
||||
return false;
|
||||
}
|
||||
out.relb = RELOCATION_TYPE_REL | s->target_index;
|
||||
bfd_h_put_32(abfd, s->_cooked_size, out.value);
|
||||
@ -919,6 +961,7 @@ DEFUN(oasys_write_sections, (abfd),
|
||||
(oasys_record_union_type *) &out,
|
||||
sizeof(out));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1032,7 +1075,7 @@ DEFUN(oasys_write_data, (abfd),
|
||||
|
||||
if (relocs_to_go != 0) {
|
||||
arelent *r = *p;
|
||||
reloc_howto_type *CONST how=r->howto;
|
||||
const reloc_howto_type * const how=r->howto;
|
||||
/* There is a relocation, is it for this byte ? */
|
||||
if (r->address == current_byte_index) {
|
||||
unsigned char rel_byte;
|
||||
@ -1152,7 +1195,8 @@ DEFUN(oasys_write_object_contents, (abfd),
|
||||
{
|
||||
oasys_write_header(abfd);
|
||||
oasys_write_syms(abfd);
|
||||
oasys_write_sections(abfd);
|
||||
if (! oasys_write_sections(abfd))
|
||||
return false;
|
||||
oasys_write_data(abfd);
|
||||
oasys_write_end(abfd);
|
||||
return true;
|
||||
@ -1179,6 +1223,11 @@ DEFUN(oasys_set_section_contents,(abfd, section, location, offset, count),
|
||||
{
|
||||
oasys_per_section(section)->data =
|
||||
(bfd_byte *)(bfd_alloc(abfd,section->_cooked_size));
|
||||
if (! oasys_per_section(section)->data)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
(void) memcpy((PTR)(oasys_per_section(section)->data + offset),
|
||||
location,
|
||||
@ -1202,9 +1251,13 @@ DEFUN(oasys_make_empty_symbol,(abfd),
|
||||
|
||||
oasys_symbol_type *new =
|
||||
(oasys_symbol_type *)bfd_zalloc (abfd, sizeof (oasys_symbol_type));
|
||||
if (!new)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
new->symbol.the_bfd = abfd;
|
||||
return &new->symbol;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1306,11 +1359,13 @@ return 0;
|
||||
#define oasys_bfd_debug_info_accumulate (FOO(void, (*), (bfd *, asection *)))bfd_void
|
||||
#define oasys_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
|
||||
#define oasys_bfd_relax_section bfd_generic_relax_section
|
||||
#define oasys_bfd_seclet_link bfd_generic_seclet_link
|
||||
#define oasys_bfd_reloc_type_lookup \
|
||||
((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
|
||||
#define oasys_bfd_make_debug_symbol \
|
||||
((asymbol *(*) PARAMS ((bfd *, void *, unsigned long))) bfd_nullvoidptr)
|
||||
#define oasys_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
|
||||
#define oasys_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
||||
#define oasys_bfd_final_link _bfd_generic_final_link
|
||||
|
||||
/*SUPPRESS 460 */
|
||||
bfd_target oasys_vec =
|
||||
@ -1321,7 +1376,7 @@ bfd_target oasys_vec =
|
||||
true, /* target headers byte order */
|
||||
(HAS_RELOC | EXEC_P | /* object flags */
|
||||
HAS_LINENO | HAS_DEBUG |
|
||||
HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
|
||||
HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
|
||||
(SEC_CODE|SEC_DATA|SEC_ROM|SEC_HAS_CONTENTS
|
||||
|SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
|
||||
0, /* leading underscore */
|
||||
|
24
bfd/opncls.c
24
bfd/opncls.c
@ -1,5 +1,5 @@
|
||||
/* opncls.c -- open and close a BFD.
|
||||
Copyright (C) 1990-1991 Free Software Foundation, Inc.
|
||||
Copyright (C) 1990 91, 92, 93, 94 Free Software Foundation, Inc.
|
||||
Written by Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
@ -29,7 +29,7 @@ FILE *bfd_open_file PARAMS ((bfd *));
|
||||
if we do that we can't use fcntl. */
|
||||
|
||||
|
||||
#define obstack_chunk_alloc xmalloc
|
||||
#define obstack_chunk_alloc malloc
|
||||
#define obstack_chunk_free free
|
||||
|
||||
/* Return a new BFD. All BFD's are allocated through this routine. */
|
||||
@ -41,10 +41,17 @@ _bfd_new_bfd ()
|
||||
|
||||
nbfd = (bfd *)bfd_zmalloc (sizeof (bfd));
|
||||
if (!nbfd)
|
||||
return 0;
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bfd_check_init();
|
||||
obstack_begin(&nbfd->memory, 128);
|
||||
if (!obstack_begin(&nbfd->memory, 128))
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return 0;
|
||||
}
|
||||
|
||||
nbfd->arch_info = &bfd_default_arch_struct;
|
||||
|
||||
@ -490,8 +497,7 @@ bfd_alloc_by_size_t (abfd, size)
|
||||
bfd *abfd;
|
||||
size_t size;
|
||||
{
|
||||
PTR res = obstack_alloc(&(abfd->memory), size);
|
||||
return res;
|
||||
return obstack_alloc(&(abfd->memory), size);
|
||||
}
|
||||
|
||||
void
|
||||
@ -525,7 +531,8 @@ bfd_zalloc (abfd, size)
|
||||
{
|
||||
PTR res;
|
||||
res = bfd_alloc(abfd, size);
|
||||
memset(res, 0, (size_t)size);
|
||||
if (res)
|
||||
memset(res, 0, (size_t)size);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -536,6 +543,7 @@ bfd_realloc (abfd, old, size)
|
||||
size_t size;
|
||||
{
|
||||
PTR res = bfd_alloc(abfd, size);
|
||||
memcpy(res, old, (size_t)size);
|
||||
if (res)
|
||||
memcpy(res, old, (size_t)size);
|
||||
return res;
|
||||
}
|
||||
|
@ -91,7 +91,8 @@ osf_core_make_empty_symbol (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
|
||||
new->the_bfd = abfd;
|
||||
if (new)
|
||||
new->the_bfd = abfd;
|
||||
return new;
|
||||
}
|
||||
|
||||
@ -139,6 +140,11 @@ osf_core_core_file_p (abfd)
|
||||
for shared libraries), but bfd doesn't permit data sections with
|
||||
the same name. Construct a unique section name. */
|
||||
secname = bfd_alloc (abfd, 40);
|
||||
if (!secname)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
sprintf (secname, ".data%d", dseccnt++);
|
||||
break;
|
||||
case SCNSTACK:
|
||||
@ -202,7 +208,7 @@ osf_core_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
#define osf_core_close_and_cleanup bfd_generic_close_and_cleanup
|
||||
#define osf_core_set_section_contents (boolean (*) PARAMS \
|
||||
((bfd *abfd, asection *section, PTR data, file_ptr offset, \
|
||||
bfd_size_type count))) bfd_false
|
||||
bfd_size_type count))) bfd_generic_set_section_contents
|
||||
#define osf_core_get_section_contents bfd_generic_get_section_contents
|
||||
#define osf_core_new_section_hook (boolean (*) PARAMS \
|
||||
((bfd *, sec_ptr))) bfd_true
|
||||
@ -253,9 +259,10 @@ swap_abort()
|
||||
{
|
||||
abort(); /* This way doesn't require any declaration for ANSI to fuck up */
|
||||
}
|
||||
#define NO_GET ((bfd_vma (*) PARAMS (( bfd_byte *))) swap_abort )
|
||||
#define NO_GET ((bfd_vma (*) PARAMS (( const bfd_byte *))) swap_abort )
|
||||
#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort )
|
||||
#define NO_SIGNED_GET ((bfd_signed_vma (*) PARAMS ((bfd_byte *))) swap_abort )
|
||||
#define NO_SIGNED_GET \
|
||||
((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort )
|
||||
|
||||
bfd_target osf_core_vec =
|
||||
{
|
||||
|
374
bfd/rs6000-core.c
Normal file
374
bfd/rs6000-core.c
Normal file
@ -0,0 +1,374 @@
|
||||
/* IBM RS/6000 "XCOFF" back-end for BFD.
|
||||
Copyright (C) 1990, 1991 Free Software Foundation, Inc.
|
||||
FIXME: Can someone provide a transliteration of this name into ASCII?
|
||||
Using the following chars caused a compiler warning on HIUX (so I replaced
|
||||
them with octal escapes), and isn't useful without an understanding of what
|
||||
character set it is.
|
||||
Written by Metin G. Ozisik, Mimi Ph\373\364ng-Th\345o V\365,
|
||||
and John Gilmore.
|
||||
Archive support from Damon A. Permezel.
|
||||
Contributed by IBM Corporation and Cygnus Support.
|
||||
|
||||
This file is part of BFD, the Binary File Descriptor library.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* This port currently only handles reading object files, except when
|
||||
compiled on an RS/6000 host. -- no archive support, no core files.
|
||||
In all cases, it does not support writing.
|
||||
|
||||
FIXMEmgo comments are left from Metin Ozisik's original port.
|
||||
|
||||
This is in a separate file from coff-rs6000.c, because it includes
|
||||
system include files that conflict with coff/rs6000.h.
|
||||
*/
|
||||
|
||||
/* Internalcoff.h and coffcode.h modify themselves based on this flag. */
|
||||
#define RS6000COFF_C 1
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
#include "libbfd.h"
|
||||
|
||||
#ifdef COREFILES_PLEASE
|
||||
|
||||
/* AOUTHDR is defined by the above. We need another defn of it, from the
|
||||
system include files. Punt the old one and get us a new name for the
|
||||
typedef in the system include files. */
|
||||
#ifdef AOUTHDR
|
||||
#undef AOUTHDR
|
||||
#endif
|
||||
#define AOUTHDR second_AOUTHDR
|
||||
|
||||
#undef SCNHDR
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
/* Support for core file stuff.. */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#include <sys/user.h>
|
||||
#include <sys/ldr.h>
|
||||
#include <sys/core.h>
|
||||
|
||||
|
||||
/* Number of special purpose registers supported by gdb. This value
|
||||
should match `tm.h' in gdb directory. Clean this mess up and use
|
||||
the macros in sys/reg.h. FIXMEmgo. */
|
||||
|
||||
#define NUM_OF_SPEC_REGS 7
|
||||
#define STACK_END_ADDR 0x2ff80000
|
||||
|
||||
#define core_hdr(bfd) (((Rs6kCorData*)(bfd->tdata.any))->hdr)
|
||||
#define core_datasec(bfd) (((Rs6kCorData*)(bfd->tdata.any))->data_section)
|
||||
#define core_stacksec(bfd) (((Rs6kCorData*)(bfd->tdata.any))->stack_section)
|
||||
#define core_regsec(bfd) (((Rs6kCorData*)(bfd->tdata.any))->reg_section)
|
||||
#define core_reg2sec(bfd) (((Rs6kCorData*)(bfd->tdata.any))->reg2_section)
|
||||
|
||||
/* These are stored in the bfd's tdata */
|
||||
typedef struct {
|
||||
struct core *hdr; /* core file header */
|
||||
asection *data_section,
|
||||
*stack_section,
|
||||
*reg_section, /* section for GPRs and special registers. */
|
||||
*reg2_section; /* section for FPRs. */
|
||||
|
||||
/* This tells us where everything is mapped (shared libraries and so on).
|
||||
GDB needs it. */
|
||||
asection *ldinfo_section;
|
||||
#define core_ldinfosec(bfd) (((Rs6kCorData *)(bfd->tdata.any))->ldinfo_section)
|
||||
} Rs6kCorData;
|
||||
|
||||
|
||||
/* Decide if a given bfd represents a `core' file or not. There really is no
|
||||
magic number or anything like, in rs6000coff. */
|
||||
|
||||
bfd_target *
|
||||
rs6000coff_core_p (abfd)
|
||||
bfd *abfd;
|
||||
{
|
||||
int fd;
|
||||
struct core_dump coredata;
|
||||
struct stat statbuf;
|
||||
char *tmpptr;
|
||||
|
||||
/* Use bfd_xxx routines, rather than O/S primitives to read coredata. FIXMEmgo */
|
||||
fd = open (abfd->filename, O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
bfd_error = system_call_error;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fstat (fd, &statbuf) < 0)
|
||||
{
|
||||
bfd_error = system_call_error;
|
||||
close (fd);
|
||||
return NULL;
|
||||
}
|
||||
if (read (fd, &coredata, sizeof (struct core_dump))
|
||||
!= sizeof (struct core_dump))
|
||||
{
|
||||
bfd_error = wrong_format;
|
||||
close (fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (close (fd) < 0)
|
||||
{
|
||||
bfd_error = system_call_error;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* If the core file ulimit is too small, the system will first
|
||||
omit the data segment, then omit the stack, then decline to
|
||||
dump core altogether (as far as I know UBLOCK_VALID and LE_VALID
|
||||
are always set) (this is based on experimentation on AIX 3.2).
|
||||
Now, the thing is that GDB users will be surprised
|
||||
if segments just silently don't appear (well, maybe they would
|
||||
think to check "info files", I don't know), but we have no way of
|
||||
returning warnings (as opposed to errors).
|
||||
|
||||
For the data segment, we have no choice but to keep going if it's
|
||||
not there, since the default behavior is not to dump it (regardless
|
||||
of the ulimit, it's based on SA_FULLDUMP). But for the stack segment,
|
||||
if it's not there, we refuse to have anything to do with this core
|
||||
file. The usefulness of a core dump without a stack segment is pretty
|
||||
limited anyway. */
|
||||
|
||||
if (!(coredata.c_flag & UBLOCK_VALID)
|
||||
|| !(coredata.c_flag & LE_VALID))
|
||||
{
|
||||
bfd_error = wrong_format;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((coredata.c_flag & CORE_TRUNC)
|
||||
|| !(coredata.c_flag & USTACK_VALID))
|
||||
{
|
||||
bfd_error = file_truncated;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (((bfd_vma)coredata.c_stack + coredata.c_size
|
||||
+ ((coredata.c_flag & FULL_CORE) ? coredata.c_u.u_dsize : 0))
|
||||
!= statbuf.st_size)
|
||||
{
|
||||
/* If the size is wrong, it means we're misinterpreting something. */
|
||||
bfd_error = wrong_format;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Sanity check on the c_tab field. */
|
||||
if ((u_long) coredata.c_tab < sizeof coredata ||
|
||||
(u_long) coredata.c_tab >= statbuf.st_size ||
|
||||
(long) coredata.c_tab >= (long)coredata.c_stack)
|
||||
{
|
||||
bfd_error = wrong_format;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* maybe you should alloc space for the whole core chunk over here!! FIXMEmgo */
|
||||
tmpptr = (char*)bfd_zalloc (abfd, sizeof (Rs6kCorData));
|
||||
if (!tmpptr)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
set_tdata (abfd, tmpptr);
|
||||
|
||||
/* .stack section. */
|
||||
if ((core_stacksec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection)))
|
||||
== NULL) {
|
||||
bfd_error = no_memory;
|
||||
/* bfd_release (abfd, ???? ) */
|
||||
return NULL;
|
||||
}
|
||||
core_stacksec (abfd)->name = ".stack";
|
||||
core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD;
|
||||
core_stacksec (abfd)->_raw_size = coredata.c_size;
|
||||
core_stacksec (abfd)->vma = STACK_END_ADDR - coredata.c_size;
|
||||
core_stacksec (abfd)->filepos = (int)coredata.c_stack; /*???? */
|
||||
|
||||
/* .reg section for GPRs and special registers. */
|
||||
if ((core_regsec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection)))
|
||||
== NULL) {
|
||||
bfd_error = no_memory;
|
||||
/* bfd_release (abfd, ???? ) */
|
||||
return NULL;
|
||||
}
|
||||
core_regsec (abfd)->name = ".reg";
|
||||
core_regsec (abfd)->flags = SEC_ALLOC;
|
||||
core_regsec (abfd)->_raw_size = (32 + NUM_OF_SPEC_REGS) * 4;
|
||||
core_regsec (abfd)->vma = 0; /* not used?? */
|
||||
core_regsec (abfd)->filepos =
|
||||
(char*)&coredata.c_u.u_save - (char*)&coredata;
|
||||
|
||||
/* .reg2 section for FPRs (floating point registers). */
|
||||
if ((core_reg2sec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection)))
|
||||
== NULL) {
|
||||
bfd_error = no_memory;
|
||||
/* bfd_release (abfd, ???? ) */
|
||||
return NULL;
|
||||
}
|
||||
core_reg2sec (abfd)->name = ".reg2";
|
||||
core_reg2sec (abfd)->flags = SEC_ALLOC;
|
||||
core_reg2sec (abfd)->_raw_size = 8 * 32; /* 32 FPRs. */
|
||||
core_reg2sec (abfd)->vma = 0; /* not used?? */
|
||||
core_reg2sec (abfd)->filepos =
|
||||
(char*)&coredata.c_u.u_save.fpr[0] - (char*)&coredata;
|
||||
|
||||
if ((core_ldinfosec (abfd) = (asection*) bfd_zalloc (abfd, sizeof (asection)))
|
||||
== NULL) {
|
||||
bfd_error = no_memory;
|
||||
/* bfd_release (abfd, ???? ) */
|
||||
return NULL;
|
||||
}
|
||||
core_ldinfosec (abfd)->name = ".ldinfo";
|
||||
core_ldinfosec (abfd)->flags = SEC_ALLOC + SEC_LOAD;
|
||||
/* To actually find out how long this section is in this particular
|
||||
core dump would require going down the whole list of struct ld_info's.
|
||||
See if we can just fake it. */
|
||||
core_ldinfosec (abfd)->_raw_size = 0x7fffffff;
|
||||
/* Not relevant for ldinfo section. */
|
||||
core_ldinfosec (abfd)->vma = 0;
|
||||
core_ldinfosec (abfd)->filepos = coredata.c_tab;
|
||||
|
||||
/* set up section chain here. */
|
||||
abfd->section_count = 4;
|
||||
abfd->sections = core_stacksec (abfd);
|
||||
core_stacksec (abfd)->next = core_regsec(abfd);
|
||||
core_regsec (abfd)->next = core_reg2sec (abfd);
|
||||
core_reg2sec (abfd)->next = core_ldinfosec (abfd);
|
||||
core_ldinfosec (abfd)->next = NULL;
|
||||
|
||||
if (coredata.c_flag & FULL_CORE)
|
||||
{
|
||||
asection *sec = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
||||
if (sec == NULL)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
sec->name = ".data";
|
||||
sec->flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS;
|
||||
sec->_raw_size = coredata.c_u.u_dsize;
|
||||
sec->vma = CDATA_ADDR (coredata.c_u.u_dsize);
|
||||
sec->filepos = (int)coredata.c_stack + coredata.c_size;
|
||||
|
||||
sec->next = abfd->sections;
|
||||
abfd->sections = sec;
|
||||
++abfd->section_count;
|
||||
}
|
||||
|
||||
return abfd->xvec; /* this is garbage for now. */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* return `true' if given core is from the given executable.. */
|
||||
boolean
|
||||
rs6000coff_core_file_matches_executable_p (core_bfd, exec_bfd)
|
||||
bfd *core_bfd;
|
||||
bfd *exec_bfd;
|
||||
{
|
||||
FILE *fd;
|
||||
struct core_dump coredata;
|
||||
struct ld_info ldinfo;
|
||||
char pathname [1024];
|
||||
char *str1, *str2;
|
||||
|
||||
/* Use bfd_xxx routines, rather than O/S primitives, do error checking!!
|
||||
FIXMEmgo */
|
||||
/* Actually should be able to use bfd_get_section_contents now that
|
||||
we have a .ldinfo section. */
|
||||
fd = fopen (core_bfd->filename, FOPEN_RB);
|
||||
|
||||
fread (&coredata, sizeof (struct core_dump), 1, fd);
|
||||
fseek (fd, (long)coredata.c_tab, 0);
|
||||
fread (&ldinfo, (char*)&ldinfo.ldinfo_filename[0] - (char*)&ldinfo.ldinfo_next,
|
||||
1, fd);
|
||||
fscanf (fd, "%s", pathname);
|
||||
|
||||
str1 = strrchr (pathname, '/');
|
||||
str2 = strrchr (exec_bfd->filename, '/');
|
||||
|
||||
/* step over character '/' */
|
||||
str1 = str1 ? str1+1 : &pathname[0];
|
||||
str2 = str2 ? str2+1 : exec_bfd->filename;
|
||||
|
||||
fclose (fd);
|
||||
return strcmp (str1, str2) == 0;
|
||||
}
|
||||
|
||||
|
||||
boolean
|
||||
rs6000coff_get_section_contents (abfd, section, location, offset, count)
|
||||
bfd *abfd;
|
||||
sec_ptr section;
|
||||
PTR location;
|
||||
file_ptr offset;
|
||||
int count;
|
||||
{
|
||||
if (count == 0)
|
||||
return true;
|
||||
|
||||
/* Reading a core file's sections will be slightly different. For the
|
||||
rest of them we can use bfd_generic_get_section_contents () I suppose. */
|
||||
/* Make sure this routine works for any bfd and any section. FIXMEmgo. */
|
||||
|
||||
if (abfd->format == bfd_core && strcmp (section->name, ".reg") == 0) {
|
||||
|
||||
struct mstsave mstatus;
|
||||
int regoffset = (char*)&mstatus.gpr[0] - (char*)&mstatus;
|
||||
|
||||
/* Assert that the only way this code will be executed is reading the
|
||||
whole section. */
|
||||
if (offset || count != (sizeof(mstatus.gpr) + (4 * NUM_OF_SPEC_REGS)))
|
||||
fprintf (stderr, "ERROR! in rs6000coff_get_section_contents()\n");
|
||||
|
||||
/* for `.reg' section, `filepos' is a pointer to the `mstsave' structure
|
||||
in the core file. */
|
||||
|
||||
/* read GPR's into the location. */
|
||||
if ( bfd_seek(abfd, section->filepos + regoffset, SEEK_SET) == -1
|
||||
|| bfd_read(location, sizeof (mstatus.gpr), 1, abfd) != sizeof (mstatus.gpr))
|
||||
return (false); /* on error */
|
||||
|
||||
/* increment location to the beginning of special registers in the section,
|
||||
reset register offset value to the beginning of first special register
|
||||
in mstsave structure, and read special registers. */
|
||||
|
||||
location = (PTR) ((char*)location + sizeof (mstatus.gpr));
|
||||
regoffset = (char*)&mstatus.iar - (char*)&mstatus;
|
||||
|
||||
if ( bfd_seek(abfd, section->filepos + regoffset, SEEK_SET) == -1
|
||||
|| bfd_read(location, 4 * NUM_OF_SPEC_REGS, 1, abfd) !=
|
||||
4 * NUM_OF_SPEC_REGS)
|
||||
return (false); /* on error */
|
||||
|
||||
/* increment location address, and read the special registers.. */
|
||||
/* FIXMEmgo */
|
||||
return (true);
|
||||
}
|
||||
|
||||
/* else, use default bfd section content transfer. */
|
||||
else
|
||||
return bfd_generic_get_section_contents
|
||||
(abfd, section, location, offset, count);
|
||||
}
|
||||
|
||||
#endif /* COREFILES_PLEASE */
|
@ -553,6 +553,8 @@ bfd_make_section_anyway (abfd, name)
|
||||
useful for things like relocs which are relative to the base of a
|
||||
section. */
|
||||
newsect->symbol = bfd_make_empty_symbol(abfd);
|
||||
if (!newsect)
|
||||
return NULL;
|
||||
newsect->symbol->name = name;
|
||||
newsect->symbol->value = 0;
|
||||
newsect->symbol->section = newsect;
|
||||
@ -637,6 +639,7 @@ DESCRIPTION
|
||||
|
||||
*/
|
||||
|
||||
/*ARGSUSED*/
|
||||
boolean
|
||||
DEFUN(bfd_set_section_flags,(abfd, section, flags),
|
||||
bfd *abfd AND
|
||||
|
64
bfd/som.c
64
bfd/som.c
@ -1021,16 +1021,16 @@ som_reloc_queue_find (p, size, queue)
|
||||
unsigned int size;
|
||||
struct reloc_queue *queue;
|
||||
{
|
||||
if (!bcmp (p, queue[0].reloc, size)
|
||||
if (queue[0].reloc && !bcmp (p, queue[0].reloc, size)
|
||||
&& size == queue[0].size)
|
||||
return 0;
|
||||
if (!bcmp (p, queue[1].reloc, size)
|
||||
if (queue[1].reloc && !bcmp (p, queue[1].reloc, size)
|
||||
&& size == queue[1].size)
|
||||
return 1;
|
||||
if (!bcmp (p, queue[2].reloc, size)
|
||||
if (queue[2].reloc && !bcmp (p, queue[2].reloc, size)
|
||||
&& size == queue[2].size)
|
||||
return 2;
|
||||
if (!bcmp (p, queue[3].reloc, size)
|
||||
if (queue[3].reloc && !bcmp (p, queue[3].reloc, size)
|
||||
&& size == queue[3].size)
|
||||
return 3;
|
||||
return -1;
|
||||
@ -1347,6 +1347,11 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field)
|
||||
|
||||
final_types = (int **) bfd_alloc_by_size_t (abfd, sizeof (int *) * 3);
|
||||
final_type = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
|
||||
if (!final_types || !final_type)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* The field selector may require additional relocations to be
|
||||
generated. It's impossible to know at this moment if additional
|
||||
@ -1369,6 +1374,11 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field)
|
||||
case e_ltsel:
|
||||
case e_rtsel:
|
||||
final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
|
||||
if (!final_types[0])
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
if (field == e_tsel)
|
||||
*final_types[0] = R_FSEL;
|
||||
else if (field == e_ltsel)
|
||||
@ -1383,6 +1393,11 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field)
|
||||
case e_lssel:
|
||||
case e_rssel:
|
||||
final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
|
||||
if (!final_types[0])
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
*final_types[0] = R_S_MODE;
|
||||
final_types[1] = final_type;
|
||||
final_types[2] = NULL;
|
||||
@ -1392,6 +1407,11 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field)
|
||||
case e_lsel:
|
||||
case e_rsel:
|
||||
final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
|
||||
if (!final_types[0])
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
*final_types[0] = R_N_MODE;
|
||||
final_types[1] = final_type;
|
||||
final_types[2] = NULL;
|
||||
@ -1401,6 +1421,11 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field)
|
||||
case e_ldsel:
|
||||
case e_rdsel:
|
||||
final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
|
||||
if (!final_types[0])
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
*final_types[0] = R_D_MODE;
|
||||
final_types[1] = final_type;
|
||||
final_types[2] = NULL;
|
||||
@ -1410,6 +1435,11 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field)
|
||||
case e_lrsel:
|
||||
case e_rrsel:
|
||||
final_types[0] = (int *) bfd_alloc_by_size_t (abfd, sizeof (int));
|
||||
if (!final_types[0])
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
*final_types[0] = R_R_MODE;
|
||||
final_types[1] = final_type;
|
||||
final_types[2] = NULL;
|
||||
@ -1541,6 +1571,11 @@ make_unique_section (abfd, name, num)
|
||||
}
|
||||
|
||||
newname = bfd_alloc (abfd, strlen (sect->name) + 1);
|
||||
if (!newname)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return NULL;
|
||||
}
|
||||
strcpy (newname, sect->name);
|
||||
|
||||
sect->name = newname;
|
||||
@ -3879,8 +3914,13 @@ som_new_section_hook (abfd, newsect)
|
||||
bfd *abfd;
|
||||
asection *newsect;
|
||||
{
|
||||
newsect->used_by_bfd
|
||||
= (PTR) bfd_zalloc (abfd, sizeof (struct som_section_data_struct));
|
||||
newsect->used_by_bfd =
|
||||
(PTR) bfd_zalloc (abfd, sizeof (struct som_section_data_struct));
|
||||
if (!newsect->used_by_bfd)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
newsect->alignment_power = 3;
|
||||
|
||||
/* Initialize the subspace_index field to -1 so that it does
|
||||
@ -3976,7 +4016,12 @@ bfd_som_attach_aux_hdr (abfd, type, string)
|
||||
pad = (4 - (len % 4));
|
||||
obj_som_version_hdr (abfd) = (struct user_string_aux_hdr *)
|
||||
bfd_zalloc (abfd, sizeof (struct aux_id)
|
||||
+ sizeof (unsigned int) + len + pad);
|
||||
+ sizeof (unsigned int) + len + pad);
|
||||
if (!obj_som_version_hdr (abfd))
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
obj_som_version_hdr (abfd)->header_id.type = VERSION_AUX_ID;
|
||||
obj_som_version_hdr (abfd)->header_id.length = len + pad;
|
||||
obj_som_version_hdr (abfd)->header_id.length += sizeof (int);
|
||||
@ -3993,6 +4038,11 @@ bfd_som_attach_aux_hdr (abfd, type, string)
|
||||
obj_som_copyright_hdr (abfd) = (struct copyright_aux_hdr *)
|
||||
bfd_zalloc (abfd, sizeof (struct aux_id)
|
||||
+ sizeof (unsigned int) + len + pad);
|
||||
if (!obj_som_copyright_hdr (abfd))
|
||||
{
|
||||
bfd_error = no_error;
|
||||
abort(); /* FIXME */
|
||||
}
|
||||
obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID;
|
||||
obj_som_copyright_hdr (abfd)->header_id.length = len + pad;
|
||||
obj_som_copyright_hdr (abfd)->header_id.length += sizeof (int);
|
||||
|
1114
bfd/srec.c
1114
bfd/srec.c
File diff suppressed because it is too large
Load Diff
17
bfd/sunos.c
17
bfd/sunos.c
@ -85,6 +85,11 @@ sunos_read_dynamic_info (abfd)
|
||||
|
||||
info = ((struct sunos_dynamic_info *)
|
||||
bfd_zalloc (abfd, sizeof (struct sunos_dynamic_info)));
|
||||
if (!info)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return false;
|
||||
}
|
||||
info->valid = false;
|
||||
info->dynsym = NULL;
|
||||
info->dynstr = NULL;
|
||||
@ -203,6 +208,11 @@ MY(read_dynamic_symbols) (abfd, syms, strs, strsize)
|
||||
(info->dynsym_count
|
||||
* EXTERNAL_NLIST_SIZE)));
|
||||
info->dynstr = (char *) bfd_alloc (abfd, info->dyninfo.ld_symb_size);
|
||||
if (!info->dynsym || !info->dynstr)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return 0;
|
||||
}
|
||||
if (bfd_seek (abfd, info->dyninfo.ld_stab, SEEK_SET) != 0
|
||||
|| (bfd_read ((PTR) info->dynsym, info->dynsym_count,
|
||||
EXTERNAL_NLIST_SIZE, abfd)
|
||||
@ -277,11 +287,16 @@ MY(read_dynamic_relocs) (abfd, relocs)
|
||||
if (! info->valid || info->dynrel_count == 0)
|
||||
return 0;
|
||||
|
||||
if (info->dynrel == (struct external_nlist *) NULL)
|
||||
if (info->dynrel == NULL)
|
||||
{
|
||||
info->dynrel = (PTR) bfd_alloc (abfd,
|
||||
(info->dynrel_count
|
||||
* obj_reloc_entry_size (abfd)));
|
||||
if (!info->dynrel)
|
||||
{
|
||||
bfd_error = no_memory;
|
||||
return (bfd_size_type) -1;
|
||||
}
|
||||
if (bfd_seek (abfd, info->dyninfo.ld_rel, SEEK_SET) != 0
|
||||
|| (bfd_read ((PTR) info->dynrel, info->dynrel_count,
|
||||
obj_reloc_entry_size (abfd), abfd)
|
||||
|
1029
bfd/tekhex.c
1029
bfd/tekhex.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user