binutils-gdb/bfd/nlm32-sparc.c

447 lines
13 KiB
C
Raw Normal View History

* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
/* Support for 32-bit SPARC NLM (NetWare Loadable Module)
Copyright (C) 1993 Free Software Foundation, Inc.
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. */
#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#define ARCH_SIZE 32
#include "nlm/sparc32-ext.h"
#define Nlm_External_Fixed_Header Nlm32_sparc_External_Fixed_Header
#include "libnlm.h"
static boolean nlm_sparc_read_reloc
PARAMS ((bfd *, nlmNAME(symbol_type) *, asection **, arelent *));
static boolean nlm_sparc_write_reloc
PARAMS ((bfd *, asection *, arelent *));
static boolean nlm_sparc_mangle_relocs
PARAMS ((bfd *, asection *, PTR, bfd_vma, bfd_size_type));
static boolean nlm_sparc_read_import
PARAMS ((bfd *, nlmNAME(symbol_type) *));
static boolean nlm_sparc_write_import
PARAMS ((bfd *, asection *, arelent *));
static boolean nlm_sparc_write_external
PARAMS ((bfd *, bfd_size_type, asymbol *, struct reloc_and_sec *));
enum reloc_type
{
R_SPARC_NONE = 0,
R_SPARC_8, R_SPARC_16, R_SPARC_32,
R_SPARC_DISP8, R_SPARC_DISP16, R_SPARC_DISP32,
R_SPARC_WDISP30, R_SPARC_WDISP22,
R_SPARC_HI22, R_SPARC_22,
R_SPARC_13, R_SPARC_LO10,
R_SPARC_GOT10, R_SPARC_GOT13, R_SPARC_GOT22,
R_SPARC_PC10, R_SPARC_PC22,
R_SPARC_WPLT30,
R_SPARC_COPY,
R_SPARC_GLOB_DAT, R_SPARC_JMP_SLOT,
R_SPARC_RELATIVE,
R_SPARC_UA32,
R_SPARC_max
};
#if 0
static CONST char *CONST reloc_type_names[] =
{
"R_SPARC_NONE",
"R_SPARC_8", "R_SPARC_16", "R_SPARC_32",
"R_SPARC_DISP8", "R_SPARC_DISP16", "R_SPARC_DISP32",
"R_SPARC_WDISP30", "R_SPARC_WDISP22",
"R_SPARC_HI22", "R_SPARC_22",
"R_SPARC_13", "R_SPARC_LO10",
"R_SPARC_GOT10", "R_SPARC_GOT13", "R_SPARC_GOT22",
"R_SPARC_PC10", "R_SPARC_PC22",
"R_SPARC_WPLT30",
"R_SPARC_COPY",
"R_SPARC_GLOB_DAT", "R_SPARC_JMP_SLOT",
"R_SPARC_RELATIVE",
"R_SPARC_UA32",
};
#endif
static reloc_howto_type nlm32_sparc_howto_table[] =
{
HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, 0,"R_SPARC_NONE", false,0,0x00000000,true),
HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,0,"R_SPARC_8", false,0,0x000000ff,true),
HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,0,"R_SPARC_16", false,0,0x0000ffff,true),
HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,0,"R_SPARC_32", false,0,0xffffffff,true),
HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, 0,"R_SPARC_DISP8", false,0,0x000000ff,true),
HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, 0,"R_SPARC_DISP16", false,0,0x0000ffff,true),
HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, 0,"R_SPARC_DISP32", false,0,0x00ffffff,true),
HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, 0,"R_SPARC_WDISP30", false,0,0x3fffffff,true),
HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, 0,"R_SPARC_WDISP22", false,0,0x003fffff,true),
HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, 0,"R_SPARC_HI22", false,0,0x003fffff,true),
HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,0,"R_SPARC_22", false,0,0x003fffff,true),
HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,0,"R_SPARC_13", false,0,0x00001fff,true),
HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, 0,"R_SPARC_LO10", false,0,0x000003ff,true),
HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_bitfield,0,"R_SPARC_GOT10", false,0,0x000003ff,true),
HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_bitfield,0,"R_SPARC_GOT13", false,0,0x00001fff,true),
HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_bitfield,0,"R_SPARC_GOT22", false,0,0x003fffff,true),
HOWTO(R_SPARC_PC10, 0,2,10,false,0,complain_overflow_bitfield,0,"R_SPARC_PC10", false,0,0x000003ff,true),
HOWTO(R_SPARC_PC22, 0,2,22,false,0,complain_overflow_bitfield,0,"R_SPARC_PC22", false,0,0x003fffff,true),
HOWTO(R_SPARC_WPLT30, 0,0,00,false,0,complain_overflow_dont, 0,"R_SPARC_WPLT30", false,0,0x00000000,true),
HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, 0,"R_SPARC_COPY", false,0,0x00000000,true),
HOWTO(R_SPARC_GLOB_DAT,0,0,00,false,0,complain_overflow_dont, 0,"R_SPARC_GLOB_DAT",false,0,0x00000000,true),
HOWTO(R_SPARC_JMP_SLOT,0,0,00,false,0,complain_overflow_dont, 0,"R_SPARC_JMP_SLOT",false,0,0x00000000,true),
HOWTO(R_SPARC_RELATIVE,0,0,00,false,0,complain_overflow_dont, 0,"R_SPARC_RELATIVE",false,0,0x00000000,true),
HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, 0,"R_SPARC_UA32", false,0,0x00000000,true),
};
/* Read a NetWare sparc reloc. */
struct nlm32_sparc_reloc_ext {
unsigned char offset[4];
unsigned char addend[4];
unsigned char type[1];
unsigned char pad1[3];
};
static boolean
nlm_sparc_read_reloc (abfd, sym, secp, rel)
bfd *abfd;
nlmNAME(symbol_type) *sym;
asection **secp;
arelent *rel;
{
bfd_vma val, addend;
int index;
unsigned int type;
struct nlm32_sparc_reloc_ext tmp_reloc;
asection *code_sec, *data_sec;
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
if (bfd_read (&tmp_reloc, 12, 1, abfd) != 12)
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
return false;
code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
data_sec = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
*secp = code_sec;
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
val = bfd_get_32 (abfd, tmp_reloc.offset);
addend = bfd_get_32 (abfd, tmp_reloc.addend);
type = bfd_get_8 (abfd, tmp_reloc.type);
rel->address = val;
rel->addend = addend;
rel->howto = NULL;
for (index = 0;
index < sizeof(nlm32_sparc_howto_table) / sizeof(reloc_howto_type);
index++)
if (nlm32_sparc_howto_table[index].type == type) {
rel->howto = &nlm32_sparc_howto_table[index];
break;
}
#ifdef DEBUG
fprintf (stderr, "%s: address = %08lx, addend = %08lx, type = %d, howto = %08lx\n",
__FUNCTION__, rel->address, rel->addend, type, rel->howto);
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
#endif
return true;
}
/* Write a NetWare sparc reloc. */
static boolean
nlm_sparc_write_reloc (abfd, sec, rel)
bfd *abfd;
asection *sec;
arelent *rel;
{
bfd_vma val;
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.
1994-02-12 08:45:54 +08:00
struct nlm32_sparc_reloc_ext tmp_reloc;
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
int index;
int type = -1;
reloc_howto_type *tmp;
for (index = 0;
index < sizeof (nlm32_sparc_howto_table) / sizeof(reloc_howto_type);
index++) {
tmp = &nlm32_sparc_howto_table[index];
if (tmp->rightshift == rel->howto->rightshift
&& tmp->size == rel->howto->size
&& tmp->bitsize == rel->howto->bitsize
&& tmp->pc_relative == rel->howto->pc_relative
&& tmp->bitpos == rel->howto->bitpos
&& tmp->src_mask == rel->howto->src_mask
&& tmp->dst_mask == rel->howto->dst_mask) {
type = tmp->type;
break;
}
}
if (type == -1)
abort();
/*
* Netware wants a list of relocs for each address.
* Format is:
* long offset
* long addend
* char type
* That should be it.
*/
/* The value we write out is the offset into the appropriate
segment. This offset is the section vma, adjusted by the vma of
the lowest section in that segment, plus the address of the
relocation. */
#if 0
val = bfd_get_section_vma (abfd, (*rel->sym_ptr_ptr)->section) + rel->address;
#else
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
val = bfd_get_section_vma (abfd, sec) + rel->address;
#endif
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
#ifdef DEBUG
fprintf (stderr, "%s: val = %08lx, addend = %08lx, type = %d\n",
__FUNCTION__, val, rel->addend, rel->howto->type);
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
#endif
bfd_put_32 (abfd, val, tmp_reloc.offset);
bfd_put_32 (abfd, rel->addend, tmp_reloc.addend);
bfd_put_8 (abfd, (short)(rel->howto->type), tmp_reloc.type);
if (bfd_write (&tmp_reloc, 12, 1, abfd) != 12)
{
abort();
}
return true;
}
/* Mangle relocs for SPARC NetWare. We can just use the standard
SPARC relocs. */
static boolean
nlm_sparc_mangle_relocs (abfd, sec, data, offset, count)
bfd *abfd;
asection *sec;
PTR data;
bfd_vma offset;
bfd_size_type count;
{
return true;
}
/* Read a NetWare sparc import record */
static boolean
nlm_sparc_read_import (abfd, sym)
bfd *abfd;
nlmNAME(symbol_type) *sym;
{
struct nlm_relent *nlm_relocs; /* relocation records for symbol */
bfd_size_type rcount; /* number of relocs */
bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* temporary 32-bit value */
unsigned char symlength; /* length of symbol name */
char *name;
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
/*
* First, read in the number of relocation
* entries for this symbol
*/
if (bfd_read ((PTR) temp, 4, 1, abfd) != 4)
return false;
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
rcount = bfd_get_32 (abfd, temp);
/*
* Next, read in the length of the symbol
*/
if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
!= sizeof (symlength))
return false;
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
sym -> symbol.the_bfd = abfd;
name = bfd_alloc (abfd, symlength + 1);
if (name == NULL)
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.
1994-02-12 08:45:54 +08:00
{
bfd_set_error (bfd_error_no_memory);
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.
1994-02-12 08:45:54 +08:00
return false;
}
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
/*
* Then read in the symbol
*/
if (bfd_read (name, symlength, 1, abfd) != symlength)
return false;
name[symlength] = '\0';
sym -> symbol.name = name;
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
sym -> symbol.flags = 0;
sym -> symbol.value = 0;
sym -> symbol.section = &bfd_und_section;
/*
* Next, start reading in the relocs.
*/
nlm_relocs = ((struct nlm_relent *)
bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
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.
1994-02-12 08:45:54 +08:00
if (!nlm_relocs)
{
bfd_set_error (bfd_error_no_memory);
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.
1994-02-12 08:45:54 +08:00
return false;
}
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
sym -> relocs = nlm_relocs;
sym -> rcnt = 0;
while (sym -> rcnt < rcount)
{
asection *section;
if (nlm_sparc_read_reloc (abfd, sym, &section,
&nlm_relocs -> reloc)
== false)
return false;
nlm_relocs -> section = section;
nlm_relocs++;
sym -> rcnt++;
}
return true;
}
static boolean
nlm_sparc_write_import (abfd, sec, rel)
bfd *abfd;
asection *sec;
arelent *rel;
{
char temp[4];
asection *code, *data, *bss, *symsec;
bfd_vma base;
code = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
data = bfd_get_section_by_name (abfd, NLM_INITIALIZED_DATA_NAME);
bss = bfd_get_section_by_name (abfd, NLM_UNINITIALIZED_DATA_NAME);
symsec = (*rel->sym_ptr_ptr)->section;
if (symsec == code) {
base = 0;
} else if (symsec == data) {
base = bfd_section_size (abfd, code);
} else if (symsec == bss) {
base = bfd_section_size (abfd, code) + bfd_section_size (abfd, data);
} else
base = 0;
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
#ifdef DEBUG
fprintf (stderr, "%s: <%x, 1>\n\t",
__FUNCTION__, base + (*rel->sym_ptr_ptr)->value);
#endif
bfd_put_32 (abfd, base + (*rel->sym_ptr_ptr)->value, temp);
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
bfd_write ((PTR)temp, 4, 1, abfd);
bfd_put_32 (abfd, 1, temp);
bfd_write ((PTR)temp, 4, 1, abfd);
if (nlm_sparc_write_reloc (abfd, sec, rel) == false)
return false;
return true;
}
/* Write out an external reference. */
static boolean
nlm_sparc_write_external (abfd, count, sym, relocs)
bfd *abfd;
bfd_size_type count;
asymbol *sym;
struct reloc_and_sec *relocs;
{
int i;
bfd_byte len;
unsigned char temp[NLM_TARGET_LONG_SIZE];
bfd_put_32 (abfd, count, temp);
if (bfd_write (temp, sizeof(temp), 1, abfd) != sizeof (temp))
return false;
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
len = strlen (sym->name);
if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
|| bfd_write (sym->name, len, 1, abfd) != len)
return false;
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
for (i = 0; i < count; i++)
{
if (nlm_sparc_write_reloc (abfd, relocs[i].sec,
relocs[i].rel) == false)
return false;
}
return true;
}
static boolean
nlm_sparc_write_export (abfd, sym, value)
bfd *abfd;
asymbol *sym;
bfd_vma value;
{
bfd_byte len;
bfd_byte temp[4];
#ifdef DEBUG
fprintf (stderr, "%s: <%x, %d, %s>\n",
__FUNCTION__, value, strlen (sym->name), sym->name);
#endif
bfd_put_32 (abfd, value, temp);
len = strlen (sym->name);
if (bfd_write (temp, 4, 1, abfd) != 4
|| bfd_write (&len, 1, 1, abfd) != 1
|| bfd_write (sym->name, len, 1, abfd) != len)
return false;
return true;
}
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
#undef nlm_swap_fixed_header_in
#undef nlm_swap_fixed_header_out
#include "nlmswap.h"
static const struct nlm_backend_data nlm32_sparc_backend =
{
"NetWare SPARC Module \032",
sizeof (Nlm32_sparc_External_Fixed_Header),
0, /* optional_prefix_size */
bfd_arch_sparc,
0,
false,
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
0, /* backend_object_p */
0, /* write_prefix_func */
nlm_sparc_read_reloc,
nlm_sparc_mangle_relocs,
nlm_sparc_read_import,
nlm_sparc_write_import,
0, /* set_public_section */
0, /* get_public_offset */
nlm_swap_fixed_header_in,
nlm_swap_fixed_header_out,
nlm_sparc_write_external,
nlm_sparc_write_export
* libnlm.h (struct nlm_backend_data): New fields optional_prefix_size, nlm_backend_object_p, nlm_write_prefix, nlm_set_public_section, nlm_get_public_offset. Removed unused nlm_write_reloc field. Changed nlm_write_import to remove unnecessary symbol argument. Renamed nlm_write_externals to nlm_write_external, and changed cound argument from bfd_vma to bfd_size_type. (nlm_optional_prefix_size, nlm_backend_object_p_func, nlm_write_prefix_func, nlm_set_public_section_func, nlm_get_public_offset_func): New accessor macros. (nlm_write_reloc_func): Removed. (nlm_write_external_func): Adjusted for field renaming. * nlm32-i386.c (nlm_i386_write_import): Renamed from nlm_i386_write_reloc. Removed old nlm_i386_write_import which just called old nlm_i386_write_reloc. (nlm_i386_write_external): Renamed from nlm_i386_write_externals. Declared. Changed second argument from bfd_vma to bfd_size_type. (nlm32_i386_backend): Adjusted for changes to fields and names. * nlm32-sparc.c (nlm_sparc_mangle_relocs): Removed unused, ifdeffed out code. (nlm_sparc_write_import): Removed second argument. (nlm_sparc_write_external): Renamed from nlm_sparc_write_externals. Changed second argument from bfd_vma to bfd_size_type. (nlm32_sparc_backend): Adjusted for changes to fields and names. * nlmcode.h: Removed some unused code. (nlm_object_p): Don't destroy tdata pointer. Call backend_object_p function if it exists. (nlm_slurp_symbol_table): Removed unused variable rcount. Call set_public_section_func if it exists instead of checking NLM_HIBIT. (nlm_compute_section_file_positions): Account for optional_prefix_size. (nlm_write_object_contents): Account for optional_prefix_size. Removed useless variable write_reloc_func. Changed declaration and call of write_import_func. Call write_prefix_func if it exists. Removed unused variables len and temp. Call get_public_offset_func if it exists rather than setting NLM_HIBIT.
1993-12-02 10:22:35 +08:00
};
#define TARGET_BIG_NAME "nlm32-sparc"
#define TARGET_BIG_SYM nlmNAME(sparc_vec)
#define TARGET_BACKEND_DATA &nlm32_sparc_backend
#include "nlm-target.h"