+2001-09-18 Alan Modra <amodra@bigpond.net.au>
+
+ * libbfd.c (bfd_bread): New function replacing bfd_read without
+ redundant params. Allow reads up to (size_t) -2 in length.
+ (bfd_bwrite): Similarly for bfd_write.
+ (real_read): Return a size_t.
+ (bfd_read): Call bfd_bread.
+ (bfd_write): Call bfd_bwrite.
+ (warn_deprecated): New function to annoy everybody.
+ (bfd_get_file_window): Don't call bfd_set_error unnecessarily.
+ * bfd-in.h (bfd_bread, bfd_bwrite, warn_deprecated): Declare.
+ (bfd_read, bfd_write): Define as macro.
+ * aix386-core.c: Replace calls to bfd_read with bfd_bread, and
+ likewise for bfd_write. Ensure function args are correct size by
+ using casts or local vars. In some cases, remove unnecessary
+ casts. Formatting fixes, in some cases removing a large expression
+ from function args by using a local var. Replace CONST with const.
+ Modify variable types to avoid warings. Use casts to avoid
+ warnings when using negative numbers in unsigned expressions.
+ * aout-adobe.c: Likewise.
+ * aout-arm.c: Likewise.
+ * aout-cris.c: Likewise.
+ * aout-encap.c: Likewise.
+ * aout-ns32k.c: Likewise.
+ * aout-target.h: Likewise.
+ * aout-tic30.c: Likewise.
+ * aoutf1.h: Likewise.
+ * aoutx.h: Likewise.
+ * archive.c: Likewise.
+ * archures.c: Likewise.
+ * bfd-in.h: Likewise.
+ * bfd.c: Likewise.
+ * binary.c: Likewise.
+ * bout.c: Likewise.
+ * cache.c: Likewise.
+ * cisco-core.c: Likewise.
+ * coff-a29k.c: Likewise.
+ * coff-alpha.c: Likewise.
+ * coff-arm.c: Likewise.
+ * coff-h8300.c: Likewise.
+ * coff-h8500.c: Likewise.
+ * coff-i386.c: Likewise.
+ * coff-i860.c: Likewise.
+ * coff-i960.c: Likewise.
+ * coff-ia64.c: Likewise.
+ * coff-m68k.c: Likewise.
+ * coff-m88k.c: Likewise.
+ * coff-mcore.c: Likewise.
+ * coff-mips.c: Likewise.
+ * coff-ppc.c: Likewise.
+ * coff-rs6000.c: Likewise.
+ * coff-sh.c: Likewise.
+ * coff-sparc.c: Likewise.
+ * coff-stgo32.c: Likewise.
+ * coff-tic30.c: Likewise.
+ * coff-tic54x.c: Likewise.
+ * coff-tic80.c: Likewise.
+ * coff-w65.c: Likewise.
+ * coff-z8k.c: Likewise.
+ * coff64-rs6000.c: Likewise.
+ * coffcode.h: Likewise.
+ * coffgen.c: Likewise.
+ * cofflink.c: Likewise.
+ * coffswap.h: Likewise.
+ * corefile.c: Likewise.
+ * cpu-arc.c: Likewise.
+ * cpu-h8300.c: Likewise.
+ * cpu-h8500.c: Likewise.
+ * cpu-i960.c: Likewise.
+ * cpu-ia64-opc.c: Likewise.
+ * cpu-ns32k.c: Likewise.
+ * cpu-pdp11.c: Likewise.
+ * cpu-pj.c: Likewise.
+ * cpu-sh.c: Likewise.
+ * cpu-w65.c: Likewise.
+ * cpu-z8k.c: Likewise.
+ * dwarf1.c: Likewise.
+ * dwarf2.c: Likewise.
+ * ecoff.c: Likewise.
+ * ecofflink.c: Likewise.
+ * ecoffswap.h: Likewise.
+ * elf-bfd.h: Likewise.
+ * elf-hppa.h: Likewise.
+ * elf-m10200.c: Likewise.
+ * elf-m10300.c: Likewise.
+ * elf.c: Likewise.
+ * elf32-arc.c: Likewise.
+ * elf32-arm.h: Likewise.
+ * elf32-avr.c: Likewise.
+ * elf32-cris.c: Likewise.
+ * elf32-fr30.c: Likewise.
+ * elf32-gen.c: Likewise.
+ * elf32-h8300.c: Likewise.
+ * elf32-hppa.c: Likewise.
+ * elf32-i370.c: Likewise.
+ * elf32-i386.c: Likewise.
+ * elf32-i860.c: Likewise.
+ * elf32-m32r.c: Likewise.
+ * elf32-m68k.c: Likewise.
+ * elf32-mcore.c: Likewise.
+ * elf32-mips.c: Likewise.
+ * elf32-openrisc.c: Likewise.
+ * elf32-pj.c: Likewise.
+ * elf32-ppc.c: Likewise.
+ * elf32-s390.c: Likewise.
+ * elf32-sh-lin.c: Likewise.
+ * elf32-sh.c: Likewise.
+ * elf32-sparc.c: Likewise.
+ * elf32-v850.c: Likewise.
+ * elf64-alpha.c: Likewise.
+ * elf64-hppa.c: Likewise.
+ * elf64-mips.c: Likewise.
+ * elf64-ppc.c: Likewise.
+ * elf64-s390.c: Likewise.
+ * elf64-sparc.c: Likewise.
+ * elf64-x86-64.c: Likewise.
+ * elfarm-nabi.c: Likewise.
+ * elfcode.h: Likewise.
+ * elfcore.h: Likewise.
+ * elflink.c: Likewise.
+ * elflink.h: Likewise.
+ * elfxx-ia64.c: Likewise.
+ * elfxx-target.h: Likewise.
+ * format.c: Likewise.
+ * hash.c: Likewise.
+ * hp300hpux.c: Likewise.
+ * hppabsd-core.c: Likewise.
+ * hpux-core.c: Likewise.
+ * i386aout.c: Likewise.
+ * i386dynix.c: Likewise.
+ * i386linux.c: Likewise.
+ * i386lynx.c: Likewise.
+ * i386mach3.c: Likewise.
+ * i386msdos.c: Likewise.
+ * i386os9k.c: Likewise.
+ * ieee.c: Likewise.
+ * ihex.c: Likewise.
+ * irix-core.c: Likewise.
+ * libaout.h: Likewise.
+ * libbfd-in.h: Likewise.
+ * libbfd.c: Likewise.
+ * libcoff-in.h: Likewise.
+ * libecoff.h: Likewise.
+ * libieee.h: Likewise.
+ * libnlm.h: Likewise.
+ * libpei.h: Likewise.
+ * libxcoff.h: Likewise.
+ * linker.c: Likewise.
+ * lynx-core.c: Likewise.
+ * m68klinux.c: Likewise.
+ * merge.c: Likewise.
+ * mipsbsd.c: Likewise.
+ * netbsd-core.c: Likewise.
+ * nlm.c: Likewise.
+ * nlm32-alpha.c: Likewise.
+ * nlm32-i386.c: Likewise.
+ * nlm32-ppc.c: Likewise.
+ * nlm32-sparc.c: Likewise.
+ * nlmcode.h: Likewise.
+ * nlmswap.h: Likewise.
+ * ns32k.h: Likewise.
+ * oasys.c: Likewise.
+ * opncls.c: Likewise.
+ * osf-core.c: Likewise.
+ * pc532-mach.c: Likewise.
+ * pdp11.c: Likewise.
+ * pe-mips.c: Likewise.
+ * peXXigen.c: Likewise.
+ * peicode.h: Likewise.
+ * ppcboot.c: Likewise.
+ * ptrace-core.c: Likewise.
+ * reloc.c: Likewise.
+ * reloc16.c: Likewise.
+ * riscix.c: Likewise.
+ * rs6000-core.c: Likewise.
+ * sco5-core.c: Likewise.
+ * section.c: Likewise.
+ * som.c: Likewise.
+ * sparclinux.c: Likewise.
+ * sparclynx.c: Likewise.
+ * srec.c: Likewise.
+ * stabs.c: Likewise.
+ * sunos.c: Likewise.
+ * syms.c: Likewise.
+ * targets.c: Likewise.
+ * tekhex.c: Likewise.
+ * trad-core.c: Likewise.
+ * versados.c: Likewise.
+ * vms-gsd.c: Likewise.
+ * vms-hdr.c: Likewise.
+ * vms-misc.c: Likewise.
+ * vms-tir.c: Likewise.
+ * vms.c: Likewise.
+ * vms.h: Likewise.
+ * xcofflink.c: Likewise.
+ * bfd-in2.h: Regenerate.
+ * libbfd.h: Regenerate.
+ * libcoff.h: Regenerate.
+
+ * bfd.c (struct _bfd): Make "where" and "origin" unsigned.
+ * bfd-in.h (file_ptr): Change from a long int to a bfd_signed_vma.
+ (ufile_ptr): Define.
+ (bfd_tell): Return a ufile_ptr.
+ * libbfd.c (bfd_tell): Likewise.
+ (bfd_seek): Use bfd_size_type locals. Don't call bfd_set_error
+ unnecessarily.
+ * aix386-core.c: Test != 0 for bfd_seek errors rather than < 0.
+ * aoutf1.h: Likewise.
+ * som.c: Likewise.
+ * cache.c (bfd_cache_lookup_worker): Guard against abfd->where
+ larger than unsigned long can represent.
+
+ * libbfd.c (bfd_malloc): Take a bfd_size_type arg. Error if
+ size overflows size_t.
+ (bfd_realloc): Likewise.
+ (bfd_zmalloc): Likewise.
+ * opncls.c (bfd_alloc): Likewise.
+ (bfd_zalloc): Likewise.
+ * libbfd-in.h (bfd_malloc, bfd_realloc, bfd_zmalloc): Update.
+ (bfd_alloc, bfd_zalloc): Update.
+
+ * libbfd.c (bfd_get_8): Mask with 0xff in case char is more than
+ 8 bits.
+ (bfd_get_signed_8): Likewise.
+ (H_PUT_64, H_PUT_32, H_PUT_16, H_PUT_8,
+ H_PUT_S64, H_PUT_S32, H_PUT_S16, H_PUT_S8,
+ H_GET_64, H_GET_32, H_GET_16, H_GET_8,
+ H_GET_S64, H_GET_S32, H_GET_S16, H_GET_S8): Define and use.
+ * libaout.h: Likewise define and use here.
+ * aout-adobe.c: Use H_GET_* and H_PUT_* macros.
+ * aout-arm.c: Likewise.
+ * aout-encap.c: Likewise.
+ * aout-ns32k.c: Likewise.
+ * aout-tic30.c: Likewise.
+ * aoutf1.h: Likewise.
+ * aoutx.h: Likewise.
+ * bout.c: Likewise.
+ * coff-alpha.c: Likewise.
+ * coff-h8300.c: Likewise.
+ * coff-h8500.c: Likewise.
+ * coff-i960.c: Likewise.
+ * coff-ia64.c: Likewise.
+ * coff-m88k.c: Likewise.
+ * coff-mips.c: Likewise.
+ * coff-ppc.c: Likewise.
+ * coff-rs6000.c: Likewise.
+ * coff-sh.c: Likewise.
+ * coff-sparc.c: Likewise.
+ * coff-stgo32.c: Likewise.
+ * coff-tic30.c: Likewise.
+ * coff-tic80.c: Likewise.
+ * coff-w65.c: Likewise.
+ * coff-z8k.c: Likewise.
+ * coff64-rs6000.c: Likewise.
+ * coffgen.c: Likewise.
+ * cofflink.c: Likewise.
+ * coffswap.h: Likewise.
+ * ecoff.c: Likewise.
+ * ecoffswap.h: Likewise.
+ * elf.c: Likewise.
+ * elf32-mips.c: Likewise.
+ * elf64-mips.c: Likewise.
+ * hp300hpux.c: Likewise.
+ * i386dynix.c: Likewise.
+ * i386lynx.c: Likewise.
+ * i386msdos.c: Likewise.
+ * i386os9k.c: Likewise.
+ * libpei.h: Likewise.
+ * nlm32-alpha.c: Likewise.
+ * nlm32-i386.c: Likewise.
+ * nlm32-ppc.c: Likewise.
+ * nlmcode.h: Likewise.
+ * nlmswap.h: Likewise.
+ * oasys.c: Likewise.
+ * pdp11.c: Likewise.
+ * pe-mips.c: Likewise.
+ * peXXigen.c: Likewise.
+ * peicode.h: Likewise.
+ * riscix.c: Likewise.
+ * sunos.c: Likewise.
+ * xcofflink.c: Likewise.
+ * elfcode.h: (put_word, get_word, put_signed_word, get_signed_word):
+ Rename to H_PUT_WORD, H_GET_WORD, H_PUT_SIGNED_WORD, H_GET_SIGNED_WORD.
+ * coff-rs6000.c (PUTWORD, PUTHALF, PUTBYTE): Don't define. Use
+ equivalent H_PUT_* macro instead.
+ (GETWORD, GETHALF, GETBYTE): Similarly.
+ * coff64-rs6000.c (PUTWORD, PUTHALF, PUTBYTE): Likewise.
+ (GETWORD, GETHALF, GETBYTE): Likewise.
+ * coffswap.h (PUTWORD, PUTHALF, PUTBYTE): Likewise.
+
+ * bfd-in.h (struct orl): Change "pos" to a union.
+ * archive.c (_bfd_compute_and_write_armap): Use it instead of casts.
+ (bsd_write_armap): Here too.
+ (coff_write_armap): And here.
+ * coff-rs6000.c (xcoff_write_armap_old): And here.
+ (xcoff_write_one_armap_big): And here.
+ (xcoff_write_armap_big): And here.
+ * ecoff.c (_bfd_ecoff_write_armap): And here.
+ * elf64-mips.c (mips_elf64_write_armap): And here.
+
+ * aoutf1.h (sunos_set_arch_mach): Make "mach" param an enum.
+ * elf-m10300.c (elf_mn10300_mach): Return an unsigned long.
+ * elf32-h8300.c (elf32_h8_mach): Likewise.
+ * elf32-mips.c (elf_mips_mach): Likewise.
+ * sparclynx.c (NAME(lynx,set_arch_mach)): Likewise.
+
+ * aix386-core.c (aix386_core_file_p): Remove redundant bfd_release
+ calls.
+ (aix386_core_vec): Typo fix.
+
+ * aout-arm.c: Include libaout.h and aout/aout64.h after N_TXTADDR
+ etc. to avoid redefined macro warning.
+ (MY(put_reloc)): Use bfd_vma for "value" rather than long.
+ (MY(fix_pcrel_26)): Likewise.
+ * aout-ns32k.c (MY(put_reloc)): Likewise.
+ * aout-cris.c (MY(swap_ext_reloc_out)): Likewise for r_addend.
+ * aoutx.h (NAME(aout,swap_ext_reloc_out)): Likewise.
+ * coff-arm.c (coff_arm_relocate_section): Likewise for my_offset.
+
+ * aout-encap.c: Include "file", not <file> for binutils headers.
+ (encap_object_p): Half baked attempt to fix compile errors in
+ code dealing with "magic".
+
+ * aout-ns32k.c: Include "file", not <file> for binutils headers.
+ (_bfd_ns32k_relocate_contents): get_data and put_data manipulate
+ bfd_vma's rather than longs.
+ * cpu-ns32k.c (ns32k_sign_extend): Delete.
+ (_bfd_ns32k_get_displacement): Return a bfd_vma, don't pass in offset.
+ (_bfd_ns32k_get_immediate): Likewise. Add code for 8 byte values,
+ remove case 3.
+ (_bfd_ns32k_put_displacement): Accept a bfd_vma, don't pass in offset.
+ Use unsigned comparisons.
+ (bfd_ns32k_put_immediate): Likewise, and add code for 8 byte values.
+ (do_ns32k_reloc): get_data and put_data operate on bfd_vma's.
+ (_bfd_do_ns32k_reloc_contents): Likewise.
+ * ns32k.h (_bfd_ns32k_get_displacement): Update prototype.
+ (_bfd_ns32k_get_immediate): Likewise.
+ (_bfd_ns32k_put_displacement): Likewise.
+ (_bfd_ns32k_put_immediate): Likewise.
+ (bfd_reloc_status_type): Likewise.
+
+ * aoutx.h (NAME(aout,find_nearest_line)): Rename 'p' to 'colon'
+ to avoid shadowing.
+ * pdp11.c (NAME(aout,find_nearest_line)): Likewise.
+ * coff-h8300.c (h8300_reloc16_extra_cases): Remove shadowing "value".
+ * coff-ppc.c (enum ref_category): Rename "data" to "tocdata" to
+ avoid shadowing.
+ (record_toc): Use a bfd_signed_vma for our_toc_offset.
+ * coffcode.h (coff_write_relocs): Rename "i" to avoid shadowing.
+ * elf.c (bfd_elf_get_bfd_needed_list): Rename "link" var to avoid
+ shadow warning.
+ (_bfd_elfcore_strndup): Likewise for "dup".
+ * elf32-cris.c (cris_elf_relocate_section): "symname" instead of
+ "name" to avoid shadowing.
+ * elf32-hppa.c (elf32_hppa_relocate_section): Remove duplicate
+ definition of "off".
+ * elf32-i386.c (elf_i386_relocate_section): Likewise.
+ * elf32-mips.c (_bfd_mips_elf_modify_segment_map): Remove duplicate
+ definition of "s".
+ (_bfd_mips_elf_final_link): Rename "i" to "j". Remove duplicate
+ "secpp".
+ * elf64-x86-64.c (elf64_x86_64_relocate_section): Rename inner "indx"
+ to avoid shadowing.
+ * elflink.h (elf_link_add_object_symbols): Rename "link" to "shlink"
+ to avoid shadowing.
+ (elf_link_input_bfd): Likewise.
+ (elf_bfd_final_link): Remove duplicate innermost "off" var.
+ * oasys.c (oasys_write_data): Rename innermost "p" to "sym".
+ * reloc16.c (bfd_coff_reloc16_relax_section): Rename "i" param to
+ "input_section".
+ * som.c (som_prep_for_fixups): Rename inner "i" to "j".
+ * sunos.c (sunos_add_dynamic_symbols): Localise "s" var.
+ (sunos_write_dynamic_symbol): Remove unused vars.
+ * syms.c (_bfd_stab_section_find_nearest_line): Remove duplicate
+ innermost "directory_name" and "file_name" vars.
+ * tekhex.c (first_phase): Rename local var "type" to "stype".
+ (tekhex_write_object_contents): Rename innermost "s" to "sym".
+ * vms-gsd.c (vms_secflag_by_name): Change "size" param to "hassize",
+ doing comparison at caller.
+ (vms_esecflag_by_name): Likewise.
+ * vms-tir.c (etir_sto): Rename innermost "psect" to "psect1".
+ * xcofflink.c (xcoff_link_input_bfd): Delete duplicate innermost "o".
+ (xcoff_write_global_symbol): Rename "p" param to "inf".
+
+ * cisco-core.c: Add missing prototypes.
+ (cisco_core_file_failing_command): Add ATTRIBUTE_UNUSED.
+ (cisco_core_file_failing_signal): Likewise.
+ (cisco_core_file_matches_executable_p): Likewise.
+ * hpux-core.c (hpux_core_core_file_failing_signal): Likewise.
+ * netbsd-core.c (netbsd_core_file_matches_executable_p): Likewise.
+ * osf-core.c (osf_core_core_file_matches_executable_p): Likewise.
+ * sco5-core.c (sco5_core_file_matches_executable_p): Likewise.
+
+ * coff-arm.c (coff_arm_link_hash_table): Use bfd_size_type for
+ thumb_glue_size and arm_glue_size.
+ * elf32-arm.h (elf32_arm_link_hash_table): Likewise here.
+
+ * coff64-rs6000.c: Group prototypes together.
+
+ * coffcode.h (coff_set_arch_mach): Add ATTRIBUTE_UNUSED.
+ (buy_and_read): Remove "seek" param. Change "size" to bfd_size_type.
+
+ * cpu-arc.c: Add missing prototypes.
+ * cpu-h8500.c: Likewise.
+ * cpu-i960.c: Likewise.
+ * cpu-pj.c: Likewise.
+ * cpu-sh.c: Likewise.
+ * cpu-w65.c: Likewise.
+ * cpu-z8k.c: Likewise.
+ * elf32-fr30.c: Likewise.
+ * elf32-h8300.c: Likewise.
+ * elf32-i370.c: Likewise.
+ * hpux-core.c: Likewise.
+ * versados.c: Likewise.
+
+ * cpu-h8300.c (bfd_default_scan_num_mach): Don't declare.
+ * cpu-h8500.c: Likewise.
+ * cpu-i960.c: Likewise.
+ * cpu-z8k.c: Likewise.
+
+ * cpu-ia64-opc.c: Correct comment.
+
+ * dwarf2.c (_bfd_dwarf2_find_nearest_line): Remove unused var.
+
+ * elf-bfd.h (elf_size_info): Change count param of write_out_phdrs
+ to unsigned.
+ (bfd_elf32_write_out_phdrs): Likewise.
+ (bfd_elf64_write_out_phdrs): Likewise.
+ (elf_linker_section_pointers): Change addend to bfd_vma.
+ (_bfd_elf_find_pointer_linker_section): Likewise.
+ (_bfd_elfcore_make_pseudosection): Change size param to size_t and
+ filepos to unsigned file_ptr.
+ (_bfd_elfcore_strndup): Change max param to size_t.
+ * elf.c (_bfd_elfcore_make_pseudosection): As above.
+ (_bfd_elfcore_strndup): Likewise.
+ (_bfd_elf_find_pointer_linker_section): Likewise.
+
+ * elf-hppa.h (elf_hppa_relocate_insn): Return an int, and change
+ insn and sym_value to ints.
+
+ * elf.c (elf_read): Make "offset" param a file_ptr, "size" a
+ bfd_size_type.
+ (elfcore_read_notes): Likewise.
+
+ * elf32-arm.h (elf32_arm_final_link_relocate): Change sym_flags
+ param from unsigned char to int.
+ (elf32_arm_relocate_section): If USE_REL, cast "rel" appropriately
+ for info_to_howto call.
+ (add_dynamic_entry): Define macro.
+ (elf32_arm_size_dynamic_sections): Use add_dynamic_entry.
+
+ * elf32-cris.c (add_dynamic_entry): Define macro.
+ (elf_cris_size_dynamic_sections): Use add_dynamic_entry.
+
+ * elf32-h8300.c (elf32_h8_final_write_processing): Make static.
+ (elf32_h8_object_p): Likewise.
+ (elf32_h8_merge_private_bfd_data): Likewise.
+ (elf32_h8_relax_section): Cast gap to int so signed comparisons work.
+
+ * elf32-hppa.c (add_dynamic_entry): Define macro.
+ (elf32_hppa_size_dynamic_sections): Use it.
+ * elf32-i370.c (add_dynamic_entry): Define macro.
+ (i370_elf_size_dynamic_sections): Use it.
+ (i370_noop): Make static.
+ * elf32-i386.c (add_dynamic_entry): Define macro.
+ (elf_i386_size_dynamic_sections): Use it.
+ * elf32-m68k.c (add_dynamic_entry): Define macro.
+ (elf_m68k_size_dynamic_sections): Use it.
+ * elf32-ppc.c (add_dynamic_entry): Define macro.
+ (ppc_elf_size_dynamic_sections): Use it.
+ * elf32-s390.c (add_dynamic_entry): Define macro.
+ (elf_s390_size_dynamic_sections): Use it.
+ * elf64-alpha.c (add_dynamic_entry): Define macro.
+ (elf64_alpha_size_dynamic_sections): Use it.
+ * elf64-hppa.c (add_dynamic_entry): Define macro.
+ (elf64_hppa_size_dynamic_sections): Use it.
+ * elf64-ppc.c (add_dynamic_entry): Define macro.
+ (ppc64_elf_size_dynamic_sections): Use it.
+ * elf64-s390.c (add_dynamic_entry): Define macro.
+ (elf_s390_size_dynamic_sections): Use it.
+ * elf64-sparc.c (add_dynamic_entry): Define macro.
+ (sparc64_elf_size_dynamic_sections): Use it.
+ * elf64-x86-64.c (add_dynamic_entry): Define macro.
+ (elf64_x86_64_size_dynamic_sections): Use it.
+ * elfxx-ia64.c (add_dynamic_entry): Define macro.
+ (elfNN_ia64_size_dynamic_sections): Use it.
+
+ * elf32-v850.c (SEXT24): Modify to avoid signed/unsigned warning.
+ (v850_elf_perform_relocation): Make "r_type" param unsigned.
+
+ * elf64-mips.c (mips_elf64_slurp_one_reloc_table): Just return
+ false if the first malloc fails rather than going via error_return.
+
+ * elf64-sparc.c (sparc64_elf_plt_entry_offset): Use a bfd_vma for
+ "index" param.
+ (sparc64_elf_plt_ptr_offset): Likewise, and for "max" param too.
+
+ * elflink.h (elf_link_input_bfd): s/ingored/ignored/ in error message.
+
+ * elfxx-ia64.c (global_sym_index): Return a long.
+
+ * ieee.c (get_symbol): Use int rather than char param.
+ (ieee_slurp_sections): Move "section" var to inner blocks.
+ (copy_expression): Don't init "value" to zero or worry about
+ clearing to zero after using.
+ (ieee_write_debug_part): Rename "output_buffer" to "obuff" to avoid
+ shadowing.
+
+ * ihex.c (ihex_write_record): Make "count" var a size_t, "addr" an
+ unsigned int.
+
+ * libbfd-in.h (BFD_ALIGN): Add cast to avoid signed/unsigned warning.
+ (bfd_write_bigendian_4byte_int): Pass an unsigned int value param.
+
+ * mipsbsd.c (mips_fix_jmp_addr): Add "error_message" param.
+
+ * pc532-mach.c (MYNSX): Delete.
+ (ns32kaout_bfd_reloc_type_lookup): Define prototype without MYNSX.
+ (write_object_contents): Correct prototype.
+
+ * peicode.h (pe_ILF_build_a_bfd): Use an unsigned int param rather
+ than unsigned short.
+
+ * section.c (bfd_set_section_contents): Remove redundant
+ "offset < 0" test. Check that "count" doesn't overflow size_t.
+ (bfd_get_section_contents): Likewise.
+
+ * som.c (som_fixup_formats): Add missing braces.
+ (som_reloc_addend): Pass a bfd_vma for "addend".
+
+ * srec.c (srec_write_record): Pass "type" as an unsigned int.
+ (srec_write_symbols): Remove an unnecessary var.
+
+ * targets.c (_bfd_target_vector): Sort entries. Sort externs
+ to match.
+ * configure.in: Sort to match. Bump version number.
+ * configure: Regenerate.
+
+ * tekhex.c (move_section_contents): Assert offset == 0.
+
+ * versados.c (new_symbol_string): Constify arg.
+ (process_esd): Use bfd_und_section_ptr rather than &bfd_und_section.
+ (versados_get_symbol_info): Make static.
+ (versados_print_symbol): Likewise.
+ (versados_get_reloc_upper_bound): Likewise.
+ (versados_canonicalize_reloc): Likewise.
+
2001-09-18 Nick Clifton <nickc@cambridge.redhat.com>
* elflink.h (elf_link_input_bfd): Fix typo in error message.
/* BFD back-end for AIX on PS/2 core files.
This was based on trad-core.c, which was written by John Gilmore of
Cygnus Support.
- Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1996, 1998, 1999, 2000
+ Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1996, 1998, 1999, 2000,
+ 2001
Free Software Foundation, Inc.
Written by Minh Tran-Le <TRANLE@INTELLICORP.COM>.
Converted to back end form by Ian Lance Taylor <ian@cygnus.com>.
{
int i, n;
unsigned char longbuf[4]; /* Raw bytes of various header fields */
- int core_size = sizeof (struct corehdr);
+ bfd_size_type core_size = sizeof (struct corehdr);
+ bfd_size_type amt;
struct corehdr *core;
struct mergem {
struct trad_core_struct coredata;
struct corehdr internal_core;
} *mergem;
- if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) != sizeof (longbuf))
+ amt = sizeof (longbuf);
+ if (bfd_bread ((PTR) longbuf, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
if (strncmp (longbuf, COR_MAGIC, 4))
return 0;
- if (bfd_seek (abfd, 0L, false) < 0)
+ if (bfd_seek (abfd, (file_ptr) 0, 0) != 0)
return 0;
- mergem = (struct mergem *) bfd_zalloc (abfd, sizeof (struct mergem));
+ amt = sizeof (struct mergem);
+ mergem = (struct mergem *) bfd_zalloc (abfd, amt);
if (mergem == NULL)
return 0;
core = &mergem->internal_core;
- if ((bfd_read ((PTR) core, 1, core_size, abfd)) != core_size)
+ if ((bfd_bread ((PTR) core, core_size, abfd)) != core_size)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
+ loser:
bfd_release (abfd, (char *) mergem);
return 0;
}
/* Create the sections. This is raunchy, but bfd_close wants to
reclaim them. */
- core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ amt = sizeof (asection);
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_regsec (abfd) == NULL)
- {
- loser:
- bfd_release (abfd, (char *) mergem);
- return 0;
- }
- core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ goto loser;
+
+ core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_reg2sec (abfd) == NULL)
- {
- loser1:
- bfd_release (abfd, core_regsec (abfd));
- goto loser;
- }
+ /* bfd_release frees everything allocated after it's arg. */
+ goto loser;
for (i = 0, n = 0; (i < MAX_CORE_SEGS) && (core->cd_segs[i].cs_type); i++)
{
if (core->cd_segs[i].cs_offset == 0)
continue;
- core_section (abfd, n) =
- (asection *) bfd_zalloc (abfd, sizeof (asection));
+ core_section (abfd, n) = (asection *) bfd_zalloc (abfd, amt);
if (core_section (abfd, n) == NULL)
- {
- int j;
- if (n > 0)
- {
- for (j = 0; j < n; j++)
- bfd_release (abfd, core_section (abfd, j));
- }
- bfd_release (abfd, (char *) mergem);
- goto loser1;
- }
+ goto loser;
switch (core->cd_segs[i].cs_type)
{
core_regsec (abfd)->_raw_size = sizeof (core->cd_regs);
core_reg2sec (abfd)->_raw_size = sizeof (core->cd_fpregs);
- core_regsec (abfd)->vma = -1;
- core_reg2sec (abfd)->vma = -1;
+ core_regsec (abfd)->vma = (bfd_vma) -1;
+ core_reg2sec (abfd)->vma = (bfd_vma) -1;
/* We'll access the regs afresh in the core file, like any section. */
core_regsec (abfd)->filepos =
abort ();
}
-#define NO_GET ((PROTO(bfd_vma, (*), ( const bfd_byte *))) swap_abort )
-#define NO_GETS ((PROTO(bfd_signed_vma, (*), (const bfd_byte *))) swap_abort )
-#define NO_PUT ((PROTO(void, (*), (bfd_vma, bfd_byte *))) swap_abort )
+#define NO_GET ((bfd_vma (*) PARAMS ((const bfd_byte *))) swap_abort)
+#define NO_GETS ((bfd_signed_vma (*) PARAMS ((const bfd_byte *))) swap_abort)
+#define NO_PUT ((void (*) PARAMS ((bfd_vma, bfd_byte *))) swap_abort)
const bfd_target aix386_core_vec = {
"aix386-core",
bfd_target_unknown_flavour,
BFD_ENDIAN_BIG, /* target byte order */
- BFD_ENDIANG_BIG, /* target headers byte order */
+ BFD_ENDIAN_BIG, /* target headers byte order */
(HAS_RELOC | EXEC_P | /* object flags */
HAS_LINENO | HAS_DEBUG |
HAS_SYMS | HAS_LOCALS | WP_TEXT),
static const bfd_target * aout_adobe_object_p PARAMS ((bfd *));
static boolean aout_adobe_mkobject PARAMS ((bfd *));
static boolean aout_adobe_write_object_contents PARAMS ((bfd *));
-static boolean aout_adobe_set_section_contents PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-static boolean aout_adobe_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, unsigned long));
+static boolean aout_adobe_set_section_contents
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
+static boolean aout_adobe_set_arch_mach
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
static int aout_adobe_sizeof_headers PARAMS ((bfd *, boolean));
/* Swaps the information in an executable header taken from a raw byte
stream memory image, into the internal exec_header structure. */
void aout_adobe_swap_exec_header_in
- PARAMS ((bfd *abfd, struct external_exec *raw_bytes,
- struct internal_exec *execp));
+ PARAMS ((bfd *, struct external_exec *, struct internal_exec *));
void
aout_adobe_swap_exec_header_in (abfd, raw_bytes, execp)
struct external_exec *bytes = (struct external_exec *) raw_bytes;
/* Now fill in fields in the execp, from the bytes in the raw data. */
- execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
+ execp->a_info = H_GET_32 (abfd, bytes->e_info);
execp->a_text = GET_WORD (abfd, bytes->e_text);
execp->a_data = GET_WORD (abfd, bytes->e_data);
execp->a_bss = GET_WORD (abfd, bytes->e_bss);
/* Swaps the information in an internal exec header structure into the
supplied buffer ready for writing to disk. */
-PROTO(void, aout_adobe_swap_exec_header_out,
- (bfd *abfd,
- struct internal_exec *execp,
- struct external_exec *raw_bytes));
+void aout_adobe_swap_exec_header_out
+ PARAMS ((bfd *, struct internal_exec *, struct external_exec *));
+
void
aout_adobe_swap_exec_header_out (abfd, execp, raw_bytes)
bfd *abfd;
/* Now fill in fields in the raw data, from the fields in the exec
struct. */
- bfd_h_put_32 (abfd, execp->a_info , bytes->e_info);
+ H_PUT_32 (abfd, execp->a_info , bytes->e_info);
PUT_WORD (abfd, execp->a_text , bytes->e_text);
PUT_WORD (abfd, execp->a_data , bytes->e_data);
PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
struct internal_exec anexec;
struct external_exec exec_bytes;
char *targ;
+ bfd_size_type amt = EXEC_BYTES_SIZE;
- if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE)
+ if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
return 0;
}
- anexec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
+ anexec.a_info = H_GET_32 (abfd, exec_bytes.e_info);
/* Normally we just compare for the magic number.
However, a bunch of Adobe tools aren't fixed up yet; they generate
flagword flags;
/* Architecture and machine type -- unknown in this format. */
- bfd_set_arch_mach (abfd, bfd_arch_unknown, 0);
+ bfd_set_arch_mach (abfd, bfd_arch_unknown, 0L);
/* The positions of the string table and symbol table. */
obj_str_filepos (abfd) = N_STROFF (*execp);
/* Suck up the section information from the file, one section at a time. */
for (;;)
{
- if (bfd_read ((PTR) ext, 1, sizeof (*ext), abfd) != sizeof (*ext))
+ bfd_size_type amt = sizeof (*ext);
+ if (bfd_bread ((PTR) ext, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
/* Fix the name, if it is a sprintf'd name. */
if (sect->name == try_again)
{
- newname = (char *) bfd_zalloc (abfd, strlen (sect->name));
+ amt = strlen (sect->name);
+ newname = (char *) bfd_zalloc (abfd, amt);
if (newname == NULL)
return 0;
strcpy (newname, sect->name);
bfd_set_section_flags (abfd, sect, flags);
/* Assumed big-endian. */
sect->_raw_size = ((ext->e_size[0] << 8)
- | ext->e_size[1] << 8)
- | ext->e_size[2];
+ | ext->e_size[1] << 8
+ | ext->e_size[2]);
sect->_cooked_size = sect->_raw_size;
- sect->vma = bfd_h_get_32 (abfd, ext->e_virtbase);
- sect->filepos = bfd_h_get_32 (abfd, ext->e_filebase);
+ sect->vma = H_GET_32 (abfd, ext->e_virtbase);
+ sect->filepos = H_GET_32 (abfd, ext->e_filebase);
/* FIXME XXX alignment? */
/* Set relocation information for first section of each type. */
bfd *abfd;
{
struct bout_data_struct *rawptr;
+ bfd_size_type amt = sizeof (struct bout_data_struct);
- rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
+ rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, amt);
if (rawptr == NULL)
return false;
struct external_exec swapped_hdr;
static struct external_segdesc sentinel[1]; /* Initialized to zero. */
asection *sect;
+ bfd_size_type amt;
exec_hdr (abfd)->a_info = ZMAGIC;
aout_adobe_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
+ amt = EXEC_BYTES_SIZE;
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE))
+ || bfd_bwrite ((PTR) &swapped_hdr, amt, abfd) != amt)
return false;
/* Now write out the section information. Text first, data next, rest
aout_adobe_write_section (abfd, sect);
/* Write final `sentinel` section header (with type of 0). */
- if (bfd_write ((PTR) sentinel, 1, sizeof (*sentinel), abfd)
- != sizeof (*sentinel))
+ amt = sizeof (*sentinel);
+ if (bfd_bwrite ((PTR) sentinel, amt, abfd) != amt)
return false;
/* Now write out reloc info, followed by syms and strings. */
if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
return false;
- if (count != 0)
- return (bfd_write ((PTR) location, 1, count, abfd) == count) ? true : false;
+ if (count == 0)
+ return true;
- return true;
+ return bfd_bwrite ((PTR) location, count, abfd) == count;
}
static boolean
as well as our own. */
#define NAME(x,y) CAT3(aoutarm,_32_,y)
-#include "libaout.h"
-#include "aout/aout64.h"
-
-#define N_TXTADDR(x) \
- ((N_MAGIC(x) == NMAGIC) ? 0x8000 : \
- (N_MAGIC(x) != ZMAGIC) ? 0 : \
- (N_SHARED_LIB(x)) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1)) : \
- TEXT_START_ADDR)
+#define N_TXTADDR(x) \
+ ((N_MAGIC (x) == NMAGIC) \
+ ? (bfd_vma) 0x8000 \
+ : ((N_MAGIC (x) != ZMAGIC) \
+ ? (bfd_vma) 0 \
+ : ((N_SHARED_LIB (x)) \
+ ? ((x).a_entry & ~(bfd_vma) (TARGET_PAGE_SIZE - 1)) \
+ : (bfd_vma) TEXT_START_ADDR)))
#define TEXT_START_ADDR 0x8000
#define TARGET_PAGE_SIZE 0x8000
#define MY_bfd_reloc_type_lookup aoutarm_bfd_reloc_type_lookup
-static boolean MY(write_object_contents) PARAMS ((bfd *));
-static bfd_reloc_status_type MY(fix_pcrel_26_done) PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static bfd_reloc_status_type MY(fix_pcrel_26) PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-static void MY(swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *, arelent *, asymbol **, bfd_size_type));
-reloc_howto_type * MY(bfd_reloc_type_lookup) PARAMS ((bfd *, bfd_reloc_code_real_type));
-reloc_howto_type * MY(reloc_howto) PARAMS ((bfd *, struct reloc_std_external *, int *, int *, int *));
-void MY(put_reloc) PARAMS ((bfd *, int, int, long, reloc_howto_type *, struct reloc_std_external *));
-void MY(relocatable_reloc) PARAMS ((reloc_howto_type *, bfd *, struct reloc_std_external *, bfd_vma *, bfd_vma));
-void MY(swap_std_reloc_out) PARAMS ((bfd *, arelent *, struct reloc_std_external *));
+#include "libaout.h"
+#include "aout/aout64.h"
+
+static boolean MY(write_object_contents)
+ PARAMS ((bfd *));
+static bfd_reloc_status_type MY(fix_pcrel_26_done)
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static bfd_reloc_status_type MY(fix_pcrel_26)
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+static void MY(swap_std_reloc_in)
+ PARAMS ((bfd *, struct reloc_std_external *, arelent *, asymbol **,
+ bfd_size_type));
+reloc_howto_type *MY(bfd_reloc_type_lookup)
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+reloc_howto_type * MY(reloc_howto)
+ PARAMS ((bfd *, struct reloc_std_external *, int *, int *, int *));
+void MY(put_reloc)
+ PARAMS ((bfd *, int, int, bfd_vma, reloc_howto_type *,
+ struct reloc_std_external *));
+void MY(relocatable_reloc)
+ PARAMS ((reloc_howto_type *, bfd *, struct reloc_std_external *, bfd_vma *,
+ bfd_vma));
+void MY(swap_std_reloc_out)
+ PARAMS ((bfd *, arelent *, struct reloc_std_external *));
\f
reloc_howto_type MY(howto_table)[] =
{
bfd *abfd;
int r_extern;
int r_index;
- long value;
+ bfd_vma value;
reloc_howto_type *howto;
struct reloc_std_external *reloc;
{
{
bfd_vma relocation;
bfd_size_type addr = reloc_entry->address;
- long target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
+ bfd_vma target = bfd_get_32 (abfd, (bfd_byte *) data + addr);
bfd_reloc_status_type flag = bfd_reloc_ok;
/* If this is an undefined symbol, return error. */
if ((relocation & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff)
flag = bfd_reloc_overflow;
}
- else if (relocation & ~0x03ffffff)
+ else if (relocation & ~ (bfd_vma) 0x03ffffff)
flag = bfd_reloc_overflow;
- target &= ~0x00ffffff;
+ target &= ~ (bfd_vma) 0x00ffffff;
target |= (relocation >> 2) & 0x00ffffff;
bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
code = BFD_RELOC_32;
break;
default:
- return (CONST struct reloc_howto_struct *) 0;
+ return (const struct reloc_howto_struct *) 0;
}
switch (code)
ASTD (BFD_RELOC_16_PCREL, 5);
ASTD (BFD_RELOC_32_PCREL, 6);
default:
- return (CONST struct reloc_howto_struct *) 0;
+ return (const struct reloc_howto_struct *) 0;
}
}
int r_pcrel;
struct aoutdata *su = &(abfd->tdata.aout_data->a);
- cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
+ cache_ptr->address = H_GET_32 (abfd, bytes->r_address);
cache_ptr->howto = MY_reloc_howto (abfd, bytes, r_index, r_extern, r_pcrel);
BFD_JUMP_TABLE_WRITE (MY),
BFD_JUMP_TABLE_LINK (MY),
BFD_JUMP_TABLE_DYNAMIC (MY),
-
+
& aout_arm_little_vec,
(PTR) MY_backend_data,
/* BFD backend for CRIS a.out binaries.
- Copyright 2000 Free Software Foundation, Inc.
+ Copyright 2000, 2001 Free Software Foundation, Inc.
Contributed by Axis Communications AB.
Written by Hans-Peter Nilsson.
after text, but with those, we don't have any choice besides reading
symbol info, and luckily there's no pressing need for correctness for
those vma:s at this time. */
-#define N_TXTADDR(x) ((x).a_entry & ~0xffff)
+#define N_TXTADDR(x) ((x).a_entry & ~(bfd_vma) 0xffff)
/* If you change this to 4, you can not link to an address N*4+2. */
#define SEGMENT_SIZE 2
int r_index;
int r_extern;
unsigned int r_type;
- unsigned int r_addend;
+ bfd_vma r_addend;
asymbol *sym = *(g->sym_ptr_ptr);
asection *output_section = sym->section->output_section;
/* BFD back-end for a.out files encapsulated with COFF headers.
- Copyright 1990, 1991, 1994, 1995, 2000 Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1994, 1995, 2000, 2001
+ Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
#endif
#include "bfd.h"
-#include <sysdep.h>
+#include "sysdep.h"
#include "libbfd.h"
-#include <aout/aout64.h>
+#include "aout/aout64.h"
#include "aout/stab_gnu.h"
#include "aout/ar.h"
#include "libaout.h" /* BFD a.out internal data structures */
short coff_magic;
struct external_exec exec_bytes;
struct internal_exec exec;
+ bfd_size_type amt = sizeof (magicbuf);
- if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
- sizeof (magicbuf))
+ if (bfd_bread ((PTR) magicbuf, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
return 0;
}
- coff_magic = bfd_h_get_16 (abfd, magicbuf);
+ coff_magic = H_GET_16 (abfd, magicbuf);
if (coff_magic != COFF_MAGIC)
return 0; /* Not an encap coff file */
- __header_offset_temp==COFF_MAGIC ? sizeof (struct coffheader) : 0)
- (fseek ((f), HEADER_OFFSET((f)), 1))
+ magic = H_GET_32 (abfd, magicbuf);
- magic = bfd_h_get_32 (abfd, magicbuf);
-
- if (N_BADMAG (*((struct internal_exec *) &magic))) return 0;
+ if (N_BADMAG (*((struct internal_exec *) &magic)))
+ return 0;
- struct external_exec exec_bytes;
- if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE) {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
+ if (bfd_seek (abfd, (file_ptr) sizeof (struct coffheader), SEEK_SET) != 0)
return 0;
- }
+
+ amt = EXEC_BYTES_SIZE;
+ if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
NAME(aout,swap_exec_header_in) (abfd, &exec_bytes, &exec);
return aout_32_some_aout_object_p (abfd, &exec, encap_realcallback);
text_start and exec_data_start. This is particularly useful
for remote debugging of embedded systems. */
if (N_FLAGS(exec_aouthdr) & N_FLAGS_COFF_ENCAPSULATE)
- {
- struct coffheader ch;
- int val;
- val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1);
- if (val == -1)
- perror_with_name (filename);
- val = myread (execchan, &ch, sizeof (ch));
- if (val < 0)
- perror_with_name (filename);
- text_start = ch.text_start;
- exec_data_start = ch.data_start;
- } else
- {
- text_start =
- IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr);
- exec_data_start = IS_OBJECT_FILE (exec_aouthdr)
- ? exec_aouthdr.a_text : N_DATADDR (exec_aouthdr);
- }
+ {
+ struct coffheader ch;
+ int val;
+ val = lseek (execchan, -(sizeof (AOUTHDR) + sizeof (ch)), 1);
+ if (val == -1)
+ perror_with_name (filename);
+ val = myread (execchan, &ch, sizeof (ch));
+ if (val < 0)
+ perror_with_name (filename);
+ text_start = ch.text_start;
+ exec_data_start = ch.data_start;
+ }
+ else
+ {
+ text_start =
+ IS_OBJECT_FILE (exec_aouthdr) ? 0 : N_TXTADDR (exec_aouthdr);
+ exec_data_start = (IS_OBJECT_FILE (exec_aouthdr)
+ ? exec_aouthdr.a_text
+ : N_DATADDR (exec_aouthdr));
+ }
/* Determine the architecture and machine type of the object file. */
bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0); /* FIXME */
struct external_exec exec_bytes;
struct internal_exec *execp = exec_hdr (abfd);
-/****** FIXME: Fragments from the old GNU LD program for dealing with
- encap coff. */
-struct coffheader coffheader;
-int need_coff_header;
+ /* FIXME: Fragments from the old GNU LD program for dealing with
+ encap coff. */
+ struct coffheader coffheader;
+ int need_coff_header;
/* Determine whether to count the header as part of
the text size, and initialize the text size accordingly.
MY(reloc_howto) PARAMS ((bfd *, struct reloc_std_external *,
int *, int *, int *));
void
-MY(put_reloc) PARAMS ((bfd *, int, int, long, reloc_howto_type *,
+MY(put_reloc) PARAMS ((bfd *, int, int, bfd_vma, reloc_howto_type *,
struct reloc_std_external *));
/* The ns32k series is ah, unusual, when it comes to relocation.
pointer, the static base register and general purpose register etc.
For example:
-
+
sym1: .long . # pc relative 2's complement
sym1: .long foo # 2's complement not pc relative
-
+
self: movd @self, r0 # pc relative displacement
movd foo, r0 # non pc relative displacement
self: movd self, r0 # pc relative immediate
movd foo, r0 # non pc relative immediate
-
+
In addition, for historical reasons the encoding of the relocation types
in the a.out format relocation entries is such that even the relocation
methods which are standard are not encoded the standard way. */
return (MY(howto_table) + r_length + 3 * (*r_pcrel) + 6 * r_ns32k_type);
}
-#define MY_reloc_howto(BFD,REL,IN,EX,PC) MY(reloc_howto) (BFD, REL, &IN, &EX, &PC)
+#define MY_reloc_howto(BFD, REL, IN, EX, PC) \
+ MY(reloc_howto) (BFD, REL, &IN, &EX, &PC)
void
MY(put_reloc) (abfd, r_extern, r_index, value, howto, reloc)
bfd *abfd;
int r_extern;
int r_index;
- long value;
+ bfd_vma value;
reloc_howto_type *howto;
struct reloc_std_external *reloc;
{
#define MY_final_link_relocate _bfd_ns32k_final_link_relocate
#define MY_relocate_contents _bfd_ns32k_relocate_contents
-#include <aoutx.h>
+#include "aoutx.h"
reloc_howto_type *
MY(bfd_reloc_type_lookup) (abfd,code)
int r_pcrel;
struct aoutdata *su = &(abfd->tdata.aout_data->a);
- cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
+ cache_ptr->address = H_GET_32 (abfd, bytes->r_address);
/* Now the fun stuff. */
cache_ptr->howto = MY_reloc_howto(abfd, bytes, r_index, r_extern, r_pcrel);
bfd_byte *location;
{
int r_ns32k_type = (howto - MY(howto_table)) / 6;
- long (*get_data) PARAMS ((bfd_byte *, long, long));
- int (*put_data) PARAMS ((long, bfd_byte *, long, long));
+ bfd_vma (*get_data) PARAMS ((bfd_byte *, int));
+ int (*put_data) PARAMS ((bfd_vma, bfd_byte *, int));
switch (r_ns32k_type)
{
/* Determine the architecture and machine type of the object file. */
#ifdef SET_ARCH_MACH
- SET_ARCH_MACH(abfd, *execp);
+ SET_ARCH_MACH (abfd, *execp);
#else
- bfd_default_set_arch_mach(abfd, DEFAULT_ARCH, 0);
+ bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0);
#endif
/* The number of relocation records. This must be called after
struct external_exec exec_bytes; /* Raw exec header from file */
struct internal_exec exec; /* Cleaned-up exec header */
const bfd_target *target;
+ bfd_size_type amt = EXEC_BYTES_SIZE;
- if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE) {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
+ if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
#ifdef SWAP_MAGIC
exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
#define MY_finish_dynamic_link 0
#endif
-static CONST struct aout_backend_data MY(backend_data) = {
+static const struct aout_backend_data MY(backend_data) = {
MY_zmagic_contiguous,
MY_text_includes_header,
MY_entry_is_text_address,
static boolean tic30_aout_write_object_contents PARAMS ((bfd *));
static boolean tic30_aout_set_sizes PARAMS ((bfd *));
static const bfd_target * tic30_aout_callback PARAMS ((bfd *));
-static boolean MY_bfd_copy_private_section_data PARAMS ((bfd *, asection *, bfd *, asection *));
+static boolean MY_bfd_copy_private_section_data
+ PARAMS ((bfd *, asection *, bfd *, asection *));
static boolean MY_bfd_final_link PARAMS ((bfd *, struct bfd_link_info *));
-reloc_howto_type * tic30_aout_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type));
-enum machine_type tic30_aout_machine_type PARAMS ((enum bfd_architecture, unsigned long, boolean *));
-boolean tic30_aout_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, unsigned long));
-
-#define MY_reloc_howto(BFD,REL,IN,EX,PC) tic30_aout_reloc_howto(BFD,REL,&IN,&EX,&PC)
+reloc_howto_type * tic30_aout_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+enum machine_type tic30_aout_machine_type
+ PARAMS ((enum bfd_architecture, unsigned long, boolean *));
+boolean tic30_aout_set_arch_mach
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
+
+#define MY_reloc_howto(BFD, REL, IN, EX, PC) \
+ tic30_aout_reloc_howto(BFD, REL, &IN, &EX, &PC)
#define MY_final_link_relocate tic30_aout_final_link_relocate
#define MY_object_p tic30_aout_object_p
#define MY_mkobject NAME(aout,mkobject)
#define MY_finish_dynamic_link 0
#endif
-static CONST struct aout_backend_data tic30_aout_backend_data =
+static const struct aout_backend_data tic30_aout_backend_data =
{
MY_zmagic_contiguous,
MY_text_includes_header,
#ifdef SET_ARCH_MACH
SET_ARCH_MACH (abfd, *execp);
#else
- bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0);
+ bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0L);
#endif
/* Now that we know the architecture, set the alignments of the
case complain_overflow_bitfield:
{
bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
- if ((check & ~reloc_bits) != 0 && (((bfd_vma) signed_check & ~reloc_bits) != (-1 & ~reloc_bits)))
+ if ((check & ~reloc_bits) != 0
+ && (((bfd_vma) signed_check & ~reloc_bits)
+ != ((bfd_vma) -1 & ~reloc_bits)))
overflow = true;
}
break;
struct external_exec exec_bytes; /* Raw exec header from file. */
struct internal_exec exec; /* Cleaned-up exec header. */
const bfd_target *target;
+ bfd_size_type amt = EXEC_BYTES_SIZE;
- if (bfd_read ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE)
+ if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
#ifdef SWAP_MAGIC
exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
#else
- exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
+ exec.a_info = H_GET_32 (abfd, exec_bytes.e_info);
#endif /* SWAP_MAGIC */
if (N_BADMAG (exec))
if (adata (abfd).exec_bytes_size > 0)
{
+ bfd_size_type amt;
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) & exec_bytes, 1, adata (abfd).exec_bytes_size, abfd) != adata (abfd).exec_bytes_size)
+ amt = adata (abfd).exec_bytes_size;
+ if (bfd_bwrite ((PTR) &exec_bytes, amt, abfd) != amt)
return false;
}
/* A.out "format 1" file handling code for BFD.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
+ 2001
Free Software Foundation, Inc.
Written by Cygnus Support.
#endif
static boolean sunos_merge_private_bfd_data PARAMS ((bfd *, bfd *));
-static void sunos_set_arch_mach PARAMS ((bfd *, int));
+static void sunos_set_arch_mach PARAMS ((bfd *, enum machine_type));
static void choose_reloc_size PARAMS ((bfd *));
static boolean sunos_write_object_contents PARAMS ((bfd *));
static const bfd_target *sunos4_core_file_p PARAMS ((bfd *));
static void
sunos_set_arch_mach (abfd, machtype)
bfd *abfd;
- int machtype;
+ enum machine_type machtype;
{
/* Determine the architecture and machine type of the object file. */
enum bfd_architecture arch;
- long machine;
+ unsigned long machine;
switch (machtype)
{
{
struct external_sun3_core *extcore = (struct external_sun3_core *) ext;
- intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
- intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
+ intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
+ intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs);
intcore->c_regs_size = sizeof (extcore->c_regs);
#if ARCH_SIZE == 64
aout_32_swap_exec_header_in
#endif
(abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
- intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
- intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
- intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
+ intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
+ intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
+ intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
- intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
+ intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
intcore->fp_stuff_pos = (long) (((struct external_sun3_core *) 0)->fp_stuff);
/* FP stuff takes up whole rest of struct, except c_ucode. */
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
(file_ptr) (((struct external_sun3_core *) 0)->fp_stuff);
/* Ucode is the last thing in the struct -- just before the end */
- intcore->c_ucode =
- bfd_h_get_32 (abfd,
- intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
+ intcore->c_ucode = H_GET_32 (abfd,
+ (intcore->c_len
+ - sizeof (extcore->c_ucode)
+ + (unsigned char *) extcore));
intcore->c_stacktop = 0x0E000000; /* By experimentation */
}
{
struct external_sparc_core *extcore = (struct external_sparc_core *) ext;
- intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
- intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
+ intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
+ intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs);
intcore->c_regs_size = sizeof (extcore->c_regs);
#if ARCH_SIZE == 64
aout_32_swap_exec_header_in
#endif
(abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
- intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
- intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
- intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
+ intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
+ intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
+ intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
intcore->c_data_addr = N_DATADDR (intcore->c_aouthdr);
- intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
+ intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
intcore->fp_stuff_pos = (long) (((struct external_sparc_core *) 0)->fp_stuff);
/* FP stuff takes up whole rest of struct, except c_ucode. */
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
(file_ptr) (((struct external_sparc_core *) 0)->fp_stuff);
/* Ucode is the last thing in the struct -- just before the end */
- intcore->c_ucode =
- bfd_h_get_32 (abfd,
- intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
+ intcore->c_ucode = H_GET_32 (abfd,
+ (intcore->c_len
+ - sizeof (extcore->c_ucode)
+ + (unsigned char *) extcore));
/* Supposedly the user stack grows downward from the bottom of kernel memory.
Presuming that this remains true, this definition will work. */
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
{
- bfd_vma sp = bfd_h_get_32
- (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
+ bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6);
if (sp < SPARC_USRSTACK_SPARC10)
intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
else
struct external_solaris_bcp_core *extcore =
(struct external_solaris_bcp_core *) ext;
- intcore->c_magic = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_magic);
- intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
+ intcore->c_magic = H_GET_32 (abfd, &extcore->c_magic);
+ intcore->c_len = H_GET_32 (abfd, &extcore->c_len);
intcore->c_regs_pos = (long) (((struct external_solaris_bcp_core *) 0)->c_regs);
intcore->c_regs_size = sizeof (extcore->c_regs);
the data section is written from address zero instead of the data
start address. */
memset ((PTR) &intcore->c_aouthdr, 0, sizeof (struct internal_exec));
- intcore->c_data_addr =
- bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_exdata_datorg);
- intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
- intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
- intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
- intcore->c_ssize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_ssize);
+ intcore->c_data_addr = H_GET_32 (abfd, &extcore->c_exdata_datorg);
+ intcore->c_signo = H_GET_32 (abfd, &extcore->c_signo);
+ intcore->c_tsize = H_GET_32 (abfd, &extcore->c_tsize);
+ intcore->c_dsize = H_GET_32 (abfd, &extcore->c_dsize);
+ intcore->c_ssize = H_GET_32 (abfd, &extcore->c_ssize);
memcpy (intcore->c_cmdname, extcore->c_cmdname, sizeof (intcore->c_cmdname));
intcore->fp_stuff_pos =
(long) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
intcore->fp_stuff_size = intcore->c_len - (sizeof extcore->c_ucode) -
(file_ptr) (((struct external_solaris_bcp_core *) 0)->fp_stuff);
/* Ucode is the last thing in the struct -- just before the end */
- intcore->c_ucode =
- bfd_h_get_32 (abfd,
- intcore->c_len - sizeof (extcore->c_ucode) + (unsigned char *) extcore);
+ intcore->c_ucode = H_GET_32 (abfd,
+ (intcore->c_len
+ - sizeof (extcore->c_ucode)
+ + (unsigned char *) extcore));
/* Supposedly the user stack grows downward from the bottom of kernel memory.
Presuming that this remains true, this definition will work. */
#define SPARC_USRSTACK_SPARC2 ((bfd_vma)0xf8000000)
#define SPARC_USRSTACK_SPARC10 ((bfd_vma)0xf0000000)
{
- bfd_vma sp = bfd_h_get_32
- (abfd, (unsigned char *) &((struct regs *) &extcore->c_regs[0])->r_o6);
+ bfd_vma sp = H_GET_32 (abfd, &((struct regs *) &extcore->c_regs[0])->r_o6);
if (sp < SPARC_USRSTACK_SPARC10)
intcore->c_stacktop = SPARC_USRSTACK_SPARC10;
else
bfd *abfd;
{
unsigned char longbuf[4]; /* Raw bytes of various header fields */
- bfd_size_type core_size;
+ bfd_size_type core_size, amt;
unsigned long core_mag;
struct internal_sunos_core *core;
char *extcore;
struct sun_core_struct suncoredata;
struct internal_sunos_core internal_sunos_core;
char external_core[1];
- }
- *mergem;
+ } *mergem;
- if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
- sizeof (longbuf))
+ if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
+ != sizeof (longbuf))
return 0;
- core_mag = bfd_h_get_32 (abfd, longbuf);
+ core_mag = H_GET_32 (abfd, longbuf);
if (core_mag != CORE_MAGIC)
return 0;
/* SunOS core headers can vary in length; second word is size; */
- if (bfd_read ((PTR) longbuf, 1, sizeof (longbuf), abfd) !=
- sizeof (longbuf))
+ if (bfd_bread ((PTR) longbuf, (bfd_size_type) sizeof (longbuf), abfd)
+ != sizeof (longbuf))
return 0;
- core_size = bfd_h_get_32 (abfd, longbuf);
+ core_size = H_GET_32 (abfd, longbuf);
/* Sanity check */
if (core_size > 20000)
return 0;
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return 0;
- mergem = (struct mergem *) bfd_zalloc (abfd, core_size + sizeof (struct mergem));
+ amt = core_size + sizeof (struct mergem);
+ mergem = (struct mergem *) bfd_zalloc (abfd, amt);
if (mergem == NULL)
return 0;
extcore = mergem->external_core;
- if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size)
+ if ((bfd_bread ((PTR) extcore, core_size, abfd)) != core_size)
{
+ loser:
bfd_release (abfd, (char *) mergem);
return 0;
}
break;
default:
bfd_set_error (bfd_error_system_call); /* FIXME */
- bfd_release (abfd, (char *) mergem);
- return 0;
+ goto loser;
}
abfd->tdata.sun_core_data = &mergem->suncoredata;
/* create the sections. This is raunchy, but bfd_close wants to reclaim
them */
- core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ amt = sizeof (asection);
+ core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_stacksec (abfd) == NULL)
- {
- loser:
- bfd_release (abfd, (char *) mergem);
- return 0;
- }
- core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ /* bfd_release frees everything allocated after it's arg. */
+ goto loser;
+
+ core_datasec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_datasec (abfd) == NULL)
- {
- loser1:
- bfd_release (abfd, core_stacksec (abfd));
- goto loser;
- }
- core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ goto loser;
+
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_regsec (abfd) == NULL)
- {
- loser2:
- bfd_release (abfd, core_datasec (abfd));
- goto loser1;
- }
- core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ goto loser;
+
+ core_reg2sec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_reg2sec (abfd) == NULL)
- {
- bfd_release (abfd, core_regsec (abfd));
- goto loser2;
- }
+ goto loser;
core_stacksec (abfd)->name = ".stack";
core_datasec (abfd)->name = ".data";
#define MY_finish_dynamic_link 0
#endif
-static CONST struct aout_backend_data sunos4_aout_backend =
+static const struct aout_backend_data sunos4_aout_backend =
{
0, /* zmagic files are not contiguous */
1, /* text includes header */
are memcmp'd, and thus the contents do matter. */
memset ((PTR) execp, 0, sizeof (struct internal_exec));
/* Now fill in fields in the execp, from the bytes in the raw data. */
- execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
+ execp->a_info = H_GET_32 (abfd, bytes->e_info);
execp->a_text = GET_WORD (abfd, bytes->e_text);
execp->a_data = GET_WORD (abfd, bytes->e_data);
execp->a_bss = GET_WORD (abfd, bytes->e_bss);
struct external_exec *bytes = (struct external_exec *)raw_bytes;
/* Now fill in fields in the raw data, from the fields in the exec struct. */
- bfd_h_put_32 (abfd, execp->a_info , bytes->e_info);
+ H_PUT_32 (abfd, execp->a_info , bytes->e_info);
PUT_WORD (abfd, execp->a_text , bytes->e_text);
PUT_WORD (abfd, execp->a_data , bytes->e_data);
PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
{
struct aout_data_struct *rawptr, *oldrawptr;
const bfd_target *result;
+ bfd_size_type amt = sizeof (struct aout_data_struct);
- rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
+ rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, amt);
if (rawptr == NULL)
return 0;
NAME(aout,mkobject) (abfd)
bfd *abfd;
{
- struct aout_data_struct *rawptr;
+ struct aout_data_struct *rawptr;
+ bfd_size_type amt = sizeof (struct aout_data_struct);
bfd_set_error (bfd_error_system_call);
- /* Use an intermediate variable for clarity */
- rawptr = (struct aout_data_struct *)bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
-
+ rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, amt);
if (rawptr == NULL)
return false;
abfd->tdata.aout_data = rawptr;
exec_hdr (abfd) = &(rawptr->e);
- obj_textsec (abfd) = (asection *)NULL;
- obj_datasec (abfd) = (asection *)NULL;
- obj_bsssec (abfd) = (asection *)NULL;
+ obj_textsec (abfd) = (asection *) NULL;
+ obj_datasec (abfd) = (asection *) NULL;
+ obj_bsssec (abfd) = (asection *) NULL;
return true;
}
{
bfd_size_type data_pad, text_pad;
file_ptr text_end;
- CONST struct aout_backend_data *abdp;
+ const struct aout_backend_data *abdp;
int ztih; /* Nonzero if text includes exec header. */
abdp = aout_backend_info (abfd);
if (count != 0)
{
if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
- || bfd_write (location, 1, count, abfd) != count)
+ || bfd_bwrite (location, count, abfd) != count)
return false;
}
{
bfd_size_type count;
struct external_nlist *syms;
+ bfd_size_type amt;
count = exec_hdr (abfd)->a_syms / EXTERNAL_NLIST_SIZE;
later on. If we put them on the objalloc it might not be
possible to free them. */
syms = ((struct external_nlist *)
- bfd_malloc ((size_t) count * EXTERNAL_NLIST_SIZE));
+ bfd_malloc (count * EXTERNAL_NLIST_SIZE));
if (syms == (struct external_nlist *) NULL && count != 0)
return false;
+ amt = exec_hdr (abfd)->a_syms;
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
- || (bfd_read (syms, 1, exec_hdr (abfd)->a_syms, abfd)
- != exec_hdr (abfd)->a_syms))
+ || bfd_bread (syms, amt, abfd) != amt)
{
free (syms);
return false;
unsigned char string_chars[BYTES_IN_WORD];
bfd_size_type stringsize;
char *strings;
+ bfd_size_type amt = BYTES_IN_WORD;
/* Get the size of the strings. */
if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0
- || (bfd_read ((PTR) string_chars, BYTES_IN_WORD, 1, abfd)
- != BYTES_IN_WORD))
+ || bfd_bread ((PTR) string_chars, amt, abfd) != amt)
return false;
stringsize = GET_WORD (abfd, string_chars);
return false;
strings = (char *) obj_aout_string_window (abfd).data;
#else
- strings = (char *) bfd_malloc ((size_t) stringsize + 1);
+ strings = (char *) bfd_malloc (stringsize + 1);
if (strings == NULL)
return false;
/* Skip space for the string count in the buffer for convenience
when using indexes. */
- if (bfd_read (strings + BYTES_IN_WORD, 1, stringsize - BYTES_IN_WORD,
- abfd)
- != stringsize - BYTES_IN_WORD)
+ amt = stringsize - BYTES_IN_WORD;
+ if (bfd_bread (strings + BYTES_IN_WORD, amt, abfd) != amt)
{
free (strings);
return false;
asection *section;
arelent_chain *reloc;
asection *into_section;
+ bfd_size_type amt;
/* This is a set symbol. The name of the symbol is the name
of the set (e.g., __CTOR_LIST__). The value of the symbol
{
char *copy;
- copy = bfd_alloc (abfd, strlen (cache_ptr->symbol.name) + 1);
+ amt = strlen (cache_ptr->symbol.name) + 1;
+ copy = bfd_alloc (abfd, amt);
if (copy == NULL)
return false;
return false;
}
- reloc = (arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
+ amt = sizeof (arelent_chain);
+ reloc = (arelent_chain *) bfd_alloc (abfd, amt);
if (reloc == NULL)
return false;
NAME(aout,make_empty_symbol) (abfd)
bfd *abfd;
{
- aout_symbol_type *new =
- (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
+ bfd_size_type amt = sizeof (aout_symbol_type);
+ aout_symbol_type *new = (aout_symbol_type *) bfd_zalloc (abfd, amt);
if (!new)
return NULL;
new->symbol.the_bfd = abfd;
return false;
in->symbol.value = GET_SWORD (abfd, ext->e_value);
- in->desc = bfd_h_get_16 (abfd, ext->e_desc);
- in->other = bfd_h_get_8 (abfd, ext->e_other);
- in->type = bfd_h_get_8 (abfd, ext->e_type);
+ in->desc = H_GET_16 (abfd, ext->e_desc);
+ in->other = H_GET_8 (abfd, ext->e_other);
+ in->type = H_GET_8 (abfd, ext->e_type);
in->symbol.udata.p = NULL;
if (! translate_from_native_sym_flags (abfd, in))
{
struct external_nlist *old_external_syms;
aout_symbol_type *cached;
- size_t cached_size;
+ bfd_size_type cached_size;
/* If there's no work to be done, don't do any */
if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
if (! aout_get_external_symbols (abfd))
return false;
- cached_size = (obj_aout_external_sym_count (abfd)
- * sizeof (aout_symbol_type));
+ cached_size = obj_aout_external_sym_count (abfd);
+ cached_size *= sizeof (aout_symbol_type);
cached = (aout_symbol_type *) bfd_malloc (cached_size);
if (cached == NULL && cached_size != 0)
return false;
if (cached_size != 0)
- memset (cached, 0, cached_size);
+ memset (cached, 0, (size_t) cached_size);
/* Convert from external symbol information to internal. */
if (! (NAME(aout,translate_symbol_table)
struct bfd_strtab_hash *tab;
{
bfd_byte buffer[BYTES_IN_WORD];
+ bfd_size_type amt = BYTES_IN_WORD;
/* The string table starts with the size. */
PUT_WORD (abfd, _bfd_stringtab_size (tab) + BYTES_IN_WORD, buffer);
- if (bfd_write ((PTR) buffer, 1, BYTES_IN_WORD, abfd) != BYTES_IN_WORD)
+ if (bfd_bwrite ((PTR) buffer, amt, abfd) != amt)
return false;
return _bfd_stringtab_emit (abfd, tab);
asymbol *g = generic[count];
bfd_size_type indx;
struct external_nlist nsp;
+ bfd_size_type amt;
indx = add_to_stringtab (abfd, strtab, g->name, false);
if (indx == (bfd_size_type) -1)
if (bfd_asymbol_flavour(g) == abfd->xvec->flavour)
{
- bfd_h_put_16(abfd, aout_symbol(g)->desc, nsp.e_desc);
- bfd_h_put_8(abfd, aout_symbol(g)->other, nsp.e_other);
- bfd_h_put_8(abfd, aout_symbol(g)->type, nsp.e_type);
+ H_PUT_16 (abfd, aout_symbol(g)->desc, nsp.e_desc);
+ H_PUT_8 (abfd, aout_symbol(g)->other, nsp.e_other);
+ H_PUT_8 (abfd, aout_symbol(g)->type, nsp.e_type);
}
else
{
- bfd_h_put_16(abfd,0, nsp.e_desc);
- bfd_h_put_8(abfd, 0, nsp.e_other);
- bfd_h_put_8(abfd, 0, nsp.e_type);
+ H_PUT_16 (abfd, 0, nsp.e_desc);
+ H_PUT_8 (abfd, 0, nsp.e_other);
+ H_PUT_8 (abfd, 0, nsp.e_type);
}
if (! translate_to_native_sym_flags (abfd, g, &nsp))
goto error_return;
- if (bfd_write((PTR)&nsp,1,EXTERNAL_NLIST_SIZE, abfd)
- != EXTERNAL_NLIST_SIZE)
+ amt = EXTERNAL_NLIST_SIZE;
+ if (bfd_bwrite ((PTR) &nsp, amt, abfd) != amt)
goto error_return;
/* NB: `KEEPIT' currently overlays `udata.p', so set this only
int r_index;
int r_extern;
unsigned int r_type;
- unsigned int r_addend;
+ bfd_vma r_addend;
asymbol *sym = *(g->sym_ptr_ptr);
asection *output_section = sym->section->output_section;
struct aoutdata *su = &(abfd->tdata.aout_data->a);
unsigned int howto_idx;
- cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
+ cache_ptr->address = H_GET_32 (abfd, bytes->r_address);
/* now the fun stuff */
if (bfd_header_big_endian (abfd)) {
sec_ptr asect;
asymbol **symbols;
{
- unsigned int count;
+ bfd_size_type count;
bfd_size_type reloc_size;
PTR relocs;
arelent *reloc_cache;
size_t each_size;
unsigned int counter = 0;
arelent *cache_ptr;
+ bfd_size_type amt;
if (asect->relocation)
return true;
count = reloc_size / each_size;
- reloc_cache = (arelent *) bfd_malloc ((size_t) (count * sizeof (arelent)));
+ amt = count * sizeof (arelent);
+ reloc_cache = (arelent *) bfd_malloc (amt);
if (reloc_cache == NULL && count != 0)
return false;
- memset (reloc_cache, 0, count * sizeof (arelent));
+ memset (reloc_cache, 0, (size_t) amt);
- relocs = bfd_malloc ((size_t) reloc_size);
+ relocs = bfd_malloc (reloc_size);
if (relocs == NULL && reloc_size != 0)
{
free (reloc_cache);
return false;
}
- if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
+ if (bfd_bread (relocs, reloc_size, abfd) != reloc_size)
{
free (relocs);
free (reloc_cache);
cache_ptr = reloc_cache;
if (each_size == RELOC_EXT_SIZE)
{
- register struct reloc_ext_external *rptr =
- (struct reloc_ext_external *) relocs;
+ struct reloc_ext_external *rptr = (struct reloc_ext_external *) relocs;
for (; counter < count; counter++, rptr++, cache_ptr++)
MY_swap_ext_reloc_in (abfd, rptr, cache_ptr, symbols,
- bfd_get_symcount (abfd));
+ (bfd_size_type) bfd_get_symcount (abfd));
}
else
{
- register struct reloc_std_external *rptr =
- (struct reloc_std_external *) relocs;
+ struct reloc_std_external *rptr = (struct reloc_std_external *) relocs;
for (; counter < count; counter++, rptr++, cache_ptr++)
MY_swap_std_reloc_in (abfd, rptr, cache_ptr, symbols,
- bfd_get_symcount (abfd));
+ (bfd_size_type) bfd_get_symcount (abfd));
}
free (relocs);
size_t each_size;
unsigned int count = section->reloc_count;
- size_t natsize;
+ bfd_size_type natsize;
if (count == 0 || section->orelocation == NULL)
return true;
each_size = obj_reloc_entry_size (abfd);
- natsize = each_size * count;
+ natsize = (bfd_size_type) each_size * count;
native = (unsigned char *) bfd_zalloc (abfd, natsize);
if (!native)
return false;
MY_swap_std_reloc_out(abfd, *generic, (struct reloc_std_external *)natptr);
}
- if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize) {
- bfd_release(abfd, native);
- return false;
- }
+ if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize)
+ {
+ bfd_release(abfd, native);
+ return false;
+ }
bfd_release (abfd, native);
return true;
break;
case bfd_print_symbol_all:
{
- CONST char *section_name = symbol->section->name;
+ const char *section_name = symbol->section->name;
bfd_print_symbol_vandf (abfd, (PTR)file, symbol);
asection *section;
asymbol **symbols;
bfd_vma offset;
- CONST char **filename_ptr;
- CONST char **functionname_ptr;
+ const char **filename_ptr;
+ const char **functionname_ptr;
unsigned int *line_ptr;
{
/* Run down the file looking for the filename, function and linenumber */
asymbol **p;
- CONST char *directory_name = NULL;
- CONST char *main_file_name = NULL;
- CONST char *current_file_name = NULL;
- CONST char *line_file_name = NULL; /* Value of current_file_name at line number. */
- CONST char *line_directory_name = NULL; /* Value of directory_name at line number. */
+ const char *directory_name = NULL;
+ const char *main_file_name = NULL;
+ const char *current_file_name = NULL;
+ const char *line_file_name = NULL; /* Value of current_file_name at line number. */
+ const char *line_directory_name = NULL; /* Value of directory_name at line number. */
bfd_vma low_line_vma = 0;
bfd_vma low_func_vma = 0;
asymbol *func = 0;
- size_t filelen, funclen;
+ bfd_size_type filelen, funclen;
char *buf;
*filename_ptr = abfd->filename;
if (func)
{
const char *function = func->name;
- char *p;
+ char *colon;
/* The caller expects a symbol name. We actually have a
function name, without the leading underscore. Put the
strcpy (buf + 1, function);
}
/* Have to remove : stuff */
- p = strchr (buf, ':');
- if (p != NULL)
- *p = '\0';
+ colon = strchr (buf, ':');
+ if (colon != NULL)
+ *colon = '\0';
*functionname_ptr = buf;
}
bfd *abfd;
{
struct aout_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct aout_link_hash_table);
- ret = ((struct aout_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct aout_link_hash_table)));
+ ret = (struct aout_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == NULL)
return (struct bfd_link_hash_table *) NULL;
if (! NAME(aout,link_hash_table_init) (ret, abfd,
strings = obj_aout_external_strings (abfd);
for (; p < pend; p++)
{
- int type = bfd_h_get_8 (abfd, p->e_type);
+ int type = H_GET_8 (abfd, p->e_type);
const char *name;
struct bfd_link_hash_entry *h;
struct aout_link_hash_entry **sym_hash;
register struct external_nlist *p;
struct external_nlist *pend;
+ bfd_size_type amt;
syms = obj_aout_external_syms (abfd);
sym_count = obj_aout_external_sym_count (abfd);
to particular symbols. We could just look them up in the hash
table, but keeping the list is more efficient. Perhaps this
should be conditional on info->keep_memory. */
- sym_hash = ((struct aout_link_hash_entry **)
- bfd_alloc (abfd,
- ((size_t) sym_count
- * sizeof (struct aout_link_hash_entry *))));
+ amt = sym_count * sizeof (struct aout_link_hash_entry *);
+ sym_hash = (struct aout_link_hash_entry **) bfd_alloc (abfd, amt);
if (sym_hash == NULL && sym_count != 0)
return false;
obj_aout_sym_hashes (abfd) = sym_hash;
*sym_hash = NULL;
- type = bfd_h_get_8 (abfd, p->e_type);
+ type = H_GET_8 (abfd, p->e_type);
/* Ignore debugging symbols. */
if ((type & N_STAB) != 0)
boolean includes_hash_initialized = false;
register bfd *sub;
bfd_size_type trsize, drsize;
- size_t max_contents_size;
- size_t max_relocs_size;
- size_t max_sym_count;
+ bfd_size_type max_contents_size;
+ bfd_size_type max_relocs_size;
+ bfd_size_type max_sym_count;
bfd_size_type text_size;
file_ptr text_end;
register struct bfd_link_order *p;
max_sym_count = 0;
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
{
- size_t sz;
+ bfd_size_type sz;
if (info->relocateable)
{
&& obj_datasec (abfd)->reloc_count == 0)
{
bfd_byte b;
+ file_ptr pos;
b = 0;
- if (bfd_seek (abfd,
- (obj_datasec (abfd)->filepos
- + exec_hdr (abfd)->a_data
- - 1),
- SEEK_SET) != 0
- || bfd_write (&b, 1, 1, abfd) != 1)
+ pos = obj_datasec (abfd)->filepos + exec_hdr (abfd)->a_data - 1;
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
goto error_return;
}
false, false) != NULL)
&& discard != discard_all)
{
- bfd_h_put_8 (output_bfd, N_TEXT, outsym->e_type);
- bfd_h_put_8 (output_bfd, 0, outsym->e_other);
- bfd_h_put_16 (output_bfd, (bfd_vma) 0, outsym->e_desc);
+ H_PUT_8 (output_bfd, N_TEXT, outsym->e_type);
+ H_PUT_8 (output_bfd, 0, outsym->e_other);
+ H_PUT_16 (output_bfd, 0, outsym->e_desc);
strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
input_bfd->filename, false);
if (strtab_index == (bfd_size_type) -1)
sym_end = sym + sym_count;
sym_hash = obj_aout_sym_hashes (input_bfd);
symbol_map = finfo->symbol_map;
- memset (symbol_map, 0, sym_count * sizeof *symbol_map);
+ memset (symbol_map, 0, (size_t) sym_count * sizeof *symbol_map);
for (; sym < sym_end; sym++, sym_hash++, symbol_map++)
{
const char *name;
we do copy the symbol over. */
*symbol_map = -1;
- type = bfd_h_get_8 (input_bfd, sym->e_type);
+ type = H_GET_8 (input_bfd, sym->e_type);
name = strings + GET_WORD (input_bfd, sym->e_strx);
h = NULL;
{
int incl_type;
- incl_type = bfd_h_get_8 (input_bfd, incl_sym->e_type);
+ incl_type = H_GET_8 (input_bfd, incl_sym->e_type);
if (incl_type == N_EINCL)
{
if (nest == 0)
{
int incl_type;
- incl_type = bfd_h_get_8 (input_bfd, incl_sym->e_type);
+ incl_type = H_GET_8 (input_bfd, incl_sym->e_type);
if (incl_type == N_EINCL)
{
if (nest == 0)
/* Copy this symbol into the list of symbols we are going to
write out. */
- bfd_h_put_8 (output_bfd, type, outsym->e_type);
- bfd_h_put_8 (output_bfd, bfd_h_get_8 (input_bfd, sym->e_other),
- outsym->e_other);
- bfd_h_put_16 (output_bfd, bfd_h_get_16 (input_bfd, sym->e_desc),
- outsym->e_desc);
+ H_PUT_8 (output_bfd, type, outsym->e_type);
+ H_PUT_8 (output_bfd, H_GET_8 (input_bfd, sym->e_other), outsym->e_other);
+ H_PUT_16 (output_bfd, H_GET_16 (input_bfd, sym->e_desc), outsym->e_desc);
copy = false;
if (! finfo->info->keep_memory)
{
/* Write out the output symbols we have just constructed. */
if (outsym > finfo->output_syms)
{
- bfd_size_type outsym_count;
+ bfd_size_type outsym_size;
if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0)
return false;
- outsym_count = outsym - finfo->output_syms;
- if (bfd_write ((PTR) finfo->output_syms,
- (bfd_size_type) EXTERNAL_NLIST_SIZE,
- (bfd_size_type) outsym_count, output_bfd)
- != outsym_count * EXTERNAL_NLIST_SIZE)
+ outsym_size = outsym - finfo->output_syms;
+ outsym_size *= EXTERNAL_NLIST_SIZE;
+ if (bfd_bwrite ((PTR) finfo->output_syms, outsym_size, output_bfd)
+ != outsym_size)
return false;
- finfo->symoff += outsym_count * EXTERNAL_NLIST_SIZE;
+ finfo->symoff += outsym_size;
}
return true;
bfd_vma val;
struct external_nlist outsym;
bfd_size_type indx;
+ bfd_size_type amt;
output_bfd = finfo->output_bfd;
return true;
}
- bfd_h_put_8 (output_bfd, type, outsym.e_type);
- bfd_h_put_8 (output_bfd, 0, outsym.e_other);
- bfd_h_put_16 (output_bfd, 0, outsym.e_desc);
+ H_PUT_8 (output_bfd, type, outsym.e_type);
+ H_PUT_8 (output_bfd, 0, outsym.e_other);
+ H_PUT_16 (output_bfd, 0, outsym.e_desc);
indx = add_to_stringtab (output_bfd, finfo->strtab, h->root.root.string,
false);
- if (indx == (bfd_size_type) -1)
+ if (indx == - (bfd_size_type) 1)
{
/* FIXME: No way to handle errors. */
abort ();
PUT_WORD (output_bfd, indx, outsym.e_strx);
PUT_WORD (output_bfd, val, outsym.e_value);
+ amt = EXTERNAL_NLIST_SIZE;
if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0
- || bfd_write ((PTR) &outsym, (bfd_size_type) EXTERNAL_NLIST_SIZE,
- (bfd_size_type) 1, output_bfd) != EXTERNAL_NLIST_SIZE)
+ || bfd_bwrite ((PTR) &outsym, amt, output_bfd) != amt)
{
/* FIXME: No way to handle errors. */
abort ();
if (rel_size > 0)
{
if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
- || bfd_read (relocs, 1, rel_size, input_bfd) != rel_size)
+ || bfd_bread (relocs, rel_size, input_bfd) != rel_size)
return false;
}
}
if (! bfd_set_section_contents (finfo->output_bfd,
input_section->output_section,
(PTR) finfo->contents,
- input_section->output_offset,
+ (file_ptr) input_section->output_offset,
input_size))
return false;
{
if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
return false;
- if (bfd_write (relocs, (bfd_size_type) 1, rel_size, finfo->output_bfd)
- != rel_size)
+ if (bfd_bwrite (relocs, rel_size, finfo->output_bfd) != rel_size)
return false;
*reloff_ptr += rel_size;
/* For base relative relocs, r_index is always an index
into the symbol table, even if r_extern is 0. */
sym = syms + r_index;
- type = bfd_h_get_8 (input_bfd, sym->e_type);
+ type = H_GET_8 (input_bfd, sym->e_type);
if ((type & N_TYPE) == N_TEXT
|| type == N_WEAKT)
r_section = obj_textsec (input_bfd);
struct reloc_std_external srel;
struct reloc_ext_external erel;
PTR rel_ptr;
+ bfd_size_type amt;
pr = p->u.reloc.p;
if (buf == (bfd_byte *) NULL)
return false;
r = MY_relocate_contents (howto, finfo->output_bfd,
- pr->addend, buf);
+ (bfd_vma) pr->addend, buf);
switch (r)
{
case bfd_reloc_ok:
}
break;
}
- ok = bfd_set_section_contents (finfo->output_bfd, o,
- (PTR) buf,
- (file_ptr) p->offset,
- size);
+ ok = bfd_set_section_contents (finfo->output_bfd, o, (PTR) buf,
+ (file_ptr) p->offset, size);
free (buf);
if (! ok)
return false;
| (howto->type << RELOC_EXT_BITS_TYPE_SH_LITTLE);
}
- PUT_WORD (finfo->output_bfd, pr->addend, erel.r_addend);
+ PUT_WORD (finfo->output_bfd, (bfd_vma) pr->addend, erel.r_addend);
#endif /* MY_put_ext_reloc */
rel_ptr = (PTR) &erel;
}
+ amt = obj_reloc_entry_size (finfo->output_bfd);
if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0
- || (bfd_write (rel_ptr, (bfd_size_type) 1,
- obj_reloc_entry_size (finfo->output_bfd),
- finfo->output_bfd)
- != obj_reloc_entry_size (finfo->output_bfd)))
+ || bfd_bwrite (rel_ptr, amt, finfo->output_bfd) != amt)
return false;
*reloff_ptr += obj_reloc_entry_size (finfo->output_bfd);
/* BFD back-end for archive files (libraries).
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000
+ 2000, 2001
Free Software Foundation, Inc.
Written by Cygnus Support. Mostly Gumby Henkel-Wallace's fault.
_bfd_generic_mkarchive (abfd)
bfd *abfd;
{
- abfd->tdata.aout_ar_data = ((struct artdata *)
- bfd_zalloc (abfd, sizeof (struct artdata)));
+ bfd_size_type amt = sizeof (struct artdata);
+ abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt);
if (bfd_ardata (abfd) == NULL)
return false;
bfd *arch_bfd, *new_elt;
file_ptr filepos;
{
- struct ar_cache *new_cache = ((struct ar_cache *)
- bfd_zalloc (arch_bfd,
- sizeof (struct ar_cache)));
+ bfd_size_type amt = sizeof (struct ar_cache);
+ struct ar_cache *new_cache = (struct ar_cache *) bfd_zalloc (arch_bfd, amt);
if (new_cache == NULL)
return false;
{
struct ar_hdr hdr;
char *hdrp = (char *) &hdr;
- unsigned int parsed_size;
+ size_t parsed_size;
struct areltdata *ared;
char *filename = NULL;
- unsigned int namelen = 0;
- unsigned int allocsize = sizeof (struct areltdata) + sizeof (struct ar_hdr);
+ bfd_size_type namelen = 0;
+ bfd_size_type allocsize = sizeof (struct areltdata) + sizeof (struct ar_hdr);
char *allocptr = 0;
- if (bfd_read ((PTR) hdrp, 1, sizeof (struct ar_hdr), abfd)
+ if (bfd_bread ((PTR) hdrp, (bfd_size_type) sizeof (struct ar_hdr), abfd)
!= sizeof (struct ar_hdr))
{
if (bfd_get_error () != bfd_error_system_call)
filename = (allocptr
+ sizeof (struct areltdata)
+ sizeof (struct ar_hdr));
- if (bfd_read (filename, 1, namelen, abfd) != namelen)
+ if (bfd_bread (filename, namelen, abfd) != namelen)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_no_more_archived_files);
ared->filename = allocptr + (sizeof (struct areltdata) +
sizeof (struct ar_hdr));
if (namelen)
- memcpy (ared->filename, hdr.ar_name, namelen);
+ memcpy (ared->filename, hdr.ar_name, (size_t) namelen);
ared->filename[namelen] = '\0';
}
{
struct artdata *tdata_hold;
char armag[SARMAG + 1];
+ bfd_size_type amt;
tdata_hold = abfd->tdata.aout_ar_data;
- if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
+ if (bfd_bread ((PTR) armag, (bfd_size_type) SARMAG, abfd) != SARMAG)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
/* We are setting bfd_ardata(abfd) here, but since bfd_ardata
involves a cast, we can't do it as the left operand of assignment. */
- abfd->tdata.aout_ar_data = ((struct artdata *)
- bfd_zalloc (abfd, sizeof (struct artdata)));
+ amt = sizeof (struct artdata);
+ abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt);
if (bfd_ardata (abfd) == NULL)
return NULL;
/* Some constants for a 32 bit BSD archive structure. We do not
support 64 bit archives presently; so far as I know, none actually
exist. Supporting them would require changing these constants, and
- changing some bfd_h_get_32 to bfd_h_get_64. */
+ changing some H_GET_32 to H_GET_64. */
/* The size of an external symdef structure. */
#define BSD_SYMDEF_SIZE 8
bfd_byte *raw_armap, *rbase;
struct artdata *ardata = bfd_ardata (abfd);
char *stringbase;
- unsigned int parsed_size;
+ bfd_size_type parsed_size, amt;
carsym *set;
mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
if (raw_armap == (bfd_byte *) NULL)
return false;
- if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
+ if (bfd_bread ((PTR) raw_armap, parsed_size, abfd) != parsed_size)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
return false;
}
- ardata->symdef_count = bfd_h_get_32 (abfd, raw_armap) / BSD_SYMDEF_SIZE;
+ ardata->symdef_count = H_GET_32 (abfd, raw_armap) / BSD_SYMDEF_SIZE;
if (ardata->symdef_count * BSD_SYMDEF_SIZE >
parsed_size - BSD_SYMDEF_COUNT_SIZE)
stringbase = ((char *) rbase
+ ardata->symdef_count * BSD_SYMDEF_SIZE
+ BSD_STRING_COUNT_SIZE);
- ardata->symdefs = (carsym *) bfd_alloc (abfd,
- (ardata->symdef_count
- * sizeof (carsym)));
+ amt = (bfd_size_type) ardata->symdef_count * sizeof (carsym);
+ ardata->symdefs = (carsym *) bfd_alloc (abfd, amt);
if (!ardata->symdefs)
return false;
counter < ardata->symdef_count;
counter++, set++, rbase += BSD_SYMDEF_SIZE)
{
- set->name = bfd_h_get_32 (abfd, rbase) + stringbase;
- set->file_offset = bfd_h_get_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
+ set->name = H_GET_32 (abfd, rbase) + stringbase;
+ set->file_offset = H_GET_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
}
ardata->first_file_filepos = bfd_tell (abfd);
int *raw_armap, *rawptr;
struct artdata *ardata = bfd_ardata (abfd);
char *stringbase;
- unsigned int stringsize;
+ bfd_size_type stringsize;
unsigned int parsed_size;
carsym *carsyms;
- unsigned int nsymz; /* Number of symbols in armap. */
+ bfd_size_type nsymz; /* Number of symbols in armap. */
bfd_vma (*swap) PARAMS ((const bfd_byte *));
char int_buf[sizeof (long)];
- unsigned int carsym_size, ptrsize, i;
+ bfd_size_type carsym_size, ptrsize;
+ unsigned int i;
mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);
if (mapdata == NULL)
parsed_size = mapdata->parsed_size;
bfd_release (abfd, (PTR) mapdata); /* Don't need it any more. */
- if (bfd_read ((PTR) int_buf, 1, 4, abfd) != 4)
+ if (bfd_bread ((PTR) int_buf, (bfd_size_type) 4, abfd) != 4)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
raw_armap = (int *) bfd_alloc (abfd, ptrsize);
if (raw_armap == NULL)
goto release_symdefs;
- if (bfd_read ((PTR) raw_armap, 1, ptrsize, abfd) != ptrsize
- || bfd_read ((PTR) stringbase, 1, stringsize, abfd) != stringsize)
+ if (bfd_bread ((PTR) raw_armap, ptrsize, abfd) != ptrsize
+ || (bfd_bread ((PTR) stringbase, stringsize, abfd) != stringsize))
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
{
struct areltdata *tmp;
- bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET);
+ bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET);
tmp = (struct areltdata *) _bfd_read_ar_hdr (abfd);
if (tmp != NULL)
{
&& tmp->arch_header[1] == ' ')
{
ardata->first_file_filepos +=
- (tmp->parsed_size + sizeof (struct ar_hdr) + 1) & ~1;
+ (tmp->parsed_size + sizeof (struct ar_hdr) + 1) & ~(unsigned) 1;
}
bfd_release (abfd, tmp);
}
bfd *abfd;
{
char nextname[17];
- int i = bfd_read ((PTR) nextname, 1, 16, abfd);
+ int i = bfd_bread ((PTR) nextname, (bfd_size_type) 16, abfd);
if (i == 0)
return true;
if (i != 16)
return false;
- if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
+ if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
return false;
if (!strncmp (nextname, "__.SYMDEF ", 16)
struct artdata *ardata = bfd_ardata (abfd);
char *stringbase;
unsigned int stringsize;
+ bfd_size_type amt;
carsym *set;
- int i = bfd_read ((PTR) nextname, 1, 16, abfd);
+ int i = bfd_bread ((PTR) nextname, (bfd_size_type) 16, abfd);
if (i == 0)
return true;
return false;
/* The archive has at least 16 bytes in it. */
- if (bfd_seek (abfd, -16L, SEEK_CUR) != 0)
+ if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
return false;
if (!strncmp (nextname, "__.SYMDEF ", 16)
if (mapdata == NULL)
return false;
- raw_armap = (bfd_byte *) bfd_zalloc (abfd, mapdata->parsed_size);
+ amt = mapdata->parsed_size;
+ raw_armap = (bfd_byte *) bfd_zalloc (abfd, amt);
if (raw_armap == NULL)
{
byebye:
return false;
}
- if (bfd_read ((PTR) raw_armap, 1, mapdata->parsed_size, abfd) !=
- mapdata->parsed_size)
+ if (bfd_bread ((PTR) raw_armap, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
goto byebye;
}
- ardata->symdef_count = bfd_h_get_16 (abfd, (PTR) raw_armap);
+ ardata->symdef_count = H_GET_16 (abfd, (PTR) raw_armap);
if (ardata->symdef_count * BSD_SYMDEF_SIZE
> mapdata->parsed_size - HPUX_SYMDEF_COUNT_SIZE)
ardata->cache = 0;
- stringsize = bfd_h_get_32 (abfd, raw_armap + HPUX_SYMDEF_COUNT_SIZE);
+ stringsize = H_GET_32 (abfd, raw_armap + HPUX_SYMDEF_COUNT_SIZE);
/* Skip sym count and string sz. */
stringbase = ((char *) raw_armap
+ HPUX_SYMDEF_COUNT_SIZE
+ BSD_STRING_COUNT_SIZE);
rbase = (bfd_byte *) stringbase + stringsize;
- ardata->symdefs = (carsym *) bfd_alloc (abfd,
- (ardata->symdef_count
- * BSD_SYMDEF_SIZE));
+ amt = (bfd_size_type) ardata->symdef_count * BSD_SYMDEF_SIZE;
+ ardata->symdefs = (carsym *) bfd_alloc (abfd, amt);
if (!ardata->symdefs)
return false;
counter < ardata->symdef_count;
counter++, set++, rbase += BSD_SYMDEF_SIZE)
{
- set->name = bfd_h_get_32 (abfd, rbase) + stringbase;
- set->file_offset = bfd_h_get_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
+ set->name = H_GET_32 (abfd, rbase) + stringbase;
+ set->file_offset = H_GET_32 (abfd, rbase + BSD_SYMDEF_OFFSET_SIZE);
}
ardata->first_file_filepos = bfd_tell (abfd);
{
char nextname[17];
struct areltdata *namedata;
+ bfd_size_type amt;
/* FIXME: Formatting sucks here, and in case of failure of BFD_READ,
we probably don't want to return true. */
bfd_seek (abfd, bfd_ardata (abfd)->first_file_filepos, SEEK_SET);
- if (bfd_read ((PTR) nextname, 1, 16, abfd) == 16)
+ if (bfd_bread ((PTR) nextname, (bfd_size_type) 16, abfd) == 16)
{
- if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
+ if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
return false;
if (strncmp (nextname, "ARFILENAMES/ ", 16) != 0 &&
if (namedata == NULL)
return false;
- bfd_ardata (abfd)->extended_names =
- bfd_zalloc (abfd, namedata->parsed_size);
+ amt = namedata->parsed_size;
+ bfd_ardata (abfd)->extended_names = bfd_zalloc (abfd, amt);
if (bfd_ardata (abfd)->extended_names == NULL)
{
byebye:
return false;
}
- if (bfd_read ((PTR) bfd_ardata (abfd)->extended_names, 1,
- namedata->parsed_size, abfd) != namedata->parsed_size)
+ if (bfd_bread ((PTR) bfd_ardata (abfd)->extended_names, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
bfd *abfd;
const char *file;
{
- CONST char *first;
- CONST char *last;
+ const char *first;
+ const char *last;
char *copy;
first = file + strlen (file) - 1;
first--;
}
- copy = (char *) bfd_alloc (abfd, last - first + 1);
+ copy = (char *) bfd_alloc (abfd, (bfd_size_type) (last - first + 1));
if (copy == NULL)
return NULL;
bfd_size_type *tablen;
{
unsigned int maxname = abfd->xvec->ar_max_namelen;
- unsigned int total_namelen = 0;
+ bfd_size_type total_namelen = 0;
bfd *current;
char *strptr;
struct areltdata *ared;
struct ar_hdr *hdr;
char *temp, *temp1;
+ bfd_size_type amt;
if (member && (member->flags & BFD_IN_MEMORY) != 0)
{
return NULL;
}
- ared = (struct areltdata *) bfd_zalloc (abfd, sizeof (struct ar_hdr) +
- sizeof (struct areltdata));
+ amt = sizeof (struct ar_hdr) + sizeof (struct areltdata);
+ ared = (struct areltdata *) bfd_zalloc (abfd, amt);
if (ared == NULL)
return NULL;
hdr = (struct ar_hdr *) (((char *) ared) + sizeof (struct areltdata));
void
bfd_dont_truncate_arname (abfd, pathname, arhdr)
bfd *abfd;
- CONST char *pathname;
+ const char *pathname;
char *arhdr;
{
/* FIXME: This interacts unpleasantly with ar's quick-append option.
void
bfd_bsd_truncate_arname (abfd, pathname, arhdr)
bfd *abfd;
- CONST char *pathname;
+ const char *pathname;
char *arhdr;
{
struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
- int length;
- CONST char *filename = strrchr (pathname, '/');
- int maxlen = ar_maxnamelen (abfd);
+ size_t length;
+ const char *filename = strrchr (pathname, '/');
+ size_t maxlen = ar_maxnamelen (abfd);
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
{
void
bfd_gnu_truncate_arname (abfd, pathname, arhdr)
bfd *abfd;
- CONST char *pathname;
+ const char *pathname;
char *arhdr;
{
struct ar_hdr *hdr = (struct ar_hdr *) arhdr;
- int length;
- CONST char *filename = strrchr (pathname, '/');
- int maxlen = ar_maxnamelen (abfd);
+ size_t length;
+ const char *filename = strrchr (pathname, '/');
+ size_t maxlen = ar_maxnamelen (abfd);
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
{
if (bfd_seek (arch, (file_ptr) 0, SEEK_SET) != 0)
return false;
#ifdef GNU960
- wrote = bfd_write (BFD_GNU960_ARMAG (arch), 1, SARMAG, arch);
+ wrote = bfd_bwrite (BFD_GNU960_ARMAG (arch), (bfd_size_type) SARMAG, arch);
#else
- wrote = bfd_write (ARMAG, 1, SARMAG, arch);
+ wrote = bfd_bwrite (ARMAG, (bfd_size_type) SARMAG, arch);
#endif
if (wrote != SARMAG)
return false;
if (makemap && hasobjects)
{
- if (_bfd_compute_and_write_armap (arch, elength) != true)
+ if (_bfd_compute_and_write_armap (arch, (unsigned int) elength) != true)
return false;
}
strcpy (hdr.ar_name, ename);
/* Round size up to even number in archive header. */
sprintf (&(hdr.ar_size[0]), "%-10d",
- (int) ((elength + 1) & ~1));
+ (int) ((elength + 1) & ~(bfd_size_type) 1));
strncpy (hdr.ar_fmag, ARFMAG, 2);
for (i = 0; i < sizeof (struct ar_hdr); i++)
if (((char *) (&hdr))[i] == '\0')
(((char *) (&hdr))[i]) = ' ';
- if ((bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
+ if ((bfd_bwrite ((PTR) &hdr, (bfd_size_type) sizeof (struct ar_hdr), arch)
!= sizeof (struct ar_hdr))
- || bfd_write (etable, 1, elength, arch) != elength)
+ || bfd_bwrite (etable, elength, arch) != elength)
return false;
if ((elength % 2) == 1)
{
- if (bfd_write ("\012", 1, 1, arch) != 1)
+ if (bfd_bwrite ("\012", (bfd_size_type) 1, arch) != 1)
return false;
}
}
struct ar_hdr *hdr = arch_hdr (current);
/* Write ar header. */
- if (bfd_write ((char *) hdr, 1, sizeof (*hdr), arch) != sizeof (*hdr))
+ if (bfd_bwrite ((PTR) hdr, (bfd_size_type) sizeof (*hdr), arch)
+ != sizeof (*hdr))
return false;
if (bfd_seek (current, (file_ptr) 0, SEEK_SET) != 0)
return false;
if (amt > remaining)
amt = remaining;
errno = 0;
- if (bfd_read (buffer, amt, 1, current) != amt)
+ if (bfd_bread (buffer, (bfd_size_type) amt, current) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
return false;
}
- if (bfd_write (buffer, amt, 1, arch) != amt)
+ if (bfd_bwrite (buffer, (bfd_size_type) amt, arch) != amt)
return false;
remaining -= amt;
}
if ((arelt_size (current) % 2) == 1)
{
- if (bfd_write ("\012", 1, 1, arch) != 1)
+ if (bfd_bwrite ("\012", (bfd_size_type) 1, arch) != 1)
return false;
}
}
bfd *current;
file_ptr elt_no = 0;
struct orl *map = NULL;
- int orl_max = 1024; /* fine initial default */
- int orl_count = 0;
+ unsigned int orl_max = 1024; /* fine initial default */
+ unsigned int orl_count = 0;
int stridx = 0; /* string index */
asymbol **syms = NULL;
long syms_max = 0;
boolean ret;
+ bfd_size_type amt;
/* Dunno if this is the best place for this info... */
if (elength != 0)
elength += sizeof (struct ar_hdr);
elength += elength % 2;
- map = (struct orl *) bfd_malloc (orl_max * sizeof (struct orl));
+ amt = (bfd_size_type) orl_max * sizeof (struct orl);
+ map = (struct orl *) bfd_malloc (amt);
if (map == NULL)
goto error_return;
/* We put the symbol names on the arch objalloc, and then discard
them when done. */
- first_name = bfd_alloc (arch, 1);
+ first_name = bfd_alloc (arch, (bfd_size_type) 1);
if (first_name == NULL)
goto error_return;
if (syms_max > 0)
free (syms);
syms_max = storage;
- syms = (asymbol **) bfd_malloc ((size_t) syms_max);
+ syms = (asymbol **) bfd_malloc ((bfd_size_type) syms_max);
if (syms == NULL)
goto error_return;
}
bfd_is_com_section (sec))
&& ! bfd_is_und_section (sec))
{
- size_t namelen;
+ bfd_size_type namelen;
struct orl *new_map;
/* This symbol will go into the archive header. */
if (orl_count == orl_max)
{
orl_max *= 2;
- new_map =
- ((struct orl *)
- bfd_realloc (map, orl_max * sizeof (struct orl)));
+ amt = (bfd_size_type) orl_max * sizeof (struct orl);
+ new_map = (struct orl *) bfd_realloc (map, amt);
if (new_map == (struct orl *) NULL)
goto error_return;
}
namelen = strlen (syms[src_count]->name);
- map[orl_count].name = ((char **)
- bfd_alloc (arch,
- sizeof (char *)));
+ amt = sizeof (char *);
+ map[orl_count].name = (char **) bfd_alloc (arch, amt);
if (map[orl_count].name == NULL)
goto error_return;
*(map[orl_count].name) = bfd_alloc (arch, namelen + 1);
if (*(map[orl_count].name) == NULL)
goto error_return;
strcpy (*(map[orl_count].name), syms[src_count]->name);
- (map[orl_count]).pos = (file_ptr) current;
- (map[orl_count]).namidx = stridx;
+ map[orl_count].u.abfd = current;
+ map[orl_count].namidx = stridx;
stridx += namelen + 1;
++orl_count;
for (i = 0; i < sizeof (struct ar_hdr); i++)
if (((char *) (&hdr))[i] == '\0')
(((char *) (&hdr))[i]) = ' ';
- if (bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
+ if (bfd_bwrite ((PTR) &hdr, (bfd_size_type) sizeof (struct ar_hdr), arch)
!= sizeof (struct ar_hdr))
return false;
- bfd_h_put_32 (arch, (bfd_vma) ranlibsize, temp);
- if (bfd_write (temp, 1, sizeof (temp), arch) != sizeof (temp))
+ H_PUT_32 (arch, ranlibsize, temp);
+ if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), arch) != sizeof (temp))
return false;
for (count = 0; count < orl_count; count++)
{
bfd_byte buf[BSD_SYMDEF_SIZE];
- if (((bfd *) (map[count]).pos) != last_elt)
+ if (map[count].u.abfd != last_elt)
{
do
{
firstreal += firstreal % 2;
current = current->next;
}
- while (current != (bfd *) (map[count]).pos);
+ while (current != map[count].u.abfd);
} /* if new archive element */
last_elt = current;
- bfd_h_put_32 (arch, map[count].namidx, buf);
- bfd_h_put_32 (arch, firstreal, buf + BSD_SYMDEF_OFFSET_SIZE);
- if (bfd_write (buf, BSD_SYMDEF_SIZE, 1, arch) != BSD_SYMDEF_SIZE)
+ H_PUT_32 (arch, map[count].namidx, buf);
+ H_PUT_32 (arch, firstreal, buf + BSD_SYMDEF_OFFSET_SIZE);
+ if (bfd_bwrite (buf, (bfd_size_type) BSD_SYMDEF_SIZE, arch)
+ != BSD_SYMDEF_SIZE)
return false;
}
/* Now write the strings themselves. */
- bfd_h_put_32 (arch, stringsize, temp);
- if (bfd_write (temp, 1, sizeof (temp), arch) != sizeof (temp))
+ H_PUT_32 (arch, stringsize, temp);
+ if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), arch) != sizeof (temp))
return false;
for (count = 0; count < orl_count; count++)
{
size_t len = strlen (*map[count].name) + 1;
- if (bfd_write (*map[count].name, 1, len, arch) != len)
+ if (bfd_bwrite (*map[count].name, (bfd_size_type) len, arch) != len)
return false;
}
bug-compatible for sun's ar we use a null. */
if (padit)
{
- if (bfd_write ("", 1, 1, arch) != 1)
+ if (bfd_bwrite ("", (bfd_size_type) 1, arch) != 1)
return false;
}
bfd_ardata (arch)->armap_datepos = (SARMAG
+ offsetof (struct ar_hdr, ar_date[0]));
if (bfd_seek (arch, bfd_ardata (arch)->armap_datepos, SEEK_SET) != 0
- || (bfd_write (hdr.ar_date, sizeof (hdr.ar_date), 1, arch)
+ || (bfd_bwrite (hdr.ar_date, (bfd_size_type) sizeof (hdr.ar_date), arch)
!= sizeof (hdr.ar_date)))
{
/* FIXME: bfd can't call perror. */
unsigned int ranlibsize = (symbol_count * 4) + 4;
unsigned int stringsize = stridx;
unsigned int mapsize = stringsize + ranlibsize;
- file_ptr archive_member_file_ptr;
+ unsigned int archive_member_file_ptr;
bfd *current = arch->archive_head;
unsigned int count;
struct ar_hdr hdr;
/* Write the ar header for this item and the number of symbols. */
- if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), arch)
+ if (bfd_bwrite ((PTR) &hdr, (bfd_size_type) sizeof (struct ar_hdr), arch)
!= sizeof (struct ar_hdr))
return false;
/* For each symbol which is used defined in this object, write
out the object file's address in the archive. */
- while (count < symbol_count && ((bfd *) (map[count]).pos) == current)
+ while (count < symbol_count && map[count].u.abfd == current)
{
bfd_write_bigendian_4byte_int (arch, archive_member_file_ptr);
count++;
{
size_t len = strlen (*map[count].name) + 1;
- if (bfd_write (*map[count].name, 1, len, arch) != len)
+ if (bfd_bwrite (*map[count].name, (bfd_size_type) len, arch) != len)
return false;
}
bug-compatible for arc960 we use a null. */
if (padit)
{
- if (bfd_write ("", 1, 1, arch) != 1)
+ if (bfd_bwrite ("", (bfd_size_type) 1, arch) != 1)
return false;
}
const char **name_ptr;
const char **name_list;
const bfd_arch_info_type * const *app;
+ bfd_size_type amt;
/* Determine the number of architectures. */
vec_length = 0;
}
}
- name_list = (const char **)
- bfd_malloc ((vec_length + 1) * sizeof (char **));
+ amt = (vec_length + 1) * sizeof (char **);
+ name_list = (const char **) bfd_malloc (amt);
if (name_list == NULL)
return NULL;
printable_name_colon = strchr (info->printable_name, ':');
if (printable_name_colon == NULL)
{
- int strlen_arch_name = strlen (info->arch_name);
+ size_t strlen_arch_name = strlen (info->arch_name);
if (strncasecmp (string, info->arch_name, strlen_arch_name) == 0)
{
if (string[strlen_arch_name] == ':')
Attempt to match: <arch> <mach>? */
if (printable_name_colon != NULL)
{
- int colon_index = printable_name_colon - info->printable_name;
+ size_t colon_index = printable_name_colon - info->printable_name;
if (strncasecmp (string, info->printable_name, colon_index) == 0
&& strcasecmp (string + colon_index,
info->printable_name + colon_index + 1) == 0)
typedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean;
#endif
-/* A pointer to a position in a file. */
-/* FIXME: This should be using off_t from <sys/types.h>.
- For now, try to avoid breaking stuff by not including <sys/types.h> here.
- This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
- Probably the best long-term answer is to avoid using file_ptr AND off_t
- in this header file, and to handle this in the BFD implementation
- rather than in its interface. */
-/* typedef off_t file_ptr; */
-typedef long int file_ptr;
-
/* Support for different sizes of target format ints and addresses.
If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be
set to 1 above. Otherwise, if gcc is being used, this code will
#endif /* not BFD64 */
+/* A pointer to a position in a file. */
+/* FIXME: This should be using off_t from <sys/types.h>.
+ For now, try to avoid breaking stuff by not including <sys/types.h> here.
+ This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
+ Probably the best long-term answer is to avoid using file_ptr AND off_t
+ in this header file, and to handle this in the BFD implementation
+ rather than in its interface. */
+/* typedef off_t file_ptr; */
+typedef bfd_signed_vma file_ptr;
+typedef bfd_vma ufile_ptr;
+
extern void bfd_sprintf_vma PARAMS ((bfd *, char *, bfd_vma));
extern void bfd_fprintf_vma PARAMS ((bfd *, PTR, bfd_vma));
Perhaps just a forward definition would do? */
struct orl { /* output ranlib */
char **name; /* symbol name */
- file_ptr pos; /* bfd* or file position */
+ union {
+ file_ptr pos;
+ bfd *abfd;
+ } u; /* bfd* or file position */
int namidx; /* index into string table */
};
\f
{
symvalue value;
char type;
- CONST char *name; /* Symbol name. */
+ const char *name; /* Symbol name. */
unsigned char stab_type; /* Stab type. */
char stab_other; /* Stab other. */
short stab_desc; /* Stab desc. */
- CONST char *stab_name; /* String for stab type. */
+ const char *stab_name; /* String for stab type. */
} symbol_info;
/* Get the name of a stabs type code. */
/* Direct I/O routines, for programs which know more about the object
file than BFD does. Use higher level routines if possible. */
-extern bfd_size_type bfd_read
- PARAMS ((PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
-extern bfd_size_type bfd_write
- PARAMS ((const PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
-extern int bfd_seek PARAMS ((bfd *abfd, file_ptr fp, int direction));
-extern long bfd_tell PARAMS ((bfd *abfd));
-extern int bfd_flush PARAMS ((bfd *abfd));
-extern int bfd_stat PARAMS ((bfd *abfd, struct stat *));
+extern bfd_size_type bfd_bread PARAMS ((PTR, bfd_size_type, bfd *));
+extern bfd_size_type bfd_bwrite PARAMS ((const PTR, bfd_size_type, bfd *));
+extern int bfd_seek PARAMS ((bfd *, file_ptr, int));
+extern ufile_ptr bfd_tell PARAMS ((bfd *));
+extern int bfd_flush PARAMS ((bfd *));
+extern int bfd_stat PARAMS ((bfd *, struct stat *));
+
+/* Deprecated old routines. */
+#if __GNUC__
+#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
+ (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__), \
+ bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
+#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
+ (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__), \
+ bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
+#else
+#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
+ (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
+ bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
+#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
+ (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
+ bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
+#endif
+extern void warn_deprecated
+ PARAMS ((const char *, const char *, int, const char *));
/* Cast from const char * to char * so that caller can assign to
a char * without a warning. */
typedef enum bfd_boolean {bfd_fffalse, bfd_tttrue} boolean;
#endif
-/* A pointer to a position in a file. */
-/* FIXME: This should be using off_t from <sys/types.h>.
- For now, try to avoid breaking stuff by not including <sys/types.h> here.
- This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
- Probably the best long-term answer is to avoid using file_ptr AND off_t
- in this header file, and to handle this in the BFD implementation
- rather than in its interface. */
-/* typedef off_t file_ptr; */
-typedef long int file_ptr;
-
/* Support for different sizes of target format ints and addresses.
If the type `long' is at least 64 bits, BFD_HOST_64BIT_LONG will be
set to 1 above. Otherwise, if gcc is being used, this code will
#endif /* not BFD64 */
+/* A pointer to a position in a file. */
+/* FIXME: This should be using off_t from <sys/types.h>.
+ For now, try to avoid breaking stuff by not including <sys/types.h> here.
+ This will break on systems with 64-bit file offsets (e.g. 4.4BSD).
+ Probably the best long-term answer is to avoid using file_ptr AND off_t
+ in this header file, and to handle this in the BFD implementation
+ rather than in its interface. */
+/* typedef off_t file_ptr; */
+typedef bfd_signed_vma file_ptr;
+typedef bfd_vma ufile_ptr;
+
extern void bfd_sprintf_vma PARAMS ((bfd *, char *, bfd_vma));
extern void bfd_fprintf_vma PARAMS ((bfd *, PTR, bfd_vma));
Perhaps just a forward definition would do? */
struct orl { /* output ranlib */
char **name; /* symbol name */
- file_ptr pos; /* bfd* or file position */
+ union {
+ file_ptr pos;
+ bfd *abfd;
+ } u; /* bfd* or file position */
int namidx; /* index into string table */
};
\f
{
symvalue value;
char type;
- CONST char *name; /* Symbol name. */
+ const char *name; /* Symbol name. */
unsigned char stab_type; /* Stab type. */
char stab_other; /* Stab other. */
short stab_desc; /* Stab desc. */
- CONST char *stab_name; /* String for stab type. */
+ const char *stab_name; /* String for stab type. */
} symbol_info;
/* Get the name of a stabs type code. */
/* Direct I/O routines, for programs which know more about the object
file than BFD does. Use higher level routines if possible. */
-extern bfd_size_type bfd_read
- PARAMS ((PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
-extern bfd_size_type bfd_write
- PARAMS ((const PTR, bfd_size_type size, bfd_size_type nitems, bfd *abfd));
-extern int bfd_seek PARAMS ((bfd *abfd, file_ptr fp, int direction));
-extern long bfd_tell PARAMS ((bfd *abfd));
-extern int bfd_flush PARAMS ((bfd *abfd));
-extern int bfd_stat PARAMS ((bfd *abfd, struct stat *));
+extern bfd_size_type bfd_bread PARAMS ((PTR, bfd_size_type, bfd *));
+extern bfd_size_type bfd_bwrite PARAMS ((const PTR, bfd_size_type, bfd *));
+extern int bfd_seek PARAMS ((bfd *, file_ptr, int));
+extern ufile_ptr bfd_tell PARAMS ((bfd *));
+extern int bfd_flush PARAMS ((bfd *));
+extern int bfd_stat PARAMS ((bfd *, struct stat *));
+
+/* Deprecated old routines. */
+#if __GNUC__
+#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
+ (warn_deprecated ("bfd_read", __FILE__, __LINE__, __FUNCTION__), \
+ bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
+#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
+ (warn_deprecated ("bfd_write", __FILE__, __LINE__, __FUNCTION__), \
+ bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
+#else
+#define bfd_read(BUF, ELTSIZE, NITEMS, ABFD) \
+ (warn_deprecated ("bfd_read", (const char *) 0, 0, (const char *) 0), \
+ bfd_bread ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
+#define bfd_write(BUF, ELTSIZE, NITEMS, ABFD) \
+ (warn_deprecated ("bfd_write", (const char *) 0, 0, (const char *) 0),\
+ bfd_bwrite ((BUF), (ELTSIZE) * (NITEMS), (ABFD)))
+#endif
+extern void warn_deprecated
+ PARAMS ((const char *, const char *, int, const char *));
/* Cast from const char * to char * so that caller can assign to
a char * without a warning. */
bfd_init PARAMS ((void));
bfd *
-bfd_openr PARAMS ((CONST char *filename, CONST char *target));
+bfd_openr PARAMS ((const char *filename, const char *target));
bfd *
-bfd_fdopenr PARAMS ((CONST char *filename, CONST char *target, int fd));
+bfd_fdopenr PARAMS ((const char *filename, const char *target, int fd));
bfd *
bfd_openstreamr PARAMS ((const char *, const char *, PTR));
bfd *
-bfd_openw PARAMS ((CONST char *filename, CONST char *target));
+bfd_openw PARAMS ((const char *filename, const char *target));
boolean
bfd_close PARAMS ((bfd *abfd));
bfd_close_all_done PARAMS ((bfd *));
bfd *
-bfd_create PARAMS ((CONST char *filename, bfd *templ));
+bfd_create PARAMS ((const char *filename, bfd *templ));
boolean
bfd_make_writable PARAMS ((bfd *abfd));
#define bfd_put_signed_8 \
bfd_put_8
#define bfd_get_8(abfd, ptr) \
- (*(unsigned char *) (ptr))
+ (*(unsigned char *) (ptr) & 0xff)
#define bfd_get_signed_8(abfd, ptr) \
- ((*(unsigned char *) (ptr) ^ 0x80) - 0x80)
+ (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80)
#define bfd_put_16(abfd, val, ptr) \
BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
/* Byte swapping macros for file header data. */
#define bfd_h_put_8(abfd, val, ptr) \
- bfd_put_8 (abfd, val, ptr)
+ bfd_put_8 (abfd, val, ptr)
#define bfd_h_put_signed_8(abfd, val, ptr) \
- bfd_put_8 (abfd, val, ptr)
+ bfd_put_8 (abfd, val, ptr)
#define bfd_h_get_8(abfd, ptr) \
- bfd_get_8 (abfd, ptr)
+ bfd_get_8 (abfd, ptr)
#define bfd_h_get_signed_8(abfd, ptr) \
- bfd_get_signed_8 (abfd, ptr)
+ bfd_get_signed_8 (abfd, ptr)
#define bfd_h_put_16(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
+ BFD_SEND (abfd, bfd_h_putx16, (val, ptr))
#define bfd_h_put_signed_16 \
- bfd_h_put_16
+ bfd_h_put_16
#define bfd_h_get_16(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx16,(ptr))
+ BFD_SEND (abfd, bfd_h_getx16, (ptr))
#define bfd_h_get_signed_16(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr))
+ BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr))
#define bfd_h_put_32(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
+ BFD_SEND (abfd, bfd_h_putx32, (val, ptr))
#define bfd_h_put_signed_32 \
- bfd_h_put_32
+ bfd_h_put_32
#define bfd_h_get_32(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx32,(ptr))
+ BFD_SEND (abfd, bfd_h_getx32, (ptr))
#define bfd_h_get_signed_32(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr))
+ BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr))
#define bfd_h_put_64(abfd, val, ptr) \
- BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
+ BFD_SEND (abfd, bfd_h_putx64, (val, ptr))
#define bfd_h_put_signed_64 \
- bfd_h_put_64
+ bfd_h_put_64
#define bfd_h_get_64(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx64,(ptr))
+ BFD_SEND (abfd, bfd_h_getx64, (ptr))
#define bfd_h_get_signed_64(abfd, ptr) \
- BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr))
+ BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr))
+
+/* Refinements on the above, which should eventually go away. Save
+ cluttering the source with (bfd_vma) and (bfd_byte *) casts. */
+
+#define H_PUT_64(abfd, val, where) \
+ bfd_h_put_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+
+#define H_PUT_32(abfd, val, where) \
+ bfd_h_put_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+
+#define H_PUT_16(abfd, val, where) \
+ bfd_h_put_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+
+#define H_PUT_8 bfd_h_put_8
+
+#define H_PUT_S64(abfd, val, where) \
+ bfd_h_put_signed_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+
+#define H_PUT_S32(abfd, val, where) \
+ bfd_h_put_signed_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+
+#define H_PUT_S16(abfd, val, where) \
+ bfd_h_put_signed_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+
+#define H_PUT_S8 bfd_h_put_signed_8
+
+#define H_GET_64(abfd, where) \
+ bfd_h_get_64 ((abfd), (bfd_byte *) (where))
+
+#define H_GET_32(abfd, where) \
+ bfd_h_get_32 ((abfd), (bfd_byte *) (where))
+
+#define H_GET_16(abfd, where) \
+ bfd_h_get_16 ((abfd), (bfd_byte *) (where))
+
+#define H_GET_8 bfd_h_get_8
+
+#define H_GET_S64(abfd, where) \
+ bfd_h_get_signed_64 ((abfd), (bfd_byte *) (where))
+
+#define H_GET_S32(abfd, where) \
+ bfd_h_get_signed_32 ((abfd), (bfd_byte *) (where))
+
+#define H_GET_S16(abfd, where) \
+ bfd_h_get_signed_16 ((abfd), (bfd_byte *) (where))
+
+#define H_GET_S8 bfd_h_get_signed_8
+
/* This structure is used for a comdat section, as in PE. A comdat
section is associated with a particular symbol. When the linker
bfd_set_section_size PARAMS ((bfd *abfd, asection *sec, bfd_size_type val));
boolean
-bfd_set_section_contents PARAMS ((bfd *abfd,
- asection *section,
- PTR data,
- file_ptr offset,
+bfd_set_section_contents PARAMS ((bfd *abfd, asection *section,
+ PTR data, file_ptr offset,
bfd_size_type count));
boolean
-bfd_get_section_contents PARAMS ((bfd *abfd, asection *section, PTR location,
- file_ptr offset, bfd_size_type count));
+bfd_get_section_contents PARAMS ((bfd *abfd, asection *section,
+ PTR location, file_ptr offset,
+ bfd_size_type count));
boolean
-bfd_copy_private_section_data PARAMS ((bfd *ibfd, asection *isec, bfd *obfd, asection *osec));
+bfd_copy_private_section_data PARAMS ((bfd *ibfd, asection *isec,
+ bfd *obfd, asection *osec));
#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
BFD_SEND (obfd, _bfd_copy_private_section_data, \
typedef enum bfd_reloc_status
{
- /* No errors detected */
+ /* No errors detected */
bfd_reloc_ok,
- /* The relocation was performed, but there was an overflow. */
+ /* The relocation was performed, but there was an overflow. */
bfd_reloc_overflow,
- /* The address to relocate was not within the section supplied. */
+ /* The address to relocate was not within the section supplied. */
bfd_reloc_outofrange,
- /* Used by special functions */
+ /* Used by special functions */
bfd_reloc_continue,
- /* Unsupported relocation size requested. */
+ /* Unsupported relocation size requested. */
bfd_reloc_notsupported,
- /* Unused */
+ /* Unused */
bfd_reloc_other,
- /* The symbol to relocate against was undefined. */
+ /* The symbol to relocate against was undefined. */
bfd_reloc_undefined,
- /* The relocation was performed, but may not be ok - presently
- generated only when linking i960 coff files with i960 b.out
- symbols. If this type is returned, the error_message argument
- to bfd_perform_relocation will be set. */
+ /* The relocation was performed, but may not be ok - presently
+ generated only when linking i960 coff files with i960 b.out
+ symbols. If this type is returned, the error_message argument
+ to bfd_perform_relocation will be set. */
bfd_reloc_dangerous
}
bfd_reloc_status_type;
typedef struct reloc_cache_entry
{
- /* A pointer into the canonical table of pointers */
+ /* A pointer into the canonical table of pointers */
struct symbol_cache_entry **sym_ptr_ptr;
- /* offset in section */
+ /* offset in section */
bfd_size_type address;
- /* addend for relocation value */
+ /* addend for relocation value */
bfd_vma addend;
- /* Pointer to how to perform the required relocation */
+ /* Pointer to how to perform the required relocation */
reloc_howto_type *howto;
} arelent;
enum complain_overflow
{
- /* Do not complain on overflow. */
+ /* Do not complain on overflow. */
complain_overflow_dont,
- /* Complain if the bitfield overflows, whether it is considered
- as signed or unsigned. */
+ /* Complain if the bitfield overflows, whether it is considered
+ as signed or unsigned. */
complain_overflow_bitfield,
- /* Complain if the value overflows when considered as signed
- number. */
+ /* Complain if the value overflows when considered as signed
+ number. */
complain_overflow_signed,
- /* Complain if the value overflows when considered as an
- unsigned number. */
+ /* Complain if the value overflows when considered as an
+ unsigned number. */
complain_overflow_unsigned
};
struct reloc_howto_struct
{
- /* The type field has mainly a documentary use - the back end can
- do what it wants with it, though normally the back end's
- external idea of what a reloc number is stored
- in this field. For example, a PC relative word relocation
- in a coff environment has the type 023 - because that's
- what the outside world calls a R_PCRWORD reloc. */
+ /* The type field has mainly a documentary use - the back end can
+ do what it wants with it, though normally the back end's
+ external idea of what a reloc number is stored
+ in this field. For example, a PC relative word relocation
+ in a coff environment has the type 023 - because that's
+ what the outside world calls a R_PCRWORD reloc. */
unsigned int type;
- /* The value the final relocation is shifted right by. This drops
- unwanted data from the relocation. */
+ /* The value the final relocation is shifted right by. This drops
+ unwanted data from the relocation. */
unsigned int rightshift;
- /* The size of the item to be relocated. This is *not* a
- power-of-two measure. To get the number of bytes operated
- on by a type of relocation, use bfd_get_reloc_size. */
+ /* The size of the item to be relocated. This is *not* a
+ power-of-two measure. To get the number of bytes operated
+ on by a type of relocation, use bfd_get_reloc_size. */
int size;
- /* The number of bits in the item to be relocated. This is used
- when doing overflow checking. */
+ /* The number of bits in the item to be relocated. This is used
+ when doing overflow checking. */
unsigned int bitsize;
- /* Notes that the relocation is relative to the location in the
- data section of the addend. The relocation function will
- subtract from the relocation value the address of the location
- being relocated. */
+ /* Notes that the relocation is relative to the location in the
+ data section of the addend. The relocation function will
+ subtract from the relocation value the address of the location
+ being relocated. */
boolean pc_relative;
- /* The bit position of the reloc value in the destination.
- The relocated value is left shifted by this amount. */
+ /* The bit position of the reloc value in the destination.
+ The relocated value is left shifted by this amount. */
unsigned int bitpos;
- /* What type of overflow error should be checked for when
- relocating. */
+ /* What type of overflow error should be checked for when
+ relocating. */
enum complain_overflow complain_on_overflow;
- /* If this field is non null, then the supplied function is
- called rather than the normal function. This allows really
- strange relocation methods to be accomodated (e.g., i960 callj
- instructions). */
+ /* If this field is non null, then the supplied function is
+ called rather than the normal function. This allows really
+ strange relocation methods to be accomodated (e.g., i960 callj
+ instructions). */
bfd_reloc_status_type (*special_function)
- PARAMS ((bfd *abfd,
- arelent *reloc_entry,
- struct symbol_cache_entry *symbol,
- PTR data,
- asection *input_section,
- bfd *output_bfd,
- char **error_message));
-
- /* The textual name of the relocation type. */
+ PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR, asection *,
+ bfd *, char **));
+
+ /* The textual name of the relocation type. */
char *name;
- /* Some formats record a relocation addend in the section contents
- rather than with the relocation. For ELF formats this is the
- distinction between USE_REL and USE_RELA (though the code checks
- for USE_REL == 1/0). The value of this field is TRUE if the
- addend is recorded with the section contents; when performing a
- partial link (ld -r) the section contents (the data) will be
- modified. The value of this field is FALSE if addends are
- recorded with the relocation (in arelent.addend); when performing
- a partial link the relocation will be modified.
- All relocations for all ELF USE_RELA targets should set this field
- to FALSE (values of TRUE should be looked on with suspicion).
- However, the converse is not true: not all relocations of all ELF
- USE_REL targets set this field to TRUE. Why this is so is peculiar
- to each particular target. For relocs that aren't used in partial
- links (e.g. GOT stuff) it doesn't matter what this is set to. */
+ /* Some formats record a relocation addend in the section contents
+ rather than with the relocation. For ELF formats this is the
+ distinction between USE_REL and USE_RELA (though the code checks
+ for USE_REL == 1/0). The value of this field is TRUE if the
+ addend is recorded with the section contents; when performing a
+ partial link (ld -r) the section contents (the data) will be
+ modified. The value of this field is FALSE if addends are
+ recorded with the relocation (in arelent.addend); when performing
+ a partial link the relocation will be modified.
+ All relocations for all ELF USE_RELA targets should set this field
+ to FALSE (values of TRUE should be looked on with suspicion).
+ However, the converse is not true: not all relocations of all ELF
+ USE_REL targets set this field to TRUE. Why this is so is peculiar
+ to each particular target. For relocs that aren't used in partial
+ links (e.g. GOT stuff) it doesn't matter what this is set to. */
boolean partial_inplace;
- /* The src_mask selects which parts of the read in data
- are to be used in the relocation sum. E.g., if this was an 8 bit
- byte of data which we read and relocated, this would be
- 0x000000ff. When we have relocs which have an addend, such as
- sun4 extended relocs, the value in the offset part of a
- relocating field is garbage so we never use it. In this case
- the mask would be 0x00000000. */
+ /* The src_mask selects which parts of the read in data
+ are to be used in the relocation sum. E.g., if this was an 8 bit
+ byte of data which we read and relocated, this would be
+ 0x000000ff. When we have relocs which have an addend, such as
+ sun4 extended relocs, the value in the offset part of a
+ relocating field is garbage so we never use it. In this case
+ the mask would be 0x00000000. */
bfd_vma src_mask;
- /* The dst_mask selects which parts of the instruction are replaced
- into the instruction. In most cases src_mask == dst_mask,
- except in the above special case, where dst_mask would be
- 0x000000ff, and src_mask would be 0x00000000. */
+ /* The dst_mask selects which parts of the instruction are replaced
+ into the instruction. In most cases src_mask == dst_mask,
+ except in the above special case, where dst_mask would be
+ 0x000000ff, and src_mask would be 0x00000000. */
bfd_vma dst_mask;
- /* When some formats create PC relative instructions, they leave
- the value of the pc of the place being relocated in the offset
- slot of the instruction, so that a PC relative relocation can
- be made just by adding in an ordinary offset (e.g., sun3 a.out).
- Some formats leave the displacement part of an instruction
- empty (e.g., m88k bcs); this flag signals the fact.*/
+ /* When some formats create PC relative instructions, they leave
+ the value of the pc of the place being relocated in the offset
+ slot of the instruction, so that a PC relative relocation can
+ be made just by adding in an ordinary offset (e.g., sun3 a.out).
+ Some formats leave the displacement part of an instruction
+ empty (e.g., m88k bcs); this flag signals the fact. */
boolean pcrel_offset;
-
};
-#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
- {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
-#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN)
+#define HOWTO(C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
+ { (unsigned) C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC }
+#define NEWHOWTO(FUNCTION, NAME, SIZE, REL, IN) \
+ HOWTO (0, 0, SIZE, 0, REL, 0, complain_overflow_dont, FUNCTION, \
+ NAME, false, 0, 0, IN)
#define EMPTY_HOWTO(C) \
- HOWTO((C),0,0,0,false,0,complain_overflow_dont,NULL,NULL,false,0,0,false)
-
-#define HOWTO_PREPARE(relocation, symbol) \
- { \
- if (symbol != (asymbol *)NULL) { \
- if (bfd_is_com_section (symbol->section)) { \
- relocation = 0; \
- } \
- else { \
- relocation = symbol->value; \
- } \
- } \
-}
+ HOWTO ((C), 0, 0, 0, false, 0, complain_overflow_dont, NULL, \
+ NULL, false, 0, 0, false)
+
+#define HOWTO_PREPARE(relocation, symbol) \
+ { \
+ if (symbol != (asymbol *) NULL) \
+ { \
+ if (bfd_is_com_section (symbol->section)) \
+ { \
+ relocation = 0; \
+ } \
+ else \
+ { \
+ relocation = symbol->value; \
+ } \
+ } \
+ }
unsigned int
bfd_get_reloc_size PARAMS ((reloc_howto_type *));
-typedef struct relent_chain {
+typedef struct relent_chain
+{
arelent relent;
- struct relent_chain *next;
+ struct relent_chain *next;
} arelent_chain;
bfd_reloc_status_type
bfd_check_overflow PARAMS ((enum complain_overflow how,
which is filled by the linker. */
BFD_RELOC_ALPHA_CODEADDR,
-/* The GPREL_HI/LO relocations together form a 32-bit offset from the
+/* The GPREL_HI/LO relocations together form a 32-bit offset from the
GP register. */
BFD_RELOC_ALPHA_GPREL_HI16,
BFD_RELOC_ALPHA_GPREL_LO16,
BFD_RELOC_PPC64_TOC16_HI,
BFD_RELOC_PPC64_TOC16_HA,
BFD_RELOC_PPC64_TOC,
- BFD_RELOC_PPC64_PLTGOT16 ,
+ BFD_RELOC_PPC64_PLTGOT16,
BFD_RELOC_PPC64_PLTGOT16_LO,
BFD_RELOC_PPC64_PLTGOT16_HI,
BFD_RELOC_PPC64_PLTGOT16_HA,
/* The text of the symbol. The name is left alone, and not copied; the
application may not alter it. */
- CONST char *name;
+ const char *name;
/* The value of the symbol. This really should be a union of a
numeric value with a pointer, since some flags indicate that
/* When a file is closed by the caching routines, BFD retains
state information on the file here: */
- file_ptr where;
+ ufile_ptr where;
/* and here: (``once'' means at least once) */
anything. I believe that this can become always an add of
origin, with origin set to 0 for non archive files. */
- file_ptr origin;
+ ufile_ptr origin;
/* Remember when output has begun, to stop strange things
from happening. */
bfd *
bfd_openr_next_archived_file PARAMS ((bfd *archive, bfd *previous));
-CONST char *
+const char *
bfd_core_file_failing_command PARAMS ((bfd *abfd));
int
char symbol_leading_char;
char ar_pad_char;
unsigned short ar_max_namelen;
- bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
+ bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *));
- void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *));
+ void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
+ bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *));
bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *));
- void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *));
+ void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
+ bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *));
bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *));
- void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *));
+ void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
+ bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *));
bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *));
- void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *));
+ void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
+ bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *));
bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *));
- void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
- bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *));
+ void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
+ bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *));
bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *));
- void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
+ void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
const struct bfd_target *(*_bfd_check_format[bfd_type_end]) PARAMS ((bfd *));
- boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
- boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
+ boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
+ boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
/* Generic entry points. */
#define BFD_JUMP_TABLE_GENERIC(NAME)\
CAT(NAME,_get_section_contents_in_window)
/* Called when the BFD is being closed to do any necessary cleanup. */
- boolean (*_close_and_cleanup) PARAMS ((bfd *));
+ boolean (*_close_and_cleanup) PARAMS ((bfd *));
/* Ask the BFD to free all cached information. */
- boolean (*_bfd_free_cached_info) PARAMS ((bfd *));
+ boolean (*_bfd_free_cached_info) PARAMS ((bfd *));
/* Called when a new section is created. */
- boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
+ boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
/* Read the contents of a section. */
- boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
- file_ptr, bfd_size_type));
- boolean (*_bfd_get_section_contents_in_window)
- PARAMS ((bfd *, sec_ptr, bfd_window *,
- file_ptr, bfd_size_type));
+ boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
+ file_ptr, bfd_size_type));
+ boolean (*_bfd_get_section_contents_in_window)
+ PARAMS ((bfd *, sec_ptr, bfd_window *, file_ptr, bfd_size_type));
/* Entry points to copy private data. */
#define BFD_JUMP_TABLE_COPY(NAME)\
CAT(NAME,_bfd_print_private_bfd_data)\
/* Called to copy BFD general private data from one object file
to another. */
- boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *));
+ boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *));
/* Called to merge BFD general private data from one object file
to a common output file when linking. */
- boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *));
+ boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *));
/* Called to copy BFD private section data from one object file
to another. */
- boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr,
- bfd *, sec_ptr));
+ boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr,
+ bfd *, sec_ptr));
/* Called to copy BFD private symbol data from one symbol
to another. */
- boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *,
- bfd *, asymbol *));
+ boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *,
+ bfd *, asymbol *));
/* Called to set private backend flags */
- boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
+ boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
/* Called to print private BFD data */
- boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
+ boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
/* Core file entry points. */
#define BFD_JUMP_TABLE_CORE(NAME)\
boolean (*_bfd_slurp_armap) PARAMS ((bfd *));
boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *));
boolean (*_bfd_construct_extended_name_table)
- PARAMS ((bfd *, char **, bfd_size_type *, const char **));
- void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *));
- boolean (*write_armap) PARAMS ((bfd *arch,
- unsigned int elength,
- struct orl *map,
- unsigned int orl_count,
- int stridx));
- PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *));
- bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev));
+ PARAMS ((bfd *, char **, bfd_size_type *, const char **));
+ void (*_bfd_truncate_arname) PARAMS ((bfd *, const char *, char *));
+ boolean (*write_armap)
+ PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
+ PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *));
+ bfd * (*openr_next_archived_file) PARAMS ((bfd *, bfd *));
#define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i))
bfd * (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex));
int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *));
CAT(NAME,_bfd_make_debug_symbol),\
CAT(NAME,_read_minisymbols),\
CAT(NAME,_minisymbol_to_symbol)
- long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *));
- long (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
- struct symbol_cache_entry **));
- struct symbol_cache_entry *
- (*_bfd_make_empty_symbol) PARAMS ((bfd *));
- void (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
- struct symbol_cache_entry *,
- bfd_print_symbol_type));
+ long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *));
+ long (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
+ struct symbol_cache_entry **));
+ struct symbol_cache_entry *
+ (*_bfd_make_empty_symbol) PARAMS ((bfd *));
+ void (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
+ struct symbol_cache_entry *,
+ bfd_print_symbol_type));
#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
- void (*_bfd_get_symbol_info) PARAMS ((bfd *,
- struct symbol_cache_entry *,
- symbol_info *));
+ void (*_bfd_get_symbol_info) PARAMS ((bfd *,
+ struct symbol_cache_entry *,
+ symbol_info *));
#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e))
- boolean (*_bfd_is_local_label_name) PARAMS ((bfd *, const char *));
+ boolean (*_bfd_is_local_label_name) PARAMS ((bfd *, const char *));
- alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
- boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd,
- struct sec *section, struct symbol_cache_entry **symbols,
- bfd_vma offset, CONST char **file, CONST char **func,
- unsigned int *line));
+ alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
+ boolean (*_bfd_find_nearest_line)
+ PARAMS ((bfd *, struct sec *, struct symbol_cache_entry **, bfd_vma,
+ const char **, const char **, unsigned int *));
/* Back-door to allow format-aware applications to create debug symbols
while using BFD for everything else. Currently used by the assembler
when creating COFF files. */
- asymbol * (*_bfd_make_debug_symbol) PARAMS ((
- bfd *abfd,
- void *ptr,
- unsigned long size));
+ asymbol *(*_bfd_make_debug_symbol) PARAMS ((bfd *, void *,
+ unsigned long size));
#define bfd_read_minisymbols(b, d, m, s) \
BFD_SEND (b, _read_minisymbols, (b, d, m, s))
- long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *,
- unsigned int *));
+ long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *,
+ unsigned int *));
#define bfd_minisymbol_to_symbol(b, d, m, f) \
BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
asymbol *(*_minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
CAT(NAME,_get_reloc_upper_bound),\
CAT(NAME,_canonicalize_reloc),\
CAT(NAME,_bfd_reloc_type_lookup)
- long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
- long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
- struct symbol_cache_entry **));
+ long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
+ long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
+ struct symbol_cache_entry **));
/* See documentation on reloc types. */
reloc_howto_type *
- (*reloc_type_lookup) PARAMS ((bfd *abfd,
- bfd_reloc_code_real_type code));
+ (*reloc_type_lookup) PARAMS ((bfd *, bfd_reloc_code_real_type));
/* Routines used when writing an object file. */
#define BFD_JUMP_TABLE_WRITE(NAME)\
CAT(NAME,_set_arch_mach),\
CAT(NAME,_set_section_contents)
- boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
- unsigned long));
- boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
- file_ptr, bfd_size_type));
+ boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
+ unsigned long));
+ boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
+ file_ptr, bfd_size_type));
/* Routines used by the linker. */
#define BFD_JUMP_TABLE_LINK(NAME)\
CAT(NAME,_bfd_link_split_section),\
CAT(NAME,_bfd_gc_sections),\
CAT(NAME,_bfd_merge_sections)
- int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
- bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *,
- struct bfd_link_info *, struct bfd_link_order *,
- bfd_byte *data, boolean relocateable,
- struct symbol_cache_entry **));
+ int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
+ bfd_byte *(*_bfd_get_relocated_section_contents)
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
+ bfd_byte *, boolean, struct symbol_cache_entry **));
- boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *,
- struct bfd_link_info *, boolean *again));
+ boolean (*_bfd_relax_section)
+ PARAMS ((bfd *, struct sec *, struct bfd_link_info *, boolean *));
/* Create a hash table for the linker. Different backends store
different information in this table. */
struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *));
/* Add symbols from this object file into the hash table. */
- boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
+ boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
/* Do a link based on the link_order structures attached to each
section of the BFD. */
- boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
+ boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
/* Should this section be split up into smaller pieces during linking. */
- boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *));
+ boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *));
/* Remove sections that are not referenced from the output. */
- boolean (*_bfd_gc_sections) PARAMS ((bfd *, struct bfd_link_info *));
+ boolean (*_bfd_gc_sections) PARAMS ((bfd *, struct bfd_link_info *));
/* Attempt to merge SEC_MERGE sections. */
- boolean (*_bfd_merge_sections) PARAMS ((bfd *, struct bfd_link_info *));
+ boolean (*_bfd_merge_sections) PARAMS ((bfd *, struct bfd_link_info *));
/* Routines to handle dynamic symbols and relocs. */
#define BFD_JUMP_TABLE_DYNAMIC(NAME)\
CAT(NAME,_get_dynamic_reloc_upper_bound),\
CAT(NAME,_canonicalize_dynamic_reloc)
/* Get the amount of memory required to hold the dynamic symbols. */
- long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *));
+ long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *));
/* Read in the dynamic symbols. */
- long (*_bfd_canonicalize_dynamic_symtab)
+ long (*_bfd_canonicalize_dynamic_symtab)
PARAMS ((bfd *, struct symbol_cache_entry **));
/* Get the amount of memory required to hold the dynamic relocs. */
- long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *));
+ long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *));
/* Read in the dynamic relocs. */
- long (*_bfd_canonicalize_dynamic_reloc)
+ long (*_bfd_canonicalize_dynamic_reloc)
PARAMS ((bfd *, arelent **, struct symbol_cache_entry **));
/* Opposite endian version of this target. */
bfd_set_default_target PARAMS ((const char *name));
const bfd_target *
-bfd_find_target PARAMS ((CONST char *target_name, bfd *abfd));
+bfd_find_target PARAMS ((const char *target_name, bfd *abfd));
const char **
bfd_target_list PARAMS ((void));
. {* When a file is closed by the caching routines, BFD retains
. state information on the file here: *}
.
-. file_ptr where;
+. ufile_ptr where;
.
. {* and here: (``once'' means at least once) *}
.
. anything. I believe that this can become always an add of
. origin, with origin set to 0 for non archive files. *}
.
-. file_ptr origin;
+. ufile_ptr origin;
.
. {* Remember when output has begun, to stop strange things
. from happening. *}
asection **secs;
{
struct elf_segment_map *m, **pm;
+ bfd_size_type amt;
if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
return true;
- m = ((struct elf_segment_map *)
- bfd_alloc (abfd,
- (sizeof (struct elf_segment_map)
- + ((size_t) count - 1) * sizeof (asection *))));
+ amt = sizeof (struct elf_segment_map);
+ amt += ((bfd_size_type) count - 1) * sizeof (asection *);
+ m = (struct elf_segment_map *) bfd_alloc (abfd, amt);
if (m == NULL)
return false;
/* BFD back-end for binary objects.
- Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000
+ Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>
&& (bfd_external_binary_architecture != bfd_arch_unknown))
bfd_set_arch_info (abfd, bfd_lookup_arch (bfd_external_binary_architecture, 0));
}
-
+
return abfd->xvec;
}
bfd_size_type count;
{
if (bfd_seek (abfd, offset, SEEK_SET) != 0
- || bfd_read (location, 1, count, abfd) != count)
+ || bfd_bread (location, count, abfd) != count)
return false;
return true;
}
bfd *abfd;
char *suffix;
{
- int size;
+ bfd_size_type size;
char *buf;
char *p;
asection *sec = (asection *) abfd->tdata.any;
asymbol *syms;
unsigned int i;
+ bfd_size_type amt = BIN_SYMS * sizeof (asymbol);
- syms = (asymbol *) bfd_alloc (abfd, BIN_SYMS * sizeof (asymbol));
+ syms = (asymbol *) bfd_alloc (abfd, amt);
if (syms == NULL)
return false;
binary_make_empty_symbol (abfd)
bfd *abfd;
{
- return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
+ return (asymbol *) bfd_alloc (abfd, (bfd_size_type) sizeof (asymbol));
}
#define binary_print_symbol _bfd_nosymbols_print_symbol
struct external_exec *bytes = (struct external_exec *)raw_bytes;
/* Now fill in fields in the execp, from the bytes in the raw data. */
- execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
+ execp->a_info = H_GET_32 (abfd, bytes->e_info);
execp->a_text = GET_WORD (abfd, bytes->e_text);
execp->a_data = GET_WORD (abfd, bytes->e_data);
execp->a_bss = GET_WORD (abfd, bytes->e_bss);
struct external_exec *bytes = (struct external_exec *)raw_bytes;
/* Now fill in fields in the raw data, from the fields in the exec struct. */
- bfd_h_put_32 (abfd, execp->a_info , bytes->e_info);
+ H_PUT_32 (abfd, execp->a_info , bytes->e_info);
PUT_WORD (abfd, execp->a_text , bytes->e_text);
PUT_WORD (abfd, execp->a_data , bytes->e_data);
PUT_WORD (abfd, execp->a_bss , bytes->e_bss);
{
struct internal_exec anexec;
struct external_exec exec_bytes;
+ bfd_size_type amt = EXEC_BYTES_SIZE;
- if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE)
+ if (bfd_bread ((PTR) &exec_bytes, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
return 0;
}
- anexec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
+ anexec.a_info = H_GET_32 (abfd, exec_bytes.e_info);
if (N_BADMAG (anexec))
{
bfd *abfd;
{
struct bout_data_struct *rawptr;
+ bfd_size_type amt = sizeof (struct bout_data_struct);
- rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
+ rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, amt);
if (rawptr == NULL)
return false;
abfd->tdata.bout_data = rawptr;
exec_hdr (abfd) = &rawptr->e;
- obj_textsec (abfd) = (asection *)NULL;
- obj_datasec (abfd) = (asection *)NULL;
- obj_bsssec (abfd) = (asection *)NULL;
+ obj_textsec (abfd) = (asection *) NULL;
+ obj_datasec (abfd) = (asection *) NULL;
+ obj_bsssec (abfd) = (asection *) NULL;
return true;
}
bfd *abfd;
{
struct external_exec swapped_hdr;
+ bfd_size_type amt;
if (! aout_32_make_sections (abfd))
return false;
bout_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
+ amt = EXEC_BYTES_SIZE;
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE))
+ || bfd_bwrite ((PTR) &swapped_hdr, amt, abfd) != amt)
return false;
/* Now write out reloc info, followed by syms and strings */
}
if (q > outsyms)
- qsort (outsyms, q - outsyms, sizeof (asymbol*), b_out_symbol_cmp);
+ qsort (outsyms, (size_t) (q - outsyms), sizeof (asymbol*),
+ b_out_symbol_cmp);
/* Back to your regularly scheduled program. */
if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*exec_hdr(abfd))), SEEK_SET)
if (! aout_32_write_syms (abfd))
return false;
- if (bfd_seek (abfd, (file_ptr) (N_TROFF(*exec_hdr(abfd))), SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) (N_TROFF(*exec_hdr(abfd))), SEEK_SET)
+ != 0)
return false;
if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd))) return false;
BFD_ASSERT (IS_BALNAME (balsym->other));
inst &= BALX_MASK;
inst |= BALX;
- bfd_put_32 (abfd, inst, (bfd_byte *) dst-4);
+ bfd_put_32 (abfd, (bfd_vma) inst, (bfd_byte *) dst-4);
symbol = balsym;
value = (symbol->symbol.value
+ output_addr (symbol->symbol.section));
word += value + reloc_entry->addend;
- bfd_put_32 (abfd, word, dst);
+ bfd_put_32 (abfd, (bfd_vma) word, dst);
return bfd_reloc_ok;
}
- output_addr (input_section))
& BAL_MASK);
}
- bfd_put_32 (abfd, word, (bfd_byte *) data + dstidx);
+ bfd_put_32 (abfd, (bfd_vma) word, (bfd_byte *) data + dstidx);
return bfd_reloc_ok;
}
asymbol **symbols;
{
register struct relocation_info *rptr;
- unsigned int counter ;
- arelent *cache_ptr ;
+ unsigned int counter;
+ arelent *cache_ptr;
int extern_mask, pcrel_mask, callj_mask, length_shift;
int incode_mask;
int size_mask;
bfd_vma prev_addr = 0;
unsigned int count;
- size_t reloc_size;
+ bfd_size_type reloc_size, amt;
struct relocation_info *relocs;
arelent *reloc_cache;
return false;
doit:
- if (bfd_seek (abfd, (file_ptr) (asect->rel_filepos), SEEK_SET) != 0)
+ if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
return false;
count = reloc_size / sizeof (struct relocation_info);
if (!relocs && reloc_size != 0)
return false;
- reloc_cache = (arelent *) bfd_malloc ((count+1) * sizeof (arelent));
+ amt = ((bfd_size_type) count + 1) * sizeof (arelent);
+ reloc_cache = (arelent *) bfd_malloc (amt);
if (!reloc_cache)
{
if (relocs != NULL)
- free ((char*)relocs);
+ free (relocs);
return false;
}
- if (bfd_read ((PTR) relocs, 1, reloc_size, abfd) != reloc_size)
+ if (bfd_bread ((PTR) relocs, reloc_size, abfd) != reloc_size)
{
free (reloc_cache);
if (relocs != NULL)
unsigned char *raw = (unsigned char *)rptr;
unsigned int symnum;
- cache_ptr->address = bfd_h_get_32 (abfd, raw + 0);
+ cache_ptr->address = H_GET_32 (abfd, raw + 0);
cache_ptr->howto = 0;
if (bfd_header_big_endian (abfd))
int len_1;
unsigned int count = section->reloc_count;
struct relocation_info *native, *natptr;
- size_t natsize = count * sizeof (struct relocation_info);
- int extern_mask, pcrel_mask, len_2, callj_mask;
+ bfd_size_type natsize;
+ int extern_mask, pcrel_mask, len_2, callj_mask;
if (count == 0)
return true;
- generic = section->orelocation;
+ generic = section->orelocation;
+ natsize = (bfd_size_type) count * sizeof (struct relocation_info);
native = ((struct relocation_info *) bfd_malloc (natsize));
if (!native && natsize != 0)
return false;
asymbol *sym = *(g->sym_ptr_ptr);
asection *output_section = sym->section->output_section;
- bfd_h_put_32(abfd, g->address, raw);
+ H_PUT_32 (abfd, g->address, raw);
/* Find a type in the output format which matches the input howto -
at the moment we assume input format == output format FIXME!! */
r_idx = 0;
raw[7] |= extern_mask;
}
- if (bfd_write ((PTR) native, 1, natsize, abfd) != natsize)
+ if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize)
{
free ((PTR)native);
return false;
if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
return false;
- if (count != 0)
- return (bfd_write ((PTR)location, 1, count, abfd) == count) ? true : false;
+ if (count == 0)
+ return true;
- return true;
+ return bfd_bwrite ((PTR) location, count, abfd) == count;
}
static boolean
bfd_vma gap;
bfd_vma old_end;
bfd_vma new_end;
- int shrink_delta;
+ unsigned int shrink_delta;
int size = r->howto->size;
/* Reduce the size of the alignment so that it's still aligned but
/* Get enough memory to hold the stuff. */
bfd *input_bfd = i->owner;
asection *input_section = i;
- int shrink = 0 ;
+ unsigned int shrink = 0 ;
arelent **reloc_vector = NULL;
- long reloc_size = bfd_get_reloc_upper_bound(input_bfd,
- input_section);
+ long reloc_size = bfd_get_reloc_upper_bound (input_bfd,
+ input_section);
if (reloc_size < 0)
return false;
{
long reloc_count;
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
+ reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
if (reloc_vector == NULL && reloc_size != 0)
goto error_return;
link_info);
break;
case ABS32CODE_SHRUNK:
- shrink+=4;
+ shrink += 4;
break;
}
}
data, relocateable,
symbols);
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
+ reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
if (reloc_vector == NULL && reloc_size != 0)
goto error_return;
BFD_ASSERT (true == bfd_get_section_contents (input_bfd,
input_section,
data,
- 0,
+ (bfd_vma) 0,
input_section->_raw_size));
reloc_count = bfd_canonicalize_reloc (input_bfd,
break;
case ALIGNDONE:
BFD_ASSERT (reloc->addend >= src_address);
- BFD_ASSERT (reloc->addend <= input_section->_raw_size);
+ BFD_ASSERT ((bfd_vma) reloc->addend
+ <= input_section->_raw_size);
src_address = reloc->addend;
dst_address = ((dst_address + reloc->howto->size)
& ~reloc->howto->size);
+ reloc->addend)
& BAL_MASK));
- bfd_put_32 (input_bfd, word, data + dst_address);
+ bfd_put_32 (input_bfd, (bfd_vma) word, data + dst_address);
dst_address += 4;
src_address += 4;
- output_addr (input_section))
& PCREL13_MASK));
- bfd_put_32 (input_bfd, word, data + dst_address);
+ bfd_put_32 (input_bfd, (bfd_vma) word, data + dst_address);
dst_address += 4;
src_address += 4;
}
{
if (bfd_open_file (abfd) == NULL)
return NULL;
- if (fseek ((FILE *) abfd->iostream, abfd->where, SEEK_SET) != 0)
+ if (abfd->where != (unsigned long) abfd->where)
+ return NULL;
+ if (fseek ((FILE *) abfd->iostream, (long) abfd->where, SEEK_SET) != 0)
return NULL;
}
/* BFD back-end for CISCO crash dumps.
-
-Copyright 1994, 1997, 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1994, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
char database[4]; /* Base of .data section (not in V3 crash info) */
char bssbase[4]; /* Base of .bss section (not in V3 crash info) */
} crashinfo_external;
-\f
+
struct cisco_core_struct
{
int sig;
};
+
+static const bfd_target *cisco_core_file_validate PARAMS ((bfd *, int));
+static const bfd_target *cisco_core_file_p PARAMS ((bfd *));
+char *cisco_core_file_failing_command PARAMS ((bfd *));
+int cisco_core_file_failing_signal PARAMS ((bfd *));
+boolean cisco_core_file_matches_executable_p PARAMS ((bfd *, bfd *));
\f
/* Examine the file for a crash info struct at the offset given by
CRASH_INFO_LOC. */
unsigned int rambase;
sec_ptr asect;
struct stat statbuf;
+ bfd_size_type amt;
- if (bfd_seek (abfd, crash_info_loc, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) crash_info_loc, SEEK_SET) != 0)
return NULL;
- nread = bfd_read (buf, 1, 4, abfd);
+ nread = bfd_bread (buf, (bfd_size_type) 4, abfd);
if (nread != 4)
{
if (bfd_get_error () != bfd_error_system_call)
}
crashinfo_offset = MASK_ADDR (bfd_get_32 (abfd, buf));
- if (bfd_seek (abfd, crashinfo_offset, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) crashinfo_offset, SEEK_SET) != 0)
{
/* Most likely we failed because of a bogus (huge) offset */
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
- nread = bfd_read (&crashinfo, 1, sizeof (crashinfo), abfd);
+ nread = bfd_bread (&crashinfo, (bfd_size_type) sizeof (crashinfo), abfd);
if (nread != sizeof (crashinfo))
{
if (bfd_get_error () != bfd_error_system_call)
/* OK, we believe you. You're a core file. */
- abfd->tdata.cisco_core_data =
- ((struct cisco_core_struct *)
- bfd_zmalloc (sizeof (struct cisco_core_struct)));
+ amt = sizeof (struct cisco_core_struct);
+ abfd->tdata.cisco_core_data = (struct cisco_core_struct *) bfd_zmalloc (amt);
if (abfd->tdata.cisco_core_data == NULL)
return NULL;
/* Create a ".reg" section to allow access to the saved
registers. */
- asect = (asection *) bfd_zmalloc (sizeof (asection));
+ asect = (asection *) bfd_zmalloc ((bfd_size_type) sizeof (asection));
if (asect == NULL)
goto error_return;
asect->name = ".reg";
/* Create a ".crash" section to allow access to the saved
crash information. */
- asect = (asection *) bfd_zmalloc (sizeof (asection));
+ asect = (asection *) bfd_zmalloc ((bfd_size_type) sizeof (asection));
if (asect == NULL)
goto error_return;
asect->name = ".crash";
/* Create a ".data" section that maps the entire file, which is
essentially a dump of the target system's RAM. */
- asect = (asection *) bfd_zmalloc (sizeof (asection));
+ asect = (asection *) bfd_zmalloc ((bfd_size_type) sizeof (asection));
if (asect == NULL)
goto error_return;
asect->name = ".data";
char *
cisco_core_file_failing_command (abfd)
- bfd *abfd;
+ bfd *abfd ATTRIBUTE_UNUSED;
{
return NULL;
}
int
cisco_core_file_failing_signal (abfd)
- bfd *abfd;
+ bfd *abfd ATTRIBUTE_UNUSED;
{
return abfd->tdata.cisco_core_data->sig;
}
boolean
cisco_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd;
- bfd *exec_bfd;
+ bfd *core_bfd ATTRIBUTE_UNUSED;
+ bfd *exec_bfd ATTRIBUTE_UNUSED;
{
return true;
}
}
signed_value >>= 2;
insn = INSERT_HWORD (insn, signed_value);
- bfd_put_32 (abfd, insn ,hit_data);
+ bfd_put_32 (abfd, (bfd_vma) insn ,hit_data);
break;
case R_ILOHALF:
insn = bfd_get_32 (abfd, hit_data);
unsigned_value = EXTRACT_HWORD(insn);
unsigned_value += sym_value + reloc_entry->addend;
insn = INSERT_HWORD(insn, unsigned_value);
- bfd_put_32 (abfd, insn, hit_data);
+ bfd_put_32 (abfd, (bfd_vma) insn, hit_data);
break;
case R_IHIHALF:
insn = bfd_get_32 (abfd, hit_data);
unsigned_value = unsigned_value >> 16;
insn = INSERT_HWORD(insn, unsigned_value);
part1_consth_active = false;
- bfd_put_32 (abfd, insn, hit_data);
+ bfd_put_32 (abfd, (bfd_vma) insn, hit_data);
break;
case R_BYTE:
insn = bfd_get_8 (abfd, hit_data);
unsigned_value = insn + sym_value + reloc_entry->addend;
if (unsigned_value & 0xffff0000)
return bfd_reloc_overflow;
- bfd_put_16 (abfd, insn, hit_data);
+ bfd_put_16 (abfd, (bfd_vma) insn, hit_data);
break;
case R_WORD:
insn = bfd_get_32 (abfd, hit_data);
insn += sym_value + reloc_entry->addend;
- bfd_put_32 (abfd, insn, hit_data);
+ bfd_put_32 (abfd, (bfd_vma) insn, hit_data);
break;
default:
*error_message = _("Unrecognized reloc");
unsigned_value = EXTRACT_HWORD (insn);
unsigned_value += val;
insn = INSERT_HWORD (insn, unsigned_value);
- bfd_put_32 (input_bfd, insn, loc);
+ bfd_put_32 (input_bfd, (bfd_vma) insn, loc);
break;
case R_IHIHALF:
symbol, and lineno ones. Give them ecoff names. Define some
accessor macros for the large sizes used for Alpha ECOFF. */
-#define GET_FILEHDR_SYMPTR bfd_h_get_64
-#define PUT_FILEHDR_SYMPTR bfd_h_put_64
-#define GET_AOUTHDR_TSIZE bfd_h_get_64
-#define PUT_AOUTHDR_TSIZE bfd_h_put_64
-#define GET_AOUTHDR_DSIZE bfd_h_get_64
-#define PUT_AOUTHDR_DSIZE bfd_h_put_64
-#define GET_AOUTHDR_BSIZE bfd_h_get_64
-#define PUT_AOUTHDR_BSIZE bfd_h_put_64
-#define GET_AOUTHDR_ENTRY bfd_h_get_64
-#define PUT_AOUTHDR_ENTRY bfd_h_put_64
-#define GET_AOUTHDR_TEXT_START bfd_h_get_64
-#define PUT_AOUTHDR_TEXT_START bfd_h_put_64
-#define GET_AOUTHDR_DATA_START bfd_h_get_64
-#define PUT_AOUTHDR_DATA_START bfd_h_put_64
-#define GET_SCNHDR_PADDR bfd_h_get_64
-#define PUT_SCNHDR_PADDR bfd_h_put_64
-#define GET_SCNHDR_VADDR bfd_h_get_64
-#define PUT_SCNHDR_VADDR bfd_h_put_64
-#define GET_SCNHDR_SIZE bfd_h_get_64
-#define PUT_SCNHDR_SIZE bfd_h_put_64
-#define GET_SCNHDR_SCNPTR bfd_h_get_64
-#define PUT_SCNHDR_SCNPTR bfd_h_put_64
-#define GET_SCNHDR_RELPTR bfd_h_get_64
-#define PUT_SCNHDR_RELPTR bfd_h_put_64
-#define GET_SCNHDR_LNNOPTR bfd_h_get_64
-#define PUT_SCNHDR_LNNOPTR bfd_h_put_64
+#define GET_FILEHDR_SYMPTR H_GET_64
+#define PUT_FILEHDR_SYMPTR H_PUT_64
+#define GET_AOUTHDR_TSIZE H_GET_64
+#define PUT_AOUTHDR_TSIZE H_PUT_64
+#define GET_AOUTHDR_DSIZE H_GET_64
+#define PUT_AOUTHDR_DSIZE H_PUT_64
+#define GET_AOUTHDR_BSIZE H_GET_64
+#define PUT_AOUTHDR_BSIZE H_PUT_64
+#define GET_AOUTHDR_ENTRY H_GET_64
+#define PUT_AOUTHDR_ENTRY H_PUT_64
+#define GET_AOUTHDR_TEXT_START H_GET_64
+#define PUT_AOUTHDR_TEXT_START H_PUT_64
+#define GET_AOUTHDR_DATA_START H_GET_64
+#define PUT_AOUTHDR_DATA_START H_PUT_64
+#define GET_SCNHDR_PADDR H_GET_64
+#define PUT_SCNHDR_PADDR H_PUT_64
+#define GET_SCNHDR_VADDR H_GET_64
+#define PUT_SCNHDR_VADDR H_PUT_64
+#define GET_SCNHDR_SIZE H_GET_64
+#define PUT_SCNHDR_SIZE H_PUT_64
+#define GET_SCNHDR_SCNPTR H_GET_64
+#define PUT_SCNHDR_SCNPTR H_PUT_64
+#define GET_SCNHDR_RELPTR H_GET_64
+#define PUT_SCNHDR_RELPTR H_PUT_64
+#define GET_SCNHDR_LNNOPTR H_GET_64
+#define PUT_SCNHDR_LNNOPTR H_PUT_64
#define ALPHAECOFF
{
const RELOC *ext = (RELOC *) ext_ptr;
- intern->r_vaddr = bfd_h_get_64 (abfd, (bfd_byte *) ext->r_vaddr);
- intern->r_symndx = bfd_h_get_32 (abfd, (bfd_byte *) ext->r_symndx);
+ intern->r_vaddr = H_GET_64 (abfd, ext->r_vaddr);
+ intern->r_symndx = H_GET_32 (abfd, ext->r_symndx);
BFD_ASSERT (bfd_header_little_endian (abfd));
BFD_ASSERT (intern->r_extern
|| (intern->r_symndx >= 0 && intern->r_symndx <= 14));
- bfd_h_put_64 (abfd, intern->r_vaddr, (bfd_byte *) ext->r_vaddr);
- bfd_h_put_32 (abfd, symndx, (bfd_byte *) ext->r_symndx);
+ H_PUT_64 (abfd, intern->r_vaddr, ext->r_vaddr);
+ H_PUT_32 (abfd, symndx, ext->r_symndx);
BFD_ASSERT (bfd_header_little_endian (abfd));
if (reloc_size < 0)
goto error_return;
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
+ reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
if (reloc_vector == NULL && reloc_size != 0)
goto error_return;
hsec = h->root.u.def.section;
name = bfd_get_section_name (output_bfd, hsec->output_section);
- r_symndx = -1;
+ r_symndx = (unsigned long) -1;
switch (name[1])
{
case 'A':
}
/* Write out the new r_symndx value. */
- bfd_h_put_32 (input_bfd, (bfd_vma) r_symndx,
- (bfd_byte *) ext_rel->r_symndx);
+ H_PUT_32 (input_bfd, r_symndx, ext_rel->r_symndx);
return relocation;
}
int tos = 0;
struct external_reloc *ext_rel;
struct external_reloc *ext_rel_end;
+ bfd_size_type amt;
/* We keep a table mapping the symndx found in an internal reloc to
the appropriate section. This is faster than looking up the
symndx_to_section = ecoff_data (input_bfd)->symndx_to_section;
if (symndx_to_section == (asection **) NULL)
{
- symndx_to_section = ((asection **)
- bfd_alloc (input_bfd,
- (NUM_RELOC_SECTIONS
- * sizeof (asection *))));
+ amt = NUM_RELOC_SECTIONS * sizeof (asection *);
+ symndx_to_section = (asection **) bfd_alloc (input_bfd, amt);
if (!symndx_to_section)
return false;
lita_sec_data = ecoff_section_data (input_bfd, lita_sec);
if (lita_sec_data == NULL)
{
+ amt = sizeof (struct ecoff_section_tdata);
lita_sec_data = ((struct ecoff_section_tdata *)
- bfd_zalloc (input_bfd,
- sizeof (struct ecoff_section_tdata)));
+ bfd_zalloc (input_bfd, amt));
ecoff_section_data (input_bfd, lita_sec) = lita_sec_data;
}
boolean gp_usedp;
bfd_vma addend;
- r_vaddr = bfd_h_get_64 (input_bfd, (bfd_byte *) ext_rel->r_vaddr);
- r_symndx = bfd_h_get_32 (input_bfd, (bfd_byte *) ext_rel->r_symndx);
+ r_vaddr = H_GET_64 (input_bfd, ext_rel->r_vaddr);
+ r_symndx = H_GET_32 (input_bfd, ext_rel->r_symndx);
r_type = ((ext_rel->r_bits[0] & RELOC_BITS0_TYPE_LITTLE)
>> RELOC_BITS0_TYPE_SH_LITTLE);
address of the relocation does not appear to include the
section VMA, unlike the other relocation types. */
if (info->relocateable)
- bfd_h_put_64 (input_bfd,
- input_section->output_offset + r_vaddr,
- (bfd_byte *) ext_rel->r_vaddr);
+ H_PUT_64 (input_bfd, input_section->output_offset + r_vaddr,
+ ext_rel->r_vaddr);
adjust_addrp = false;
break;
if (info->relocateable)
{
/* Adjust r_vaddr by the addend. */
- bfd_h_put_64 (input_bfd, addend,
- (bfd_byte *) ext_rel->r_vaddr);
+ H_PUT_64 (input_bfd, addend, ext_rel->r_vaddr);
}
else
{
if (info->relocateable && adjust_addrp)
{
/* Change the address of the relocation. */
- bfd_h_put_64 (input_bfd,
- (input_section->output_section->vma
- + input_section->output_offset
- - input_section->vma
- + r_vaddr),
- (bfd_byte *) ext_rel->r_vaddr);
+ H_PUT_64 (input_bfd,
+ (input_section->output_section->vma
+ + input_section->output_offset
+ - input_section->vma
+ + r_vaddr),
+ ext_rel->r_vaddr);
}
if (gp_usedp && gp_undefined)
/* This is a compressed file. We must set the size correctly.
The size is the eight bytes after the dummy file header. */
- if (bfd_seek (abfd, FILHSZ, SEEK_CUR) != 0
- || bfd_read (ab, 1, 8, abfd) != 8
- || bfd_seek (abfd, - (FILHSZ + 8), SEEK_CUR) != 0)
+ if (bfd_seek (abfd, (file_ptr) FILHSZ, SEEK_CUR) != 0
+ || bfd_bread (ab, (bfd_size_type) 8, abfd) != 8
+ || bfd_seek (abfd, (file_ptr) (- (FILHSZ + 8)), SEEK_CUR) != 0)
return NULL;
- ret->parsed_size = bfd_h_get_64 (abfd, ab);
+ ret->parsed_size = H_GET_64 (abfd, ab);
}
return (PTR) ret;
return nbfd;
/* We must uncompress this element. We do this by copying it into a
- memory buffer, and making bfd_read and bfd_seek use that buffer.
+ memory buffer, and making bfd_bread and bfd_seek use that buffer.
This can use a lot of memory, but it's simpler than getting a
temporary file, making that work with the file descriptor caching
code, and making sure that it is deleted at all appropriate
times. It can be changed if it ever becomes important. */
/* The compressed file starts with a dummy ECOFF file header. */
- if (bfd_seek (nbfd, FILHSZ, SEEK_SET) != 0)
+ if (bfd_seek (nbfd, (file_ptr) FILHSZ, SEEK_SET) != 0)
goto error_return;
/* The next eight bytes are the real file size. */
- if (bfd_read (ab, 1, 8, nbfd) != 8)
+ if (bfd_bread (ab, (bfd_size_type) 8, nbfd) != 8)
goto error_return;
- size = bfd_h_get_64 (nbfd, ab);
+ size = H_GET_64 (nbfd, ab);
if (size == 0)
buf = NULL;
left = size;
/* I don't know what the next eight bytes are for. */
- if (bfd_read (ab, 1, 8, nbfd) != 8)
+ if (bfd_bread (ab, (bfd_size_type) 8, nbfd) != 8)
goto error_return;
/* This is the uncompression algorithm. It's a simple
next eight bytes in the output stream. */
memset (dict, 0, sizeof dict);
h = 0;
- while (bfd_read (&b, 1, 1, nbfd) == 1)
+ while (bfd_bread (&b, (bfd_size_type) 1, nbfd) == 1)
{
unsigned int i;
n = dict[h];
else
{
- if (! bfd_read (&n, 1, 1, nbfd))
+ if (! bfd_bread (&n, (bfd_size_type) 1, nbfd))
goto error_return;
dict[h] = n;
}
/* Now the uncompressed file contents are in buf. */
bim = ((struct bfd_in_memory *)
- bfd_alloc (nbfd, sizeof (struct bfd_in_memory)));
+ bfd_alloc (nbfd, (bfd_size_type) sizeof (struct bfd_in_memory)));
if (bim == NULL)
goto error_return;
bim->size = size;
/* Macros for manipulation the bits in the flags field of the coff data
structure. */
-#define APCS_26_FLAG( abfd ) (coff_data (abfd)->flags & F_APCS_26)
-#define APCS_FLOAT_FLAG( abfd ) (coff_data (abfd)->flags & F_APCS_FLOAT)
-#define PIC_FLAG( abfd ) (coff_data (abfd)->flags & F_PIC)
-#define APCS_SET( abfd ) (coff_data (abfd)->flags & F_APCS_SET)
-#define SET_APCS_FLAGS( abfd, flgs) (coff_data (abfd)->flags = \
- (coff_data (abfd)->flags & ~ (F_APCS_26 | F_APCS_FLOAT | F_PIC)) \
- | (flgs | F_APCS_SET))
-#define INTERWORK_FLAG( abfd ) (coff_data (abfd)->flags & F_INTERWORK)
-#define INTERWORK_SET( abfd ) (coff_data (abfd)->flags & F_INTERWORK_SET)
-#define SET_INTERWORK_FLAG( abfd, flg ) (coff_data (abfd)->flags = \
- (coff_data (abfd)->flags & ~ F_INTERWORK) \
- | (flg | F_INTERWORK_SET))
+#define APCS_26_FLAG(abfd) \
+ (coff_data (abfd)->flags & F_APCS_26)
+
+#define APCS_FLOAT_FLAG(abfd) \
+ (coff_data (abfd)->flags & F_APCS_FLOAT)
+
+#define PIC_FLAG(abfd) \
+ (coff_data (abfd)->flags & F_PIC)
+
+#define APCS_SET(abfd) \
+ (coff_data (abfd)->flags & F_APCS_SET)
+
+#define SET_APCS_FLAGS(abfd, flgs) \
+ do \
+ { \
+ coff_data (abfd)->flags &= ~(F_APCS_26 | F_APCS_FLOAT | F_PIC); \
+ coff_data (abfd)->flags |= (flgs) | F_APCS_SET; \
+ } \
+ while (0)
+
+#define INTERWORK_FLAG(abfd) \
+ (coff_data (abfd)->flags & F_INTERWORK)
+
+#define INTERWORK_SET(abfd) \
+ (coff_data (abfd)->flags & F_INTERWORK_SET)
+
+#define SET_INTERWORK_FLAG(abfd, flg) \
+ do \
+ { \
+ coff_data (abfd)->flags &= ~F_INTERWORK; \
+ coff_data (abfd)->flags |= (flg) | F_INTERWORK_SET; \
+ } \
+ while (0)
#ifndef NUM_ELEM
#define NUM_ELEM(a) ((sizeof (a)) / sizeof ((a)[0]))
asection *, struct internal_reloc *, boolean *));
static reloc_howto_type * coff_arm_rtype_to_howto
PARAMS ((bfd *, asection *, struct internal_reloc *,
- struct coff_link_hash_entry *, struct internal_syment *, bfd_vma *));
+ struct coff_link_hash_entry *, struct internal_syment *,
+ bfd_vma *));
static bfd_reloc_status_type coff_thumb_pcrel_common
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **,
thumb_pcrel_branchtype));
-static CONST struct reloc_howto_struct * coff_arm_reloc_type_lookup
+static const struct reloc_howto_struct * coff_arm_reloc_type_lookup
PARAMS ((bfd *, bfd_reloc_code_real_type));
static struct bfd_link_hash_table * coff_arm_link_hash_table_create
PARAMS ((bfd *));
static insn32 insert_thumb_branch
PARAMS ((insn32, int));
static struct coff_link_hash_entry * find_thumb_glue
- PARAMS ((struct bfd_link_info *, CONST char *, bfd *));
+ PARAMS ((struct bfd_link_info *, const char *, bfd *));
static struct coff_link_hash_entry * find_arm_glue
- PARAMS ((struct bfd_link_info *, CONST char *, bfd *));
+ PARAMS ((struct bfd_link_info *, const char *, bfd *));
#ifndef COFF_IMAGE_WITH_PE
static void record_arm_to_thumb_glue
PARAMS ((struct bfd_link_info *, struct coff_link_hash_entry *));
diff = reloc_entry->addend;
-#define DOIT(x) \
- x = ((x & ~howto->dst_mask) | (((x & howto->src_mask) + diff) & howto->dst_mask))
+#define DOIT(x) \
+ x = ((x & ~howto->dst_mask) \
+ | (((x & howto->src_mask) + diff) & howto->dst_mask))
if (diff != 0)
{
{
short x = bfd_get_16 (abfd, addr);
DOIT (x);
- bfd_put_16 (abfd, x, addr);
+ bfd_put_16 (abfd, (bfd_vma) x, addr);
}
break;
{
long x = bfd_get_32 (abfd, addr);
DOIT (x);
- bfd_put_32 (abfd, x, addr);
+ bfd_put_32 (abfd, (bfd_vma) x, addr);
}
break;
if ((relocation & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff)
flag = bfd_reloc_overflow;
}
- else if (relocation & ~0x03ffffff)
+ else if (relocation & ~(bfd_vma) 0x03ffffff)
flag = bfd_reloc_overflow;
target &= ~0x00ffffff;
target |= (relocation >> 2) & 0x00ffffff;
- bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
+ bfd_put_32 (abfd, (bfd_vma) target, (bfd_byte *) data + addr);
/* Now the ARM magic... Change the reloc type so that it is marked as done.
Strictly this is only necessary if we are doing a partial relocation. */
case b23:
if (bfd_big_endian (abfd))
- target |= ((relocation & 0xfff) >> 1) | ((relocation << 4) & 0x07ff0000);
+ target |= (((relocation & 0xfff) >> 1)
+ | ((relocation << 4) & 0x07ff0000));
else
- target |= ((relocation & 0xffe) << 15) | ((relocation >> 12) & 0x7ff);
+ target |= (((relocation & 0xffe) << 15)
+ | ((relocation >> 12) & 0x7ff));
break;
default:
abort ();
}
- bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
+ bfd_put_32 (abfd, (bfd_vma) target, (bfd_byte *) data + addr);
/* Now the ARM magic... Change the reloc type so that it is marked as done.
Strictly this is only necessary if we are doing a partial relocation. */
char **error_message;
{
return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
- input_section, output_bfd, error_message, b23);
+ input_section, output_bfd, error_message,
+ b23);
}
static bfd_reloc_status_type
char **error_message;
{
return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
- input_section, output_bfd, error_message, b12);
+ input_section, output_bfd, error_message,
+ b12);
}
static bfd_reloc_status_type
char **error_message;
{
return coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data,
- input_section, output_bfd, error_message, b9);
+ input_section, output_bfd, error_message,
+ b9);
}
-static CONST struct reloc_howto_struct *
+static const struct reloc_howto_struct *
coff_arm_reloc_type_lookup (abfd, code)
bfd * abfd;
bfd_reloc_code_real_type code;
code = BFD_RELOC_32;
break;
default:
- return (CONST struct reloc_howto_struct *) 0;
+ return (const struct reloc_howto_struct *) 0;
}
switch (code)
ASTD (BFD_RELOC_THUMB_PCREL_BRANCH23, ARM_THUMB23);
ASTD (BFD_RELOC_THUMB_PCREL_BLX, ARM_THUMB23);
#endif
- default: return (CONST struct reloc_howto_struct *) 0;
+ default: return (const struct reloc_howto_struct *) 0;
}
}
struct coff_link_hash_table root;
/* The size in bytes of the section containg the Thumb-to-ARM glue. */
- long int thumb_glue_size;
+ bfd_size_type thumb_glue_size;
/* The size in bytes of the section containg the ARM-to-Thumb glue. */
- long int arm_glue_size;
+ bfd_size_type arm_glue_size;
/* An arbitary input BFD chosen to hold the glue sections. */
bfd * bfd_of_glue_owner;
bfd * abfd;
{
struct coff_arm_link_hash_table * ret;
+ bfd_size_type amt = sizeof (struct coff_arm_link_hash_table);
- ret = ((struct coff_arm_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct coff_arm_link_hash_table)));
+ ret = (struct coff_arm_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct coff_arm_link_hash_table *) NULL)
return NULL;
else if ((br_insn & HI_LOW_ORDER) == HI_LOW_ORDER)
br_insn = HI_LOW_ORDER | (high_bits << 16) | low_bits;
else
- /* FIXME: the BFD library should never abort - it should return an error status. */
+ /* FIXME: the BFD library should never abort except for internal errors
+ - it should return an error status. */
abort (); /* Error - not a valid branch instruction form. */
return br_insn;
\f
static struct coff_link_hash_entry *
find_thumb_glue (info, name, input_bfd)
- struct bfd_link_info * info;
- CONST char * name;
- bfd * input_bfd;
+ struct bfd_link_info *info;
+ const char *name;
+ bfd *input_bfd;
{
- char * tmp_name;
- struct coff_link_hash_entry * myh;
+ char *tmp_name;
+ struct coff_link_hash_entry *myh;
+ bfd_size_type amt = strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1;
- tmp_name = ((char *)
- bfd_malloc (strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1));
+ tmp_name = (char *) bfd_malloc (amt);
BFD_ASSERT (tmp_name);
static struct coff_link_hash_entry *
find_arm_glue (info, name, input_bfd)
- struct bfd_link_info * info;
- CONST char * name;
- bfd * input_bfd;
+ struct bfd_link_info *info;
+ const char *name;
+ bfd *input_bfd;
{
- char * tmp_name;
+ char *tmp_name;
struct coff_link_hash_entry * myh;
+ bfd_size_type amt = strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1;
- tmp_name = ((char *)
- bfd_malloc (strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1));
+ tmp_name = (char *) bfd_malloc (amt);
BFD_ASSERT (tmp_name);
&& info->relocateable
&& (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak)
- && h->root.u.def.section->output_section == input_section->output_section)
+ && (h->root.u.def.section->output_section
+ == input_section->output_section))
{
static reloc_howto_type fake_arm26_reloc =
HOWTO (ARM_26,
{
/* Arm code calling a Thumb function. */
unsigned long int tmp;
- long int my_offset;
+ bfd_vma my_offset;
asection * s;
long int ret_offset;
struct coff_link_hash_entry * myh;
--my_offset;
myh->root.u.def.value = my_offset;
- bfd_put_32 (output_bfd, a2t1_ldr_insn,
+ bfd_put_32 (output_bfd, (bfd_vma) a2t1_ldr_insn,
s->contents + my_offset);
- bfd_put_32 (output_bfd, a2t2_bx_r12_insn,
+ bfd_put_32 (output_bfd, (bfd_vma) a2t2_bx_r12_insn,
s->contents + my_offset + 4);
/* It's a thumb address. Add the low order bit. */
if (info->base_file)
arm_emit_base_file_entry (info, output_bfd, s,
- my_offset + 8);
+ my_offset + 8);
}
tmp = tmp | ((ret_offset >> 2) & 0x00FFFFFF);
- bfd_put_32 (output_bfd, tmp, contents + rel->r_vaddr
- - input_section->vma);
+ bfd_put_32 (output_bfd, (bfd_vma) tmp,
+ contents + rel->r_vaddr - input_section->vma);
done = 1;
}
}
{
/* Thumb code calling an ARM function */
asection * s = 0;
- long int my_offset;
+ bfd_vma my_offset;
unsigned long int tmp;
long int ret_offset;
struct coff_link_hash_entry * myh;
if (globals->support_old_code)
{
- bfd_put_16 (output_bfd, t2a1_push_insn,
+ bfd_put_16 (output_bfd, (bfd_vma) t2a1_push_insn,
s->contents + my_offset);
- bfd_put_16 (output_bfd, t2a2_ldr_insn,
+ bfd_put_16 (output_bfd, (bfd_vma) t2a2_ldr_insn,
s->contents + my_offset + 2);
- bfd_put_16 (output_bfd, t2a3_mov_insn,
+ bfd_put_16 (output_bfd, (bfd_vma) t2a3_mov_insn,
s->contents + my_offset + 4);
- bfd_put_16 (output_bfd, t2a4_bx_insn,
+ bfd_put_16 (output_bfd, (bfd_vma) t2a4_bx_insn,
s->contents + my_offset + 6);
- bfd_put_32 (output_bfd, t2a5_pop_insn,
+ bfd_put_32 (output_bfd, (bfd_vma) t2a5_pop_insn,
s->contents + my_offset + 8);
- bfd_put_32 (output_bfd, t2a6_bx_insn,
+ bfd_put_32 (output_bfd, (bfd_vma) t2a6_bx_insn,
s->contents + my_offset + 12);
/* Store the address of the function in the last word of the stub. */
s->contents + my_offset + 16);
if (info->base_file)
- arm_emit_base_file_entry (info, output_bfd, s, my_offset + 16);
+ arm_emit_base_file_entry (info, output_bfd, s,
+ my_offset + 16);
}
else
{
- bfd_put_16 (output_bfd, t2a1_bx_pc_insn,
+ bfd_put_16 (output_bfd, (bfd_vma) t2a1_bx_pc_insn,
s->contents + my_offset);
- bfd_put_16 (output_bfd, t2a2_noop_insn,
+ bfd_put_16 (output_bfd, (bfd_vma) t2a2_noop_insn,
s->contents + my_offset + 2);
ret_offset =
+ 8); /* ARM branches work from the pc of the instruction + 8. */
bfd_put_32 (output_bfd,
- t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),
+ (bfd_vma) t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),
s->contents + my_offset + 4);
}
- input_section->vma);
bfd_put_32 (output_bfd,
- insert_thumb_branch (tmp, ret_offset),
- contents + rel->r_vaddr
- - input_section->vma);
+ (bfd_vma) insert_thumb_branch (tmp,
+ ret_offset),
+ contents + rel->r_vaddr - input_section->vma);
done = 1;
}
{
/* Emit a reloc if the backend thinks it needs it. */
if (sym && pe_data(output_bfd)->in_reloc_p(output_bfd, howto))
- arm_emit_base_file_entry (info, output_bfd, input_section, rel->r_vaddr);
+ arm_emit_base_file_entry (info, output_bfd, input_section,
+ rel->r_vaddr);
}
#if 1 /* THUMBEXTENSION */
BFD_ASSERT (s != NULL);
- foo = (bfd_byte *) bfd_alloc
- (globals->bfd_of_glue_owner, globals->arm_glue_size);
+ foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner,
+ globals->arm_glue_size);
#if 0
- memset (foo, test_char, globals->arm_glue_size);
+ memset (foo, test_char, (size_t) globals->arm_glue_size);
#endif
s->_raw_size = s->_cooked_size = globals->arm_glue_size;
BFD_ASSERT (s != NULL);
- foo = (bfd_byte *) bfd_alloc
- (globals->bfd_of_glue_owner, globals->thumb_glue_size);
+ foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner,
+ globals->thumb_glue_size);
#if 0
- memset (foo, test_char, globals->thumb_glue_size);
+ memset (foo, test_char, (size_t) globals->thumb_glue_size);
#endif
s->_raw_size = s->_cooked_size = globals->thumb_glue_size;
char * tmp_name;
struct coff_link_hash_entry * myh;
struct coff_arm_link_hash_table * globals;
+ bfd_vma val;
+ bfd_size_type amt;
globals = coff_arm_hash_table (info);
BFD_ASSERT (s != NULL);
- tmp_name = ((char *)
- bfd_malloc (strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1));
+ amt = strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1;
+ tmp_name = (char *) bfd_malloc (amt);
BFD_ASSERT (tmp_name);
though the section isn't allocated yet, this is where we will be putting
it. */
+ val = globals->arm_glue_size + 1;
bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
- BSF_GLOBAL,
- s, globals->arm_glue_size + 1,
- NULL, true, false,
+ BSF_GLOBAL, s, val, NULL, true, false,
(struct bfd_link_hash_entry **) & myh);
free (tmp_name);
char * tmp_name;
struct coff_link_hash_entry * myh;
struct coff_arm_link_hash_table * globals;
+ bfd_vma val;
+ bfd_size_type amt;
globals = coff_arm_hash_table (info);
BFD_ASSERT (s != NULL);
- tmp_name = (char *) bfd_malloc (strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
+ amt = strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1;
+ tmp_name = (char *) bfd_malloc (amt);
BFD_ASSERT (tmp_name);
return; /* we've already seen this guy */
}
+ val = globals->thumb_glue_size + 1;
bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
- BSF_GLOBAL, s, globals->thumb_glue_size + 1,
- NULL, true, false,
- (struct bfd_link_hash_entry **) & myh);
+ BSF_GLOBAL, s, val, NULL, true, false,
+ (struct bfd_link_hash_entry **) &myh);
/* If we mark it 'thumb', the disassembler will do a better job. */
myh->class = C_THUMBEXTFUNC;
#define CHANGE_TO_ARM "__%s_change_to_arm"
#define BACK_FROM_ARM "__%s_back_from_arm"
- tmp_name = (char *) bfd_malloc (strlen (name) + strlen (CHANGE_TO_ARM) + 1);
+ amt = strlen (name) + strlen (CHANGE_TO_ARM) + 1;
+ tmp_name = (char *) bfd_malloc (amt);
BFD_ASSERT (tmp_name);
sprintf (tmp_name, globals->support_old_code ? BACK_FROM_ARM : CHANGE_TO_ARM, name);
myh = NULL;
-
+ val = globals->thumb_glue_size + (globals->support_old_code ? 8 : 4);
bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name,
- BSF_LOCAL, s, globals->thumb_glue_size
- + (globals->support_old_code ? 8 : 4),
- NULL, true, false,
+ BSF_LOCAL, s, val, NULL, true, false,
(struct bfd_link_hash_entry **) & myh);
free (tmp_name);
if (LOCAL_LABEL_PREFIX[0] != 0)
{
- int len = strlen (LOCAL_LABEL_PREFIX);
+ size_t len = strlen (LOCAL_LABEL_PREFIX);
if (strncmp (name, LOCAL_LABEL_PREFIX, len) != 0)
return false;
bfd *abfd;
{
struct h8300_coff_link_hash_table *ret;
- ret = ((struct h8300_coff_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct h8300_coff_link_hash_table)));
+ bfd_size_type amt = sizeof (struct h8300_coff_link_hash_table);
+
+ ret = (struct h8300_coff_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == NULL)
return NULL;
- if (!_bfd_link_hash_table_init (&ret->root.root, abfd, _bfd_generic_link_hash_newfunc))
+ if (!_bfd_link_hash_table_init (&ret->root.root, abfd,
+ _bfd_generic_link_hash_newfunc))
{
bfd_release (abfd, ret);
return NULL;
#define __A_MAGIC_SET__
/* Code to swap in the reloc. */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_IN_RELOC_OFFSET H_GET_32
+#define SWAP_OUT_RELOC_OFFSET H_PUT_32
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
dst->r_stuff[0] = 'S'; \
dst->r_stuff[1] = 'C';
/* Everything looks OK. Apply the relocation and update the
src/dst address appropriately. */
- bfd_put_16 (abfd, gap, data + dst_address);
+ bfd_put_16 (abfd, (bfd_vma) gap, data + dst_address);
dst_address += 2;
src_address += 2;
/* We need to find the symbol so we can determine it's
address in the function vector table. */
asymbol *symbol;
- bfd_vma value;
const char *name;
+ struct funcvec_hash_table *ftab;
struct funcvec_hash_entry *h;
asection *vectors_sec = h8300_coff_hash_table (link_info)->vectors_sec;
name = symbol->name;
if (symbol->flags & BSF_LOCAL)
{
- char *new_name = bfd_malloc (strlen (name) + 9);
+ char *new_name = bfd_malloc ((bfd_size_type) strlen (name) + 9);
if (new_name == NULL)
abort ();
name = new_name;
}
- h = funcvec_hash_lookup (h8300_coff_hash_table (link_info)->funcvec_hash_table,
- name, false, false);
+ ftab = h8300_coff_hash_table (link_info)->funcvec_hash_table;
+ h = funcvec_hash_lookup (ftab, name, false, false);
/* This shouldn't ever happen. If it does that means we've got
data corruption of some kind. Aborting seems like a reasonable
bfd_set_section_contents (vectors_sec->output_section->owner,
vectors_sec->output_section,
vectors_sec->contents,
- vectors_sec->output_offset,
+ (file_ptr) vectors_sec->output_offset,
vectors_sec->_raw_size);
break;
}
{
asection *sec;
struct funcvec_hash_table *funcvec_hash_table;
+ bfd_size_type amt;
/* If we haven't created a vectors section, do so now. */
if (!h8300_coff_hash_table (info)->vectors_sec)
return false;
/* Also create the vector hash table. */
- funcvec_hash_table = ((struct funcvec_hash_table *)
- bfd_alloc (abfd, sizeof (struct funcvec_hash_table)));
+ amt = sizeof (struct funcvec_hash_table);
+ funcvec_hash_table = (struct funcvec_hash_table *) bfd_alloc (abfd, amt);
if (!funcvec_hash_table)
return false;
if (reloc_size <= 0)
continue;
- relocs = (arelent **) bfd_malloc ((size_t) reloc_size);
+ relocs = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
if (!relocs)
return false;
&& symbol != bfd_abs_section_ptr->symbol)
{
+ struct funcvec_hash_table *ftab;
struct funcvec_hash_entry *h;
name = symbol->name;
if (symbol->flags & BSF_LOCAL)
{
- char *new_name = bfd_malloc (strlen (name) + 9);
+ char *new_name;
+ new_name = bfd_malloc ((bfd_size_type) strlen (name) + 9);
if (new_name == NULL)
abort ();
}
/* Look this symbol up in the function vector hash table. */
- h = funcvec_hash_lookup (h8300_coff_hash_table (info)->funcvec_hash_table,
- name, false, false);
+ ftab = h8300_coff_hash_table (info)->funcvec_hash_table;
+ h = funcvec_hash_lookup (ftab, name, false, false);
/* If this symbol isn't already in the hash table, add
it and bump up the size of the hash table. */
if (h == NULL)
{
- h = funcvec_hash_lookup (h8300_coff_hash_table (info)->funcvec_hash_table,
- name, true, true);
+ h = funcvec_hash_lookup (ftab, name, true, true);
if (h == NULL)
{
free (relocs);
/* Now actually allocate some space for the function vector. It's
wasteful to do this more than once, but this is easier. */
- if (h8300_coff_hash_table (info)->vectors_sec->_raw_size != 0)
+ sec = h8300_coff_hash_table (info)->vectors_sec;
+ if (sec->_raw_size != 0)
{
/* Free the old contents. */
- if (h8300_coff_hash_table (info)->vectors_sec->contents)
- free (h8300_coff_hash_table (info)->vectors_sec->contents);
+ if (sec->contents)
+ free (sec->contents);
/* Allocate new contents. */
- h8300_coff_hash_table (info)->vectors_sec->contents
- = bfd_malloc (h8300_coff_hash_table (info)->vectors_sec->_raw_size);
+ sec->contents = bfd_malloc (sec->_raw_size);
}
return true;
#define __A_MAGIC_SET__
/* Code to swap in the reloc. */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_IN_RELOC_OFFSET H_GET_32
+#define SWAP_OUT_RELOC_OFFSET H_PUT_32
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
dst->r_stuff[0] = 'S'; \
dst->r_stuff[1] = 'C';
int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
int o = bfd_get_32 (in_abfd, data+ *dst_ptr -1);
v = (v & 0x00ffffff) | (o & 0xff00000);
- bfd_put_32 (in_abfd, v, data + *dst_ptr -1);
+ bfd_put_32 (in_abfd, (bfd_vma) v, data + *dst_ptr -1);
(*dst_ptr) += 3;
(*src_ptr) += 3;;
}
case R_H8500_IMM32:
{
int v = bfd_coff_reloc16_get_value (reloc, link_info, input_section);
- bfd_put_32 (in_abfd, v, data + *dst_ptr);
+ bfd_put_32 (in_abfd, (bfd_vma) v, data + *dst_ptr);
(*dst_ptr) += 4;
(*src_ptr) += 4;;
}
input_section, reloc->address)))
abort ();
}
- bfd_put_16 (in_abfd, gap, data + *dst_ptr);
+ bfd_put_16 (in_abfd, (bfd_vma) gap, data + *dst_ptr);
(*dst_ptr) += 2;
(*src_ptr) += 2;
break;
{
short x = bfd_get_16 (abfd, addr);
DOIT (x);
- bfd_put_16 (abfd, x, addr);
+ bfd_put_16 (abfd, (bfd_vma) x, addr);
}
break;
{
long x = bfd_get_32 (abfd, addr);
DOIT (x);
- bfd_put_32 (abfd, x, addr);
+ bfd_put_32 (abfd, (bfd_vma) x, addr);
}
break;
{
short x = bfd_get_16 (abfd, addr);
DOIT (x);
- bfd_put_16 (abfd, x, addr);
+ bfd_put_16 (abfd, (bfd_vma) x, addr);
}
break;
{
long x = bfd_get_32 (abfd, addr);
DOIT (x);
- bfd_put_32 (abfd, x, addr);
+ bfd_put_32 (abfd, (bfd_vma) x, addr);
}
break;
/* BFD back-end for Intel 960 COFF files.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1999, 2000
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001
Free Software Foundation, Inc.
Written by Cygnus Support.
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
#define COFF_ALIGN_IN_SECTION_HEADER 1
-#define GET_SCNHDR_ALIGN bfd_h_get_32
-#define PUT_SCNHDR_ALIGN bfd_h_put_32
+#define GET_SCNHDR_ALIGN H_GET_32
+#define PUT_SCNHDR_ALIGN H_PUT_32
/* The i960 does not support an MMU, so COFF_PAGE_SIZE can be
arbitrarily small. */
sym and auxents untouched, so the delta between the two
is the offset of the bal entry point. */
word = ((word + olf) & BAL_MASK) | BAL;
- bfd_put_32 (abfd, word, (bfd_byte *) data + reloc_entry->address);
+ bfd_put_32 (abfd, (bfd_vma) word,
+ (bfd_byte *) data + reloc_entry->address);
}
result = bfd_reloc_ok;
break;
if (coff_section_data (output_bfd, osec) == NULL)
{
- osec->used_by_bfd =
- ((PTR) bfd_zalloc (abfd,
- sizeof (struct coff_section_tdata)));
+ bfd_size_type amt = sizeof (struct coff_section_tdata);
+ osec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (osec->used_by_bfd == NULL)
return bfd_reloc_overflow;
}
bfd_coff_swap_sym_out (abfd, (PTR) &isym, (PTR) esym);
- if (bfd_write (esym, symesz, 1, abfd) != symesz)
+ if (bfd_bwrite (esym, symesz, abfd) != symesz)
{
free (esym);
return false;
+ (rel->r_vaddr - input_section->vma)));
word = ((word + olf - val) & BAL_MASK) | BAL;
bfd_put_32 (input_bfd,
- word,
- (contents
- + (rel->r_vaddr - input_section->vma)));
+ (bfd_vma) word,
+ contents + (rel->r_vaddr - input_section->vma));
done = true;
}
break;
struct external_PEI_IMAGE_hdr image_hdr;
file_ptr offset;
- if (bfd_seek (abfd, 0x00, SEEK_SET) != 0
- || bfd_read (&dos_hdr, 1, sizeof (dos_hdr), abfd)
- != sizeof (dos_hdr))
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || (bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd)
+ != sizeof (dos_hdr)))
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
this routine can only be called correctly for a PEI file, check
the e_magic number here, and, if it doesn't match, clobber the
f_magic number so that we don't get a false match. */
- if (bfd_h_get_16 (abfd, (bfd_byte *) dos_hdr.e_magic) != DOSMAGIC)
+ if (H_GET_16 (abfd, dos_hdr.e_magic) != DOSMAGIC)
{
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
- offset = bfd_h_get_32 (abfd, (bfd_byte *) dos_hdr.e_lfanew);
- if (bfd_seek (abfd, (file_ptr) offset, SEEK_SET) != 0
- || bfd_read (&image_hdr, 1, sizeof (image_hdr), abfd)
- != sizeof (image_hdr))
+ offset = H_GET_32 (abfd, dos_hdr.e_lfanew);
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0
+ || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd)
+ != sizeof (image_hdr)))
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
- if (bfd_h_get_32 (abfd, (bfd_byte *) image_hdr.nt_signature)
+ if (H_GET_32 (abfd, image_hdr.nt_signature)
!= 0x4550)
{
bfd_set_error (bfd_error_wrong_format);
/* Here is the hack. coff_object_p wants to read filhsz bytes to
pick up the COFF header for PE, see "struct external_PEI_filehdr"
in include/coff/pe.h. We adjust so that that will work. */
- if (bfd_seek (abfd,
- (file_ptr) (offset - sizeof (dos_hdr)),
- SEEK_SET)
- != 0)
+ if (bfd_seek (abfd, offset - sizeof (dos_hdr), SEEK_SET) != 0)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
{
short x = bfd_get_16 (abfd, addr);
DOIT (x);
- bfd_put_16 (abfd, x, addr);
+ bfd_put_16 (abfd, (bfd_vma) x, addr);
}
break;
{
long x = bfd_get_32 (abfd, addr);
DOIT (x);
- bfd_put_32 (abfd, x, addr);
+ bfd_put_32 (abfd, (bfd_vma) x, addr);
}
break;
bfd_size_type symesz;
struct internal_reloc *irel, *irelend;
bfd_byte *p;
+ bfd_size_type amt;
BFD_ASSERT (! info->relocateable);
NULL);
irelend = irel + datasec->reloc_count;
- relsec->contents = (bfd_byte *) bfd_alloc (abfd, datasec->reloc_count * 12);
+ amt = (bfd_size_type) datasec->reloc_count * 12;
+ relsec->contents = (bfd_byte *) bfd_alloc (abfd, amt);
if (relsec->contents == NULL)
return false;
/* BFD back-end for Motorola 88000 COFF "Binary Compatability Standard" files.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1998, 1999, 2000,
+ 2001
Free Software Foundation, Inc.
Written by Cygnus Support.
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
-#define GET_SCNHDR_NRELOC bfd_h_get_32
-#define GET_SCNHDR_NLNNO bfd_h_get_32
+#define GET_SCNHDR_NRELOC H_GET_32
+#define GET_SCNHDR_NLNNO H_GET_32
/* On coff-m88k, local labels start with '@'. */
relocation <<= (bfd_vma) howto->bitpos;
if (relocation)
- bfd_put_16 (abfd, relocation, (unsigned char *) data + addr);
+ bfd_put_16 (abfd, (bfd_vma) relocation,
+ (unsigned char *) data + addr);
}
/* If we are not producing relocateable output, return an error if
#define RTYPE2HOWTO(cache_ptr, dst) rtype2howto (cache_ptr, dst)
/* Code to swap in the reloc offset */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_16
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_16
+#define SWAP_IN_RELOC_OFFSET H_GET_16
+#define SWAP_OUT_RELOC_OFFSET H_PUT_16
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
reloc_processing(relent, reloc, symbols, abfd, section)
{
mcore_hash_table * ret;
- ret = ((mcore_hash_table *) bfd_alloc (abfd, sizeof (* ret)));
+ ret = (mcore_hash_table *) bfd_alloc (abfd, (bfd_size_type) sizeof (* ret));
if (ret == (mcore_hash_table *) NULL)
return NULL;
{
const RELOC *ext = (RELOC *) ext_ptr;
- intern->r_vaddr = bfd_h_get_32 (abfd, (bfd_byte *) ext->r_vaddr);
+ intern->r_vaddr = H_GET_32 (abfd, ext->r_vaddr);
if (bfd_header_big_endian (abfd))
{
intern->r_symndx = (((int) ext->r_bits[0]
r_symndx = intern->r_offset & 0xffffff;
}
- bfd_h_put_32 (abfd, intern->r_vaddr, (bfd_byte *) ext->r_vaddr);
+ H_PUT_32 (abfd, intern->r_vaddr, ext->r_vaddr);
if (bfd_header_big_endian (abfd))
{
ext->r_bits[0] = r_symndx >> RELOC_BITS0_SYMNDX_SH_LEFT_BIG;
return bfd_reloc_outofrange;
/* Save the information, and let REFLO do the actual relocation. */
- n = (struct mips_hi *) bfd_malloc (sizeof *n);
+ n = (struct mips_hi *) bfd_malloc ((bfd_size_type) sizeof *n);
if (n == NULL)
return bfd_reloc_outofrange;
n->addr = (bfd_byte *) data + reloc_entry->address;
if ((val & 0x8000) != 0)
val += 0x10000;
- insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
- bfd_put_32 (abfd, insn, l->addr);
+ insn = (insn &~ (unsigned) 0xffff) | ((val >> 16) & 0xffff);
+ bfd_put_32 (abfd, (bfd_vma) insn, l->addr);
next = l->next;
free (l);
{
for (i = 0; i < count; i++, sym++)
{
- register CONST char *name;
+ register const char *name;
name = bfd_asymbol_name (*sym);
if (*name == '_' && strcmp (name, "_gp") == 0)
|| (symbol->flags & BSF_SECTION_SYM) != 0)
val += relocation - gp;
- insn = (insn &~ 0xffff) | (val & 0xffff);
- bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
+ insn = (insn &~ (unsigned) 0xffff) | (val & 0xffff);
+ bfd_put_32 (abfd, (bfd_vma) insn, (bfd_byte *) data + reloc_entry->address);
if (relocateable != false)
reloc_entry->address += input_section->output_offset;
return bfd_reloc_outofrange;
/* Save the information, and let RELLO do the actual relocation. */
- n = (struct mips_hi *) bfd_malloc (sizeof *n);
+ n = (struct mips_hi *) bfd_malloc ((bfd_size_type) sizeof *n);
if (n == NULL)
return bfd_reloc_outofrange;
n->addr = (bfd_byte *) data + reloc_entry->address;
if ((val & 0x8000) != 0)
val += 0x10000;
- insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
- bfd_put_32 (abfd, insn, l->addr);
+ insn = (insn &~ (unsigned) 0xffff) | ((val >> 16) & 0xffff);
+ bfd_put_32 (abfd, (bfd_vma) insn, l->addr);
next = l->next;
free (l);
if ((val & 0x8000) != 0)
val += 0x10000;
- insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
+ insn = (insn &~ (unsigned) 0xffff) | ((val >> 16) & 0xffff);
bfd_put_32 (input_bfd, (bfd_vma) insn,
contents + adjust + refhi->r_vaddr - input_section->vma);
}
unsigned int i;
boolean got_lo;
struct internal_reloc lo_int_rel;
+ bfd_size_type amt;
BFD_ASSERT (input_bfd->xvec->byteorder
== output_bfd->xvec->byteorder);
symndx_to_section = ecoff_data (input_bfd)->symndx_to_section;
if (symndx_to_section == (asection **) NULL)
{
- symndx_to_section = ((asection **)
- bfd_alloc (input_bfd,
- (NUM_RELOC_SECTIONS
- * sizeof (asection *))));
+ amt = NUM_RELOC_SECTIONS * sizeof (asection *);
+ symndx_to_section = (asection **) bfd_alloc (input_bfd, amt);
if (!symndx_to_section)
return false;
asection *sec;
{
struct ecoff_section_tdata *section_tdata;
+ bfd_size_type amt;
section_tdata = ecoff_section_data (abfd, sec);
if (section_tdata == (struct ecoff_section_tdata *) NULL)
{
- sec->used_by_bfd =
- (PTR) bfd_alloc (abfd, sizeof (struct ecoff_section_tdata));
+ amt = sizeof (struct ecoff_section_tdata);
+ sec->used_by_bfd = (PTR) bfd_alloc (abfd, amt);
if (sec->used_by_bfd == NULL)
return false;
if (section_tdata->external_relocs == NULL)
{
- bfd_size_type external_relocs_size;
-
- external_relocs_size = (ecoff_backend (abfd)->external_reloc_size
- * sec->reloc_count);
-
- section_tdata->external_relocs =
- (PTR) bfd_alloc (abfd, external_relocs_size);
- if (section_tdata->external_relocs == NULL && external_relocs_size != 0)
+ amt = ecoff_backend (abfd)->external_reloc_size;
+ amt *= sec->reloc_count;
+ section_tdata->external_relocs = (PTR) bfd_alloc (abfd, amt);
+ if (section_tdata->external_relocs == NULL && amt != 0)
return false;
if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
- || (bfd_read (section_tdata->external_relocs, 1,
- external_relocs_size, abfd)
- != external_relocs_size))
+ || bfd_bread (section_tdata->external_relocs, amt, abfd) != amt)
return false;
}
struct ecoff_link_hash_entry **adj_h_ptr;
struct ecoff_link_hash_entry **adj_h_ptr_end;
struct ecoff_value_adjust *adjust;
+ bfd_size_type amt;
/* If we have already expanded this reloc, we certainly don't
need to do it again. */
if (info->keep_memory)
contents = (bfd_byte *) bfd_alloc (abfd, sec->_raw_size);
else
- contents = (bfd_byte *) bfd_malloc ((size_t) sec->_raw_size);
+ contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
if (contents == (bfd_byte *) NULL)
goto error_return;
if (! bfd_get_section_contents (abfd, sec, (PTR) contents,
if (offsets == (long *) NULL)
{
- size_t size;
+ bfd_size_type size;
- size = sec->reloc_count * sizeof (long);
+ size = (bfd_size_type) sec->reloc_count * sizeof (long);
offsets = (long *) bfd_alloc (abfd, size);
if (offsets == (long *) NULL)
goto error_return;
- memset (offsets, 0, size);
+ memset (offsets, 0, (size_t) size);
section_tdata->offsets = offsets;
}
/* Add an entry to the symbol value adjust list. This is used
by bfd_ecoff_debug_accumulate to adjust the values of
internal symbols and FDR's. */
- adjust = ((struct ecoff_value_adjust *)
- bfd_alloc (abfd, sizeof (struct ecoff_value_adjust)));
+ amt = sizeof (struct ecoff_value_adjust);
+ adjust = (struct ecoff_value_adjust *) bfd_alloc (abfd, amt);
if (adjust == (struct ecoff_value_adjust *) NULL)
goto error_return;
if ((relocation & 0x8000) != 0)
relocation += 0x10000;
- bfd_put_32 (input_bfd, 0x04110001, location); /* bal .+8 */
+ bfd_put_32 (input_bfd, (bfd_vma) 0x04110001, location); /* bal .+8 */
bfd_put_32 (input_bfd,
0x3c010000 | ((relocation >> 16) & 0xffff), /* lui $at,XX */
location + 4);
bfd_put_32 (input_bfd,
0x24210000 | (relocation & 0xffff), /* addiu $at,$at,XX */
location + 8);
- bfd_put_32 (input_bfd, 0x003f0821, location + 12); /* addu $at,$at,$ra */
- bfd_put_32 (input_bfd, 0x0020f809, location + 16); /* jalr $at */
+ bfd_put_32 (input_bfd,
+ (bfd_vma) 0x003f0821, location + 12); /* addu $at,$at,$ra */
+ bfd_put_32 (input_bfd,
+ (bfd_vma) 0x0020f809, location + 16); /* jalr $at */
return true;
}
struct external_reloc *ext_rel;
struct external_reloc *ext_rel_end;
bfd_byte *p;
+ bfd_size_type amt;
BFD_ASSERT (! info->relocateable);
if (! mips_read_relocs (abfd, datasec))
return false;
- relsec->contents = (bfd_byte *) bfd_alloc (abfd, datasec->reloc_count * 4);
+ amt = (bfd_size_type) datasec->reloc_count * 4;
+ relsec->contents = (bfd_byte *) bfd_alloc (abfd, amt);
if (relsec->contents == NULL)
return false;
bfd *abfd;
{
struct ppc_coff_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct ppc_coff_link_hash_table);
- ret = ((struct ppc_coff_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct ppc_coff_link_hash_table)));
+ ret = (struct ppc_coff_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == NULL)
return NULL;
if (! ppc_coff_link_hash_table_init (ret, abfd,
{
priv,
pub,
- data
+ tocdata
};
struct list_ele
extern struct list_ele *tail;
static void record_toc
- PARAMS ((asection *, int, enum ref_category, const char *));
+ PARAMS ((asection *, bfd_signed_vma, enum ref_category, const char *));
static void
record_toc (toc_section, our_toc_offset, cat, name)
asection *toc_section;
- int our_toc_offset;
+ bfd_signed_vma our_toc_offset;
enum ref_category cat;
const char *name;
{
/* add this entry to our toc addr-offset-name list */
- struct list_ele *t;
- t = (struct list_ele *) bfd_malloc (sizeof (struct list_ele));
+ bfd_size_type amt = sizeof (struct list_ele);
+ struct list_ele *t = (struct list_ele *) bfd_malloc (amt);
+
if (t == NULL)
abort ();
t->next = 0;
if (local_syms == 0)
{
unsigned int i;
+ bfd_size_type amt;
/* allocate a table */
- local_syms =
- (int *) bfd_zalloc (abfd,
- obj_raw_syment_count(abfd) * sizeof (int));
+ amt = (bfd_size_type) obj_raw_syment_count (abfd) * sizeof (int);
+ local_syms = (int *) bfd_zalloc (abfd, amt);
if (local_syms == 0)
return false;
- obj_coff_local_toc_table(abfd) = local_syms;
- for (i = 0; i < obj_raw_syment_count(abfd); ++i)
+ obj_coff_local_toc_table (abfd) = local_syms;
+ for (i = 0; i < obj_raw_syment_count (abfd); ++i)
{
- SET_UNALLOCATED(local_syms[i]);
+ SET_UNALLOCATED (local_syms[i]);
}
}
return false;
case IMAGE_REL_PPC_TOCREL16:
{
- bfd_vma our_toc_offset;
+ bfd_signed_vma our_toc_offset;
int fixit;
DUMP_RELOC2(howto->name, rel);
else
{
/* write out the toc entry */
- record_toc(toc_section,
- our_toc_offset,
- priv,
- strdup(name));
+ record_toc (toc_section, our_toc_offset, priv,
+ strdup (name));
- bfd_put_32 (output_bfd,
- val,
+ bfd_put_32 (output_bfd, val,
toc_section->contents + our_toc_offset);
MARK_AS_WRITTEN(local_toc_table[symndx]);
the IAT to be part of the toc, thus saving a load.
*/
- our_toc_offset = val -
- (toc_section->output_section->vma +
- toc_section->output_offset);
+ our_toc_offset = val - (toc_section->output_section->vma
+ + toc_section->output_offset);
/* The size must still fit in a 16bit displacment */
- if (our_toc_offset >= 65535)
+ if ((bfd_vma) our_toc_offset >= 65535)
{
(*_bfd_error_handler)
- (_("%s: Relocation for %s of %x exceeds Toc size limit"),
- bfd_get_filename (input_bfd), name, our_toc_offset);
+ (_("%s: Relocation for %s of %lx exceeds Toc size limit"),
+ bfd_get_filename (input_bfd), name,
+ (unsigned long) our_toc_offset);
bfd_set_error (bfd_error_bad_value);
return false;
}
- record_toc(toc_section, our_toc_offset, pub, strdup(name));
+ record_toc (toc_section, our_toc_offset, pub,
+ strdup (name));
}
else if (IS_WRITTEN(our_toc_offset))
{
}
else
{
- record_toc(toc_section, our_toc_offset, pub, strdup(name));
+ record_toc(toc_section, our_toc_offset, pub,
+ strdup (name));
/* write out the toc entry */
- bfd_put_32 (output_bfd,
- val,
+ bfd_put_32 (output_bfd, val,
toc_section->contents + our_toc_offset);
MARK_AS_WRITTEN(h->toc_offset);
isn't absolute - we output the address here
to a file */
- bfd_vma addr = toc_section->output_section->vma
- + toc_section->output_offset + our_toc_offset;
+ bfd_vma addr = (toc_section->output_section->vma
+ + toc_section->output_offset + our_toc_offset);
if (coff_data(output_bfd)->pe)
addr -= pe_data(output_bfd)->pe_opthdr.ImageBase;
}
/* FIXME: this test is conservative */
- if ( (r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN &&
- our_toc_offset > toc_section->_raw_size)
+ if ((r_flags & IMAGE_REL_PPC_TOCDEFN) != IMAGE_REL_PPC_TOCDEFN
+ && (bfd_vma) our_toc_offset > toc_section->_raw_size)
{
(*_bfd_error_handler)
- (_("%s: Relocation exceeds allocated TOC (%x)"),
+ (_("%s: Relocation exceeds allocated TOC (%lx)"),
bfd_get_filename (input_bfd),
- toc_section->_raw_size);
+ (unsigned long) toc_section->_raw_size);
bfd_set_error (bfd_error_bad_value);
return false;
}
/* Now we know the relocation for this toc reference */
relocation = our_toc_offset + TOC_LOAD_ADJUSTMENT;
- rstat = _bfd_relocate_contents (howto,
- input_bfd,
- relocation,
- loc);
+ rstat = _bfd_relocate_contents (howto, input_bfd, relocation, loc);
}
break;
case IMAGE_REL_PPC_IFGLUE:
if (h->symbol_is_glue == 1)
{
x = bfd_get_32 (input_bfd, loc);
- bfd_put_32 (input_bfd, h->glue_insn, loc);
+ bfd_put_32 (input_bfd, (bfd_vma) h->glue_insn, loc);
}
}
}
case IMAGE_REL_PPC_ADDR32NB:
{
- struct coff_link_hash_entry *myh = 0;
const char *name = 0;
DUMP_RELOC2(howto->name, rel);
{
/* set magic values */
int idata5offset;
- struct coff_link_hash_entry *myh = 0;
+ struct coff_link_hash_entry *myh;
myh = coff_link_hash_lookup (coff_hash_table (info),
"__idata5_magic__",
false, false, true);
if (target != 0)
{
- myh = 0;
+ struct coff_link_hash_entry *myh;
myh = coff_link_hash_lookup (coff_hash_table (info),
target,
cat = _("private ");
else if (t->cat == pub)
cat = _("public ");
- else if (t->cat == data)
+ else if (t->cat == tocdata)
cat = _("data-in-toc ");
if (t->offset > global_toc_size)
{
fprintf (file,
_("**** global_toc_size %ld(%lx), thunk_size %ld(%lx)\n"),
- global_toc_size, global_toc_size, thunk_size, thunk_size);
+ global_toc_size, global_toc_size,
+ thunk_size, thunk_size);
cat = _("Out of bounds!");
}
}
{
asection *s;
bfd_byte *foo;
+ bfd_size_type amt;
static char test_char = '1';
if ( global_toc_size == 0 ) /* FIXME: does this get me in trouble? */
abort ();
}
- foo = (bfd_byte *) bfd_alloc(bfd_of_toc_owner, global_toc_size);
- memset(foo, test_char, global_toc_size);
+ amt = global_toc_size;
+ foo = (bfd_byte *) bfd_alloc (bfd_of_toc_owner, amt);
+ memset(foo, test_char, (size_t) global_toc_size);
s->_raw_size = s->_cooked_size = global_toc_size;
s->contents = foo;
boolean debug_merge_allocated;
asection *o;
struct bfd_link_order *p;
- size_t max_sym_count;
- size_t max_lineno_count;
- size_t max_reloc_count;
- size_t max_output_reloc_count;
- size_t max_contents_size;
+ bfd_size_type max_sym_count;
+ bfd_size_type max_lineno_count;
+ bfd_size_type max_reloc_count;
+ bfd_size_type max_output_reloc_count;
+ bfd_size_type max_contents_size;
file_ptr rel_filepos;
unsigned int relsz;
file_ptr line_filepos;
bfd *sub;
bfd_byte *external_relocs = NULL;
char strbuf[STRING_SIZE_SIZE];
+ bfd_size_type amt;
symesz = bfd_coff_symesz (abfd);
/* We use section_count + 1, rather than section_count, because
the target_index fields are 1 based. */
- finfo.section_info =
- ((struct coff_link_section_info *)
- bfd_malloc ((abfd->section_count + 1)
- * sizeof (struct coff_link_section_info)));
+ amt = abfd->section_count + 1;
+ amt *= sizeof (struct coff_link_section_info);
+ finfo.section_info = (struct coff_link_section_info *) bfd_malloc (amt);
if (finfo.section_info == NULL)
goto error_return;
for (i = 0; i <= abfd->section_count; i++)
but only when doing a relocateable link, which is not the
common case. */
BFD_ASSERT (info->relocateable);
+ amt = o->reloc_count;
+ amt *= sizeof (struct internal_reloc);
finfo.section_info[o->target_index].relocs =
- ((struct internal_reloc *)
- bfd_malloc (o->reloc_count * sizeof (struct internal_reloc)));
+ (struct internal_reloc *) bfd_malloc (amt);
+ amt = o->reloc_count;
+ amt *= sizeof (struct coff_link_hash_entry *);
finfo.section_info[o->target_index].rel_hashes =
- ((struct coff_link_hash_entry **)
- bfd_malloc (o->reloc_count
- * sizeof (struct coff_link_hash_entry *)));
+ (struct coff_link_hash_entry **) bfd_malloc (amt);
if (finfo.section_info[o->target_index].relocs == NULL
|| finfo.section_info[o->target_index].rel_hashes == NULL)
goto error_return;
max_sym_count = 0;
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
{
- size_t sz;
+ bfd_size_type sz;
sub->output_has_begun = false;
sz = obj_raw_syment_count (sub);
}
/* Allocate some buffers used while linking. */
- finfo.internal_syms = ((struct internal_syment *)
- bfd_malloc (max_sym_count
- * sizeof (struct internal_syment)));
- finfo.sec_ptrs = (asection **) bfd_malloc (max_sym_count
- * sizeof (asection *));
- finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
- finfo.outsyms = ((bfd_byte *)
- bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
- finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
- * bfd_coff_linesz (abfd));
+ amt = max_sym_count * sizeof (struct internal_syment);
+ finfo.internal_syms = (struct internal_syment *) bfd_malloc (amt);
+ amt = max_sym_count * sizeof (asection *);
+ finfo.sec_ptrs = (asection **) bfd_malloc (amt);
+ amt = max_sym_count * sizeof (long);
+ finfo.sym_indices = (long *) bfd_malloc (amt);
+ amt = (max_sym_count + 1) * symesz;
+ finfo.outsyms = (bfd_byte *) bfd_malloc (amt);
+ amt = max_lineno_count * bfd_coff_linesz (abfd);
+ finfo.linenos = (bfd_byte *) bfd_malloc (amt);
finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
if (! info->relocateable)
- finfo.internal_relocs = ((struct internal_reloc *)
- bfd_malloc (max_reloc_count
- * sizeof (struct internal_reloc)));
+ {
+ amt = max_reloc_count * sizeof (struct internal_reloc);
+ finfo.internal_relocs = (struct internal_reloc *) bfd_malloc (amt);
+ }
if ((finfo.internal_syms == NULL && max_sym_count > 0)
|| (finfo.sec_ptrs == NULL && max_sym_count > 0)
|| (finfo.sym_indices == NULL && max_sym_count > 0)
if (finfo.last_file_index != -1
&& (unsigned int) finfo.last_file.n_value != obj_raw_syment_count (abfd))
{
+ file_ptr pos;
+
finfo.last_file.n_value = obj_raw_syment_count (abfd);
bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
(PTR) finfo.outsyms);
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + finfo.last_file_index * symesz),
- SEEK_SET) != 0
- || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz)
+ pos = obj_sym_filepos (abfd) + finfo.last_file_index * symesz;
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (finfo.outsyms, symesz, abfd) != symesz)
return false;
}
/* Now that we have written out all the global symbols, we know
the symbol indices to use for relocs against them, and we can
finally write out the relocs. */
- external_relocs = ((bfd_byte *)
- bfd_malloc (max_output_reloc_count * relsz));
+ amt = max_output_reloc_count * relsz;
+ external_relocs = (bfd_byte *) bfd_malloc (amt);
if (external_relocs == NULL)
goto error_return;
bfd_coff_swap_reloc_out (abfd, (PTR) irel, (PTR) erel);
}
+ amt = relsz * o->reloc_count;
if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
- || bfd_write ((PTR) external_relocs, relsz, o->reloc_count,
- abfd) != relsz * o->reloc_count)
+ || bfd_bwrite ((PTR) external_relocs, amt, abfd) != amt)
goto error_return;
}
/* Write out the string table. */
if (obj_raw_syment_count (abfd) != 0)
{
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + obj_raw_syment_count (abfd) * symesz),
- SEEK_SET) != 0)
+ file_ptr pos;
+
+ pos = obj_sym_filepos (abfd) + obj_raw_syment_count (abfd) * symesz;
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0)
return false;
#if STRING_SIZE_SIZE == 4
- bfd_h_put_32 (abfd,
- _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
- (bfd_byte *) strbuf);
+ H_PUT_32 (abfd,
+ _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
+ strbuf);
#else
- #error Change bfd_h_put_32
+ #error Change H_PUT_32 above
#endif
- if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
+ if (bfd_bwrite (strbuf, (bfd_size_type) STRING_SIZE_SIZE, abfd)
+ != STRING_SIZE_SIZE)
return false;
if (! _bfd_stringtab_emit (abfd, finfo.strtab))
#define COFF_LONG_FILENAMES
#define NO_COFF_SYMBOLS
#define RTYPE2HOWTO(cache_ptr, dst) _bfd_xcoff_rtype2howto (cache_ptr, dst)
-#define coff_mkobject _bfd_xcoff_mkobject
-#define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
-#define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
-#define coff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup
+#define coff_mkobject _bfd_xcoff_mkobject
+#define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
+#define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
+#define coff_bfd_reloc_type_lookup _bfd_xcoff_reloc_type_lookup
#ifdef AIX_CORE
extern const bfd_target * rs6000coff_core_p ();
extern boolean rs6000coff_core_file_matches_executable_p ();
bfd *abfd;
{
coff_data_type *coff;
+ bfd_size_type amt = sizeof (struct xcoff_tdata);
- abfd->tdata.xcoff_obj_data =
- ((struct xcoff_tdata *)
- bfd_zalloc (abfd, sizeof (struct xcoff_tdata)));
+ abfd->tdata.xcoff_obj_data = (struct xcoff_tdata *) bfd_zalloc (abfd, amt);
if (abfd->tdata.xcoff_obj_data == NULL)
return false;
coff = coff_data (abfd);
return false;
}
\f
-
-
void
_bfd_xcoff_swap_sym_in (abfd, ext1, in1)
bfd *abfd;
else
{
in->_n._n_n._n_zeroes = 0;
- in->_n._n_n._n_offset =
- bfd_h_get_32 (abfd, (bfd_byte *) ext->e.e.e_offset);
+ in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset);
}
- in->n_value = bfd_h_get_32 (abfd, (bfd_byte *) ext->e_value);
- in->n_scnum = bfd_h_get_16 (abfd, (bfd_byte *) ext->e_scnum);
- in->n_type = bfd_h_get_16 (abfd, (bfd_byte *) ext->e_type);
- in->n_sclass = bfd_h_get_8 (abfd, ext->e_sclass);
- in->n_numaux = bfd_h_get_8 (abfd, ext->e_numaux);
+ in->n_value = H_GET_32 (abfd, ext->e_value);
+ in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
+ in->n_type = H_GET_16 (abfd, ext->e_type);
+ in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
+ in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
}
unsigned int
}
else
{
- bfd_h_put_32 (abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
- bfd_h_put_32 (abfd, in->_n._n_n._n_offset,
- (bfd_byte *) ext->e.e.e_offset);
+ H_PUT_32 (abfd, 0, ext->e.e.e_zeroes);
+ H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e.e.e_offset);
}
- bfd_h_put_32 (abfd, in->n_value , (bfd_byte *) ext->e_value);
- bfd_h_put_16 (abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
- bfd_h_put_16 (abfd, in->n_type , (bfd_byte *) ext->e_type);
- bfd_h_put_8 (abfd, in->n_sclass , ext->e_sclass);
- bfd_h_put_8 (abfd, in->n_numaux , ext->e_numaux);
+ H_PUT_32 (abfd, in->n_value, ext->e_value);
+ H_PUT_16 (abfd, in->n_scnum, ext->e_scnum);
+ H_PUT_16 (abfd, in->n_type, ext->e_type);
+ H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
+ H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
return bfd_coff_symesz (abfd);
}
-#define PUTWORD bfd_h_put_32
-#define PUTHALF bfd_h_put_16
-#define PUTBYTE bfd_h_put_8
-#define GETWORD bfd_h_get_32
-#define GETHALF bfd_h_get_16
-#define GETBYTE bfd_h_get_8
-
void
_bfd_xcoff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
bfd *abfd;
if (ext->x_file.x_fname[0] == 0)
{
in->x_file.x_n.x_zeroes = 0;
- in->x_file.x_n.x_offset =
- bfd_h_get_32 (abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
+ in->x_file.x_n.x_offset =
+ H_GET_32 (abfd, ext->x_file.x_n.x_offset);
}
else
{
case C_HIDEXT:
if (indx + 1 == numaux)
{
- in->x_csect.x_scnlen.l =
- bfd_h_get_32 (abfd, ext->x_csect.x_scnlen);
- in->x_csect.x_parmhash = bfd_h_get_32 (abfd,
- ext->x_csect.x_parmhash);
- in->x_csect.x_snhash = bfd_h_get_16 (abfd, ext->x_csect.x_snhash);
+ in->x_csect.x_scnlen.l = H_GET_32 (abfd, ext->x_csect.x_scnlen);
+ in->x_csect.x_parmhash = H_GET_32 (abfd, ext->x_csect.x_parmhash);
+ in->x_csect.x_snhash = H_GET_16 (abfd, ext->x_csect.x_snhash);
/* We don't have to hack bitfields in x_smtyp because it's
defined by shifts-and-ands, which are equivalent on all
byte orders. */
- in->x_csect.x_smtyp = bfd_h_get_8 (abfd, ext->x_csect.x_smtyp);
- in->x_csect.x_smclas = bfd_h_get_8 (abfd, ext->x_csect.x_smclas);
- in->x_csect.x_stab = bfd_h_get_32 (abfd, ext->x_csect.x_stab);
- in->x_csect.x_snstab = bfd_h_get_16 (abfd, ext->x_csect.x_snstab);
+ in->x_csect.x_smtyp = H_GET_8 (abfd, ext->x_csect.x_smtyp);
+ in->x_csect.x_smclas = H_GET_8 (abfd, ext->x_csect.x_smclas);
+ in->x_csect.x_stab = H_GET_32 (abfd, ext->x_csect.x_stab);
+ in->x_csect.x_snstab = H_GET_16 (abfd, ext->x_csect.x_snstab);
goto end;
}
break;
case C_HIDDEN:
if (type == T_NULL)
{
- in->x_scn.x_scnlen = bfd_h_get_32(abfd,
- (bfd_byte *) ext->x_scn.x_scnlen);
- in->x_scn.x_nreloc = bfd_h_get_16(abfd,
- (bfd_byte *) ext->x_scn.x_nreloc);
- in->x_scn.x_nlinno = bfd_h_get_16(abfd,
- (bfd_byte *) ext->x_scn.x_nlinno);
+ in->x_scn.x_scnlen = H_GET_32 (abfd, ext->x_scn.x_scnlen);
+ in->x_scn.x_nreloc = H_GET_16 (abfd, ext->x_scn.x_nreloc);
+ in->x_scn.x_nlinno = H_GET_16 (abfd, ext->x_scn.x_nlinno);
/* PE defines some extra fields; we zero them out for
safety. */
in->x_scn.x_checksum = 0;
break;
}
- in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
- in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
+ in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->x_sym.x_tagndx);
+ in->x_sym.x_tvndx = H_GET_16 (abfd, ext->x_sym.x_tvndx);
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
{
- in->x_sym.x_fcnary.x_fcn.x_lnnoptr = bfd_h_get_32(abfd, (bfd_byte *)
- ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
- in->x_sym.x_fcnary.x_fcn.x_endndx.l = bfd_h_get_32(abfd, (bfd_byte *)
- ext->x_sym.x_fcnary.x_fcn.x_endndx);
+ in->x_sym.x_fcnary.x_fcn.x_lnnoptr =
+ H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
+ in->x_sym.x_fcnary.x_fcn.x_endndx.l =
+ H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx);
}
else
{
in->x_sym.x_fcnary.x_ary.x_dimen[0] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+ H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
in->x_sym.x_fcnary.x_ary.x_dimen[1] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+ H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
in->x_sym.x_fcnary.x_ary.x_dimen[2] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+ H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
in->x_sym.x_fcnary.x_ary.x_dimen[3] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+ H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
}
if (ISFCN (type))
{
- in->x_sym.x_misc.x_fsize = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
+ in->x_sym.x_misc.x_fsize = H_GET_32 (abfd, ext->x_sym.x_misc.x_fsize);
}
else
{
- in->x_sym.x_misc.x_lnsz.x_lnno = bfd_h_get_16 (abfd, (bfd_byte *)
- ext->x_sym.x_misc.x_lnsz.x_lnno);
- in->x_sym.x_misc.x_lnsz.x_size = bfd_h_get_16 (abfd, (bfd_byte *)
- ext->x_sym.x_misc.x_lnsz.x_size);
+ in->x_sym.x_misc.x_lnsz.x_lnno =
+ H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_lnno);
+ in->x_sym.x_misc.x_lnsz.x_size =
+ H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_size);
}
end: ;
case C_FILE:
if (in->x_file.x_fname[0] == 0)
{
- PUTWORD (abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
- PUTWORD (abfd,
- in->x_file.x_n.x_offset,
- (bfd_byte *) ext->x_file.x_n.x_offset);
+ H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
+ H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
}
else
{
case C_HIDEXT:
if (indx + 1 == numaux)
{
- PUTWORD (abfd, in->x_csect.x_scnlen.l,ext->x_csect.x_scnlen);
- PUTWORD (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
- PUTHALF (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
+ H_PUT_32 (abfd, in->x_csect.x_scnlen.l, ext->x_csect.x_scnlen);
+ H_PUT_32 (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
+ H_PUT_16 (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
/* We don't have to hack bitfields in x_smtyp because it's
defined by shifts-and-ands, which are equivalent on all
byte orders. */
- PUTBYTE (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
- PUTBYTE (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
- PUTWORD (abfd, in->x_csect.x_stab, ext->x_csect.x_stab);
- PUTHALF (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab);
+ H_PUT_8 (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
+ H_PUT_8 (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
+ H_PUT_32 (abfd, in->x_csect.x_stab, ext->x_csect.x_stab);
+ H_PUT_16 (abfd, in->x_csect.x_snstab, ext->x_csect.x_snstab);
goto end;
}
break;
case C_HIDDEN:
if (type == T_NULL)
{
- bfd_h_put_32(abfd, in->x_scn.x_scnlen, (bfd_byte *) ext->x_scn.x_scnlen);
- bfd_h_put_16(abfd, in->x_scn.x_nreloc, (bfd_byte *) ext->x_scn.x_nreloc);
- bfd_h_put_16(abfd, in->x_scn.x_nlinno, (bfd_byte *) ext->x_scn.x_nlinno);
+ H_PUT_32 (abfd, in->x_scn.x_scnlen, ext->x_scn.x_scnlen);
+ H_PUT_16 (abfd, in->x_scn.x_nreloc, ext->x_scn.x_nreloc);
+ H_PUT_16 (abfd, in->x_scn.x_nlinno, ext->x_scn.x_nlinno);
goto end;
}
break;
}
- PUTWORD (abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
- bfd_h_put_16 (abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
+ H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->x_sym.x_tagndx);
+ H_PUT_16 (abfd, in->x_sym.x_tvndx, ext->x_sym.x_tvndx);
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
{
- bfd_h_put_32 (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr,
- (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
- PUTWORD (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l,
- (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx);
+ H_PUT_32 (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr,
+ ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
+ H_PUT_32 (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l,
+ ext->x_sym.x_fcnary.x_fcn.x_endndx);
}
else
{
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+ H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
+ ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+ H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
+ ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+ H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
+ ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+ H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
+ ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
}
if (ISFCN (type))
- PUTWORD (abfd, in->x_sym.x_misc.x_fsize,
- (bfd_byte *) ext->x_sym.x_misc.x_fsize);
+ H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize);
else
{
- bfd_h_put_16 (abfd, in->x_sym.x_misc.x_lnsz.x_lnno,
- (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno);
- bfd_h_put_16 (abfd, in->x_sym.x_misc.x_lnsz.x_size,
- (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_size);
+ H_PUT_16 (abfd, in->x_sym.x_misc.x_lnsz.x_lnno,
+ ext->x_sym.x_misc.x_lnsz.x_lnno);
+ H_PUT_16 (abfd, in->x_sym.x_misc.x_lnsz.x_size,
+ ext->x_sym.x_misc.x_lnsz.x_size);
}
end:
type matches this information. The bitsize is not significant
for R_REF relocs. */
if (relent->howto->dst_mask != 0
- && (relent->howto->bitsize
+ && (relent->howto->bitsize
!= ((unsigned int) internal->r_size & 0x3f) + 1))
abort ();
#if 0
return false;
/* The symbol table starts with a normal archive header. */
- if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
+ if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
+ != SIZEOF_AR_HDR)
return false;
/* Skip the name (normally empty). */
namlen = strtol (hdr.namlen, (char **) NULL, 10);
- if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0)
+ off = ((namlen + 1) & ~ (size_t) 1) + SXCOFFARFMAG;
+ if (bfd_seek (abfd, off, SEEK_CUR) != 0)
return false;
sz = strtol (hdr.size, (char **) NULL, 10);
contents = (bfd_byte *) bfd_alloc (abfd, sz);
if (contents == NULL)
return false;
- if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
+ if (bfd_bread ((PTR) contents, sz, abfd) != sz)
return false;
/* The symbol table starts with a four byte count. */
- c = bfd_h_get_32 (abfd, contents);
-
+ c = H_GET_32 (abfd, contents);
+
if (c * 4 >= sz)
{
bfd_set_error (bfd_error_bad_value);
return false;
}
-
- bfd_ardata (abfd)->symdefs = ((carsym *)
- bfd_alloc (abfd, c * sizeof (carsym)));
+
+ bfd_ardata (abfd)->symdefs =
+ ((carsym *) bfd_alloc (abfd, c * sizeof (carsym)));
if (bfd_ardata (abfd)->symdefs == NULL)
return false;
-
+
/* After the count comes a list of four byte file offsets. */
for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 4;
i < c;
++i, ++arsym, p += 4)
- arsym->file_offset = bfd_h_get_32 (abfd, p);
+ arsym->file_offset = H_GET_32 (abfd, p);
}
else
{
return false;
/* The symbol table starts with a normal archive header. */
- if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd)
+ if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
!= SIZEOF_AR_HDR_BIG)
return false;
/* Skip the name (normally empty). */
namlen = strtol (hdr.namlen, (char **) NULL, 10);
- if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0)
+ off = ((namlen + 1) & ~ (size_t) 1) + SXCOFFARFMAG;
+ if (bfd_seek (abfd, off, SEEK_CUR) != 0)
return false;
/* XXX This actually has to be a call to strtoll (at least on 32-bit
contents = (bfd_byte *) bfd_alloc (abfd, sz);
if (contents == NULL)
return false;
- if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
+ if (bfd_bread ((PTR) contents, sz, abfd) != sz)
return false;
/* The symbol table starts with an eight byte count. */
- c = bfd_h_get_64 (abfd, contents);
+ c = H_GET_64 (abfd, contents);
if (c * 8 >= sz)
{
bfd_set_error (bfd_error_bad_value);
return false;
}
-
- bfd_ardata (abfd)->symdefs = ((carsym *)
- bfd_alloc (abfd, c * sizeof (carsym)));
+
+ bfd_ardata (abfd)->symdefs =
+ ((carsym *) bfd_alloc (abfd, c * sizeof (carsym)));
if (bfd_ardata (abfd)->symdefs == NULL)
return false;
-
+
/* After the count comes a list of eight byte file offsets. */
for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 8;
i < c;
++i, ++arsym, p += 8)
- arsym->file_offset = bfd_h_get_64 (abfd, p);
+ arsym->file_offset = H_GET_64 (abfd, p);
}
/* After the file offsets come null terminated symbol names. */
bfd *abfd;
{
char magic[SXCOFFARMAG];
+ bfd_size_type amt;
- if (bfd_read ((PTR) magic, SXCOFFARMAG, 1, abfd) != SXCOFFARMAG)
+ if (bfd_bread ((PTR) magic, (bfd_size_type) SXCOFFARMAG, abfd) != SXCOFFARMAG)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
/* We are setting bfd_ardata(abfd) here, but since bfd_ardata
involves a cast, we can't do it as the left operand of
assignment. */
- abfd->tdata.aout_ar_data =
- (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
-
+ amt = sizeof (struct artdata);
+ abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt);
if (bfd_ardata (abfd) == (struct artdata *) NULL)
return NULL;
memcpy (hdr.magic, magic, SXCOFFARMAG);
/* Now read the rest of the file header. */
- if (bfd_read ((PTR) &hdr.memoff, SIZEOF_AR_FILE_HDR - SXCOFFARMAG, 1,
- abfd) != SIZEOF_AR_FILE_HDR - SXCOFFARMAG)
+ if (bfd_bread ((PTR) &hdr.memoff,
+ (bfd_size_type) SIZEOF_AR_FILE_HDR - SXCOFFARMAG, abfd)
+ != SIZEOF_AR_FILE_HDR - SXCOFFARMAG)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
(char **) NULL, 10);
- bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR);
+ amt = SIZEOF_AR_FILE_HDR;
+ bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt);
if (bfd_ardata (abfd)->tdata == NULL)
return NULL;
memcpy (hdr.magic, magic, SXCOFFARMAG);
/* Now read the rest of the file header. */
- if (bfd_read ((PTR) &hdr.memoff, SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG, 1,
- abfd) != SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG)
+ if (bfd_bread ((PTR) &hdr.memoff,
+ (bfd_size_type) SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG, abfd)
+ != SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
(char **) NULL, 10);
- bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR_BIG);
+ amt = SIZEOF_AR_FILE_HDR_BIG;
+ bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt);
if (bfd_ardata (abfd)->tdata == NULL)
return NULL;
_bfd_xcoff_read_ar_hdr (abfd)
bfd *abfd;
{
- size_t namlen;
+ bfd_size_type namlen;
struct areltdata *ret;
+ bfd_size_type amt = sizeof (struct areltdata);
- ret = (struct areltdata *) bfd_alloc (abfd, sizeof (struct areltdata));
+ ret = (struct areltdata *) bfd_alloc (abfd, amt);
if (ret == NULL)
return NULL;
struct xcoff_ar_hdr hdr;
struct xcoff_ar_hdr *hdrp;
- if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR)
+ if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
+ != SIZEOF_AR_HDR)
{
free (ret);
return NULL;
}
namlen = strtol (hdr.namlen, (char **) NULL, 10);
- hdrp = (struct xcoff_ar_hdr *) bfd_alloc (abfd,
- SIZEOF_AR_HDR + namlen + 1);
+ amt = SIZEOF_AR_HDR + namlen + 1;
+ hdrp = (struct xcoff_ar_hdr *) bfd_alloc (abfd, amt);
if (hdrp == NULL)
{
free (ret);
return NULL;
}
memcpy (hdrp, &hdr, SIZEOF_AR_HDR);
- if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR, 1, namlen, abfd) != namlen)
+ if (bfd_bread ((char *) hdrp + SIZEOF_AR_HDR, namlen, abfd) != namlen)
{
free (ret);
return NULL;
struct xcoff_ar_hdr_big hdr;
struct xcoff_ar_hdr_big *hdrp;
- if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd)
+ if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
!= SIZEOF_AR_HDR_BIG)
{
free (ret);
}
namlen = strtol (hdr.namlen, (char **) NULL, 10);
- hdrp = (struct xcoff_ar_hdr_big *) bfd_alloc (abfd,
- SIZEOF_AR_HDR_BIG
- + namlen + 1);
+ amt = SIZEOF_AR_HDR_BIG + namlen + 1;
+ hdrp = (struct xcoff_ar_hdr_big *) bfd_alloc (abfd, amt);
if (hdrp == NULL)
{
free (ret);
return NULL;
}
memcpy (hdrp, &hdr, SIZEOF_AR_HDR_BIG);
- if (bfd_read ((char *) hdrp + SIZEOF_AR_HDR_BIG, 1, namlen, abfd) != namlen)
+ if (bfd_bread ((char *) hdrp + SIZEOF_AR_HDR_BIG, namlen, abfd) != namlen)
{
free (ret);
return NULL;
}
/* Skip over the XCOFFARFMAG at the end of the file name. */
- if (bfd_seek (abfd, (namlen & 1) + SXCOFFARFMAG, SEEK_CUR) != 0)
+ if (bfd_seek (abfd, (file_ptr) ((namlen & 1) + SXCOFFARFMAG), SEEK_CUR) != 0)
return NULL;
return (PTR) ret;
if (*p == '\0')
*p = ' ';
- if (bfd_write ((PTR) &hdr, SIZEOF_AR_HDR, 1, abfd) != SIZEOF_AR_HDR
- || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG)
+ if (bfd_bwrite ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
+ != SIZEOF_AR_HDR
+ || (bfd_bwrite (XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)
+ != SXCOFFARFMAG))
return false;
- bfd_h_put_32 (abfd, orl_count, buf);
- if (bfd_write (buf, 1, 4, abfd) != 4)
+ H_PUT_32 (abfd, orl_count, buf);
+ if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)
return false;
sub = abfd->archive_head;
{
size_t namlen;
- while (((bfd *) (map[i]).pos) == sub)
+ while (map[i].u.abfd == sub)
{
- bfd_h_put_32 (abfd, fileoff, buf);
- if (bfd_write (buf, 1, 4, abfd) != 4)
+ H_PUT_32 (abfd, fileoff, buf);
+ if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)
return false;
++i;
}
namlen = strlen (normalize_filename (sub));
- namlen = (namlen + 1) &~ 1;
+ namlen = (namlen + 1) &~ (size_t) 1;
fileoff += (SIZEOF_AR_HDR
+ namlen
+ SXCOFFARFMAG
name = *map[i].name;
namlen = strlen (name);
- if (bfd_write (name, 1, namlen + 1, abfd) != namlen + 1)
+ if (bfd_bwrite (name, (bfd_size_type) (namlen + 1), abfd) != namlen + 1)
return false;
}
char b;
b = '\0';
- if (bfd_write (&b, 1, 1, abfd) != 1)
+ if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
return false;
}
sprintf (hdr.nextoff, "%ld", (strtol (prevoff, (char **) NULL, 10)
+ (long) (4 + orl_ccount * 4 + stridx)));
}
-
+
memcpy (hdr.prevoff, prevoff, sizeof (hdr.prevoff));
sprintf (hdr.date, "%d", 0);
sprintf (hdr.uid, "%d", 0);
memcpy (nextoff, hdr.nextoff, sizeof (hdr.nextoff));
- if (bfd_write ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd) != SIZEOF_AR_HDR_BIG
- || bfd_write (XCOFFARFMAG, 1, SXCOFFARFMAG, abfd) != SXCOFFARFMAG)
+ if ((bfd_bwrite ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
+ != SIZEOF_AR_HDR_BIG)
+ || (bfd_bwrite (XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)
+ != SXCOFFARFMAG))
return false;
- bfd_h_put_32 (abfd, orl_ccount, buf);
- if (bfd_write (buf, 1, 4, abfd) != 4)
+ H_PUT_32 (abfd, orl_ccount, buf);
+ if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)
return false;
sub = abfd->archive_head;
{
size_t namlen;
- if ((bfd_arch_bits_per_address ((bfd *) map[i].pos) == 64) == bits64)
- while (((bfd *) (map[i]).pos) == sub)
+ if ((bfd_arch_bits_per_address (map[i].u.abfd) == 64) == bits64)
+ while (map[i].u.abfd == sub)
{
- bfd_h_put_32 (abfd, fileoff, buf);
- if (bfd_write (buf, 1, 4, abfd) != 4)
+ H_PUT_32 (abfd, fileoff, buf);
+ if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)
return false;
i++;
}
else
- while (((bfd *) (map[i]).pos) == sub)
+ while (map[i].u.abfd == sub)
i++;
namlen = strlen (normalize_filename (sub));
- namlen = (namlen + 1) &~ 1;
+ namlen = (namlen + 1) &~ (size_t) 1;
fileoff += (SIZEOF_AR_HDR_BIG
+ namlen
+ SXCOFFARFMAG
{
const char *name;
size_t namlen;
- bfd *ob = (bfd *)map[i].pos;
+ bfd *ob = map[i].u.abfd;
if (ob != object_bfd)
arch_info = bfd_get_arch_info (ob);
name = *map[i].name;
namlen = strlen (name);
- if (bfd_write (name, 1, namlen + 1, abfd) != namlen + 1)
+ if (bfd_bwrite (name, (bfd_size_type) (namlen + 1), abfd) != namlen + 1)
return false;
}
char b;
b = '\0';
- if (bfd_write (&b, 1, 1, abfd) != 1)
+ if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
return false;
}
object_bfd = NULL;
for (i = 0; i < orl_count; i++)
{
- bfd *ob = (bfd *)map[i].pos;
+ bfd *ob = map[i].u.abfd;
unsigned int len;
if (ob != object_bfd)
arch_info = bfd_get_arch_info (ob);
/* Now write out each map. */
if (! xcoff_write_one_armap_big (abfd, map, orl_count, orl_count_32,
- stridx_32, false,
+ stridx_32, false,
xcoff_ardata_big (abfd)->memoff,
xcoff_ardata_big (abfd)->symoff))
return false;
xcoff_ardata_big (abfd)->symoff,
xcoff_ardata_big (abfd)->symoff64))
return false;
-
+
return true;
}
bfd *abfd;
{
struct xcoff_ar_file_hdr fhdr;
- size_t count;
- size_t total_namlen;
+ bfd_size_type count;
+ bfd_size_type total_namlen;
file_ptr *offsets;
boolean makemap;
boolean hasobjects;
- file_ptr prevoff, nextoff;
+ ufile_ptr prevoff, nextoff;
bfd *sub;
- unsigned int i;
+ size_t i;
struct xcoff_ar_hdr ahdr;
bfd_size_type size;
char *p;
if (offsets == NULL)
return false;
- if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) SIZEOF_AR_FILE_HDR, SEEK_SET) != 0)
return false;
makemap = bfd_has_map (abfd);
for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++)
{
const char *name;
- size_t namlen;
+ bfd_size_type namlen;
struct xcoff_ar_hdr *ahdrp;
bfd_size_type remaining;
if (sub->arelt_data == NULL)
{
- sub->arelt_data = bfd_alloc (sub, sizeof (struct areltdata));
+ size = sizeof (struct areltdata);
+ sub->arelt_data = bfd_alloc (sub, size);
if (sub->arelt_data == NULL)
return false;
}
/* If the length of the name is odd, we write out the null byte
after the name as well. */
- namlen = (namlen + 1) &~ 1;
+ namlen = (namlen + 1) &~ (bfd_size_type) 1;
remaining = arelt_size (sub);
size = (SIZEOF_AR_HDR
if (*p == '\0')
*p = ' ';
- if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
- || bfd_write ((PTR) name, 1, namlen, abfd) != namlen
- || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
+ if ((bfd_bwrite ((PTR) ahdrp, (bfd_size_type) SIZEOF_AR_HDR, abfd)
+ != SIZEOF_AR_HDR)
+ || (bfd_bwrite ((PTR) name, namlen, abfd) != namlen)
+ || (bfd_bwrite ((PTR) XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)
!= SXCOFFARFMAG))
return false;
amt = sizeof buffer;
if (amt > remaining)
amt = remaining;
- if (bfd_read (buffer, 1, amt, sub) != amt
- || bfd_write (buffer, 1, amt, abfd) != amt)
+ if (bfd_bread (buffer, amt, sub) != amt
+ || bfd_bwrite (buffer, amt, abfd) != amt)
return false;
remaining -= amt;
}
bfd_byte b;
b = '\0';
- if (bfd_write (&b, 1, 1, abfd) != 1)
+ if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
return false;
}
}
if (*p == '\0')
*p = ' ';
- if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_HDR, abfd) != SIZEOF_AR_HDR
- || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
+ if ((bfd_bwrite ((PTR) &ahdr, (bfd_size_type) SIZEOF_AR_HDR, abfd)
+ != SIZEOF_AR_HDR)
+ || (bfd_bwrite ((PTR) XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)
!= SXCOFFARFMAG))
return false;
sprintf (decbuf, "%-12ld", (long) count);
- if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
+ if (bfd_bwrite ((PTR) decbuf, (bfd_size_type) 12, abfd) != 12)
return false;
- for (i = 0; i < count; i++)
+ for (i = 0; i < (size_t) count; i++)
{
sprintf (decbuf, "%-12ld", (long) offsets[i]);
- if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
+ if (bfd_bwrite ((PTR) decbuf, (bfd_size_type) 12, abfd) != 12)
return false;
}
for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
{
const char *name;
- size_t namlen;
+ bfd_size_type namlen;
name = normalize_filename (sub);
namlen = strlen (name);
- if (bfd_write ((PTR) name, 1, namlen + 1, abfd) != namlen + 1)
+ if (bfd_bwrite ((PTR) name, namlen + 1, abfd) != namlen + 1)
return false;
}
if ((size & 1) != 0)
bfd_byte b;
b = '\0';
- if (bfd_write ((PTR) &b, 1, 1, abfd) != 1)
+ if (bfd_bwrite ((PTR) &b, (bfd_size_type) 1, abfd) != 1)
return false;
}
*p = ' ';
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || (bfd_write ((PTR) &fhdr, SIZEOF_AR_FILE_HDR, 1, abfd) !=
- SIZEOF_AR_FILE_HDR))
+ || (bfd_bwrite ((PTR) &fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR, abfd)
+ != SIZEOF_AR_FILE_HDR))
return false;
return true;
bfd *abfd;
{
struct xcoff_ar_file_hdr_big fhdr;
- size_t count;
- size_t total_namlen;
+ bfd_size_type count;
+ bfd_size_type total_namlen;
file_ptr *offsets;
boolean makemap;
boolean hasobjects;
- file_ptr prevoff, nextoff;
+ ufile_ptr prevoff, nextoff;
bfd *sub;
- unsigned int i;
+ size_t i;
struct xcoff_ar_hdr_big ahdr;
bfd_size_type size;
char *p;
if (offsets == NULL)
return false;
- if (bfd_seek (abfd, SIZEOF_AR_FILE_HDR_BIG, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) SIZEOF_AR_FILE_HDR_BIG, SEEK_SET) != 0)
return false;
makemap = bfd_has_map (abfd);
for (sub = abfd->archive_head, i = 0; sub != NULL; sub = sub->next, i++)
{
const char *name;
- size_t namlen;
+ bfd_size_type namlen;
struct xcoff_ar_hdr_big *ahdrp;
bfd_size_type remaining;
if (sub->arelt_data == NULL)
{
- sub->arelt_data = bfd_alloc (sub, sizeof (struct areltdata));
+ size = sizeof (struct areltdata);
+ sub->arelt_data = bfd_alloc (sub, size);
if (sub->arelt_data == NULL)
return false;
}
/* If the length of the name is odd, we write out the null byte
after the name as well. */
- namlen = (namlen + 1) &~ 1;
+ namlen = (namlen + 1) &~ (bfd_size_type) 1;
remaining = arelt_size (sub);
size = (SIZEOF_AR_HDR_BIG
if (*p == '\0')
*p = ' ';
- if (bfd_write ((PTR) ahdrp, 1, SIZEOF_AR_HDR_BIG, abfd)
- != SIZEOF_AR_HDR_BIG
- || bfd_write ((PTR) name, 1, namlen, abfd) != namlen
- || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
+ if ((bfd_bwrite ((PTR) ahdrp, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
+ != SIZEOF_AR_HDR_BIG)
+ || bfd_bwrite ((PTR) name, (bfd_size_type) namlen, abfd) != namlen
+ || (bfd_bwrite ((PTR) XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)
!= SXCOFFARFMAG))
return false;
amt = sizeof buffer;
if (amt > remaining)
amt = remaining;
- if (bfd_read (buffer, 1, amt, sub) != amt
- || bfd_write (buffer, 1, amt, abfd) != amt)
+ if (bfd_bread (buffer, amt, sub) != amt
+ || bfd_bwrite (buffer, amt, abfd) != amt)
return false;
remaining -= amt;
}
bfd_byte b;
b = '\0';
- if (bfd_write (&b, 1, 1, abfd) != 1)
+ if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
return false;
}
}
if (*p == '\0')
*p = ' ';
- if (bfd_write ((PTR) &ahdr, 1, SIZEOF_AR_HDR_BIG, abfd) != SIZEOF_AR_HDR_BIG
- || (bfd_write ((PTR) XCOFFARFMAG, 1, SXCOFFARFMAG, abfd)
+ if ((bfd_bwrite ((PTR) &ahdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
+ != SIZEOF_AR_HDR_BIG)
+ || (bfd_bwrite ((PTR) XCOFFARFMAG, (bfd_size_type) SXCOFFARFMAG, abfd)
!= SXCOFFARFMAG))
return false;
sprintf (decbuf, "%-12ld", (long) count);
- if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
+ if (bfd_bwrite ((PTR) decbuf, (bfd_size_type) 12, abfd) != 12)
return false;
- for (i = 0; i < count; i++)
+ for (i = 0; i < (size_t) count; i++)
{
sprintf (decbuf, "%-12ld", (long) offsets[i]);
- if (bfd_write ((PTR) decbuf, 1, 12, abfd) != 12)
+ if (bfd_bwrite ((PTR) decbuf, (bfd_size_type) 12, abfd) != 12)
return false;
}
for (sub = abfd->archive_head; sub != NULL; sub = sub->next)
name = normalize_filename (sub);
namlen = strlen (name);
- if (bfd_write ((PTR) name, 1, namlen + 1, abfd) != namlen + 1)
+ if (bfd_bwrite ((PTR) name, (bfd_size_type) (namlen + 1), abfd)
+ != namlen + 1)
return false;
}
if ((size & 1) != 0)
bfd_byte b;
b = '\0';
- if (bfd_write ((PTR) &b, 1, 1, abfd) != 1)
+ if (bfd_bwrite ((PTR) &b, (bfd_size_type) 1, abfd) != 1)
return false;
}
*p = ' ';
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || (bfd_write ((PTR) &fhdr, SIZEOF_AR_FILE_HDR_BIG, 1, abfd) !=
- SIZEOF_AR_FILE_HDR_BIG))
+ || (bfd_bwrite ((PTR) &fhdr, (bfd_size_type) SIZEOF_AR_FILE_HDR_BIG, abfd)
+ != SIZEOF_AR_FILE_HDR_BIG))
return false;
return true;
{
struct external_ldhdr *dst = (struct external_ldhdr *) d;
- bfd_put_32 (abfd, src->l_version, dst->l_version);
+ bfd_put_32 (abfd, (bfd_vma) src->l_version, dst->l_version);
bfd_put_32 (abfd, src->l_nsyms, dst->l_nsyms);
bfd_put_32 (abfd, src->l_nreloc, dst->l_nreloc);
bfd_put_32 (abfd, src->l_istlen, dst->l_istlen);
memcpy (dst->_l._l_name, src->_l._l_name, SYMNMLEN);
else
{
- bfd_put_32 (abfd, 0, dst->_l._l_l._l_zeroes);
- bfd_put_32 (abfd, src->_l._l_l._l_offset, dst->_l._l_l._l_offset);
+ bfd_put_32 (abfd, (bfd_vma) 0, dst->_l._l_l._l_zeroes);
+ bfd_put_32 (abfd, (bfd_vma) src->_l._l_l._l_offset,
+ dst->_l._l_l._l_offset);
}
bfd_put_32 (abfd, src->l_value, dst->l_value);
- bfd_put_16 (abfd, src->l_scnum, dst->l_scnum);
+ bfd_put_16 (abfd, (bfd_vma) src->l_scnum, dst->l_scnum);
bfd_put_8 (abfd, src->l_smtype, dst->l_smtype);
bfd_put_8 (abfd, src->l_smclas, dst->l_smclas);
bfd_put_32 (abfd, src->l_ifile, dst->l_ifile);
bfd_put_32 (abfd, src->l_vaddr, dst->l_vaddr);
bfd_put_32 (abfd, src->l_symndx, dst->l_symndx);
- bfd_put_16 (abfd, src->l_rtype, dst->l_rtype);
- bfd_put_16 (abfd, src->l_rsecnm, dst->l_rsecnm);
+ bfd_put_16 (abfd, (bfd_vma) src->l_rtype, dst->l_rtype);
+ bfd_put_16 (abfd, (bfd_vma) src->l_rsecnm, dst->l_rsecnm);
}
\f
addend = 0;
}
else
- {
+ {
h = obj_xcoff_sym_hashes (input_bfd)[symndx];
sym = syms + symndx;
addend = - sym->n_value;
if (next == 0x4def7b82 /* cror 15,15,15 */
|| next == 0x4ffffb82 /* cror 31,31,31 */
|| next == 0x60000000) /* ori r0,r0,0 */
- bfd_put_32 (input_bfd, 0x80410014, pnext); /* lwz r1,20(r1) */
+ bfd_put_32 (input_bfd,
+ (bfd_vma) 0x80410014, /* lwz r1,20(r1) */
+ pnext);
}
else
{
if (next == 0x80410014) /* lwz r1,20(r1) */
- bfd_put_32 (input_bfd, 0x60000000, pnext); /* ori r0,r0,0 */
+ bfd_put_32 (input_bfd,
+ (bfd_vma) 0x60000000, /* ori r0,r0,0 */
+ pnext);
}
}
{
if (ldinfo->string_size + len + 3 > ldinfo->string_alc)
{
- size_t newalc;
+ bfd_size_type newalc;
bfd_byte *newstrings;
newalc = ldinfo->string_alc * 2;
ldinfo->strings = newstrings;
}
- bfd_put_16 (ldinfo->output_bfd, len + 1,
- ldinfo->strings + ldinfo->string_size);
+ bfd_put_16 (ldinfo->output_bfd, (bfd_vma) (len + 1),
+ ldinfo->strings + ldinfo->string_size);
strcpy (ldinfo->strings + ldinfo->string_size + 2, name);
ldsym->_l._l_l._l_zeroes = 0;
ldsym->_l._l_l._l_offset = ldinfo->string_size + 2;
}
static boolean
-_bfd_xcoff_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab,
+_bfd_xcoff_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab,
struct internal_syment *sym,
const char *name)
{
}
static asection *
-xcoff_create_csect_from_smclas (abfd, aux, symbol_name)
+xcoff_create_csect_from_smclas (abfd, aux, symbol_name)
bfd *abfd;
union internal_auxent *aux;
const char *symbol_name;
{
".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
".sv", ".bs", ".ds", ".uc", ".ti", ".tb", NULL, ".tc0",
- ".td", NULL, ".sv3264"
+ ".td", NULL, ".sv3264"
};
if ((19 >= aux->x_csect.x_smclas) &&
(NULL != names[aux->x_csect.x_smclas]))
{
- return_value = bfd_make_section_anyway
+ return_value = bfd_make_section_anyway
(abfd, names[aux->x_csect.x_smclas]);
}
else
return return_value;
}
-static boolean
+static boolean
xcoff_is_lineno_count_overflow (abfd, value)
bfd *abfd ATTRIBUTE_UNUSED;
bfd_vma value;
return false;
}
-static boolean
+static boolean
xcoff_is_reloc_count_overflow (abfd, value)
bfd *abfd ATTRIBUTE_UNUSED;
bfd_vma value;
bfd *abfd;
struct internal_ldhdr *ldhdr;
{
- return bfd_xcoff_ldhdrsz(abfd) +
+ return bfd_xcoff_ldhdrsz(abfd) +
(ldhdr->l_nsyms * bfd_xcoff_ldsymsz(abfd));
}
static reloc_howto_type xcoff_dynamic_reloc =
-HOWTO (0, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+HOWTO (0, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_POS", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
+ 0, /* special_function */
+ "R_POS", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
false); /* pcrel_offset */
-/* glink
-
- The first word of global linkage code must be modified by filling in
+/* glink
+
+ The first word of global linkage code must be modified by filling in
the correct TOC offset. */
static unsigned long xcoff_glink_code[9] =
};
-static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
+static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
{
{ /* COFF backend, defined in libcoff.h. */
_bfd_xcoff_swap_aux_in, /* _bfd_coff_swap_aux_in */
- _bfd_xcoff_swap_sym_in, /* _bfd_coff_swap_sym_in */
+ _bfd_xcoff_swap_sym_in, /* _bfd_coff_swap_sym_in */
coff_swap_lineno_in, /* _bfd_coff_swap_lineno_in */
_bfd_xcoff_swap_aux_out, /* _bfd_swap_aux_out */
_bfd_xcoff_swap_sym_out, /* _bfd_swap_sym_out */
dummy_reloc16_estimate, /* _bfd_coff_reloc16_estimate */
NULL, /* bfd_coff_sym_is_global */
coff_compute_section_file_positions, /* _bfd_coff_compute_section_file_positions */
- NULL , /* _bfd_coff_start_final_link */
+ NULL, /* _bfd_coff_start_final_link */
xcoff_ppc_relocate_section, /* _bfd_coff_relocate_section */
coff_rtype_to_howto, /* _bfd_coff_rtype_to_howto */
- NULL , /* _bfd_coff_addust_symndx */
+ NULL, /* _bfd_coff_addust_symndx */
_bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */
coff_link_output_has_begun, /* _bfd_coff_link_output_has_begun */
coff_final_link_postscript /* _bfd_coff_final_link_postscript */
0x01DF, /* magic number */
bfd_arch_rs6000, /* architecture */
bfd_mach_rs6k, /* machine */
-
+
/* Function pointers to xcoff specific swap routines. */
xcoff_swap_ldhdr_in, /* _xcoff_swap_ldhdr_in */
xcoff_swap_ldhdr_out, /* _xcoff_swap_ldhdr_out */
bfd_putb32, /* bfd_putx32 */
bfd_getb16, /* bfd_getx16 */
bfd_getb_signed_16, /* bfd_getx_signed_16 */
- bfd_putb16, /* bfd_putx16 */
+ bfd_putb16, /* bfd_putx16 */
/* hdrs */
bfd_getb64, /* bfd_h_getx64 */
bfd_getb16, /* bfd_h_getx16 */
bfd_getb_signed_16, /* bfd_h_getx_signed_16 */
bfd_putb16, /* bfd_h_putx16 */
-
+
{ /* bfd_check_format */
- _bfd_dummy_target,
- coff_object_p,
- _bfd_xcoff_archive_p,
+ _bfd_dummy_target,
+ coff_object_p,
+ _bfd_xcoff_archive_p,
CORE_FILE_P
},
-
+
{ /* bfd_set_format */
- bfd_false,
+ bfd_false,
coff_mkobject,
- _bfd_generic_mkarchive,
+ _bfd_generic_mkarchive,
bfd_false
},
-
+
{/* bfd_write_contents */
- bfd_false,
+ bfd_false,
coff_write_object_contents,
- _bfd_xcoff_write_archive_contents,
+ _bfd_xcoff_write_archive_contents,
bfd_false
},
-
+
/* Generic */
bfd_true, /* _close_and_cleanup */
bfd_true, /* _bfd_free_cached_info */
coff_new_section_hook, /* _new_section_hook */
_bfd_generic_get_section_contents, /* _bfd_get_section_contents */
/* _bfd_get_section_contents_in_window */
- _bfd_generic_get_section_contents_in_window,
+ _bfd_generic_get_section_contents_in_window,
/* Copy */
_bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */
- /* _bfd_merge_private_bfd_data */
+ /* _bfd_merge_private_bfd_data */
((boolean (*) (bfd *, bfd *)) bfd_true),
/* _bfd_copy_pivate_section_data */
((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
coff_core_file_failing_command, /* _core_file_failing_command */
coff_core_file_failing_signal, /* _core_file_failing_signal */
/* _core_file_matches_executable_p */
- coff_core_file_matches_executable_p,
+ coff_core_file_matches_executable_p,
/* Archive */
_bfd_xcoff_slurp_armap, /* _slurp_armap */
- /* XCOFF archives do not have
- anything which corresponds to
+ /* XCOFF archives do not have
+ anything which corresponds to
an extended name table. */
bfd_false, /* _slurp_extended_name_table */
/* _construct_extended_name_table */
_bfd_xcoff_openr_next_archived_file, /* _openr_next_archived_file */
_bfd_generic_get_elt_at_index, /* _get_elt_at_index */
_bfd_xcoff_generic_stat_arch_elt, /* _generic_dtat_arch_elt */
- /* XCOFF archives do not have
+ /* XCOFF archives do not have
a timestamp. */
bfd_true, /* _update_armap_timestamp */
_bfd_xcoff_bfd_final_link, /* _bfd_filnal_link */
_bfd_generic_link_split_section, /* _bfd_link_split_section */
bfd_generic_gc_sections, /* _bfd_gc_sections */
- bfd_generic_merge_sections, /* _bfd_merge_sections */
+ bfd_generic_merge_sections, /* _bfd_merge_sections */
/* Dynamic */
/* _get_dynamic_symtab_upper_bound */
- _bfd_xcoff_get_dynamic_symtab_upper_bound,
+ _bfd_xcoff_get_dynamic_symtab_upper_bound,
_bfd_xcoff_canonicalize_dynamic_symtab, /* _cononicalize_dynamic_symtab */
_bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */
_bfd_xcoff_canonicalize_dynamic_reloc, /* _cononicalize_dynamic_reloc */
/* Opposite endian version, none exists */
NULL,
-
+
/* back end data */
(void *) &bfd_xcoff_backend_data,
};
-/*
+/*
* xcoff-powermac target
* Old target.
- * Only difference between this target and the rs6000 target is the
+ * Only difference between this target and the rs6000 target is the
* the default architecture and machine type used in coffcode.h
*
* PowerPC Macs use the same magic numbers as RS/6000
* (because that's how they were bootstrapped originally),
- * but they are always PowerPC architecture.
+ * but they are always PowerPC architecture.
*/
-static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data =
+static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data =
{
{ /* COFF backend, defined in libcoff.h */
_bfd_xcoff_swap_aux_in, /* _bfd_coff_swap_aux_in */
- _bfd_xcoff_swap_sym_in, /* _bfd_coff_swap_sym_in */
+ _bfd_xcoff_swap_sym_in, /* _bfd_coff_swap_sym_in */
coff_swap_lineno_in, /* _bfd_coff_swap_lineno_in */
_bfd_xcoff_swap_aux_out, /* _bfd_swap_aux_out */
_bfd_xcoff_swap_sym_out, /* _bfd_swap_sym_out */
AUXESZ, /* _bfd_auxesz */
RELSZ, /* _bfd_relsz */
LINESZ, /* _bfd_linesz */
- FILNMLEN, /* _bfd_filnmlen */
+ FILNMLEN, /* _bfd_filnmlen */
true, /* _bfd_coff_long_filenames */
false, /* _bfd_coff_long_section_names */
(3), /* _bfd_coff_default_section_alignment_power */
coff_mkobject_hook, /* _bfd_mkobject_hook */
styp_to_sec_flags, /* _bfd_syp_to_sec_flags */
coff_set_alignment_hook, /* _bfd_set_alignment_hook */
- coff_slurp_symbol_table, /* _bfd_coff_slurp_symbol_table */
+ coff_slurp_symbol_table, /* _bfd_coff_slurp_symbol_table */
symname_in_debug_hook, /* _coff_symname_in_debug_hook */
coff_pointerize_aux_hook, /* _bfd_coff_pointerize_aux_hook */
coff_print_aux, /* bfd_coff_print_aux */
NULL, /* bfd_coff_sym_is_global */
/* _bfd_coff_compute_section_file_positions */
coff_compute_section_file_positions,
- NULL , /* _bfd_coff_start_final_link */
- xcoff_ppc_relocate_section, /* _bfd_coff_relocate_section */
+ NULL, /* _bfd_coff_start_final_link */
+ xcoff_ppc_relocate_section, /* _bfd_coff_relocate_section */
coff_rtype_to_howto, /* _bfd_coff_rtype_to_howto */
- NULL , /* _bfd_coff_addust_symndx */
+ NULL, /* _bfd_coff_addust_symndx */
_bfd_generic_link_add_one_symbol, /* _bfd_coff_add_one_symbol */
coff_link_output_has_begun, /* _bfd_coff_link_output_has_begun */
coff_final_link_postscript /* _bfd_coff_final_link_postscript */
/* glink */
&xcoff_glink_code[0],
(36), /* _xcoff_glink_size */
-
+
};
/* The transfer vector that leads the outside world to all of the above. */
bfd_putb32, /* bfd_putx32 */
bfd_getb16, /* bfd_getx16 */
bfd_getb_signed_16, /* bfd_getx_signed_16 */
- bfd_putb16, /* bfd_putx16 */
+ bfd_putb16, /* bfd_putx16 */
/* hdrs */
bfd_getb64, /* bfd_h_getx64 */
bfd_getb16, /* bfd_h_getx16 */
bfd_getb_signed_16, /* bfd_h_getx_signed_16 */
bfd_putb16, /* bfd_h_putx16 */
-
+
{ /* bfd_check_format */
- _bfd_dummy_target,
- coff_object_p,
- _bfd_xcoff_archive_p,
+ _bfd_dummy_target,
+ coff_object_p,
+ _bfd_xcoff_archive_p,
CORE_FILE_P
},
-
+
{ /* bfd_set_format */
- bfd_false,
+ bfd_false,
coff_mkobject,
- _bfd_generic_mkarchive,
+ _bfd_generic_mkarchive,
bfd_false
},
-
+
{/* bfd_write_contents */
- bfd_false,
+ bfd_false,
coff_write_object_contents,
- _bfd_xcoff_write_archive_contents,
+ _bfd_xcoff_write_archive_contents,
bfd_false
},
-
+
/* Generic */
bfd_true, /* _close_and_cleanup */
bfd_true, /* _bfd_free_cached_info */
coff_new_section_hook, /* _new_section_hook */
_bfd_generic_get_section_contents, /* _bfd_get_section_contents */
/* _bfd_get_section_contents_in_window */
- _bfd_generic_get_section_contents_in_window,
+ _bfd_generic_get_section_contents_in_window,
/* Copy */
_bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */
- /* _bfd_merge_private_bfd_data */
+ /* _bfd_merge_private_bfd_data */
((boolean (*) (bfd *, bfd *)) bfd_true),
/* _bfd_copy_pivate_section_data */
((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
coff_core_file_failing_command, /* _core_file_failing_command */
coff_core_file_failing_signal, /* _core_file_failing_signal */
/* _core_file_matches_executable_p */
- coff_core_file_matches_executable_p,
+ coff_core_file_matches_executable_p,
/* Archive */
_bfd_xcoff_slurp_armap, /* _slurp_armap */
- /* XCOFF archives do not have
- anything which corresponds to
+ /* XCOFF archives do not have
+ anything which corresponds to
an extended name table. */
bfd_false, /* _slurp_extended_name_table */
/* _construct_extended_name_table */
_bfd_xcoff_openr_next_archived_file, /* _openr_next_archived_file */
_bfd_generic_get_elt_at_index, /* _get_elt_at_index */
_bfd_xcoff_generic_stat_arch_elt, /* _generic_dtat_arch_elt */
- /* XCOFF archives do not have
+ /* XCOFF archives do not have
a timestamp. */
bfd_true, /* _update_armap_timestamp */
/* Dynamic */
/* _get_dynamic_symtab_upper_bound */
- _bfd_xcoff_get_dynamic_symtab_upper_bound,
+ _bfd_xcoff_get_dynamic_symtab_upper_bound,
_bfd_xcoff_canonicalize_dynamic_symtab, /* _cononicalize_dynamic_symtab */
_bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */
_bfd_xcoff_canonicalize_dynamic_reloc, /* _cononicalize_dynamic_reloc */
/* Opposite endian version, none exists */
NULL,
-
+
/* back end data */
(void *) &bfd_pmac_xcoff_backend_data,
};
#ifndef COFF_WITH_PE
/* Swap the r_offset field in and out. */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_IN_RELOC_OFFSET H_GET_32
+#define SWAP_OUT_RELOC_OFFSET H_PUT_32
/* Swap out extra information in the reloc structure. */
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
#endif
insn = bfd_get_32 (abfd, hit_data);
insn += sym_value + reloc_entry->addend;
- bfd_put_32 (abfd, insn, hit_data);
+ bfd_put_32 (abfd, (bfd_vma) insn, hit_data);
break;
#ifdef COFF_WITH_PE
case R_SH_IMAGEBASE:
insn = bfd_get_32 (abfd, hit_data);
- insn += (sym_value + reloc_entry->addend
- - pe_data (input_section->output_section->owner)->pe_opthdr.ImageBase);
- bfd_put_32 (abfd, insn, hit_data);
+ insn += sym_value + reloc_entry->addend;
+ insn -= pe_data (input_section->output_section->owner)->pe_opthdr.ImageBase;
+ bfd_put_32 (abfd, (bfd_vma) insn, hit_data);
break;
#endif
case R_SH_PCDISP:
if (insn & 0x800)
sym_value -= 0x1000;
insn = (insn & 0xf000) | (sym_value & 0xfff);
- bfd_put_16 (abfd, insn, hit_data);
+ bfd_put_16 (abfd, (bfd_vma) insn, hit_data);
if (sym_value < (bfd_vma) -0x1000 || sym_value >= 0x1000)
return bfd_reloc_overflow;
break;
on a four byte boundary. */
paddr = insn & 0xff;
paddr *= 4;
- paddr += (laddr + 4) &~ 3;
+ paddr += (laddr + 4) &~ (bfd_vma) 3;
if (paddr >= sec->_raw_size)
{
((*_bfd_error_handler)
if (coff_section_data (abfd, sec) == NULL)
{
- sec->used_by_bfd =
- ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
+ bfd_size_type amt = sizeof (struct coff_section_tdata);
+ sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (sec->used_by_bfd == NULL)
goto error_return;
}
it will be handled here like other internal PCDISP
relocs. */
bfd_put_16 (abfd,
- 0xb000 | ((foff >> 1) & 0xfff),
+ (bfd_vma) 0xb000 | ((foff >> 1) & 0xfff),
contents + irel->r_vaddr - sec->vma);
}
else
/* We can't fully resolve this yet, because the external
symbol value may be changed by future relaxing. We let
the final link phase handle it. */
- bfd_put_16 (abfd, 0xb000, contents + irel->r_vaddr - sec->vma);
+ bfd_put_16 (abfd, (bfd_vma) 0xb000,
+ contents + irel->r_vaddr - sec->vma);
}
/* See if there is another R_SH_USES reloc referring to the same
{
if (coff_section_data (abfd, sec) == NULL)
{
- sec->used_by_bfd =
- ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
+ bfd_size_type amt = sizeof (struct coff_section_tdata);
+ sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (sec->used_by_bfd == NULL)
goto error_return;
}
/* Cache the section contents for coff_link_input_bfd. */
if (coff_section_data (abfd, sec) == NULL)
{
- sec->used_by_bfd =
- ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata)));
+ bfd_size_type amt = sizeof (struct coff_section_tdata);
+ sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (sec->used_by_bfd == NULL)
goto error_return;
coff_section_data (abfd, sec)->relocs = NULL;
}
/* Actually delete the bytes. */
- memmove (contents + addr, contents + addr + count, toaddr - addr - count);
+ memmove (contents + addr, contents + addr + count,
+ (size_t) (toaddr - addr - count));
if (irelalign == NULL)
sec->_cooked_size -= count;
else
BFD_ASSERT ((count & 1) == 0);
for (i = 0; i < count; i += 2)
- bfd_put_16 (abfd, NOP_OPCODE, contents + toaddr - count + i);
+ bfd_put_16 (abfd, (bfd_vma) NOP_OPCODE, contents + toaddr - count + i);
}
/* Adjust all the relocs. */
insn += adjust / 2;
if ((oinsn & 0xff00) != (insn & 0xff00))
overflow = true;
- bfd_put_16 (abfd, insn, contents + nraddr);
+ bfd_put_16 (abfd, (bfd_vma) insn, contents + nraddr);
break;
case R_SH_PCDISP:
insn += adjust / 2;
if ((oinsn & 0xf000) != (insn & 0xf000))
overflow = true;
- bfd_put_16 (abfd, insn, contents + nraddr);
+ bfd_put_16 (abfd, (bfd_vma) insn, contents + nraddr);
break;
case R_SH_PCRELIMM8BY4:
}
if ((oinsn & 0xff00) != (insn & 0xff00))
overflow = true;
- bfd_put_16 (abfd, insn, contents + nraddr);
+ bfd_put_16 (abfd, (bfd_vma) insn, contents + nraddr);
break;
case R_SH_SWITCH8:
voff += adjust;
if (voff < 0 || voff >= 0xff)
overflow = true;
- bfd_put_8 (abfd, voff, contents + nraddr);
+ bfd_put_8 (abfd, (bfd_vma) voff, contents + nraddr);
break;
case R_SH_SWITCH16:
voff += adjust;
if (voff < - 0x8000 || voff >= 0x8000)
overflow = true;
- bfd_put_signed_16 (abfd, voff, contents + nraddr);
+ bfd_put_signed_16 (abfd, (bfd_vma) voff, contents + nraddr);
break;
case R_SH_SWITCH32:
voff += adjust;
- bfd_put_signed_32 (abfd, voff, contents + nraddr);
+ bfd_put_signed_32 (abfd, (bfd_vma) voff, contents + nraddr);
break;
case R_SH_USES:
{
/* Tail recursion. */
return sh_relax_delete_bytes (abfd, sec, alignaddr,
- alignto - alignaddr);
+ (int) (alignto - alignaddr));
}
}
struct internal_reloc *irel, *irelend;
bfd_vma *labels = NULL;
bfd_vma *label, *label_end;
+ bfd_size_type amt;
*pswapped = false;
irelend = internal_relocs + sec->reloc_count;
/* Get all the addresses with labels on them. */
- labels = (bfd_vma *) bfd_malloc (sec->reloc_count * sizeof (bfd_vma));
+ amt = (bfd_size_type) sec->reloc_count * sizeof (bfd_vma);
+ labels = (bfd_vma *) bfd_malloc (amt);
if (labels == NULL)
goto error_return;
label_end = labels;
/* Swap the instructions themselves. */
i1 = bfd_get_16 (abfd, contents + addr);
i2 = bfd_get_16 (abfd, contents + addr + 2);
- bfd_put_16 (abfd, i2, contents + addr);
- bfd_put_16 (abfd, i1, contents + addr + 2);
+ bfd_put_16 (abfd, (bfd_vma) i2, contents + addr);
+ bfd_put_16 (abfd, (bfd_vma) i1, contents + addr + 2);
/* Adjust all reloc addresses. */
irelend = internal_relocs + sec->reloc_count;
insn += add / 2;
if ((oinsn & 0xff00) != (insn & 0xff00))
overflow = true;
- bfd_put_16 (abfd, insn, loc);
+ bfd_put_16 (abfd, (bfd_vma) insn, loc);
break;
case R_SH_PCDISP:
insn += add / 2;
if ((oinsn & 0xf000) != (insn & 0xf000))
overflow = true;
- bfd_put_16 (abfd, insn, loc);
+ bfd_put_16 (abfd, (bfd_vma) insn, loc);
break;
case R_SH_PCRELIMM8BY4:
insn += add / 2;
if ((oinsn & 0xff00) != (insn & 0xff00))
overflow = true;
- bfd_put_16 (abfd, insn, loc);
+ bfd_put_16 (abfd, (bfd_vma) insn, loc);
}
break;
symbols);
memcpy (data, coff_section_data (input_bfd, input_section)->contents,
- input_section->_raw_size);
+ (size_t) input_section->_raw_size);
if ((input_section->flags & SEC_RELOC) != 0
&& input_section->reloc_count > 0)
bfd_byte *esym, *esymend;
struct internal_syment *isymp;
asection **secpp;
+ bfd_size_type amt;
if (! _bfd_coff_get_external_symbols (input_bfd))
goto error_return;
if (internal_relocs == NULL)
goto error_return;
- internal_syms = ((struct internal_syment *)
- bfd_malloc (obj_raw_syment_count (input_bfd)
- * sizeof (struct internal_syment)));
+ amt = obj_raw_syment_count (input_bfd);
+ amt *= sizeof (struct internal_syment);
+ internal_syms = (struct internal_syment *) bfd_malloc (amt);
if (internal_syms == NULL)
goto error_return;
- sections = (asection **) bfd_malloc (obj_raw_syment_count (input_bfd)
- * sizeof (asection *));
+ amt = obj_raw_syment_count (input_bfd);
+ amt *= sizeof (asection *);
+ sections = (asection **) bfd_malloc (amt);
if (sections == NULL)
goto error_return;
static reloc_howto_type *coff_sparc_reloc_type_lookup
PARAMS ((bfd *, bfd_reloc_code_real_type));
static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
-
+
enum reloc_type
{
R_SPARC_NONE = 0,
};
#if 0
-static CONST char *CONST reloc_type_names[] =
+static const char *const reloc_type_names[] =
{
"R_SPARC_NONE",
"R_SPARC_8", "R_SPARC_16", "R_SPARC_32",
unsigned char coff_reloc_val;
};
-static CONST struct coff_reloc_map sparc_reloc_map[] =
+static const struct coff_reloc_map sparc_reloc_map[] =
{
{ BFD_RELOC_NONE, R_SPARC_NONE, },
{ BFD_RELOC_16, R_SPARC_16, },
#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_IN_RELOC_OFFSET H_GET_32
+#define SWAP_OUT_RELOC_OFFSET H_PUT_32
#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
cache_ptr->addend = reloc.r_offset;
/* This macro is used, because I cannot assume the endianess of the
host system */
-#define _H(index) (bfd_h_get_16(abfd, (bfd_byte *) (header+index*2)))
+#define _H(index) (H_GET_16 (abfd, (header+index*2)))
/* These bytes are a 2048-byte DOS executable, which loads the COFF
image into memory and then runs it. It is called 'stub' */
ADJUST_VAL (filehdr_dst->f_symptr, STUBSIZE);
/* Save now the stub to be used later */
- bfd_coff_go32stub (abfd) = (PTR) bfd_alloc (abfd, STUBSIZE);
+ bfd_coff_go32stub (abfd) = (PTR) bfd_alloc (abfd, (bfd_size_type) STUBSIZE);
/* Since this function returns no status, I do not set here
any bfd_error_...
int f;
unsigned char header[10];
char magic[8];
- unsigned long coff_start, exe_start;
+ unsigned long coff_start;
+ long exe_start;
/* Check at first the environment variable $(GO32STUB) */
stub = getenv ("GO32STUB");
goto stub_end;
}
exe_start = _H (4) * 16;
- if ((unsigned long) lseek (f, exe_start, SEEK_SET) != exe_start)
+ if ((long) lseek (f, exe_start, SEEK_SET) != exe_start)
{
close (f);
goto stub_end;
goto stub_end;
}
/* Now we found a correct stub (hopefully) */
- bfd_coff_go32stub (abfd) = (PTR) bfd_alloc (abfd, coff_start);
+ bfd_coff_go32stub (abfd)
+ = (PTR) bfd_alloc (abfd, (bfd_size_type) coff_start);
if (bfd_coff_go32stub (abfd) == NULL)
{
close (f);
stub */
if (bfd_coff_go32stub (abfd) == NULL)
{
- bfd_coff_go32stub (abfd) = (PTR) bfd_alloc (abfd, STUBSIZE);
+ bfd_coff_go32stub (abfd)
+ = (PTR) bfd_alloc (abfd, (bfd_size_type) STUBSIZE);
if (bfd_coff_go32stub (abfd) == NULL)
{
return;
#define __A_MAGIC_SET__
/* Code to swap in the reloc */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_IN_RELOC_OFFSET H_GET_32
+#define SWAP_OUT_RELOC_OFFSET H_PUT_32
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) dst->r_stuff[0] = 'S'; \
dst->r_stuff[1] = 'C';
}
/* COFF0 differs in file/section header size and relocation entry size. */
-static CONST bfd_coff_backend_data ticoff0_swap_table =
+static const bfd_coff_backend_data ticoff0_swap_table =
{
coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
coff_SWAP_aux_out, coff_SWAP_sym_out,
};
/* COFF1 differs in section header size. */
-static CONST bfd_coff_backend_data ticoff1_swap_table =
+static const bfd_coff_backend_data ticoff1_swap_table =
{
coff_SWAP_aux_in, coff_SWAP_sym_in, coff_SWAP_lineno_in,
coff_SWAP_aux_out, coff_SWAP_sym_out,
#define COFF_ALIGN_IN_SECTION_HEADER 1
#define COFF_ALIGN_IN_SFLAGS 1
-#define GET_SCNHDR_FLAGS bfd_h_get_16
-#define PUT_SCNHDR_FLAGS bfd_h_put_16
+#define GET_SCNHDR_FLAGS H_GET_16
+#define PUT_SCNHDR_FLAGS H_PUT_16
static void rtype2howto
PARAMS ((arelent *cache_ptr, struct internal_reloc *dst));
#define __A_MAGIC_SET__
/* Code to swap in the reloc */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_IN_RELOC_OFFSET H_GET_32
+#define SWAP_OUT_RELOC_OFFSET H_PUT_32
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
dst->r_stuff[0] = 'S'; \
dst->r_stuff[1] = 'C';
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
input_section);
- bfd_put_16 (abfd, gap, data + dst_address);
+ bfd_put_16 (abfd, (bfd_vma) gap, data + dst_address);
dst_address += 2;
src_address += 2;
}
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
input_section);
gap >>= 8;
- bfd_put_16 (abfd, gap, data + dst_address);
+ bfd_put_16 (abfd, (bfd_vma) gap, data + dst_address);
dst_address += 2;
src_address += 2;
}
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
input_section);
gap >>= 16;
- bfd_put_16 (abfd, gap, data + dst_address);
+ bfd_put_16 (abfd, (bfd_vma) gap, data + dst_address);
dst_address += 2;
src_address += 2;
}
{
unsigned int gap = bfd_coff_reloc16_get_value (reloc, link_info,
input_section);
- bfd_put_16 (abfd, gap, data + dst_address);
+ bfd_put_16 (abfd, (bfd_vma) gap, data + dst_address);
bfd_put_8 (abfd, gap >> 16, data+dst_address + 2);
dst_address += 3;
src_address += 3;
#define __A_MAGIC_SET__
/* Code to swap in the reloc. */
-#define SWAP_IN_RELOC_OFFSET bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_IN_RELOC_OFFSET H_GET_32
+#define SWAP_OUT_RELOC_OFFSET H_PUT_32
#define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \
dst->r_stuff[0] = 'S'; \
dst->r_stuff[1] = 'C';
input_section, reloc->address)))
abort ();
}
- bfd_put_16 (in_abfd,gap,data + *dst_ptr);
+ bfd_put_16 (in_abfd, (bfd_vma) gap, data + *dst_ptr);
(*dst_ptr) += 2;
(*src_ptr) += 2;
break;
#include "coff/internal.h"
#include "coff/xcoff.h"
#include "coff/rs6k64.h"
-#include "libcoff.h"
+#include "libcoff.h"
#include "libxcoff.h"
-#define GET_FILEHDR_SYMPTR bfd_h_get_64
-#define PUT_FILEHDR_SYMPTR bfd_h_put_64
-#define GET_AOUTHDR_DATA_START bfd_h_get_64
-#define PUT_AOUTHDR_DATA_START bfd_h_put_64
-#define GET_AOUTHDR_TEXT_START bfd_h_get_64
-#define PUT_AOUTHDR_TEXT_START bfd_h_put_64
-#define GET_AOUTHDR_TSIZE bfd_h_get_64
-#define PUT_AOUTHDR_TSIZE bfd_h_put_64
-#define GET_AOUTHDR_DSIZE bfd_h_get_64
-#define PUT_AOUTHDR_DSIZE bfd_h_put_64
-#define GET_AOUTHDR_BSIZE bfd_h_get_64
-#define PUT_AOUTHDR_BSIZE bfd_h_put_64
-#define GET_AOUTHDR_ENTRY bfd_h_get_64
-#define PUT_AOUTHDR_ENTRY bfd_h_put_64
-#define GET_SCNHDR_PADDR bfd_h_get_64
-#define PUT_SCNHDR_PADDR bfd_h_put_64
-#define GET_SCNHDR_VADDR bfd_h_get_64
-#define PUT_SCNHDR_VADDR bfd_h_put_64
-#define GET_SCNHDR_SIZE bfd_h_get_64
-#define PUT_SCNHDR_SIZE bfd_h_put_64
-#define GET_SCNHDR_SCNPTR bfd_h_get_64
-#define PUT_SCNHDR_SCNPTR bfd_h_put_64
-#define GET_SCNHDR_RELPTR bfd_h_get_64
-#define PUT_SCNHDR_RELPTR bfd_h_put_64
-#define GET_SCNHDR_LNNOPTR bfd_h_get_64
-#define PUT_SCNHDR_LNNOPTR bfd_h_put_64
-#define GET_SCNHDR_NRELOC bfd_h_get_32
+#define GET_FILEHDR_SYMPTR H_GET_64
+#define PUT_FILEHDR_SYMPTR H_PUT_64
+#define GET_AOUTHDR_DATA_START H_GET_64
+#define PUT_AOUTHDR_DATA_START H_PUT_64
+#define GET_AOUTHDR_TEXT_START H_GET_64
+#define PUT_AOUTHDR_TEXT_START H_PUT_64
+#define GET_AOUTHDR_TSIZE H_GET_64
+#define PUT_AOUTHDR_TSIZE H_PUT_64
+#define GET_AOUTHDR_DSIZE H_GET_64
+#define PUT_AOUTHDR_DSIZE H_PUT_64
+#define GET_AOUTHDR_BSIZE H_GET_64
+#define PUT_AOUTHDR_BSIZE H_PUT_64
+#define GET_AOUTHDR_ENTRY H_GET_64
+#define PUT_AOUTHDR_ENTRY H_PUT_64
+#define GET_SCNHDR_PADDR H_GET_64
+#define PUT_SCNHDR_PADDR H_PUT_64
+#define GET_SCNHDR_VADDR H_GET_64
+#define PUT_SCNHDR_VADDR H_PUT_64
+#define GET_SCNHDR_SIZE H_GET_64
+#define PUT_SCNHDR_SIZE H_PUT_64
+#define GET_SCNHDR_SCNPTR H_GET_64
+#define PUT_SCNHDR_SCNPTR H_PUT_64
+#define GET_SCNHDR_RELPTR H_GET_64
+#define PUT_SCNHDR_RELPTR H_PUT_64
+#define GET_SCNHDR_LNNOPTR H_GET_64
+#define PUT_SCNHDR_LNNOPTR H_PUT_64
+#define GET_SCNHDR_NRELOC H_GET_32
#define MAX_SCNHDR_NRELOC 0xffffffff
-#define PUT_SCNHDR_NRELOC bfd_h_put_32
-#define GET_SCNHDR_NLNNO bfd_h_get_32
+#define PUT_SCNHDR_NRELOC H_PUT_32
+#define GET_SCNHDR_NLNNO H_GET_32
#define MAX_SCNHDR_NLNNO 0xffffffff
-#define PUT_SCNHDR_NLNNO bfd_h_put_32
-#define GET_RELOC_VADDR bfd_h_get_64
-#define PUT_RELOC_VADDR bfd_h_put_64
+#define PUT_SCNHDR_NLNNO H_PUT_32
+#define GET_RELOC_VADDR H_GET_64
+#define PUT_RELOC_VADDR H_PUT_64
#define COFF_FORCE_SYMBOLS_IN_STRINGS
#define COFF_DEBUG_STRING_WIDE_PREFIX
-#define COFF_ADJUST_SCNHDR_OUT_POST(ABFD,INT,EXT) \
-do { \
- memset (((SCNHDR *)EXT)->s_pad, 0, sizeof (((SCNHDR *)EXT)->s_pad));\
-} while(0)
-
-/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
- from smaller values. Start with zero, widen, *then* decrement. */
-#define MINUS_ONE (((bfd_vma)0) - 1)
-
+#define COFF_ADJUST_SCNHDR_OUT_POST(ABFD, INT, EXT) \
+ do \
+ { \
+ memset (((SCNHDR *) EXT)->s_pad, 0, \
+ sizeof (((SCNHDR *) EXT)->s_pad)); \
+ } \
+ while (0)
#define NO_COFF_LINENOS
#define coff_SWAP_lineno_in _bfd_xcoff64_swap_lineno_in
#define coff_SWAP_lineno_out _bfd_xcoff64_swap_lineno_out
-#define PUTWORD bfd_h_put_32
-#define PUTHALF bfd_h_put_16
-#define PUTBYTE bfd_h_put_8
-#define GETWORD bfd_h_get_32
-#define GETHALF bfd_h_get_16
-#define GETBYTE bfd_h_get_8
-
-
static void _bfd_xcoff64_swap_lineno_in PARAMS ((bfd *, PTR, PTR));
static unsigned int _bfd_xcoff64_swap_lineno_out PARAMS ((bfd *, PTR, PTR));
static boolean _bfd_xcoff64_put_ldsymbol_name
PARAMS ((bfd *, struct xcoff_loader_info *, struct internal_ldsym *,
const char *));
+static void _bfd_xcoff64_swap_sym_in PARAMS ((bfd *, PTR, PTR));
+static unsigned int _bfd_xcoff64_swap_sym_out PARAMS ((bfd *, PTR, PTR));
+static void _bfd_xcoff64_swap_aux_in
+ PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+static unsigned int _bfd_xcoff64_swap_aux_out
+ PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+extern boolean _bfd_xcoff_mkobject PARAMS ((bfd *));
+extern boolean _bfd_xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *));
+extern boolean _bfd_xcoff_is_local_label_name PARAMS ((bfd *, const char *));
+extern void xcoff64_rtype2howto
+ PARAMS ((arelent *, struct internal_reloc *));
+extern reloc_howto_type * xcoff64_reloc_type_lookup
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
+extern boolean _bfd_xcoff_slurp_armap PARAMS ((bfd *));
+extern PTR _bfd_xcoff_read_ar_hdr PARAMS ((bfd *));
+extern bfd *_bfd_xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
+extern int _bfd_xcoff_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
+extern boolean _bfd_xcoff_write_armap
+ PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
+extern boolean _bfd_xcoff_write_archive_contents PARAMS ((bfd *));
+extern int _bfd_xcoff_sizeof_headers PARAMS ((bfd *, boolean));
+extern void _bfd_xcoff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
+extern unsigned int _bfd_xcoff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
+extern void _bfd_xcoff_swap_aux_in
+ PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+extern unsigned int _bfd_xcoff_swap_aux_out
+ PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+static void xcoff64_swap_ldhdr_in
+ PARAMS ((bfd *, const PTR, struct internal_ldhdr *));
+static void xcoff64_swap_ldhdr_out
+ PARAMS ((bfd *, const struct internal_ldhdr *, PTR d));
+static void xcoff64_swap_ldsym_in
+ PARAMS ((bfd *, const PTR, struct internal_ldsym *));
+static void xcoff64_swap_ldsym_out
+ PARAMS ((bfd *, const struct internal_ldsym *, PTR d));
+static void xcoff64_swap_ldrel_in
+ PARAMS ((bfd *, const PTR, struct internal_ldrel *));
+static void xcoff64_swap_ldrel_out
+ PARAMS ((bfd *, const struct internal_ldrel *, PTR d));
+static boolean xcoff64_write_object_contents PARAMS ((bfd *));
+static boolean xcoff64_ppc_relocate_section
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *,
+ asection **sections));
+static boolean xcoff64_slurp_armap PARAMS ((bfd *));
+static const bfd_target *xcoff64_archive_p PARAMS ((bfd *));
+static bfd *xcoff64_openr_next_archived_file PARAMS ((bfd *, bfd *));
+static int xcoff64_sizeof_headers PARAMS ((bfd *, boolean));
+static asection *xcoff64_create_csect_from_smclas
+ PARAMS ((bfd *, union internal_auxent *, const char *));
+static boolean xcoff64_is_lineno_count_overflow PARAMS ((bfd *, bfd_vma));
+static boolean xcoff64_is_reloc_count_overflow PARAMS ((bfd *, bfd_vma));
+static bfd_vma xcoff64_loader_symbol_offset
+ PARAMS ((bfd *, struct internal_ldhdr *));
+static bfd_vma xcoff64_loader_reloc_offset
+ PARAMS ((bfd *, struct internal_ldhdr *));
+
+/* coffcode.h needs these to be defined */
+/* Internalcoff.h and coffcode.h modify themselves based on these flags. */
+#define XCOFF64
+#define RS6000COFF_C 1
+
+#define SELECT_RELOC(internal, howto) \
+ { \
+ internal.r_type = howto->type; \
+ internal.r_size = \
+ ((howto->complain_on_overflow == complain_overflow_signed \
+ ? 0x80 \
+ : 0) \
+ | (howto->bitsize - 1)); \
+ }
-/* For XCOFF64, the effective width of symndx changes depending on
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
+#define COFF_LONG_FILENAMES
+#define NO_COFF_SYMBOLS
+#define RTYPE2HOWTO(cache_ptr, dst) xcoff64_rtype2howto (cache_ptr, dst)
+#define coff_mkobject _bfd_xcoff_mkobject
+#define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
+#define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
+#define coff_bfd_reloc_type_lookup xcoff64_reloc_type_lookup
+#ifdef AIX_CORE
+extern const bfd_target * rs6000coff_core_p ();
+extern boolean rs6000coff_core_file_matches_executable_p ();
+extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd));
+extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd));
+#define CORE_FILE_P rs6000coff_core_p
+#define coff_core_file_failing_command \
+ rs6000coff_core_file_failing_command
+#define coff_core_file_failing_signal \
+ rs6000coff_core_file_failing_signal
+#define coff_core_file_matches_executable_p \
+ rs6000coff_core_file_matches_executable_p
+#else
+#define CORE_FILE_P _bfd_dummy_target
+#define coff_core_file_failing_command \
+ _bfd_nocore_core_file_failing_command
+#define coff_core_file_failing_signal \
+ _bfd_nocore_core_file_failing_signal
+#define coff_core_file_matches_executable_p \
+ _bfd_nocore_core_file_matches_executable_p
+#endif
+#define coff_SWAP_sym_in _bfd_xcoff64_swap_sym_in
+#define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out
+#define coff_SWAP_aux_in _bfd_xcoff64_swap_aux_in
+#define coff_SWAP_aux_out _bfd_xcoff64_swap_aux_out
+
+
+#include "coffcode.h"
+
+/* For XCOFF64, the effective width of symndx changes depending on
whether we are the first entry. Sigh. */
static void
_bfd_xcoff64_swap_lineno_in (abfd, ext1, in1)
- bfd *abfd;
+ bfd *abfd;
PTR ext1;
PTR in1;
{
- LINENO *ext = (LINENO *)ext1;
- struct internal_lineno *in = (struct internal_lineno *)in1;
+ LINENO *ext = (LINENO *) ext1;
+ struct internal_lineno *in = (struct internal_lineno *) in1;
- in->l_lnno = bfd_h_get_32(abfd, (bfd_byte *) (ext->l_lnno));
+ in->l_lnno = H_GET_32 (abfd, (ext->l_lnno));
if (in->l_lnno == 0)
- in->l_addr.l_symndx =
- bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx);
+ in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx);
else
- in->l_addr.l_paddr =
- bfd_h_get_64(abfd, (bfd_byte *) ext->l_addr.l_paddr);
+ in->l_addr.l_paddr = H_GET_64 (abfd, ext->l_addr.l_paddr);
}
static unsigned int
_bfd_xcoff64_swap_lineno_out (abfd, inp, outp)
- bfd *abfd;
- PTR inp;
- PTR outp;
+ bfd *abfd;
+ PTR inp;
+ PTR outp;
{
- struct internal_lineno *in = (struct internal_lineno *)inp;
- struct external_lineno *ext = (struct external_lineno *)outp;
- PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *)
- ext->l_addr.l_symndx);
+ struct internal_lineno *in = (struct internal_lineno *) inp;
+ struct external_lineno *ext = (struct external_lineno *) outp;
+
+ H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
+ H_PUT_32 (abfd, in->l_lnno, (ext->l_lnno));
- bfd_h_put_32 (abfd, in->l_lnno, (bfd_byte *) (ext->l_lnno));
if (in->l_lnno == 0)
- bfd_h_put_32 (abfd, in->l_addr.l_symndx, (bfd_byte *)ext->l_addr.l_symndx);
+ H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
else
- bfd_h_put_64 (abfd, in->l_addr.l_paddr, (bfd_byte *)ext->l_addr.l_paddr);
+ H_PUT_64 (abfd, in->l_addr.l_paddr, ext->l_addr.l_paddr);
return bfd_coff_linesz (abfd);
}
-
-static void _bfd_xcoff64_swap_sym_in PARAMS ((bfd *, PTR, PTR));
-static unsigned int _bfd_xcoff64_swap_sym_out PARAMS ((bfd *, PTR, PTR));
-static void _bfd_xcoff64_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
-static unsigned int _bfd_xcoff64_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));
-
static void
_bfd_xcoff64_swap_sym_in (abfd, ext1, in1)
- bfd *abfd;
+ bfd *abfd;
PTR ext1;
PTR in1;
{
- struct external_syment *ext = (struct external_syment *)ext1;
- struct internal_syment *in = (struct internal_syment *)in1;
+ struct external_syment *ext = (struct external_syment *) ext1;
+ struct internal_syment *in = (struct internal_syment *) in1;
in->_n._n_n._n_zeroes = 0;
- in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e_offset);
- in->n_value = bfd_h_get_64(abfd, (bfd_byte *) ext->e_value);
- in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
- in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
- in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
- in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
+ in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e_offset);
+ in->n_value = H_GET_64 (abfd, ext->e_value);
+ in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
+ in->n_type = H_GET_16 (abfd, ext->e_type);
+ in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
+ in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
}
static unsigned int
_bfd_xcoff64_swap_sym_out (abfd, inp, extp)
- bfd *abfd;
- PTR inp;
- PTR extp;
+ bfd *abfd;
+ PTR inp;
+ PTR extp;
{
- struct internal_syment *in = (struct internal_syment *)inp;
- struct external_syment *ext =(struct external_syment *)extp;
-
- bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e_offset);
- bfd_h_put_64(abfd, in->n_value , (bfd_byte *) ext->e_value);
- bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
- bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type);
- bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass);
- bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux);
+ struct internal_syment *in = (struct internal_syment *) inp;
+ struct external_syment *ext = (struct external_syment *) extp;
+
+ H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e_offset);
+ H_PUT_64 (abfd, in->n_value, ext->e_value);
+ H_PUT_16 (abfd, in->n_scnum, ext->e_scnum);
+ H_PUT_16 (abfd, in->n_type, ext->e_type);
+ H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
+ H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
return bfd_coff_symesz (abfd);
}
static void
_bfd_xcoff64_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
- bfd *abfd;
- PTR ext1;
- int type;
- int class;
- int indx;
- int numaux;
- PTR in1;
+ bfd *abfd;
+ PTR ext1;
+ int type;
+ int class;
+ int indx;
+ int numaux;
+ PTR in1;
{
- union external_auxent *ext = (union external_auxent *)ext1;
- union internal_auxent *in = (union internal_auxent *)in1;
+ union external_auxent *ext = (union external_auxent *) ext1;
+ union internal_auxent *in = (union internal_auxent *) in1;
- switch (class) {
+ switch (class)
+ {
case C_FILE:
- if (ext->x_file.x_n.x_zeroes == 0) {
+ if (ext->x_file.x_n.x_zeroes == 0)
+ {
in->x_file.x_n.x_zeroes = 0;
- in->x_file.x_n.x_offset =
- bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
- } else {
+ in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
+ }
+ else
+ {
memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
}
goto end;
bfd_signed_vma h = 0;
bfd_vma l = 0;
- h = bfd_h_get_signed_32(abfd, ext->x_csect.x_scnlen_hi);
- l = bfd_h_get_32 (abfd, ext->x_csect.x_scnlen_lo);
+ h = H_GET_S32 (abfd, ext->x_csect.x_scnlen_hi);
+ l = H_GET_32 (abfd, ext->x_csect.x_scnlen_lo);
in->x_csect.x_scnlen.l = h << 32 | (l & 0xffffffff);
- in->x_csect.x_parmhash = bfd_h_get_32 (abfd,
- ext->x_csect.x_parmhash);
- in->x_csect.x_snhash = bfd_h_get_16 (abfd, ext->x_csect.x_snhash);
+ in->x_csect.x_parmhash = H_GET_32 (abfd, ext->x_csect.x_parmhash);
+ in->x_csect.x_snhash = H_GET_16 (abfd, ext->x_csect.x_snhash);
/* We don't have to hack bitfields in x_smtyp because it's
defined by shifts-and-ands, which are equivalent on all
byte orders. */
- in->x_csect.x_smtyp = bfd_h_get_8 (abfd, ext->x_csect.x_smtyp);
- in->x_csect.x_smclas = bfd_h_get_8 (abfd, ext->x_csect.x_smclas);
+ in->x_csect.x_smtyp = H_GET_8 (abfd, ext->x_csect.x_smtyp);
+ in->x_csect.x_smclas = H_GET_8 (abfd, ext->x_csect.x_smclas);
goto end;
}
break;
case C_STAT:
case C_LEAFSTAT:
case C_HIDDEN:
- if (type == T_NULL) {
+ if (type == T_NULL)
+ {
/* PE defines some extra fields; we zero them out for
- safety. */
+ safety. */
in->x_scn.x_checksum = 0;
in->x_scn.x_associated = 0;
in->x_scn.x_comdat = 0;
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
{
- in->x_sym.x_fcnary.x_fcn.x_lnnoptr = bfd_h_get_64(abfd, (bfd_byte *)
- ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
- in->x_sym.x_fcnary.x_fcn.x_endndx.l = bfd_h_get_32(abfd, (bfd_byte *)
- ext->x_sym.x_fcnary.x_fcn.x_endndx);
+ in->x_sym.x_fcnary.x_fcn.x_lnnoptr
+ = H_GET_64 (abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
+ in->x_sym.x_fcnary.x_fcn.x_endndx.l
+ = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx);
+ }
+ if (ISFCN (type))
+ {
+ in->x_sym.x_misc.x_fsize
+ = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_fsize);
+ }
+ else
+ {
+ in->x_sym.x_misc.x_lnsz.x_lnno
+ = H_GET_32 (abfd, ext->x_sym.x_fcnary.x_lnsz.x_lnno);
+ in->x_sym.x_misc.x_lnsz.x_size
+ = H_GET_16 (abfd, ext->x_sym.x_fcnary.x_lnsz.x_size);
}
- if (ISFCN(type)) {
- in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_fsize);
- }
- else {
- in->x_sym.x_misc.x_lnsz.x_lnno = bfd_h_get_32(abfd, (bfd_byte *)
- ext->x_sym.x_fcnary.x_lnsz.x_lnno);
- in->x_sym.x_misc.x_lnsz.x_size = bfd_h_get_16(abfd, (bfd_byte *)
- ext->x_sym.x_fcnary.x_lnsz.x_size);
- }
-
-end: ;
- /* the semicolon is because MSVC doesn't like labels at
- end of block. */
+ end: ;
}
-
-
static unsigned int
_bfd_xcoff64_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
- bfd *abfd;
- PTR inp;
- int type;
- int class;
- int indx ATTRIBUTE_UNUSED;
- int numaux ATTRIBUTE_UNUSED;
- PTR extp;
+ bfd *abfd;
+ PTR inp;
+ int type;
+ int class;
+ int indx ATTRIBUTE_UNUSED;
+ int numaux ATTRIBUTE_UNUSED;
+ PTR extp;
{
- union internal_auxent *in = (union internal_auxent *)inp;
- union external_auxent *ext = (union external_auxent *)extp;
+ union internal_auxent *in = (union internal_auxent *) inp;
+ union external_auxent *ext = (union external_auxent *) extp;
- memset((PTR)ext, 0, bfd_coff_auxesz (abfd));
+ memset ((PTR) ext, 0, bfd_coff_auxesz (abfd));
switch (class)
{
- case C_FILE:
- if (ext->x_file.x_n.x_zeroes == 0) {
- bfd_h_put_32 (abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
- bfd_h_put_32 (abfd, in->x_file.x_n.x_offset,
- (bfd_byte *) ext->x_file.x_n.x_offset);
- } else {
- memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
- }
- bfd_h_put_8 (abfd, _AUX_FILE, (bfd_byte *) ext->x_auxtype.x_auxtype);
- goto end;
-
- /* RS/6000 "csect" auxents */
- case C_EXT:
- case C_HIDEXT:
- if (indx + 1 == numaux)
- {
- bfd_vma temp;
-
- temp = in->x_csect.x_scnlen.l & 0xffffffff;
- bfd_h_put_32 (abfd, temp, ext->x_csect.x_scnlen_lo);
- temp = in->x_csect.x_scnlen.l >> 32;
- bfd_h_put_32 (abfd, temp, ext->x_csect.x_scnlen_hi);
- bfd_h_put_32 (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
- bfd_h_put_16 (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
- /* We don't have to hack bitfields in x_smtyp because it's
- defined by shifts-and-ands, which are equivalent on all
- byte orders. */
- bfd_h_put_8 (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
- bfd_h_put_8 (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
- bfd_h_put_8 (abfd, _AUX_CSECT, (bfd_byte *) ext->x_auxtype.x_auxtype);
- goto end;
- }
- break;
-
- case C_STAT:
- case C_LEAFSTAT:
- case C_HIDDEN:
- if (type == T_NULL) {
+ case C_FILE:
+ if (ext->x_file.x_n.x_zeroes == 0)
+ {
+ H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
+ H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
+ }
+ else
+ {
+ memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
+ }
+ H_PUT_8 (abfd, _AUX_FILE, ext->x_auxtype.x_auxtype);
goto end;
+
+ /* RS/6000 "csect" auxents */
+ case C_EXT:
+ case C_HIDEXT:
+ if (indx + 1 == numaux)
+ {
+ bfd_vma temp;
+
+ temp = in->x_csect.x_scnlen.l & 0xffffffff;
+ H_PUT_32 (abfd, temp, ext->x_csect.x_scnlen_lo);
+ temp = in->x_csect.x_scnlen.l >> 32;
+ H_PUT_32 (abfd, temp, ext->x_csect.x_scnlen_hi);
+ H_PUT_32 (abfd, in->x_csect.x_parmhash, ext->x_csect.x_parmhash);
+ H_PUT_16 (abfd, in->x_csect.x_snhash, ext->x_csect.x_snhash);
+ /* We don't have to hack bitfields in x_smtyp because it's
+ defined by shifts-and-ands, which are equivalent on all
+ byte orders. */
+ H_PUT_8 (abfd, in->x_csect.x_smtyp, ext->x_csect.x_smtyp);
+ H_PUT_8 (abfd, in->x_csect.x_smclas, ext->x_csect.x_smclas);
+ H_PUT_8 (abfd, _AUX_CSECT, ext->x_auxtype.x_auxtype);
+ goto end;
+ }
+ break;
+
+ case C_STAT:
+ case C_LEAFSTAT:
+ case C_HIDDEN:
+ if (type == T_NULL)
+ {
+ goto end;
+ }
+ break;
}
- break;
- }
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
{
- bfd_h_put_64(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr,
- (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
- bfd_h_put_8 (abfd, _AUX_FCN, (bfd_byte *) ext->x_auxtype.x_auxtype);
- bfd_h_put_32(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l,
- (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx);
+ H_PUT_64 (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr,
+ ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
+ H_PUT_8 (abfd, _AUX_FCN,
+ ext->x_auxtype.x_auxtype);
+ H_PUT_32 (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l,
+ ext->x_sym.x_fcnary.x_fcn.x_endndx);
}
if (ISFCN (type))
- bfd_h_put_32 (abfd, in->x_sym.x_misc.x_fsize,
- (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_fsize);
+ {
+ H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize,
+ ext->x_sym.x_fcnary.x_fcn.x_fsize);
+ }
else
{
- bfd_h_put_32(abfd, in->x_sym.x_misc.x_lnsz.x_lnno,
- (bfd_byte *)ext->x_sym.x_fcnary.x_lnsz.x_lnno);
- bfd_h_put_16(abfd, in->x_sym.x_misc.x_lnsz.x_size,
- (bfd_byte *)ext->x_sym.x_fcnary.x_lnsz.x_size);
+ H_PUT_32 (abfd, in->x_sym.x_misc.x_lnsz.x_lnno,
+ ext->x_sym.x_fcnary.x_lnsz.x_lnno);
+ H_PUT_16 (abfd, in->x_sym.x_misc.x_lnsz.x_size,
+ ext->x_sym.x_fcnary.x_lnsz.x_size);
}
-end:
+ end:
return bfd_coff_auxesz (abfd);
}
static boolean
-_bfd_xcoff64_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab,
+_bfd_xcoff64_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab,
struct internal_syment *sym,
const char *name) {
boolean hash;
bfd_size_type indx;
-
+
hash = true;
-
+
if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
hash = false;
-
+
indx = _bfd_stringtab_add (strtab, name, hash, false);
-
+
if (indx == (bfd_size_type) -1)
return false;
-
+
sym->_n._n_n._n_zeroes = 0;
sym->_n._n_n._n_offset = STRING_SIZE_SIZE + indx;
-
+
return true;
}
static boolean
_bfd_xcoff64_put_ldsymbol_name (abfd, ldinfo, ldsym, name)
bfd *abfd ATTRIBUTE_UNUSED;
- struct xcoff_loader_info *ldinfo;
- struct internal_ldsym *ldsym;
- const char *name;
+ struct xcoff_loader_info *ldinfo;
+ struct internal_ldsym *ldsym;
+ const char *name;
{
size_t len;
len = strlen (name);
- if (ldinfo->string_size + len + 3 > ldinfo->string_alc){
- size_t newalc;
- bfd_byte *newstrings;
-
- newalc = ldinfo->string_alc * 2;
- if (newalc == 0)
- newalc = 32;
- while (ldinfo->string_size + len + 3 > newalc)
- newalc *= 2;
-
- newstrings = ((bfd_byte *)
- bfd_realloc ((PTR) ldinfo->strings, newalc));
- if (newstrings == NULL) {
- ldinfo->failed = true;
- return false;
+ if (ldinfo->string_size + len + 3 > ldinfo->string_alc)
+ {
+ bfd_size_type newalc;
+ bfd_byte *newstrings;
+
+ newalc = ldinfo->string_alc * 2;
+ if (newalc == 0)
+ newalc = 32;
+ while (ldinfo->string_size + len + 3 > newalc)
+ newalc *= 2;
+
+ newstrings = ((bfd_byte *)
+ bfd_realloc ((PTR) ldinfo->strings, newalc));
+ if (newstrings == NULL)
+ {
+ ldinfo->failed = true;
+ return false;
+ }
+ ldinfo->string_alc = newalc;
+ ldinfo->strings = newstrings;
}
- ldinfo->string_alc = newalc;
- ldinfo->strings = newstrings;
- }
-
- bfd_put_16 (ldinfo->output_bfd, len + 1,
+
+ bfd_put_16 (ldinfo->output_bfd, (bfd_vma) (len + 1),
ldinfo->strings + ldinfo->string_size);
strcpy (ldinfo->strings + ldinfo->string_size + 2, name);
ldsym->_l._l_l._l_zeroes = 0;
ldsym->_l._l_l._l_offset = ldinfo->string_size + 2;
ldinfo->string_size += len + 3;
-
+
return true;
}
-extern boolean _bfd_xcoff_mkobject PARAMS ((bfd *));
-extern boolean _bfd_xcoff_copy_private_bfd_data PARAMS ((bfd *, bfd *));
-extern boolean _bfd_xcoff_is_local_label_name PARAMS ((bfd *, const char *));
-extern void xcoff64_rtype2howto
- PARAMS ((arelent *, struct internal_reloc *));
-extern reloc_howto_type * xcoff64_reloc_type_lookup
- PARAMS ((bfd *, bfd_reloc_code_real_type));
-extern boolean _bfd_xcoff_slurp_armap PARAMS ((bfd *));
-extern PTR _bfd_xcoff_read_ar_hdr PARAMS ((bfd *));
-extern bfd *_bfd_xcoff_openr_next_archived_file PARAMS ((bfd *, bfd *));
-extern int _bfd_xcoff_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
-extern boolean _bfd_xcoff_write_armap
- PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
-extern boolean _bfd_xcoff_write_archive_contents PARAMS ((bfd *));
-extern int _bfd_xcoff_sizeof_headers PARAMS ((bfd *, boolean));
-extern void _bfd_xcoff_swap_sym_in PARAMS ((bfd *, PTR, PTR));
-extern unsigned int _bfd_xcoff_swap_sym_out PARAMS ((bfd *, PTR, PTR));
-extern void _bfd_xcoff_swap_aux_in PARAMS ((bfd *, PTR, int, int, int, int, PTR));
-extern unsigned int _bfd_xcoff_swap_aux_out PARAMS ((bfd *, PTR, int, int, int, int, PTR));
-
-/* coffcode.h needs these to be defined */
-/* Internalcoff.h and coffcode.h modify themselves based on these flags. */
-#define XCOFF64
-#define RS6000COFF_C 1
-
-#define SELECT_RELOC(internal, howto) \
- { \
- internal.r_type = howto->type; \
- internal.r_size = \
- ((howto->complain_on_overflow == complain_overflow_signed \
- ? 0x80 \
- : 0) \
- | (howto->bitsize - 1)); \
- }
-
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
-#define COFF_LONG_FILENAMES
-#define NO_COFF_SYMBOLS
-#define RTYPE2HOWTO(cache_ptr, dst) xcoff64_rtype2howto (cache_ptr, dst)
-#define coff_mkobject _bfd_xcoff_mkobject
-#define coff_bfd_copy_private_bfd_data _bfd_xcoff_copy_private_bfd_data
-#define coff_bfd_is_local_label_name _bfd_xcoff_is_local_label_name
-#define coff_bfd_reloc_type_lookup xcoff64_reloc_type_lookup
-#ifdef AIX_CORE
-extern const bfd_target * rs6000coff_core_p ();
-extern boolean rs6000coff_core_file_matches_executable_p ();
-extern char *rs6000coff_core_file_failing_command PARAMS ((bfd *abfd));
-extern int rs6000coff_core_file_failing_signal PARAMS ((bfd *abfd));
-#define CORE_FILE_P rs6000coff_core_p
-#define coff_core_file_failing_command \
- rs6000coff_core_file_failing_command
-#define coff_core_file_failing_signal \
- rs6000coff_core_file_failing_signal
-#define coff_core_file_matches_executable_p \
- rs6000coff_core_file_matches_executable_p
-#else
-#define CORE_FILE_P _bfd_dummy_target
-#define coff_core_file_failing_command \
- _bfd_nocore_core_file_failing_command
-#define coff_core_file_failing_signal \
- _bfd_nocore_core_file_failing_signal
-#define coff_core_file_matches_executable_p \
- _bfd_nocore_core_file_matches_executable_p
-#endif
-#define coff_SWAP_sym_in _bfd_xcoff64_swap_sym_in
-#define coff_SWAP_sym_out _bfd_xcoff64_swap_sym_out
-#define coff_SWAP_aux_in _bfd_xcoff64_swap_aux_in
-#define coff_SWAP_aux_out _bfd_xcoff64_swap_aux_out
-
-
-
-#include "coffcode.h"
-
/* Routines to swap information in the XCOFF .loader section. If we
ever need to write an XCOFF loader, this stuff will need to be
moved to another file shared by the linker (which XCOFF calls the
``binder'') and the loader. */
-static void xcoff64_swap_ldhdr_in
- PARAMS ((bfd *, const PTR, struct internal_ldhdr *));
-static void xcoff64_swap_ldhdr_out
- PARAMS ((bfd *, const struct internal_ldhdr *, PTR d));
-static void xcoff64_swap_ldsym_in
- PARAMS ((bfd *, const PTR, struct internal_ldsym *));
-static void xcoff64_swap_ldsym_out
- PARAMS ((bfd *, const struct internal_ldsym *, PTR d));
-static void xcoff64_swap_ldrel_in
- PARAMS ((bfd *, const PTR, struct internal_ldrel *));
-static void xcoff64_swap_ldrel_out
- PARAMS ((bfd *, const struct internal_ldrel *, PTR d));
-static boolean xcoff64_write_object_contents PARAMS ((bfd *));
-static boolean xcoff64_ppc_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
- struct internal_reloc *, struct internal_syment *,
- asection **sections));
-static boolean xcoff64_slurp_armap PARAMS ((bfd *));
-static const bfd_target *xcoff64_archive_p PARAMS ((bfd *));
-static bfd *xcoff64_openr_next_archived_file PARAMS ((bfd *, bfd *));
-static int xcoff64_sizeof_headers PARAMS ((bfd *, boolean));
-static asection *xcoff64_create_csect_from_smclas
- PARAMS ((bfd *, union internal_auxent *, const char *));
-static boolean xcoff64_is_lineno_count_overflow PARAMS ((bfd *, bfd_vma));
-static boolean xcoff64_is_reloc_count_overflow PARAMS ((bfd *, bfd_vma));
-static bfd_vma xcoff64_loader_symbol_offset
- PARAMS ((bfd *, struct internal_ldhdr *));
-static bfd_vma xcoff64_loader_reloc_offset
- PARAMS ((bfd *, struct internal_ldhdr *));
-
/* Swap in the ldhdr structure. */
static void
{
struct external_ldhdr *dst = (struct external_ldhdr *) d;
- bfd_put_32 (abfd, src->l_version, dst->l_version);
+ bfd_put_32 (abfd, (bfd_vma) src->l_version, dst->l_version);
bfd_put_32 (abfd, src->l_nsyms, dst->l_nsyms);
bfd_put_32 (abfd, src->l_nreloc, dst->l_nreloc);
bfd_put_32 (abfd, src->l_istlen, dst->l_istlen);
struct internal_ldsym *dst;
{
const struct external_ldsym *src = (const struct external_ldsym *) s;
- /*
- * XCOFF64 does not use l_zeroes like XCOFF32
- * Set the internal l_zeroes to 0 so the common 32/64 code uses l_value
- * as an offset into the loader symbol table
- */
+ /* XCOFF64 does not use l_zeroes like XCOFF32
+ Set the internal l_zeroes to 0 so the common 32/64 code uses l_value
+ as an offset into the loader symbol table. */
dst->_l._l_l._l_zeroes = 0;
dst->_l._l_l._l_offset = bfd_get_32 (abfd, src->l_offset);
dst->l_value = bfd_get_64 (abfd, src->l_value);
struct external_ldsym *dst = (struct external_ldsym *) d;
bfd_put_64 (abfd, src->l_value, dst->l_value);
- bfd_put_32 (abfd, src->_l._l_l._l_offset, dst->l_offset);
- bfd_put_16 (abfd, src->l_scnum, dst->l_scnum);
+ bfd_put_32 (abfd, (bfd_vma) src->_l._l_l._l_offset, dst->l_offset);
+ bfd_put_16 (abfd, (bfd_vma) src->l_scnum, dst->l_scnum);
bfd_put_8 (abfd, src->l_smtype, dst->l_smtype);
bfd_put_8 (abfd, src->l_smclas, dst->l_smclas);
bfd_put_32 (abfd, src->l_ifile, dst->l_ifile);
struct external_ldrel *dst = (struct external_ldrel *) d;
bfd_put_64 (abfd, src->l_vaddr, dst->l_vaddr);
- bfd_put_16 (abfd, src->l_rtype, dst->l_rtype);
- bfd_put_16 (abfd, src->l_rsecnm, dst->l_rsecnm);
+ bfd_put_16 (abfd, (bfd_vma) src->l_rtype, dst->l_rtype);
+ bfd_put_16 (abfd, (bfd_vma) src->l_rsecnm, dst->l_rsecnm);
bfd_put_32 (abfd, src->l_symndx, dst->l_symndx);
}
unsigned long reloc_size = 0;
unsigned long lnno_size = 0;
boolean long_section_names;
- asection *text_sec = ((void *)0) ;
- asection *data_sec = ((void *)0) ;
- asection *bss_sec = ((void *)0) ;
+ asection *text_sec = ((void *) 0);
+ asection *data_sec = ((void *) 0);
+ asection *bss_sec = ((void *) 0);
struct internal_filehdr internal_f;
struct internal_aouthdr internal_a;
bfd_set_error (bfd_error_system_call);
- if (abfd->output_has_begun == false) {
- if (! bfd_coff_compute_section_file_positions (abfd))
- return false;
- }
+ if (abfd->output_has_begun == false)
+ {
+ if (! bfd_coff_compute_section_file_positions (abfd))
+ return false;
+ }
/* Work out the size of the reloc and linno areas */
reloc_base = obj_relocbase (abfd);
- for (current = abfd->sections; current != NULL; current = current->next) {
+ for (current = abfd->sections; current != NULL; current = current->next)
reloc_size += current->reloc_count * bfd_coff_relsz (abfd);
- }
lineno_base = reloc_base + reloc_size;
sym_base = lineno_base + lnno_size;
- /* Indicate in each section->line_filepos its actual file address */
- for (current = abfd->sections; current != NULL; current = current->next) {
- if (current->lineno_count) {
- current->line_filepos = lineno_base;
- current->moving_line_filepos = lineno_base;
- lineno_base += current->lineno_count * bfd_coff_linesz (abfd);
- } else {
- current->line_filepos = 0;
+ /* Indicate in each section->line_filepos its actual file address */
+ for (current = abfd->sections; current != NULL; current = current->next)
+ {
+ if (current->lineno_count)
+ {
+ current->line_filepos = lineno_base;
+ current->moving_line_filepos = lineno_base;
+ lineno_base += current->lineno_count * bfd_coff_linesz (abfd);
+ }
+ else
+ {
+ current->line_filepos = 0;
+ }
+
+ if (current->reloc_count)
+ {
+ current->rel_filepos = reloc_base;
+ reloc_base += current->reloc_count * bfd_coff_relsz (abfd);
+ }
+ else
+ {
+ current->rel_filepos = 0;
+ }
+ }
+
+ if ((abfd->flags & EXEC_P) != 0)
+ {
+ scn_base = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd);
+ internal_f.f_opthdr = bfd_coff_aoutsz (abfd);
}
-
- if (current->reloc_count) {
- current->rel_filepos = reloc_base;
- reloc_base += current->reloc_count * bfd_coff_relsz (abfd);
- } else {
- current->rel_filepos = 0;
+ else
+ {
+ scn_base = bfd_coff_filhsz (abfd);
+ internal_f.f_opthdr = 0;
}
- }
-
- if ((abfd->flags & EXEC_P) != 0) {
- scn_base = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd);
- internal_f.f_opthdr = bfd_coff_aoutsz (abfd);
- } else {
- scn_base = bfd_coff_filhsz (abfd);
- internal_f.f_opthdr = 0;
- }
internal_f.f_nscns = 0;
return false;
long_section_names = false;
- for (current = abfd->sections; current != NULL; current = current->next) {
-
- struct internal_scnhdr section;
- struct external_scnhdr buff;
-
- internal_f.f_nscns++;
-
- strncpy (section.s_name, current->name, SCNNMLEN);
-
- section.s_vaddr = current->vma;
- section.s_paddr = current->lma;
- section.s_size = current->_raw_size;
-
- /*
- If this section has no size or is unloadable then the scnptr
- will be 0 too
- */
- if (current->_raw_size == 0 ||
- (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0) {
- section.s_scnptr = 0;
- } else {
- section.s_scnptr = current->filepos;
- }
+ for (current = abfd->sections; current != NULL; current = current->next)
+ {
+ struct internal_scnhdr section;
+ struct external_scnhdr buff;
+ bfd_size_type amount;
- section.s_relptr = current->rel_filepos;
- section.s_lnnoptr = current->line_filepos;
- section.s_nreloc = current->reloc_count;
+ internal_f.f_nscns++;
- section.s_nlnno = current->lineno_count;
- if (current->reloc_count != 0)
- hasrelocs = true;
- if (current->lineno_count != 0)
- haslinno = true;
+ strncpy (section.s_name, current->name, SCNNMLEN);
- section.s_flags = sec_to_styp_flags (current->name, current->flags);
+ section.s_vaddr = current->vma;
+ section.s_paddr = current->lma;
+ section.s_size = current->_raw_size;
- if (!strcmp (current->name, _TEXT)) {
- text_sec = current;
- } else if (!strcmp (current->name, _DATA)) {
- data_sec = current;
- } else if (!strcmp (current->name, _BSS)) {
- bss_sec = current;
- }
+ /* If this section has no size or is unloadable then the scnptr
+ will be 0 too. */
+ if (current->_raw_size == 0
+ || (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
+ {
+ section.s_scnptr = 0;
+ }
+ else
+ {
+ section.s_scnptr = current->filepos;
+ }
+
+ section.s_relptr = current->rel_filepos;
+ section.s_lnnoptr = current->line_filepos;
+ section.s_nreloc = current->reloc_count;
+
+ section.s_nlnno = current->lineno_count;
+ if (current->reloc_count != 0)
+ hasrelocs = true;
+ if (current->lineno_count != 0)
+ haslinno = true;
- if (bfd_coff_swap_scnhdr_out (abfd, §ion, &buff) == 0
- || bfd_write ((PTR) (&buff), 1, bfd_coff_scnhsz (abfd), abfd)
- != bfd_coff_scnhsz (abfd))
+ section.s_flags = sec_to_styp_flags (current->name, current->flags);
+
+ if (!strcmp (current->name, _TEXT))
+ {
+ text_sec = current;
+ }
+ else if (!strcmp (current->name, _DATA))
+ {
+ data_sec = current;
+ }
+ else if (!strcmp (current->name, _BSS))
+ {
+ bss_sec = current;
+ }
+
+ amount = bfd_coff_scnhsz (abfd);
+ if (bfd_coff_swap_scnhdr_out (abfd, §ion, &buff) == 0
+ || bfd_bwrite ((PTR) (&buff), amount, abfd) != amount)
return false;
- }
+ }
internal_f.f_timdat = 0;
memset (&internal_a, 0, sizeof internal_a);
- /*
- * This can only be called from the xcoff64 backend so the magic # must
- * be for xcoff64
- */
+ /* This can only be called from the xcoff64 backend so the magic #
+ must be for xcoff64. */
internal_f.f_magic = 0757;
internal_a.magic = (abfd->flags & D_PAGED) ? RS6K_AOUTHDR_ZMAGIC :
internal_f.f_symptr = 0;
internal_f.f_nsyms = 0;
- /*
- * If bfd_get_symcount (abfd) != 0, then we are not using the COFF
- * backend linker, and obj_raw_syment_count is not valid until after
- * coff_write_symbols is called.
- */
- if (bfd_get_symcount (abfd) != 0) {
- int firstundef;
+ /* If bfd_get_symcount (abfd) != 0, then we are not using the COFF
+ backend linker, and obj_raw_syment_count is not valid until after
+ coff_write_symbols is called. */
+ if (bfd_get_symcount (abfd) != 0)
+ {
+ int firstundef;
- if (!coff_renumber_symbols (abfd, &firstundef))
- return false;
- coff_mangle_symbols (abfd);
- if (! coff_write_symbols (abfd))
- return false;
- if (! coff_write_linenumbers (abfd))
- return false;
- if (! coff_write_relocs (abfd, firstundef))
- return false;
+ if (!coff_renumber_symbols (abfd, &firstundef))
+ return false;
+ coff_mangle_symbols (abfd);
+ if (! coff_write_symbols (abfd))
+ return false;
+ if (! coff_write_linenumbers (abfd))
+ return false;
+ if (! coff_write_relocs (abfd, firstundef))
+ return false;
- internal_f.f_symptr = sym_base;
- internal_f.f_nsyms = bfd_get_symcount (abfd);
- } else if (obj_raw_syment_count (abfd) != 0) {
- internal_f.f_symptr = sym_base;
-
- /*
- * AIX appears to require that F_RELFLG not be set if there are
- * local symbols but no relocations.
- */
- internal_f.f_flags &=~ F_RELFLG;
- } else {
- internal_f.f_flags |= F_LSYMS;
- }
+ internal_f.f_symptr = sym_base;
+ internal_f.f_nsyms = bfd_get_symcount (abfd);
+ }
+ else if (obj_raw_syment_count (abfd) != 0)
+ {
+ internal_f.f_symptr = sym_base;
+
+ /* AIX appears to require that F_RELFLG not be set if there are
+ local symbols but no relocations. */
+ internal_f.f_flags &=~ F_RELFLG;
+ }
+ else
+ {
+ internal_f.f_flags |= F_LSYMS;
+ }
- if (text_sec) {
- internal_a.tsize = bfd_get_section_size_before_reloc (text_sec);
+ if (text_sec)
+ {
+ internal_a.tsize = bfd_get_section_size_before_reloc (text_sec);
internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
- }
+ }
- if (data_sec) {
- internal_a.dsize = bfd_get_section_size_before_reloc (data_sec);
- internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
- }
+ if (data_sec)
+ {
+ internal_a.dsize = bfd_get_section_size_before_reloc (data_sec);
+ internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
+ }
- if (bss_sec) {
- internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec);
- if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
- internal_a.data_start = bss_sec->vma;
- }
+ if (bss_sec)
+ {
+ internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec);
+ if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
+ internal_a.data_start = bss_sec->vma;
+ }
internal_a.entry = bfd_get_start_address (abfd);
internal_f.f_nsyms = obj_raw_syment_count (abfd);
- if (xcoff_data (abfd)->full_aouthdr) {
-
+ if (xcoff_data (abfd)->full_aouthdr)
+ {
bfd_vma toc;
asection *loader_sec;
if (internal_a.o_snentry == 0)
internal_a.entry = (bfd_vma) -1;
- if (text_sec != NULL) {
+ if (text_sec != NULL)
+ {
internal_a.o_sntext = text_sec->target_index;
internal_a.o_algntext = bfd_get_section_alignment (abfd, text_sec);
- } else {
- internal_a.o_sntext = 0;
- internal_a.o_algntext = 0;
- }
-
- if (data_sec != NULL) {
- internal_a.o_sndata = data_sec->target_index;
- internal_a.o_algndata = bfd_get_section_alignment (abfd, data_sec);
- } else {
- internal_a.o_sndata = 0;
- internal_a.o_algndata = 0;
- }
+ }
+ else
+ {
+ internal_a.o_sntext = 0;
+ internal_a.o_algntext = 0;
+ }
+
+ if (data_sec != NULL)
+ {
+ internal_a.o_sndata = data_sec->target_index;
+ internal_a.o_algndata = bfd_get_section_alignment (abfd, data_sec);
+ }
+ else
+ {
+ internal_a.o_sndata = 0;
+ internal_a.o_algndata = 0;
+ }
loader_sec = bfd_get_section_by_name (abfd, ".loader");
if (loader_sec != NULL)
}
internal_a.o_maxstack = xcoff_data (abfd)->maxstack;
internal_a.o_maxdata = xcoff_data (abfd)->maxdata;
- }
-
- if (bfd_seek (abfd, (file_ptr) 0, 0 ) != 0)
+ }
+
+ if (bfd_seek (abfd, (file_ptr) 0, 0) != 0)
return false;
-
+
{
char * buff;
- bfd_size_type amount;
-
- buff = bfd_malloc (bfd_coff_filhsz (abfd));
- if (buff == ((void *)0) )
+ bfd_size_type amount = bfd_coff_filhsz (abfd);
+
+ buff = bfd_malloc (amount);
+ if (buff == NULL)
return false;
-
- bfd_coff_swap_filehdr_out (abfd, (PTR) & internal_f, (PTR) buff);
- amount = bfd_write ((PTR) buff, 1, bfd_coff_filhsz (abfd), abfd);
-
+
+ bfd_coff_swap_filehdr_out (abfd, (PTR) &internal_f, (PTR) buff);
+ amount = bfd_bwrite ((PTR) buff, amount, abfd);
+
free (buff);
-
+
if (amount != bfd_coff_filhsz (abfd))
return false;
}
-
- if (abfd->flags & EXEC_P) {
- char * buff;
- bfd_size_type amount;
+ if (abfd->flags & EXEC_P)
+ {
+ char * buff;
+ bfd_size_type amount = bfd_coff_aoutsz (abfd);
- buff = bfd_malloc (bfd_coff_aoutsz (abfd));
- if (buff == NULL)
- return false;
-
- bfd_coff_swap_aouthdr_out (abfd, (PTR) & internal_a, (PTR) buff);
- amount = bfd_write ((PTR) buff, 1, bfd_coff_aoutsz (abfd), abfd);
+ buff = bfd_malloc (amount);
+ if (buff == NULL)
+ return false;
- free (buff);
-
- if (amount != bfd_coff_aoutsz (abfd))
- return false;
- }
+ bfd_coff_swap_aouthdr_out (abfd, (PTR) & internal_a, (PTR) buff);
+ amount = bfd_bwrite ((PTR) buff, amount, abfd);
+
+ free (buff);
+ if (amount != bfd_coff_aoutsz (abfd))
+ return false;
+ }
return true;
}
symndx = rel->r_symndx;
- if (symndx == -1) {
- h = NULL;
- sym = NULL;
- addend = 0;
- } else {
- h = obj_xcoff_sym_hashes (input_bfd)[symndx];
- sym = syms + symndx;
- addend = - sym->n_value;
- }
+ if (symndx == -1)
+ {
+ h = NULL;
+ sym = NULL;
+ addend = 0;
+ }
+ else
+ {
+ h = obj_xcoff_sym_hashes (input_bfd)[symndx];
+ sym = syms + symndx;
+ addend = - sym->n_value;
+ }
/* We build the howto information on the fly. */
howto.name = "internal";
howto.partial_inplace = true;
- if (howto.bitsize == 64) {
- howto.src_mask = howto.dst_mask = MINUS_ONE;
- } else if (howto.bitsize == 32) {
- howto.src_mask = howto.dst_mask = 0xffffffff;
- } else {
- howto.src_mask = howto.dst_mask = (1 << howto.bitsize) - 1;
- if (howto.bitsize == 16)
- howto.size = 1;
- }
+ if (howto.bitsize == 64)
+ {
+ howto.src_mask = howto.dst_mask = MINUS_ONE;
+ }
+ else if (howto.bitsize == 32)
+ {
+ howto.src_mask = howto.dst_mask = 0xffffffff;
+ }
+ else
+ {
+ howto.src_mask = howto.dst_mask = (1 << howto.bitsize) - 1;
+ if (howto.bitsize == 16)
+ howto.size = 1;
+ }
howto.pcrel_offset = false;
val = 0;
- if (h == NULL) {
- asection *sec;
-
- if (symndx == -1) {
- sec = bfd_abs_section_ptr;
- val = 0;
- } else {
- sec = sections[symndx];
- /* Hack to make sure we use the right TOC anchor value
- if this reloc is against the TOC anchor. */
- if (sec->name[3] == '0'
- && strcmp (sec->name, ".tc0") == 0)
- val = xcoff_data (output_bfd)->toc;
+ if (h == NULL)
+ {
+ asection *sec;
+
+ if (symndx == -1)
+ {
+ sec = bfd_abs_section_ptr;
+ val = 0;
+ }
else
- val = (sec->output_section->vma
- + sec->output_offset
- + sym->n_value
- - sec->vma);
+ {
+ sec = sections[symndx];
+ /* Hack to make sure we use the right TOC anchor value
+ if this reloc is against the TOC anchor. */
+ if (sec->name[3] == '0'
+ && strcmp (sec->name, ".tc0") == 0)
+ val = xcoff_data (output_bfd)->toc;
+ else
+ val = (sec->output_section->vma
+ + sec->output_offset
+ + sym->n_value
+ - sec->vma);
+ }
+
}
+ else
+ {
- } else {
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ asection *sec;
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak) {
- asection *sec;
-
- sec = h->root.u.def.section;
- val = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
+ sec = h->root.u.def.section;
+ val = (h->root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
- } else if (h->root.type == bfd_link_hash_common) {
- asection *sec;
-
- sec = h->root.u.c.p->section;
- val = (sec->output_section->vma
- + sec->output_offset);
- } else if ((h->flags & XCOFF_DEF_DYNAMIC) != 0
- || (h->flags & XCOFF_IMPORT) != 0) {
- /* Every symbol in a shared object is defined somewhere. */
- val = 0;
- } else if (! info->relocateable) {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd, input_section,
- rel->r_vaddr - input_section->vma, true)))
- return false;
-
- /* Don't try to process the reloc. It can't help, and
- it may generate another error. */
- continue;
+ }
+ else if (h->root.type == bfd_link_hash_common)
+ {
+ asection *sec;
+
+ sec = h->root.u.c.p->section;
+ val = (sec->output_section->vma
+ + sec->output_offset);
+ }
+ else if ((h->flags & XCOFF_DEF_DYNAMIC) != 0
+ || (h->flags & XCOFF_IMPORT) != 0)
+ {
+ /* Every symbol in a shared object is defined somewhere. */
+ val = 0;
+ }
+ else if (! info->relocateable)
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.string, input_bfd, input_section,
+ rel->r_vaddr - input_section->vma, true)))
+ return false;
+
+ /* Don't try to process the reloc. It can't help, and
+ it may generate another error. */
+ continue;
+ }
}
- }
/* I took the relocation type definitions from two documents:
the PowerPC AIX Version 4 Application Binary Interface, First
32-Bit Hardware Implementation (June 30, 1994). Differences
between the documents are noted below. */
- switch (rel->r_type) {
- case R_RTB:
- case R_RRTBI:
- case R_RRTBA:
- /* These relocs are defined by the PowerPC ABI to be
- relative branches which use half of the difference
- between the symbol and the program counter. I can't
- quite figure out when this is useful. These relocs are
- not defined by the PowerOpen ABI. */
- default:
- (*_bfd_error_handler)
- (_("%s: unsupported relocation type 0x%02x"),
- bfd_get_filename (input_bfd), (unsigned int) rel->r_type);
- bfd_set_error (bfd_error_bad_value);
- return false;
- case R_POS:
- /* Simple positive relocation. */
- break;
- case R_NEG:
- /* Simple negative relocation. */
- val = - val;
- break;
- case R_REL:
- /* Simple PC relative relocation. */
- howto.pc_relative = true;
- break;
- case R_TOC:
- /* TOC relative relocation. The value in the instruction in
- the input file is the offset from the input file TOC to
- the desired location. We want the offset from the final
- TOC to the desired location. We have:
- isym = iTOC + in
- iinsn = in + o
- osym = oTOC + on
- oinsn = on + o
- so we must change insn by on - in.
- */
- case R_GL:
- /* Global linkage relocation. The value of this relocation
- is the address of the entry in the TOC section. */
- case R_TCL:
- /* Local object TOC address. I can't figure out the
- difference between this and case R_GL. */
- case R_TRL:
- /* TOC relative relocation. A TOC relative load instruction
- which may be changed to a load address instruction.
- FIXME: We don't currently implement this optimization. */
- case R_TRLA:
- /* TOC relative relocation. This is a TOC relative load
- address instruction which may be changed to a load
- instruction. FIXME: I don't know if this is the correct
- implementation. */
- if (h != NULL && h->smclas != XMC_TD)
- {
- if (h->toc_section == NULL)
- {
- (*_bfd_error_handler)
- (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
- bfd_get_filename (input_bfd), rel->r_vaddr,
- h->root.root.string);
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
- val = (h->toc_section->output_section->vma
- + h->toc_section->output_offset);
+ switch (rel->r_type)
+ {
+ case R_RTB:
+ case R_RRTBI:
+ case R_RRTBA:
+ /* These relocs are defined by the PowerPC ABI to be
+ relative branches which use half of the difference
+ between the symbol and the program counter. I can't
+ quite figure out when this is useful. These relocs are
+ not defined by the PowerOpen ABI. */
+ default:
+ (*_bfd_error_handler)
+ (_("%s: unsupported relocation type 0x%02x"),
+ bfd_get_filename (input_bfd), (unsigned int) rel->r_type);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ case R_POS:
+ /* Simple positive relocation. */
+ break;
+ case R_NEG:
+ /* Simple negative relocation. */
+ val = - val;
+ break;
+ case R_REL:
+ /* Simple PC relative relocation. */
+ howto.pc_relative = true;
+ break;
+ case R_TOC:
+ /* TOC relative relocation. The value in the instruction in
+ the input file is the offset from the input file TOC to
+ the desired location. We want the offset from the final
+ TOC to the desired location. We have:
+ isym = iTOC + in
+ iinsn = in + o
+ osym = oTOC + on
+ oinsn = on + o
+ so we must change insn by on - in.
+ */
+ case R_GL:
+ /* Global linkage relocation. The value of this relocation
+ is the address of the entry in the TOC section. */
+ case R_TCL:
+ /* Local object TOC address. I can't figure out the
+ difference between this and case R_GL. */
+ case R_TRL:
+ /* TOC relative relocation. A TOC relative load instruction
+ which may be changed to a load address instruction.
+ FIXME: We don't currently implement this optimization. */
+ case R_TRLA:
+ /* TOC relative relocation. This is a TOC relative load
+ address instruction which may be changed to a load
+ instruction. FIXME: I don't know if this is the correct
+ implementation. */
+ if (h != NULL && h->smclas != XMC_TD)
+ {
+ if (h->toc_section == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"),
+ bfd_get_filename (input_bfd), rel->r_vaddr,
+ h->root.root.string);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
- }
+ BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
+ val = (h->toc_section->output_section->vma
+ + h->toc_section->output_offset);
+ }
+ val = ((val - xcoff_data (output_bfd)->toc)
+ - (sym->n_value - xcoff_data (input_bfd)->toc));
- val = ((val - xcoff_data (output_bfd)->toc)
- - (sym->n_value - xcoff_data (input_bfd)->toc));
-
- addend = 0;
- break;
- case R_BA:
- /* Absolute branch. We don't want to mess with the lower
- two bits of the instruction. */
- case R_CAI:
- /* The PowerPC ABI defines this as an absolute call which
- may be modified to become a relative call. The PowerOpen
- ABI does not define this relocation type. */
- case R_RBA:
- /* Absolute branch which may be modified to become a
- relative branch. */
- case R_RBAC:
- /* The PowerPC ABI defines this as an absolute branch to a
- fixed address which may be modified to an absolute branch
- to a symbol. The PowerOpen ABI does not define this
- relocation type. */
- case R_RBRC:
- /* The PowerPC ABI defines this as an absolute branch to a
- fixed address which may be modified to a relative branch.
- The PowerOpen ABI does not define this relocation type. */
- howto.src_mask &= ~3;
- howto.dst_mask = howto.src_mask;
- break;
- case R_BR:
- /* Relative branch. We don't want to mess with the lower
- two bits of the instruction. */
- case R_CREL:
- /* The PowerPC ABI defines this as a relative call which may
- be modified to become an absolute call. The PowerOpen
- ABI does not define this relocation type. */
- case R_RBR:
- /* A relative branch which may be modified to become an
- absolute branch. FIXME: We don't implement this,
- although we should for symbols of storage mapping class
- XMC_XO. */
- howto.pc_relative = true;
- howto.src_mask &= ~3;
- howto.dst_mask = howto.src_mask;
- howto.size = 2;
- howto.complain_on_overflow = complain_overflow_bitfield;
- break;
- case R_RL:
- /* The PowerPC AIX ABI describes this as a load which may be
- changed to a load address. The PowerOpen ABI says this
- is the same as case R_POS. */
- break;
- case R_RLA:
- /* The PowerPC AIX ABI describes this as a load address
- which may be changed to a load. The PowerOpen ABI says
- this is the same as R_POS. */
- break;
- }
+ addend = 0;
+ break;
+ case R_BA:
+ /* Absolute branch. We don't want to mess with the lower
+ two bits of the instruction. */
+ case R_CAI:
+ /* The PowerPC ABI defines this as an absolute call which
+ may be modified to become a relative call. The PowerOpen
+ ABI does not define this relocation type. */
+ case R_RBA:
+ /* Absolute branch which may be modified to become a
+ relative branch. */
+ case R_RBAC:
+ /* The PowerPC ABI defines this as an absolute branch to a
+ fixed address which may be modified to an absolute branch
+ to a symbol. The PowerOpen ABI does not define this
+ relocation type. */
+ case R_RBRC:
+ /* The PowerPC ABI defines this as an absolute branch to a
+ fixed address which may be modified to a relative branch.
+ The PowerOpen ABI does not define this relocation type. */
+ howto.src_mask &= ~3;
+ howto.dst_mask = howto.src_mask;
+ break;
+ case R_BR:
+ /* Relative branch. We don't want to mess with the lower
+ two bits of the instruction. */
+ case R_CREL:
+ /* The PowerPC ABI defines this as a relative call which may
+ be modified to become an absolute call. The PowerOpen
+ ABI does not define this relocation type. */
+ case R_RBR:
+ /* A relative branch which may be modified to become an
+ absolute branch. FIXME: We don't implement this,
+ although we should for symbols of storage mapping class
+ XMC_XO. */
+ howto.pc_relative = true;
+ howto.src_mask &= ~3;
+ howto.dst_mask = howto.src_mask;
+ howto.size = 2;
+ howto.complain_on_overflow = complain_overflow_bitfield;
+ break;
+ case R_RL:
+ /* The PowerPC AIX ABI describes this as a load which may be
+ changed to a load address. The PowerOpen ABI says this
+ is the same as case R_POS. */
+ break;
+ case R_RLA:
+ /* The PowerPC AIX ABI describes this as a load address
+ which may be changed to a load. The PowerOpen ABI says
+ this is the same as R_POS. */
+ break;
+ }
/* If we see an R_BR or R_RBR reloc which is jumping to global
linkage code, and it is followed by an appropriate cror nop
call is followed by a ld r2,40(r1), but the call is not
going to global linkage code, we can replace the load with a
cror. */
- if ((rel->r_type == R_BR || rel->r_type == R_RBR) &&
- h != NULL &&
- h->root.type == bfd_link_hash_defined &&
- (rel->r_vaddr - input_section->vma + 8
- <= input_section->_cooked_size)) {
-
+ if ((rel->r_type == R_BR || rel->r_type == R_RBR)
+ && h != NULL
+ && h->root.type == bfd_link_hash_defined
+ && (rel->r_vaddr - input_section->vma + 8
+ <= input_section->_cooked_size))
+ {
bfd_byte *pnext;
unsigned long next;
/* The _ptrgl function is magic. It is used by the AIX
- * compiler to call a function through a pointer.
- *
+ * compiler to call a function through a pointer.
+ *
* special case XMC_GL, global linkage
*/
if (h->smclas == XMC_GL
|| strcmp (h->root.root.string, "._ptrgl") == 0)
{
- if (next == 0x4def7b82 /* cror 15,15,15 */
- || next == 0x4ffffb82 /* cror 31,31,31 */
- || next == 0x60000000) /* ori r0,r0,0 */
- bfd_put_32 (input_bfd, 0xe8410028, pnext); /* ld r2,40(r1) */
+ if (next == 0x4def7b82 /* cror 15,15,15 */
+ || next == 0x4ffffb82 /* cror 31,31,31 */
+ || next == 0x60000000 /* ori r0,r0,0 */)
+ bfd_put_32 (input_bfd, (bfd_vma) 0xe8410028 /* ld r2,40(r1) */,
+ pnext);
}
else
{
- if (next == 0xe8410028) /* ld r2,40(r1) */
- bfd_put_32 (input_bfd, 0x60000000, pnext); /* ori r0,r0,0 */
+ if (next == 0xe8410028 /* ld r2,40(r1) */)
+ bfd_put_32 (input_bfd, (bfd_vma) 0x60000000 /* ori r0,r0,0 */,
+ pnext);
}
}
reloc_howto_type xcoff64_howto_table[] =
{
/* Standard 64 bit relocation. */
- HOWTO (0, /* type */
- 0, /* rightshift */
- 4, /* size (0 = byte, 1 = short, 2 = long) */
- 64, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (0, /* type */
+ 0, /* rightshift */
+ 4, /* size (0 = byte, 1 = short, 2 = long) */
+ 64, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_POS", /* name */
- true, /* partial_inplace */
- MINUS_ONE, /* src_mask */
- MINUS_ONE, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_POS", /* name */
+ true, /* partial_inplace */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ false), /* pcrel_offset */
/* 64 bit relocation, but store negative value. */
- HOWTO (1, /* type */
- 0, /* rightshift */
- -4, /* size (0 = byte, 1 = short, 2 = long) */
- 64, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (1, /* type */
+ 0, /* rightshift */
+ -4, /* size (0 = byte, 1 = short, 2 = long) */
+ 64, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_NEG", /* name */
- true, /* partial_inplace */
- MINUS_ONE, /* src_mask */
- MINUS_ONE, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_NEG", /* name */
+ true, /* partial_inplace */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ false), /* pcrel_offset */
/* 32 bit PC relative relocation. */
- HOWTO (2, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (2, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "R_REL", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_REL", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
/* 16 bit TOC relative relocation. */
- HOWTO (3, /* type */
- 0, /* rightshift */
- 1, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (3, /* type */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_TOC", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* I don't really know what this is. */
- HOWTO (4, /* type */
- 1, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ 0, /* special_function */
+ "R_TOC", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* I don't really know what this is. */
+ HOWTO (4, /* type */
+ 1, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RTB", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_RTB", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
/* External TOC relative symbol. */
- HOWTO (5, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (5, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_GL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Local TOC relative symbol. */
- HOWTO (6, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ 0, /* special_function */
+ "R_GL", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Local TOC relative symbol. */
+ HOWTO (6, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_TCL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_TCL", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
EMPTY_HOWTO (7),
/* Non modifiable absolute branch. */
- HOWTO (8, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (8, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_BA", /* name */
- true, /* partial_inplace */
- 0x3fffffc, /* src_mask */
- 0x3fffffc, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_BA", /* name */
+ true, /* partial_inplace */
+ 0x3fffffc, /* src_mask */
+ 0x3fffffc, /* dst_mask */
+ false), /* pcrel_offset */
EMPTY_HOWTO (9),
/* Non modifiable relative branch. */
- HOWTO (0xa, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- true, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (0xa, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ true, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "R_BR", /* name */
- true, /* partial_inplace */
- 0x3fffffc, /* src_mask */
- 0x3fffffc, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_BR", /* name */
+ true, /* partial_inplace */
+ 0x3fffffc, /* src_mask */
+ 0x3fffffc, /* dst_mask */
+ false), /* pcrel_offset */
EMPTY_HOWTO (0xb),
/* Indirect load. */
- HOWTO (0xc, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (0xc, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_RL", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
/* Load address. */
- HOWTO (0xd, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (0xd, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RLA", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_RLA", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
EMPTY_HOWTO (0xe),
- /* Non-relocating reference. */
- HOWTO (0xf, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ /* Non-relocating reference. */
+ HOWTO (0xf, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_REF", /* name */
- false, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_REF", /* name */
+ false, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ false), /* pcrel_offset */
EMPTY_HOWTO (0x10),
EMPTY_HOWTO (0x11),
/* TOC relative indirect load. */
- HOWTO (0x12, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (0x12, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_TRL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* TOC relative load address. */
- HOWTO (0x13, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ 0, /* special_function */
+ "R_TRL", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* TOC relative load address. */
+ HOWTO (0x13, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_TRLA", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_TRLA", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
/* Modifiable relative branch. */
- HOWTO (0x14, /* type */
- 1, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (0x14, /* type */
+ 1, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RRTBI", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_RRTBI", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
/* Modifiable absolute branch. */
- HOWTO (0x15, /* type */
- 1, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (0x15, /* type */
+ 1, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RRTBA", /* name */
- true, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable call absolute indirect. */
- HOWTO (0x16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ 0, /* special_function */
+ "R_RRTBA", /* name */
+ true, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Modifiable call absolute indirect. */
+ HOWTO (0x16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_CAI", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- /* Modifiable call relative. */
- HOWTO (0x17, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ 0, /* special_function */
+ "R_CAI", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ /* Modifiable call relative. */
+ HOWTO (0x17, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_CREL", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_CREL", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
/* Modifiable branch absolute. */
- HOWTO (0x18, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (0x18, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RBA", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_RBA", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
/* Modifiable branch absolute. */
- HOWTO (0x19, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (0x19, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RBAC", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_RBAC", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
/* Modifiable branch relative. */
- HOWTO (0x1a, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (0x1a, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_signed, /* complain_on_overflow */
- 0, /* special_function */
- "R_RBR", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
+ 0, /* special_function */
+ "R_RBR", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
/* Modifiable branch absolute. */
- HOWTO (0x1b, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
+ HOWTO (0x1b, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_RBRC", /* name */
- true, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- false), /* pcrel_offset */
-
- HOWTO (0, /* type */
- 0, /* rightshift */
- 4, /* size (0 = byte, 1 = short, 2 = long) */
- 64, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_POS", /* name */
- true, /* partial_inplace */
- MINUS_ONE, /* src_mask */
- MINUS_ONE, /* dst_mask */
- false) /* pcrel_offset */
-
+ 0, /* special_function */
+ "R_RBRC", /* name */
+ true, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ false), /* pcrel_offset */
+
+ HOWTO (0, /* type */
+ 0, /* rightshift */
+ 4, /* size (0 = byte, 1 = short, 2 = long) */
+ 64, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ 0, /* special_function */
+ "R_POS", /* name */
+ true, /* partial_inplace */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ false) /* pcrel_offset */
};
void
type matches this information. The bitsize is not significant
for R_REF relocs. */
if (relent->howto->dst_mask != 0
- && (relent->howto->bitsize
+ && (relent->howto->bitsize
!= ((unsigned int) internal->r_size & 0x3f) + 1))
abort ();
#if 0
{
file_ptr off;
size_t namlen;
- bfd_size_type sz;
+ bfd_size_type sz, amt;
bfd_byte *contents, *cend;
bfd_vma c, i;
carsym *arsym;
bfd_byte *p;
+ file_ptr pos;
/* This is for the new format. */
struct xcoff_ar_hdr_big hdr;
- if (xcoff_ardata (abfd) == NULL) {
- bfd_has_map (abfd) = false;
- return true;
- }
+ if (xcoff_ardata (abfd) == NULL)
+ {
+ bfd_has_map (abfd) = false;
+ return true;
+ }
off = strtol (xcoff_ardata_big (abfd)->symoff64, (char **) NULL, 10);
- if (off == 0) {
- bfd_has_map (abfd) = false;
- return true;
- }
+ if (off == 0)
+ {
+ bfd_has_map (abfd) = false;
+ return true;
+ }
if (bfd_seek (abfd, off, SEEK_SET) != 0)
return false;
/* The symbol table starts with a normal archive header. */
- if (bfd_read ((PTR) &hdr, SIZEOF_AR_HDR_BIG, 1, abfd) != SIZEOF_AR_HDR_BIG)
+ if (bfd_bread ((PTR) &hdr, (bfd_size_type) SIZEOF_AR_HDR_BIG, abfd)
+ != SIZEOF_AR_HDR_BIG)
return false;
/* Skip the name (normally empty). */
namlen = strtol (hdr.namlen, (char **) NULL, 10);
- if (bfd_seek (abfd, ((namlen + 1) & ~1) + SXCOFFARFMAG, SEEK_CUR) != 0)
+ pos = ((namlen + 1) & ~(size_t) 1) + SXCOFFARFMAG;
+ if (bfd_seek (abfd, pos, SEEK_CUR) != 0)
return false;
/* XXX This actually has to be a call to strtoll (at least on 32-bit
contents = (bfd_byte *) bfd_alloc (abfd, sz);
if (contents == NULL)
return false;
- if (bfd_read ((PTR) contents, 1, sz, abfd) != sz)
+ if (bfd_bread ((PTR) contents, sz, abfd) != sz)
return false;
/* The symbol table starts with an eight byte count. */
- c = bfd_h_get_64 (abfd, contents);
+ c = H_GET_64 (abfd, contents);
- if (c * 8 >= sz) {
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
-
- bfd_ardata (abfd)->symdefs = ((carsym *)
- bfd_alloc (abfd, c * sizeof (carsym)));
+ if (c * 8 >= sz)
+ {
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ amt = c;
+ amt *= sizeof (carsym);
+ bfd_ardata (abfd)->symdefs = (carsym *) bfd_alloc (abfd, amt);
if (bfd_ardata (abfd)->symdefs == NULL)
return false;
-
+
/* After the count comes a list of eight byte file offsets. */
for (i = 0, arsym = bfd_ardata (abfd)->symdefs, p = contents + 8;
i < c;
++i, ++arsym, p += 8)
- arsym->file_offset = bfd_h_get_64 (abfd, p);
+ arsym->file_offset = H_GET_64 (abfd, p);
/* After the file offsets come null terminated symbol names. */
cend = contents + sz;
}
-
/* See if this is an NEW XCOFF archive. */
static const bfd_target *
char magic[SXCOFFARMAG];
/* This is the new format. */
struct xcoff_ar_file_hdr_big hdr;
-
- if (bfd_read ((PTR) magic, SXCOFFARMAG, 1, abfd) != SXCOFFARMAG) {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
+ bfd_size_type amt = SXCOFFARMAG;
- if (strncmp (magic, XCOFFARMAGBIG, SXCOFFARMAG) != 0) {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
+ if (bfd_bread ((PTR) magic, amt, abfd) != amt)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
+
+ if (strncmp (magic, XCOFFARMAGBIG, SXCOFFARMAG) != 0)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
/* We are setting bfd_ardata(abfd) here, but since bfd_ardata
involves a cast, we can't do it as the left operand of
assignment. */
- abfd->tdata.aout_ar_data =
- (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
+ amt = sizeof (struct artdata);
+ abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt);
if (bfd_ardata (abfd) == (struct artdata *) NULL)
return NULL;
memcpy (hdr.magic, magic, SXCOFFARMAG);
/* Now read the rest of the file header. */
- if (bfd_read ((PTR) &hdr.memoff, SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG, 1,
- abfd) != SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG) {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
+ if (bfd_bread ((PTR) &hdr.memoff,
+ (bfd_size_type) (SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG),
+ abfd) != SIZEOF_AR_FILE_HDR_BIG - SXCOFFARMAG)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return NULL;
+ }
/* XXX This actually has to be a call to strtoll (at least on 32-bit
machines) since the field width is 20 and there numbers with more
bfd_ardata (abfd)->first_file_filepos = strtol (hdr.firstmemoff,
(char **) NULL, 10);
- bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, SIZEOF_AR_FILE_HDR_BIG);
+ amt = SIZEOF_AR_FILE_HDR_BIG;
+ bfd_ardata (abfd)->tdata = bfd_zalloc (abfd, amt);
if (bfd_ardata (abfd)->tdata == NULL)
return NULL;
-
+
memcpy (bfd_ardata (abfd)->tdata, &hdr, SIZEOF_AR_FILE_HDR_BIG);
- if (! xcoff64_slurp_armap (abfd)) {
-
- bfd_release (abfd, bfd_ardata (abfd));
- abfd->tdata.aout_ar_data = (struct artdata *) NULL;
- return NULL;
- }
+ if (! xcoff64_slurp_armap (abfd))
+ {
+ bfd_release (abfd, bfd_ardata (abfd));
+ abfd->tdata.aout_ar_data = (struct artdata *) NULL;
+ return NULL;
+ }
return abfd->xvec;
}
{
file_ptr filestart;
- if ((xcoff_ardata (archive) == NULL) ||
- (! xcoff_big_format_p (archive))) {
- bfd_set_error (bfd_error_invalid_operation);
- return NULL;
- }
+ if ((xcoff_ardata (archive) == NULL)
+ || ! xcoff_big_format_p (archive))
+ {
+ bfd_set_error (bfd_error_invalid_operation);
+ return NULL;
+ }
- if (last_file == NULL) {
+ if (last_file == NULL)
+ {
filestart = bfd_ardata (archive)->first_file_filepos;
- } else {
- /* XXX These actually have to be a calls to strtoll (at least
- on 32-bit machines) since the fields's width is 20 and
- there numbers with more than 32 bits can be represented. */
- filestart = strtol (arch_xhdr_big (last_file)->nextoff, (char **) NULL,
- 10);
- }
+ }
+ else
+ {
+ /* XXX These actually have to be a calls to strtoll (at least
+ on 32-bit machines) since the fields's width is 20 and
+ there numbers with more than 32 bits can be represented. */
+ filestart = strtol (arch_xhdr_big (last_file)->nextoff, (char **) NULL,
+ 10);
+ }
/* XXX These actually have to be calls to strtoll (at least on 32-bit
machines) since the fields's width is 20 and there numbers with more
than 32 bits can be represented. */
|| filestart == strtol (xcoff_ardata_big (archive)->memoff,
(char **) NULL, 10)
|| filestart == strtol (xcoff_ardata_big (archive)->symoff,
- (char **) NULL, 10)) {
- bfd_set_error (bfd_error_no_more_archived_files);
- return NULL;
- }
+ (char **) NULL, 10))
+ {
+ bfd_set_error (bfd_error_no_more_archived_files);
+ return NULL;
+ }
return _bfd_get_elt_at_filepos (archive, filestart);
}
{
int size;
- size = bfd_coff_filhsz(abfd);
+ size = bfd_coff_filhsz (abfd);
- /*
- * Don't think the small aout header can be used since some of the the
- * old elements have been reordered past the end of the old coff
- * small aout size
- */
+ /* Don't think the small aout header can be used since some of the the
+ old elements have been reordered past the end of the old coff
+ small aout size. */
if (xcoff_data (abfd)->full_aouthdr)
- size += bfd_coff_aoutsz(abfd);
+ size += bfd_coff_aoutsz (abfd);
- size += abfd->section_count * bfd_coff_scnhsz(abfd);
+ size += abfd->section_count * bfd_coff_scnhsz (abfd);
return size;
}
static asection *
-xcoff64_create_csect_from_smclas (abfd, aux, symbol_name)
+xcoff64_create_csect_from_smclas (abfd, aux, symbol_name)
bfd *abfd;
union internal_auxent *aux;
const char *symbol_name;
{
asection *return_value = NULL;
- /*
- * Changes from 32 :
- * .sv == 8, is only for 32 bit programs
- * .ti == 12 and .tb == 13 are now reserved
- */
- static const char *names[19] = {
+ /* Changes from 32 :
+ .sv == 8, is only for 32 bit programs
+ .ti == 12 and .tb == 13 are now reserved. */
+ static const char *names[19] =
+ {
".pr", ".ro", ".db", ".tc", ".ua", ".rw", ".gl", ".xo",
NULL, ".bs", ".ds", ".uc", NULL, NULL, NULL, ".tc0",
- ".td", ".sv64", ".sv3264"
+ ".td", ".sv64", ".sv3264"
};
- if ((19 >= aux->x_csect.x_smclas) &&
- (NULL != names[aux->x_csect.x_smclas])) {
+ if ((19 >= aux->x_csect.x_smclas)
+ && (NULL != names[aux->x_csect.x_smclas]))
+ {
- return_value = bfd_make_section_anyway
- (abfd, names[aux->x_csect.x_smclas]);
+ return_value = bfd_make_section_anyway
+ (abfd, names[aux->x_csect.x_smclas]);
- } else {
- (*_bfd_error_handler)
- (_("%s: symbol `%s' has unrecognized smclas %d"),
- bfd_get_filename (abfd), symbol_name, aux->x_csect.x_smclas);
- bfd_set_error (bfd_error_bad_value);
- }
+ }
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: symbol `%s' has unrecognized smclas %d"),
+ bfd_get_filename (abfd), symbol_name, aux->x_csect.x_smclas);
+ bfd_set_error (bfd_error_bad_value);
+ }
return return_value;
}
-static boolean
+static boolean
xcoff64_is_lineno_count_overflow (abfd, value)
- bfd *abfd ATTRIBUTE_UNUSED;
- bfd_vma value ATTRIBUTE_UNUSED;
+ bfd *abfd ATTRIBUTE_UNUSED;
+ bfd_vma value ATTRIBUTE_UNUSED;
{
return false;
}
-static boolean
+static boolean
xcoff64_is_reloc_count_overflow (abfd, value)
- bfd *abfd ATTRIBUTE_UNUSED;
- bfd_vma value ATTRIBUTE_UNUSED;
+ bfd *abfd ATTRIBUTE_UNUSED;
+ bfd_vma value ATTRIBUTE_UNUSED;
{
return false;
}
static bfd_vma
xcoff64_loader_symbol_offset (abfd, ldhdr)
- bfd *abfd ATTRIBUTE_UNUSED;
- struct internal_ldhdr *ldhdr;
+ bfd *abfd ATTRIBUTE_UNUSED;
+ struct internal_ldhdr *ldhdr;
{
return (ldhdr->l_symoff);
}
static bfd_vma
xcoff64_loader_reloc_offset (abfd, ldhdr)
- bfd *abfd ATTRIBUTE_UNUSED;
- struct internal_ldhdr *ldhdr;
+ bfd *abfd ATTRIBUTE_UNUSED;
+ struct internal_ldhdr *ldhdr;
{
return (ldhdr->l_rldoff);
}
/* The typical dynamic reloc. */
static reloc_howto_type xcoff64_dynamic_reloc =
- HOWTO (0, /* type */
- 0, /* rightshift */
- 4, /* size (0 = byte, 1 = short, 2 = long) */
- 64, /* bitsize */
- false, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield, /* complain_on_overflow */
- 0, /* special_function */
- "R_POS", /* name */
- true, /* partial_inplace */
- MINUS_ONE, /* src_mask */
- MINUS_ONE, /* dst_mask */
- false); /* pcrel_offset */
+HOWTO (0, /* type */
+ 0, /* rightshift */
+ 4, /* size (0 = byte, 1 = short, 2 = long) */
+ 64, /* bitsize */
+ false, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ 0, /* special_function */
+ "R_POS", /* name */
+ true, /* partial_inplace */
+ MINUS_ONE, /* src_mask */
+ MINUS_ONE, /* dst_mask */
+ false); /* pcrel_offset */
static unsigned long xcoff64_glink_code[10] =
{
0x00000018, /* ??? */
};
-static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
+static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
{
{ /* COFF backend, defined in libcoff.h */
_bfd_xcoff64_swap_aux_in, /* _bfd_coff_swap_aux_in */
- _bfd_xcoff64_swap_sym_in, /* _bfd_coff_swap_sym_in */
+ _bfd_xcoff64_swap_sym_in, /* _bfd_coff_swap_sym_in */
_bfd_xcoff64_swap_lineno_in, /* _bfd_coff_swap_lineno_in */
_bfd_xcoff64_swap_aux_out, /* _bfd_swap_aux_out */
_bfd_xcoff64_swap_sym_out, /* _bfd_swap_sym_out */
dummy_reloc16_extra_cases, /* _bfd_coff_reloc16_extra_cases */
dummy_reloc16_estimate, /* _bfd_coff_reloc16_estimate */
NULL, /* bfd_coff_sym_is_global */
- /* _bfd_coff_compute_section_file_positions */
+ /* _bfd_coff_compute_section_file_positions */
coff_compute_section_file_positions,
NULL , /* _bfd_coff_start_final_link */
xcoff64_ppc_relocate_section, /* _bfd_coff_relocate_section */
/* dynamic reloc howto */
&xcoff64_dynamic_reloc,
- xcoff64_create_csect_from_smclas,
+ xcoff64_create_csect_from_smclas,
/* lineno and reloc count overflow */
xcoff64_is_lineno_count_overflow,
xcoff64_is_reloc_count_overflow,
-
+
xcoff64_loader_symbol_offset,
xcoff64_loader_reloc_offset,
'/', /* ar_pad_char */
15, /* ar_max_namelen??? FIXMEmgo */
- /* data */
+ /* data */
bfd_getb64, /* bfd_getx64 */
bfd_getb_signed_64, /* bfd_getx_signed_64 */
bfd_putb64, /* bfd_putx64 */
bfd_putb32, /* bfd_putx32 */
bfd_getb16, /* bfd_getx16 */
bfd_getb_signed_16, /* bfd_getx_signed_16 */
- bfd_putb16, /* bfd_putx16 */
+ bfd_putb16, /* bfd_putx16 */
- /* hdrs */
+ /* hdrs */
bfd_getb64, /* bfd_h_getx64 */
bfd_getb_signed_64, /* bfd_h_getx_signed_64 */
bfd_putb64, /* bfd_h_putx64 */
bfd_getb16, /* bfd_h_getx16 */
bfd_getb_signed_16, /* bfd_h_getx_signed_16 */
bfd_putb16, /* bfd_h_putx16 */
-
+
{ /* bfd_check_format */
- _bfd_dummy_target,
- coff_object_p,
- xcoff64_archive_p,
- CORE_FILE_P
+ _bfd_dummy_target,
+ coff_object_p,
+ xcoff64_archive_p,
+ CORE_FILE_P
},
-
+
{ /* bfd_set_format */
- bfd_false,
+ bfd_false,
coff_mkobject,
- _bfd_generic_mkarchive,
+ _bfd_generic_mkarchive,
bfd_false
},
-
+
{/* bfd_write_contents */
- bfd_false,
+ bfd_false,
xcoff64_write_object_contents,
- _bfd_xcoff_write_archive_contents,
+ _bfd_xcoff_write_archive_contents,
bfd_false
},
-
+
/* Generic */
bfd_true, /* _close_and_cleanup */
bfd_true, /* _bfd_free_cached_info */
coff_new_section_hook, /* _new_section_hook */
_bfd_generic_get_section_contents, /* _bfd_get_section_contents */
- /* _bfd_get_section_contents_in_window */
- _bfd_generic_get_section_contents_in_window,
+ /* _bfd_get_section_contents_in_window */
+ _bfd_generic_get_section_contents_in_window,
/* Copy */
_bfd_xcoff_copy_private_bfd_data, /* _bfd_copy_private_bfd */
- /* _bfd_merge_private_bfd_data */
+ /* _bfd_merge_private_bfd_data */
((boolean (*) (bfd *, bfd *)) bfd_true),
- /* _bfd_copy_pivate_section_data */
+ /* _bfd_copy_pivate_section_data */
((boolean (*) (bfd *, asection *, bfd *, asection *)) bfd_true),
- /* _bfd_copy_private_symbol_data */
+ /* _bfd_copy_private_symbol_data */
((boolean (*) (bfd *, asymbol *, bfd *, asymbol *)) bfd_true),
((boolean (*) (bfd *, flagword)) bfd_true), /* _bfd_set_private_flags */
((boolean (*) (bfd *, void * )) bfd_true), /* _bfd_print_private_bfd_data */
/* Core */
coff_core_file_failing_command, /* _core_file_failing_command */
coff_core_file_failing_signal, /* _core_file_failing_signal */
- /* _core_file_matches_executable_p */
- coff_core_file_matches_executable_p,
+ /* _core_file_matches_executable_p */
+ coff_core_file_matches_executable_p,
/* Archive */
xcoff64_slurp_armap, /* _slurp_armap */
- /* XCOFF archives do not have
- anything which corresponds to
- an extended name table. */
+ /* XCOFF archives do not have
+ anything which corresponds to
+ an extended name table. */
bfd_false, /* _slurp_extended_name_table */
- /* _construct_extended_name_table */
+ /* _construct_extended_name_table */
((boolean (*) (bfd *, char **, bfd_size_type *, const char **)) bfd_false),
bfd_dont_truncate_arname, /* _truncate_arname */
_bfd_xcoff_write_armap, /* _write_armap */
xcoff64_openr_next_archived_file, /* _openr_next_archived_file */
_bfd_generic_get_elt_at_index, /* _get_elt_at_index */
_bfd_xcoff_generic_stat_arch_elt, /* _generic_dtat_arch_elt */
- /* XCOFF archives do not have
- a timestamp. */
+ /* XCOFF archives do not have
+ a timestamp. */
bfd_true, /* _update_armap_timestamp */
/* Symbols */
/* Link */
xcoff64_sizeof_headers, /* _sizeof_headers */
- /* _bfd_get_relocated_section_contents */
+ /* _bfd_get_relocated_section_contents */
bfd_generic_get_relocated_section_contents,
bfd_generic_relax_section, /* _bfd_relax_section */
_bfd_xcoff_bfd_link_hash_table_create, /* _bfd_link_hash_table_create */
bfd_generic_merge_sections, /* _bfd_merge_sections */
/* Dynamic */
- /* _get_dynamic_symtab_upper_bound */
- _bfd_xcoff_get_dynamic_symtab_upper_bound,
+ /* _get_dynamic_symtab_upper_bound */
+ _bfd_xcoff_get_dynamic_symtab_upper_bound,
_bfd_xcoff_canonicalize_dynamic_symtab, /* _cononicalize_dynamic_symtab */
_bfd_xcoff_get_dynamic_reloc_upper_bound,/* _get_dynamic_reloc_upper_bound */
_bfd_xcoff_canonicalize_dynamic_reloc, /* _cononicalize_dynamic_reloc */
/* Opposite endian version, none exists */
NULL,
-
+
/* back end data */
(void *) &bfd_xcoff_backend_data,
};
.
.typedef struct coff_ptr_struct
.{
+. {* Remembers the offset from the first symbol in the file for
+. this symbol. Generated by coff_renumber_symbols. *}
+. unsigned int offset;
.
-. {* Remembers the offset from the first symbol in the file for
-. this symbol. Generated by coff_renumber_symbols. *}
-.unsigned int offset;
+. {* Should the value of this symbol be renumbered. Used for
+. XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. *}
+. unsigned int fix_value : 1;
.
-. {* Should the value of this symbol be renumbered. Used for
-. XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. *}
-.unsigned int fix_value : 1;
+. {* Should the tag field of this symbol be renumbered.
+. Created by coff_pointerize_aux. *}
+. unsigned int fix_tag : 1;
.
-. {* Should the tag field of this symbol be renumbered.
-. Created by coff_pointerize_aux. *}
-.unsigned int fix_tag : 1;
+. {* Should the endidx field of this symbol be renumbered.
+. Created by coff_pointerize_aux. *}
+. unsigned int fix_end : 1;
.
-. {* Should the endidx field of this symbol be renumbered.
-. Created by coff_pointerize_aux. *}
-.unsigned int fix_end : 1;
+. {* Should the x_csect.x_scnlen field be renumbered.
+. Created by coff_pointerize_aux. *}
+. unsigned int fix_scnlen : 1;
.
-. {* Should the x_csect.x_scnlen field be renumbered.
-. Created by coff_pointerize_aux. *}
-.unsigned int fix_scnlen : 1;
+. {* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the
+. index into the line number entries. Set by coff_slurp_symbol_table. *}
+. unsigned int fix_line : 1;
.
-. {* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the
-. index into the line number entries. Set by
-. coff_slurp_symbol_table. *}
-.unsigned int fix_line : 1;
-.
-. {* The container for the symbol structure as read and translated
-. from the file. *}
-.
-.union {
-. union internal_auxent auxent;
-. struct internal_syment syment;
-. } u;
+. {* The container for the symbol structure as read and translated
+. from the file. *}
+. union
+. {
+. union internal_auxent auxent;
+. struct internal_syment syment;
+. } u;
.} combined_entry_type;
.
.
.
.typedef struct coff_symbol_struct
.{
-. {* The actual symbol which the rest of BFD works with *}
-.asymbol symbol;
+. {* The actual symbol which the rest of BFD works with *}
+. asymbol symbol;
.
-. {* A pointer to the hidden information for this symbol *}
-.combined_entry_type *native;
+. {* A pointer to the hidden information for this symbol *}
+. combined_entry_type *native;
.
-. {* A pointer to the linenumber information for this symbol *}
-.struct lineno_cache_entry *lineno;
+. {* A pointer to the linenumber information for this symbol *}
+. struct lineno_cache_entry *lineno;
.
-. {* Have the line numbers been relocated yet ? *}
-.boolean done_lineno;
+. {* Have the line numbers been relocated yet ? *}
+. boolean done_lineno;
.} coff_symbol_type;
*/
static boolean coff_set_flags
PARAMS ((bfd *, unsigned int *, unsigned short *));
static boolean coff_set_arch_mach
- PARAMS ((bfd *, enum bfd_architecture, unsigned long));
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long)) ATTRIBUTE_UNUSED;
static boolean coff_compute_section_file_positions PARAMS ((bfd *));
static boolean coff_write_object_contents PARAMS ((bfd *)) ATTRIBUTE_UNUSED;
static boolean coff_set_section_contents
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
-static PTR buy_and_read PARAMS ((bfd *, file_ptr, int, size_t));
+static PTR buy_and_read PARAMS ((bfd *, file_ptr, bfd_size_type));
static boolean coff_slurp_line_table PARAMS ((bfd *, asection *));
static boolean coff_slurp_symbol_table PARAMS ((bfd *));
static enum coff_symbol_classification coff_classify_symbol
static long
sec_to_styp_flags (sec_name, sec_flags)
- CONST char *sec_name;
+ const char *sec_name;
flagword sec_flags;
{
long styp_flags = 0;
if ((sec_flags & SEC_ALLOC) != 0 && (sec_flags & SEC_LOAD) == 0)
styp_flags |= IMAGE_SCN_CNT_UNINITIALIZED_DATA; /* ==STYP_BSS */
/* skip ROM */
- /* skip CONSTRUCTOR */
+ /* skip constRUCTOR */
/* skip CONTENTS */
#ifdef STYP_NOLOAD
if ((sec_flags & (SEC_NEVER_LOAD | SEC_COFF_SHARED_LIBRARY)) != 0)
if (! _bfd_coff_get_external_symbols (abfd))
return sec_flags;
-
+
esymstart = esym = (bfd_byte *) obj_coff_external_syms (abfd);
esymend = esym + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
drop through from the above). */
{
char *newname;
+ bfd_size_type amt;
/* This must the the second symbol with the
section #. It is the actual symbol name.
Intel puts the two adjacent, but Alpha (at
least) spreads them out. */
- section->comdat =
- bfd_alloc (abfd, sizeof (struct bfd_comdat_info));
+ amt = sizeof (struct bfd_comdat_info);
+ section->comdat = bfd_alloc (abfd, amt);
if (section->comdat == NULL)
abort ();
section->comdat->symbol =
(esym - esymstart) / bfd_coff_symesz (abfd);
- newname = bfd_alloc (abfd, strlen (symname) + 1);
+ amt = strlen (symname) + 1;
+ newname = bfd_alloc (abfd, amt);
if (newname == NULL)
abort ();
{
long flag = styp_flags & - styp_flags;
char * unhandled = NULL;
-
+
styp_flags &= ~ flag;
/* We infer from the distinct read/write/execute bits the settings
case STYP_NOLOAD:
sec_flags |= SEC_NEVER_LOAD;
break;
-#endif
+#endif
case IMAGE_SCN_MEM_READ:
/* Ignored, assume it always to be true. */
break;
break;
default:
/* Silently ignore for now. */
- break;
+ break;
}
/* If the section flag was not handled, report it here. */
if (flags_ptr)
* flags_ptr = sec_flags;
-
+
return result;
}
Special entry points for gdb to swap in coff symbol table parts:
.typedef struct
.{
-. void (*_bfd_coff_swap_aux_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. int type,
-. int class,
-. int indaux,
-. int numaux,
-. PTR in));
+. void (*_bfd_coff_swap_aux_in)
+. PARAMS ((bfd *, PTR, int, int, int, int, PTR));
.
-. void (*_bfd_coff_swap_sym_in) PARAMS ((
-. bfd *abfd ,
-. PTR ext,
-. PTR in));
+. void (*_bfd_coff_swap_sym_in)
+. PARAMS ((bfd *, PTR, PTR));
.
-. void (*_bfd_coff_swap_lineno_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
+. void (*_bfd_coff_swap_lineno_in)
+. PARAMS ((bfd *, PTR, PTR));
.
-
-Special entry points for gas to swap out coff parts:
-
-. unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. int type,
-. int class,
-. int indaux,
-. int numaux,
-. PTR ext));
+. unsigned int (*_bfd_coff_swap_aux_out)
+. PARAMS ((bfd *, PTR, int, int, int, int, PTR));
.
-. unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR ext));
+. unsigned int (*_bfd_coff_swap_sym_out)
+. PARAMS ((bfd *, PTR, PTR));
.
-. unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR ext));
+. unsigned int (*_bfd_coff_swap_lineno_out)
+. PARAMS ((bfd *, PTR, PTR));
.
-. unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
-. bfd *abfd,
-. PTR src,
-. PTR dst));
+. unsigned int (*_bfd_coff_swap_reloc_out)
+. PARAMS ((bfd *, PTR, PTR));
.
-. unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR out));
+. unsigned int (*_bfd_coff_swap_filehdr_out)
+. PARAMS ((bfd *, PTR, PTR));
.
-. unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR out));
+. unsigned int (*_bfd_coff_swap_aouthdr_out)
+. PARAMS ((bfd *, PTR, PTR));
.
-. unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
-. bfd *abfd,
-. PTR in,
-. PTR out));
+. unsigned int (*_bfd_coff_swap_scnhdr_out)
+. PARAMS ((bfd *, PTR, PTR));
.
-
-Special entry points for generic COFF routines to call target
-dependent COFF routines:
-
-. unsigned int _bfd_filhsz;
-. unsigned int _bfd_aoutsz;
-. unsigned int _bfd_scnhsz;
-. unsigned int _bfd_symesz;
-. unsigned int _bfd_auxesz;
-. unsigned int _bfd_relsz;
-. unsigned int _bfd_linesz;
-. unsigned int _bfd_filnmlen;
-. boolean _bfd_coff_long_filenames;
-. boolean _bfd_coff_long_section_names;
-. unsigned int _bfd_coff_default_section_alignment_power;
-. boolean _bfd_coff_force_symnames_in_strings;
-. unsigned int _bfd_coff_debug_string_prefix_length;
-. void (*_bfd_coff_swap_filehdr_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-. void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-. void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-. void (*_bfd_coff_swap_reloc_in) PARAMS ((
-. bfd *abfd,
-. PTR ext,
-. PTR in));
-. boolean (*_bfd_coff_bad_format_hook) PARAMS ((
-. bfd *abfd,
-. PTR internal_filehdr));
-. boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
-. bfd *abfd,
-. PTR internal_filehdr));
-. PTR (*_bfd_coff_mkobject_hook) PARAMS ((
-. bfd *abfd,
-. PTR internal_filehdr,
-. PTR internal_aouthdr));
-. boolean (*_bfd_styp_to_sec_flags_hook) PARAMS ((
-. bfd *abfd,
-. PTR internal_scnhdr,
-. const char *name,
-. asection *section,
-. flagword *flags_ptr));
-. void (*_bfd_set_alignment_hook) PARAMS ((
-. bfd *abfd,
-. asection *sec,
-. PTR internal_scnhdr));
-. boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
-. bfd *abfd));
-. boolean (*_bfd_coff_symname_in_debug) PARAMS ((
-. bfd *abfd,
-. struct internal_syment *sym));
-. boolean (*_bfd_coff_pointerize_aux_hook) PARAMS ((
-. bfd *abfd,
-. combined_entry_type *table_base,
-. combined_entry_type *symbol,
-. unsigned int indaux,
-. combined_entry_type *aux));
-. boolean (*_bfd_coff_print_aux) PARAMS ((
-. bfd *abfd,
-. FILE *file,
-. combined_entry_type *table_base,
-. combined_entry_type *symbol,
-. combined_entry_type *aux,
-. unsigned int indaux));
-. void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
-. bfd *abfd,
-. struct bfd_link_info *link_info,
-. struct bfd_link_order *link_order,
-. arelent *reloc,
-. bfd_byte *data,
-. unsigned int *src_ptr,
-. unsigned int *dst_ptr));
-. int (*_bfd_coff_reloc16_estimate) PARAMS ((
-. bfd *abfd,
-. asection *input_section,
-. arelent *r,
-. unsigned int shrink,
-. struct bfd_link_info *link_info));
-. enum coff_symbol_classification (*_bfd_coff_classify_symbol) PARAMS ((
-. bfd *abfd,
-. struct internal_syment *));
-. boolean (*_bfd_coff_compute_section_file_positions) PARAMS ((
-. bfd *abfd));
-. boolean (*_bfd_coff_start_final_link) PARAMS ((
-. bfd *output_bfd,
-. struct bfd_link_info *info));
-. boolean (*_bfd_coff_relocate_section) PARAMS ((
-. bfd *output_bfd,
-. struct bfd_link_info *info,
-. bfd *input_bfd,
-. asection *input_section,
-. bfd_byte *contents,
-. struct internal_reloc *relocs,
-. struct internal_syment *syms,
-. asection **sections));
-. reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS ((
-. bfd *abfd,
-. asection *sec,
-. struct internal_reloc *rel,
-. struct coff_link_hash_entry *h,
-. struct internal_syment *sym,
-. bfd_vma *addendp));
-. boolean (*_bfd_coff_adjust_symndx) PARAMS ((
-. bfd *obfd,
-. struct bfd_link_info *info,
-. bfd *ibfd,
-. asection *sec,
-. struct internal_reloc *reloc,
-. boolean *adjustedp));
-. boolean (*_bfd_coff_link_add_one_symbol) PARAMS ((
-. struct bfd_link_info *info,
-. bfd *abfd,
-. const char *name,
-. flagword flags,
-. asection *section,
-. bfd_vma value,
-. const char *string,
-. boolean copy,
-. boolean collect,
-. struct bfd_link_hash_entry **hashp));
+. unsigned int _bfd_filhsz;
+. unsigned int _bfd_aoutsz;
+. unsigned int _bfd_scnhsz;
+. unsigned int _bfd_symesz;
+. unsigned int _bfd_auxesz;
+. unsigned int _bfd_relsz;
+. unsigned int _bfd_linesz;
+. unsigned int _bfd_filnmlen;
+. boolean _bfd_coff_long_filenames;
+. boolean _bfd_coff_long_section_names;
+. unsigned int _bfd_coff_default_section_alignment_power;
+. boolean _bfd_coff_force_symnames_in_strings;
+. unsigned int _bfd_coff_debug_string_prefix_length;
+.
+. void (*_bfd_coff_swap_filehdr_in)
+. PARAMS ((bfd *, PTR, PTR));
+.
+. void (*_bfd_coff_swap_aouthdr_in)
+. PARAMS ((bfd *, PTR, PTR));
+.
+. void (*_bfd_coff_swap_scnhdr_in)
+. PARAMS ((bfd *, PTR, PTR));
+.
+. void (*_bfd_coff_swap_reloc_in)
+. PARAMS ((bfd *abfd, PTR, PTR));
+.
+. boolean (*_bfd_coff_bad_format_hook)
+. PARAMS ((bfd *, PTR));
+.
+. boolean (*_bfd_coff_set_arch_mach_hook)
+. PARAMS ((bfd *, PTR));
+.
+. PTR (*_bfd_coff_mkobject_hook)
+. PARAMS ((bfd *, PTR, PTR));
+.
+. boolean (*_bfd_styp_to_sec_flags_hook)
+. PARAMS ((bfd *, PTR, const char *, asection *, flagword *));
+.
+. void (*_bfd_set_alignment_hook)
+. PARAMS ((bfd *, asection *, PTR));
+.
+. boolean (*_bfd_coff_slurp_symbol_table)
+. PARAMS ((bfd *));
+.
+. boolean (*_bfd_coff_symname_in_debug)
+. PARAMS ((bfd *, struct internal_syment *));
+.
+. boolean (*_bfd_coff_pointerize_aux_hook)
+. PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
+. unsigned int, combined_entry_type *));
+.
+. boolean (*_bfd_coff_print_aux)
+. PARAMS ((bfd *, FILE *, combined_entry_type *, combined_entry_type *,
+. combined_entry_type *, unsigned int));
+.
+. void (*_bfd_coff_reloc16_extra_cases)
+. PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
+. bfd_byte *, unsigned int *, unsigned int *));
+.
+. int (*_bfd_coff_reloc16_estimate)
+. PARAMS ((bfd *, asection *, arelent *, unsigned int,
+. struct bfd_link_info *));
+.
+. enum coff_symbol_classification (*_bfd_coff_classify_symbol)
+. PARAMS ((bfd *, struct internal_syment *));
+.
+. boolean (*_bfd_coff_compute_section_file_positions)
+. PARAMS ((bfd *));
.
-. boolean (*_bfd_coff_link_output_has_begun) PARAMS ((
-. bfd * abfd,
-. struct coff_final_link_info * pfinfo));
-. boolean (*_bfd_coff_final_link_postscript) PARAMS ((
-. bfd * abfd,
-. struct coff_final_link_info * pfinfo));
+. boolean (*_bfd_coff_start_final_link)
+. PARAMS ((bfd *, struct bfd_link_info *));
+.
+. boolean (*_bfd_coff_relocate_section)
+. PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+. struct internal_reloc *, struct internal_syment *, asection **));
+.
+. reloc_howto_type *(*_bfd_coff_rtype_to_howto)
+. PARAMS ((bfd *, asection *, struct internal_reloc *,
+. struct coff_link_hash_entry *, struct internal_syment *,
+. bfd_vma *));
+.
+. boolean (*_bfd_coff_adjust_symndx)\
+. PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
+. struct internal_reloc *, boolean *));
+.
+. boolean (*_bfd_coff_link_add_one_symbol)
+. PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword,
+. asection *, bfd_vma, const char *, boolean, boolean,
+. struct bfd_link_hash_entry **));
+.
+. boolean (*_bfd_coff_link_output_has_begun)
+. PARAMS ((bfd *, struct coff_final_link_info *));
+.
+. boolean (*_bfd_coff_final_link_postscript)
+. PARAMS ((bfd *, struct coff_final_link_info *));
.
.} bfd_coff_backend_data;
.
-.#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
+.#define coff_backend_info(abfd) \
+. ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
.
.#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
-. ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
+. ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
.
.#define bfd_coff_swap_sym_in(a,e,i) \
-. ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
+. ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
.
.#define bfd_coff_swap_lineno_in(a,e,i) \
-. ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
+. ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
.
.#define bfd_coff_swap_reloc_out(abfd, i, o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
+. ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
.
.#define bfd_coff_swap_lineno_out(abfd, i, o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
+. ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
.
.#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
-. ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
+. ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
.
.#define bfd_coff_swap_sym_out(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
+. ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
.
.#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
+. ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
.
.#define bfd_coff_swap_filehdr_out(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
+. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
.
.#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
+. ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
.
.#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
.#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
.#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
.#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
.#define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen)
-.#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
+.#define bfd_coff_long_filenames(abfd) \
+. (coff_backend_info (abfd)->_bfd_coff_long_filenames)
.#define bfd_coff_long_section_names(abfd) \
-. (coff_backend_info (abfd)->_bfd_coff_long_section_names)
+. (coff_backend_info (abfd)->_bfd_coff_long_section_names)
.#define bfd_coff_default_section_alignment_power(abfd) \
-. (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
+. (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
.#define bfd_coff_swap_filehdr_in(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
+. ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
.
.#define bfd_coff_swap_aouthdr_in(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
+. ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
.
.#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
+. ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
.
.#define bfd_coff_swap_reloc_in(abfd, i, o) \
-. ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
+. ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
.
.#define bfd_coff_bad_format_hook(abfd, filehdr) \
-. ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
+. ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
.
.#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
-. ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
+. ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
.#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
-. ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
+. ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
.
.#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\
-. ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
-. (abfd, scnhdr, name, section, flags_ptr))
+. ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
+. (abfd, scnhdr, name, section, flags_ptr))
.
.#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
-. ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
+. ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
.
.#define bfd_coff_slurp_symbol_table(abfd)\
-. ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
+. ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
.
.#define bfd_coff_symname_in_debug(abfd, sym)\
-. ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
+. ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
.
.#define bfd_coff_force_symnames_in_strings(abfd)\
-. (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings)
+. (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings)
.
.#define bfd_coff_debug_string_prefix_length(abfd)\
-. (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length)
+. (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length)
.
.#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
-. ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
-. (abfd, file, base, symbol, aux, indaux))
+. ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
+. (abfd, file, base, symbol, aux, indaux))
.
.#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
-. ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
-. (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
+. ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
+. (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
.
.#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
-. ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
-. (abfd, section, reloc, shrink, link_info))
+. ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
+. (abfd, section, reloc, shrink, link_info))
.
.#define bfd_coff_classify_symbol(abfd, sym)\
-. ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
-. (abfd, sym))
+. ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
+. (abfd, sym))
.
.#define bfd_coff_compute_section_file_positions(abfd)\
-. ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
-. (abfd))
+. ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
+. (abfd))
.
.#define bfd_coff_start_final_link(obfd, info)\
-. ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
-. (obfd, info))
+. ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
+. (obfd, info))
.#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
-. ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
-. (obfd, info, ibfd, o, con, rel, isyms, secs))
+. ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
+. (obfd, info, ibfd, o, con, rel, isyms, secs))
.#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
-. ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
-. (abfd, sec, rel, h, sym, addendp))
+. ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
+. (abfd, sec, rel, h, sym, addendp))
.#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
-. ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
-. (obfd, info, ibfd, sec, rel, adjustedp))
+. ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
+. (obfd, info, ibfd, sec, rel, adjustedp))
.#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\
-. ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
-. (info, abfd, name, flags, section, value, string, cp, coll, hashp))
+. ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
+. (info, abfd, name, flags, section, value, string, cp, coll, hashp))
.
.#define bfd_coff_link_output_has_begun(a,p) \
-. ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a,p))
+. ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a,p))
.#define bfd_coff_final_link_postscript(a,p) \
-. ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a,p))
+. ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a,p))
.
*/
asection * section;
{
combined_entry_type *native;
+ bfd_size_type amt;
section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
@@ The 10 is a guess at a plausible maximum number of aux entries
(but shouldn't be a constant). */
- native = ((combined_entry_type *)
- bfd_zalloc (abfd, sizeof (combined_entry_type) * 10));
+ amt = sizeof (combined_entry_type) * 10;
+ native = (combined_entry_type *) bfd_zalloc (abfd, amt);
if (native == NULL)
return false;
PTR scnhdr;
{
struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
+ bfd_size_type amt;
ALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_64BYTES, 6)
ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_32BYTES, 5)
mapped onto a generic BFD section bit. */
if (coff_section_data (abfd, section) == NULL)
{
- section->used_by_bfd =
- (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));
+ amt = sizeof (struct coff_section_tdata);
+ section->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (section->used_by_bfd == NULL)
{
/* FIXME: Return error. */
}
if (pei_section_data (abfd, section) == NULL)
{
- coff_section_data (abfd, section)->tdata =
- (PTR) bfd_zalloc (abfd, sizeof (struct pei_section_tdata));
+ amt = sizeof (struct pei_section_tdata);
+ coff_section_data (abfd, section)->tdata = (PTR) bfd_zalloc (abfd, amt);
if (coff_section_data (abfd, section)->tdata == NULL)
{
/* FIXME: Return error. */
{
struct external_reloc dst;
struct internal_reloc n;
- int oldpos = bfd_tell (abfd);
- bfd_seek (abfd, hdr->s_relptr, 0);
- if (bfd_read ((PTR) & dst, 1, bfd_coff_relsz (abfd), abfd)
+ file_ptr oldpos = bfd_tell (abfd);
+ bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0);
+ if (bfd_bread ((PTR) &dst, (bfd_size_type) bfd_coff_relsz (abfd), abfd)
!= bfd_coff_relsz (abfd))
return;
coff_swap_reloc_in (abfd, &dst, &n);
bfd_seek (abfd, oldpos, 0);
- section->reloc_count =
- hdr->s_nreloc = n.r_vaddr;
+ section->reloc_count = hdr->s_nreloc = n.r_vaddr;
}
}
#undef ALIGN_SET
if ((hdr->s_flags & STYP_OVRFLO) == 0)
return;
- real_sec = coff_section_from_bfd_index (abfd, hdr->s_nreloc);
+ real_sec = coff_section_from_bfd_index (abfd, (int) hdr->s_nreloc);
if (real_sec == NULL)
return;
bfd * abfd;
{
coff_data_type *coff;
+ bfd_size_type amt = sizeof (coff_data_type);
- abfd->tdata.coff_obj_data = (struct coff_tdata *) bfd_zalloc (abfd, sizeof (coff_data_type));
+ abfd->tdata.coff_obj_data = (struct coff_tdata *) bfd_zalloc (abfd, amt);
if (abfd->tdata.coff_obj_data == 0)
return false;
coff = coff_data (abfd);
bfd *abfd;
PTR filehdr;
{
- long machine;
+ unsigned long machine;
enum bfd_architecture arch;
struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
{
bfd_byte *buf;
struct internal_syment sym;
+ bfd_size_type amt = bfd_coff_symesz (abfd);
- buf = (bfd_byte *) bfd_malloc (bfd_coff_symesz (abfd));
+ buf = (bfd_byte *) bfd_malloc (amt);
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
- || (bfd_read (buf, 1, bfd_coff_symesz (abfd), abfd)
- != bfd_coff_symesz (abfd)))
+ || bfd_bread (buf, amt, abfd) != amt)
{
free (buf);
return false;
if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) != XTY_LD)
{
BFD_ASSERT (! aux->fix_scnlen);
-#ifdef XCOFF64
+#ifdef XCOFF64
fprintf (file, "val %5lld", aux->u.auxent.x_csect.x_scnlen.l);
#else
fprintf (file, "val %5ld", (long) aux->u.auxent.x_csect.x_scnlen.l);
#ifndef TARG_AUX
p = s->orelocation;
#else
- /* sort relocations before we write them out */
- p = (arelent **) bfd_malloc (s->reloc_count * sizeof (arelent *));
- if (p == NULL && s->reloc_count > 0)
- return false;
- memcpy (p, s->orelocation, s->reloc_count * sizeof (arelent *));
- qsort (p, s->reloc_count, sizeof (arelent *), compare_arelent_ptr);
+ {
+ /* sort relocations before we write them out */
+ bfd_size_type amt;
+
+ amt = s->reloc_count;
+ amt *= sizeof (arelent *);
+ p = (arelent **) bfd_malloc (amt);
+ if (p == NULL && s->reloc_count > 0)
+ return false;
+ memcpy (p, s->orelocation, (size_t) amt);
+ qsort (p, s->reloc_count, sizeof (arelent *), compare_arelent_ptr);
+ }
#endif
if (bfd_seek (abfd, s->rel_filepos, SEEK_SET) != 0)
/* add one to count *this* reloc (grr) */
n.r_vaddr = s->reloc_count + 1;
coff_swap_reloc_out (abfd, &n, &dst);
- if (bfd_write ((PTR) & dst, 1, bfd_coff_relsz (abfd), abfd)
- != bfd_coff_relsz (abfd))
+ if (bfd_bwrite ((PTR) & dst, (bfd_size_type) bfd_coff_relsz (abfd),
+ abfd) != bfd_coff_relsz (abfd))
return false;
}
#endif
if (q->sym_ptr_ptr[0]->the_bfd != abfd)
{
- int i;
+ int j;
const char *sname = q->sym_ptr_ptr[0]->name;
asymbol **outsyms = abfd->outsymbols;
- for (i = first_undef; outsyms[i]; i++)
+ for (j = first_undef; outsyms[j]; j++)
{
- const char *intable = outsyms[i]->name;
+ const char *intable = outsyms[j]->name;
if (strcmp (intable, sname) == 0) {
/* got a hit, so repoint the reloc */
- q->sym_ptr_ptr = outsyms + i;
+ q->sym_ptr_ptr = outsyms + j;
break;
}
}
n.r_type = q->howto->type;
#endif
coff_swap_reloc_out (abfd, &n, &dst);
- if (bfd_write ((PTR) & dst, 1, bfd_coff_relsz (abfd), abfd)
- != bfd_coff_relsz (abfd))
+ if (bfd_bwrite ((PTR) & dst, (bfd_size_type) bfd_coff_relsz (abfd),
+ abfd) != bfd_coff_relsz (abfd))
return false;
}
right order in the image file itself, but we do need to get the
target_index values right. */
- int count;
+ unsigned int count;
asection **section_list;
- int i;
+ unsigned int i;
int target_index;
+ bfd_size_type amt;
count = 0;
for (current = abfd->sections; current != NULL; current = current->next)
++count;
/* We allocate an extra cell to simplify the final loop. */
- section_list = bfd_malloc (sizeof (struct asection *) * (count + 1));
+ amt = sizeof (struct asection *) * (count + 1);
+ section_list = bfd_malloc (amt);
if (section_list == NULL)
return false;
page size too, and remember both sizes. */
if (coff_section_data (abfd, current) == NULL)
{
- current->used_by_bfd =
- (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));
+ bfd_size_type amt = sizeof (struct coff_section_tdata);
+ current->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (current->used_by_bfd == NULL)
return false;
}
if (pei_section_data (abfd, current) == NULL)
{
- coff_section_data (abfd, current)->tdata =
- (PTR) bfd_zalloc (abfd, sizeof (struct pei_section_tdata));
+ bfd_size_type amt = sizeof (struct pei_section_tdata);
+ coff_section_data (abfd, current)->tdata
+ = (PTR) bfd_zalloc (abfd, amt);
if (coff_section_data (abfd, current)->tdata == NULL)
return false;
}
b = 0;
if (bfd_seek (abfd, sofar - 1, SEEK_SET) != 0
- || bfd_write (&b, 1, 1, abfd) != 1)
+ || bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
return false;
}
asymbol **sympp2;
unsigned int i;
int need_text = 1, need_data = 1, need_bss = 1, need_file = 1;
+ bfd_size_type amt;
for (i = 0; i < nsyms; i++)
{
coff_symbol_type *csym = coff_symbol_from (abfd, sympp[i]);
- CONST char *name;
+ const char *name;
if (csym)
{
/* only do this if there is a coff representation of the input
if (!need_text && !need_data && !need_bss && !need_file)
return true;
nsyms += need_text + need_data + need_bss + need_file;
- sympp2 = (asymbol **) bfd_alloc (abfd, nsyms * sizeof (asymbol *));
+ amt = nsyms;
+ amt *= sizeof (asymbol *);
+ sympp2 = (asymbol **) bfd_alloc (abfd, amt);
if (!sympp2)
return false;
memcpy (sympp2, sympp, i * sizeof (asymbol *));
{
scn_base = bfd_coff_filhsz (abfd);
#ifdef RS6000COFF_C
-#ifndef XCOFF64
+#ifndef XCOFF64
if (xcoff_data (abfd)->full_aouthdr)
scn_base += bfd_coff_aoutsz (abfd);
else
scn_base += SMALL_AOUTSZ;
-#endif
+#endif
#endif
}
#endif
{
SCNHDR buff;
+ bfd_size_type amt = bfd_coff_scnhsz (abfd);
+
if (coff_swap_scnhdr_out (abfd, §ion, &buff) == 0
- || bfd_write ((PTR) (&buff), 1, bfd_coff_scnhsz (abfd), abfd)
- != bfd_coff_scnhsz (abfd))
+ || bfd_bwrite ((PTR) &buff, amt, abfd) != amt)
return false;
}
}
#ifdef RS6000COFF_C
-#ifndef XCOFF64
+#ifndef XCOFF64
/* XCOFF handles overflows in the reloc and line number count fields
by creating a new section header to hold the correct values. */
for (current = abfd->sections; current != NULL; current = current->next)
{
struct internal_scnhdr scnhdr;
SCNHDR buff;
+ bfd_size_type amt;
internal_f.f_nscns++;
strncpy (&(scnhdr.s_name[0]), current->name, 8);
scnhdr.s_nreloc = current->target_index;
scnhdr.s_nlnno = current->target_index;
scnhdr.s_flags = STYP_OVRFLO;
+ amt = bfd_coff_scnhsz (abfd);
if (coff_swap_scnhdr_out (abfd, &scnhdr, &buff) == 0
- || bfd_write ((PTR) &buff, 1, bfd_coff_scnhsz (abfd), abfd)
- != bfd_coff_scnhsz (abfd))
+ || bfd_bwrite ((PTR) &buff, amt, abfd) != amt)
return false;
}
}
{
internal_f.f_opthdr = 0;
#ifdef RS6000COFF_C
-#ifndef XCOFF64
+#ifndef XCOFF64
if (xcoff_data (abfd)->full_aouthdr)
internal_f.f_opthdr = bfd_coff_aoutsz (abfd);
else
internal_f.f_opthdr = SMALL_AOUTSZ;
-#endif
+#endif
#endif
}
rounded up to the page size. */
b = 0;
if (bfd_seek (abfd,
- BFD_ALIGN (sym_base, COFF_PAGE_SIZE) - 1,
+ (file_ptr) BFD_ALIGN (sym_base, COFF_PAGE_SIZE) - 1,
SEEK_SET) != 0
- || bfd_write (&b, 1, 1, abfd) != 1)
+ || bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
return false;
}
#endif
{
char * buff;
- bfd_size_type amount;
+ bfd_size_type amount = bfd_coff_filhsz (abfd);
- buff = bfd_malloc (bfd_coff_filhsz (abfd));
+ buff = bfd_malloc (amount);
if (buff == NULL)
return false;
- bfd_coff_swap_filehdr_out (abfd, (PTR) & internal_f, (PTR) buff);
- amount = bfd_write ((PTR) buff, 1, bfd_coff_filhsz (abfd), abfd);
+ bfd_coff_swap_filehdr_out (abfd, (PTR) &internal_f, (PTR) buff);
+ amount = bfd_bwrite ((PTR) buff, amount, abfd);
free (buff);
/* Note that peicode.h fills in a PEAOUTHDR, not an AOUTHDR.
include/coff/pe.h sets AOUTSZ == sizeof (PEAOUTHDR)) */
char * buff;
- bfd_size_type amount;
+ bfd_size_type amount = bfd_coff_aoutsz (abfd);
- buff = bfd_malloc (bfd_coff_aoutsz (abfd));
+ buff = bfd_malloc (amount);
if (buff == NULL)
return false;
- coff_swap_aouthdr_out (abfd, (PTR) & internal_a, (PTR) buff);
- amount = bfd_write ((PTR) buff, 1, bfd_coff_aoutsz (abfd), abfd);
+ coff_swap_aouthdr_out (abfd, (PTR) &internal_a, (PTR) buff);
+ amount = bfd_bwrite ((PTR) buff, amount, abfd);
free (buff);
size = bfd_coff_aoutsz (abfd);
else
size = SMALL_AOUTSZ;
- if (bfd_write ((PTR) &buff, 1, size, abfd) != size)
+ if (bfd_bwrite ((PTR) &buff, (bfd_size_type) size, abfd) != size)
return false;
}
#endif
if (section->filepos == 0)
return true;
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0)
+ if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
return false;
- if (count != 0)
- {
- return (bfd_write (location, 1, count, abfd) == count) ? true : false;
- }
- return true;
+ if (count == 0)
+ return true;
+
+ return bfd_bwrite (location, count, abfd) == count;
}
#if 0
static boolean
#endif
static PTR
-buy_and_read (abfd, where, seek_direction, size)
+buy_and_read (abfd, where, size)
bfd *abfd;
file_ptr where;
- int seek_direction;
- size_t size;
+ bfd_size_type size;
{
PTR area = (PTR) bfd_alloc (abfd, size);
if (!area)
return (NULL);
- if (bfd_seek (abfd, where, seek_direction) != 0
- || bfd_read (area, 1, size, abfd) != size)
+ if (bfd_seek (abfd, where, SEEK_SET) != 0
+ || bfd_bread (area, size, abfd) != size)
return (NULL);
return (area);
} /* buy_and_read() */
{
LINENO *native_lineno;
alent *lineno_cache;
+ bfd_size_type amt;
BFD_ASSERT (asect->lineno == (alent *) NULL);
- native_lineno = (LINENO *) buy_and_read (abfd,
- asect->line_filepos,
- SEEK_SET,
- (size_t) (bfd_coff_linesz (abfd) *
- asect->lineno_count));
- lineno_cache =
- (alent *) bfd_alloc (abfd, (size_t) ((asect->lineno_count + 1) * sizeof (alent)));
+ amt = (bfd_size_type) bfd_coff_linesz (abfd) * asect->lineno_count;
+ native_lineno = (LINENO *) buy_and_read (abfd, asect->line_filepos, amt);
+ amt = ((bfd_size_type) asect->lineno_count + 1) * sizeof (alent);
+ lineno_cache = (alent *) bfd_alloc (abfd, amt);
if (lineno_cache == NULL)
return false;
else
combined_entry_type *native_symbols;
coff_symbol_type *cached_area;
unsigned int *table_ptr;
+ bfd_size_type amt;
unsigned int number_of_symbols = 0;
} /* on error */
/* Allocate enough room for all the symbols in cached form */
- cached_area = ((coff_symbol_type *)
- bfd_alloc (abfd,
- (obj_raw_syment_count (abfd)
- * sizeof (coff_symbol_type))));
-
+ amt = obj_raw_syment_count (abfd);
+ amt *= sizeof (coff_symbol_type);
+ cached_area = (coff_symbol_type *) bfd_alloc (abfd, amt);
if (cached_area == NULL)
return false;
- table_ptr = ((unsigned int *)
- bfd_alloc (abfd,
- (obj_raw_syment_count (abfd)
- * sizeof (unsigned int))));
+
+ amt = obj_raw_syment_count (abfd);
+ amt *= sizeof (unsigned int);
+ table_ptr = (unsigned int *) bfd_alloc (abfd, amt);
if (table_ptr == NULL)
return false;
RELOC *native_relocs;
arelent *reloc_cache;
arelent *cache_ptr;
-
unsigned int idx;
+ bfd_size_type amt;
if (asect->relocation)
return true;
return true;
if (!coff_slurp_symbol_table (abfd))
return false;
- native_relocs =
- (RELOC *) buy_and_read (abfd,
- asect->rel_filepos,
- SEEK_SET,
- (size_t) (bfd_coff_relsz (abfd) *
- asect->reloc_count));
- reloc_cache = (arelent *)
- bfd_alloc (abfd, (size_t) (asect->reloc_count * sizeof (arelent)));
+ amt = (bfd_size_type) bfd_coff_relsz (abfd) * asect->reloc_count;
+ native_relocs = (RELOC *) buy_and_read (abfd, asect->rel_filepos, amt);
+ amt = (bfd_size_type) asect->reloc_count * sizeof (arelent);
+ reloc_cache = (arelent *) bfd_alloc (abfd, amt);
if (reloc_cache == NULL)
return false;
static char *build_debug_section
PARAMS ((bfd *));
static char *copy_name
- PARAMS ((bfd *, char *, int));
+ PARAMS ((bfd *, char *, size_t));
#define STRING_SIZE_SIZE (4)
strindex does not run us past the end, but right now we
don't know the length of the string table. */
strings += strindex;
- name = bfd_alloc (abfd, strlen (strings) + 1);
+ name = bfd_alloc (abfd, (bfd_size_type) strlen (strings) + 1);
if (name == NULL)
return false;
strcpy (name, strings);
if (name == NULL)
{
/* Assorted wastage to null-terminate the name, thanks AT&T! */
- name = bfd_alloc (abfd, sizeof (hdr->s_name) + 1);
+ name = bfd_alloc (abfd, (bfd_size_type) sizeof (hdr->s_name) + 1);
if (name == NULL)
return false;
strncpy (name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
if (! bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name, return_section,
& flags))
result = false;
-
+
return_section->flags = flags;
/* At least on i386-coff, the line number count for a shared library
flagword oflags = abfd->flags;
bfd_vma ostart = bfd_get_start_address (abfd);
PTR tdata;
- size_t readsize; /* length of file_info */
+ bfd_size_type readsize; /* length of file_info */
unsigned int scnhsz;
char *external_sections;
return 0;
scnhsz = bfd_coff_scnhsz (abfd);
- readsize = nscns * scnhsz;
+ readsize = (bfd_size_type) nscns * scnhsz;
external_sections = (char *) bfd_alloc (abfd, readsize);
if (!external_sections)
goto fail;
- if (bfd_read ((PTR) external_sections, 1, readsize, abfd) != readsize)
+ if (bfd_bread ((PTR) external_sections, readsize, abfd) != readsize)
goto fail;
/* Set the arch/mach *before* swapping in sections; section header swapping
coff_object_p (abfd)
bfd *abfd;
{
- unsigned int filhsz;
- unsigned int aoutsz;
- int nscns;
+ bfd_size_type filhsz;
+ bfd_size_type aoutsz;
+ unsigned int nscns;
PTR filehdr;
struct internal_filehdr internal_f;
struct internal_aouthdr internal_a;
filehdr = bfd_alloc (abfd, filhsz);
if (filehdr == NULL)
return 0;
- if (bfd_read (filehdr, 1, filhsz, abfd) != filhsz)
+ if (bfd_bread (filehdr, filhsz, abfd) != filhsz)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
opthdr = bfd_alloc (abfd, aoutsz);
if (opthdr == NULL)
return 0;;
- if (bfd_read (opthdr, 1, internal_f.f_opthdr, abfd)
+ if (bfd_bread (opthdr, (bfd_size_type) internal_f.f_opthdr, abfd)
!= internal_f.f_opthdr)
{
return 0;
bfd_byte *erel;
bfd_byte *erel_end;
struct internal_reloc *irel;
+ bfd_size_type amt;
if (coff_section_data (abfd, sec) != NULL
&& coff_section_data (abfd, sec)->relocs != NULL)
relsz = bfd_coff_relsz (abfd);
+ amt = sec->reloc_count * relsz;
if (external_relocs == NULL)
{
- free_external = (bfd_byte *) bfd_malloc (sec->reloc_count * relsz);
+ free_external = (bfd_byte *) bfd_malloc (amt);
if (free_external == NULL && sec->reloc_count > 0)
goto error_return;
external_relocs = free_external;
}
if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
- || (bfd_read (external_relocs, relsz, sec->reloc_count, abfd)
- != relsz * sec->reloc_count))
+ || bfd_bread (external_relocs, amt, abfd) != amt)
goto error_return;
if (internal_relocs == NULL)
{
- free_internal = ((struct internal_reloc *)
- bfd_malloc (sec->reloc_count
- * sizeof (struct internal_reloc)));
+ amt = sec->reloc_count;
+ amt *= sizeof (struct internal_reloc);
+ free_internal = (struct internal_reloc *) bfd_malloc (amt);
if (free_internal == NULL && sec->reloc_count > 0)
goto error_return;
internal_relocs = free_internal;
{
if (coff_section_data (abfd, sec) == NULL)
{
- sec->used_by_bfd =
- (PTR) bfd_zalloc (abfd,
- sizeof (struct coff_section_tdata));
+ amt = sizeof (struct coff_section_tdata);
+ sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (sec->used_by_bfd == NULL)
goto error_return;
coff_section_data (abfd, sec)->contents = NULL;
{
asymbol **newsyms;
unsigned int i;
+ bfd_size_type amt;
- newsyms = (asymbol **) bfd_alloc (bfd_ptr,
- sizeof (asymbol *) * (symbol_count + 1));
+ amt = sizeof (asymbol *) * ((bfd_size_type) symbol_count + 1);
+ newsyms = (asymbol **) bfd_alloc (bfd_ptr, amt);
if (!newsyms)
return false;
bfd_ptr->outsymbols = newsyms;
if (s->fix_value)
{
/* FIXME: We should use a union here. */
- s->u.syment.n_value =
- (bfd_vma)((combined_entry_type *)
+ s->u.syment.n_value =
+ (bfd_vma)((combined_entry_type *)
((unsigned long) s->u.syment.n_value))->offset;
s->fix_value = 0;
}
}
else
{
- long filepos;
+ file_ptr filepos;
bfd_byte buf[4];
int prefix_len = bfd_coff_debug_string_prefix_length (abfd);
*debug_string_section_p = bfd_get_section_by_name (abfd, ".debug");
filepos = bfd_tell (abfd);
if (prefix_len == 4)
- bfd_put_32 (abfd, name_length + 1, buf);
+ bfd_put_32 (abfd, (bfd_vma) (name_length + 1), buf);
else
- bfd_put_16 (abfd, name_length + 1, buf);
+ bfd_put_16 (abfd, (bfd_vma) (name_length + 1), buf);
if (!bfd_set_section_contents (abfd,
*debug_string_section_p,
|| !bfd_set_section_contents (abfd,
*debug_string_section_p,
(PTR) symbol->name,
- ((file_ptr) *debug_string_size_p
- + prefix_len),
+ (file_ptr) (*debug_string_size_p
+ + prefix_len),
(bfd_size_type) name_length + 1))
abort ();
if (bfd_seek (abfd, filepos, SEEK_SET) != 0)
if (!buf)
return false;
bfd_coff_swap_sym_out (abfd, &native->u.syment, buf);
- if (bfd_write (buf, 1, symesz, abfd) != symesz)
+ if (bfd_bwrite (buf, symesz, abfd) != symesz)
return false;
bfd_release (abfd, buf);
&((native + j + 1)->u.auxent),
type,
class,
- j,
+ (int) j,
native->u.syment.n_numaux,
buf);
- if (bfd_write (buf, 1, auxesz, abfd) != auxesz)
+ if (bfd_bwrite (buf, auxesz, abfd) != auxesz)
return false;
}
bfd_release (abfd, buf);
bfd_byte buffer[STRING_SIZE_SIZE];
#if STRING_SIZE_SIZE == 4
- bfd_h_put_32 (abfd, size, buffer);
+ H_PUT_32 (abfd, size, buffer);
#else
- #error Change bfd_h_put_32
+ #error Change H_PUT_32
#endif
- if (bfd_write ((PTR) buffer, 1, sizeof (buffer), abfd) != sizeof (buffer))
+ if (bfd_bwrite ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd)
+ != sizeof (buffer))
return false;
/* Handle long section names. This code must handle section
len = strlen (o->name);
if (len > SCNNMLEN)
{
- if (bfd_write (o->name, 1, len + 1, abfd) != len + 1)
+ if (bfd_bwrite (o->name, (bfd_size_type) (len + 1), abfd)
+ != len + 1)
return false;
}
}
&& c_symbol->native->u.syment.n_numaux > 0)
{
if (bfd_coff_force_symnames_in_strings (abfd))
- bfd_write (".file", 1, 6, abfd);
+ {
+ if (bfd_bwrite (".file", (bfd_size_type) 6, abfd) != 6)
+ return false;
+ }
maxlen = bfd_coff_filnmlen (abfd);
}
else
if (name_length > maxlen)
{
- if (bfd_write ((PTR) (q->name), 1, name_length + 1, abfd)
- != name_length + 1)
+ if (bfd_bwrite ((PTR) (q->name), (bfd_size_type) name_length + 1,
+ abfd) != name_length + 1)
return false;
}
}
bfd_byte buffer[STRING_SIZE_SIZE];
#if STRING_SIZE_SIZE == 4
- bfd_h_put_32 (abfd, size, buffer);
+ H_PUT_32 (abfd, size, buffer);
#else
- #error Change bfd_h_put_32
+ #error Change H_PUT_32
#endif
- if (bfd_write ((PTR) buffer, 1, STRING_SIZE_SIZE, abfd)
+ if (bfd_bwrite ((PTR) buffer, (bfd_size_type) STRING_SIZE_SIZE, abfd)
!= STRING_SIZE_SIZE)
return false;
}
out.l_lnno = 0;
out.l_addr.l_symndx = l->u.offset;
bfd_coff_swap_lineno_out (abfd, &out, buff);
- if (bfd_write (buff, 1, linesz, abfd) != linesz)
+ if (bfd_bwrite (buff, (bfd_size_type) linesz, abfd)
+ != linesz)
return false;
l++;
while (l->line_number)
out.l_lnno = l->line_number;
out.l_addr.l_symndx = l->u.offset;
bfd_coff_swap_lineno_out (abfd, &out, buff);
- if (bfd_write (buff, 1, linesz, abfd) != linesz)
+ if (bfd_bwrite (buff, (bfd_size_type) linesz, abfd)
+ != linesz)
return false;
l++;
}
combined_entry_type e[10];
};
struct foo *f;
- f = (struct foo *) bfd_alloc (abfd, sizeof (*f));
+ f = (struct foo *) bfd_alloc (abfd, (bfd_size_type) sizeof (*f));
if (!f)
{
bfd_set_error (bfd_error_no_error);
bfd *abfd;
{
char *debug_section;
- long position;
+ file_ptr position;
+ bfd_size_type sec_size;
asection *sect = bfd_get_section_by_name (abfd, ".debug");
return NULL;
}
- debug_section = (PTR) bfd_alloc (abfd,
- bfd_get_section_size_before_reloc (sect));
+ sec_size = bfd_get_section_size_before_reloc (sect);
+ debug_section = (PTR) bfd_alloc (abfd, sec_size);
if (debug_section == NULL)
return NULL;
position = bfd_tell (abfd);
if (bfd_seek (abfd, sect->filepos, SEEK_SET) != 0
- || (bfd_read (debug_section,
- bfd_get_section_size_before_reloc (sect), 1, abfd)
- != bfd_get_section_size_before_reloc (sect))
+ || bfd_bread (debug_section, sec_size, abfd) != sec_size
|| bfd_seek (abfd, position, SEEK_SET) != 0)
return NULL;
return debug_section;
copy_name (abfd, name, maxlen)
bfd *abfd;
char *name;
- int maxlen;
+ size_t maxlen;
{
- int len;
+ size_t len;
char *newname;
for (len = 0; len < maxlen; ++len)
}
}
- if ((newname = (PTR) bfd_alloc (abfd, len + 1)) == NULL)
+ if ((newname = (PTR) bfd_alloc (abfd, (bfd_size_type) len + 1)) == NULL)
return (NULL);
strncpy (newname, name, len);
newname[len] = '\0';
bfd *abfd;
{
bfd_size_type symesz;
- size_t size;
+ bfd_size_type size;
PTR syms;
if (obj_coff_external_syms (abfd) != NULL)
return false;
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
- || bfd_read (syms, size, 1, abfd) != size)
+ || bfd_bread (syms, size, abfd) != size)
{
if (syms != NULL)
free (syms);
bfd *abfd;
{
char extstrsize[STRING_SIZE_SIZE];
- size_t strsize;
+ bfd_size_type strsize;
char *strings;
+ file_ptr pos;
if (obj_coff_strings (abfd) != NULL)
return obj_coff_strings (abfd);
return NULL;
}
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd)),
- SEEK_SET) != 0)
+ pos = obj_sym_filepos (abfd);
+ pos += obj_raw_syment_count (abfd) * bfd_coff_symesz (abfd);
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0)
return NULL;
- if (bfd_read (extstrsize, sizeof extstrsize, 1, abfd) != sizeof extstrsize)
+ if (bfd_bread (extstrsize, (bfd_size_type) sizeof extstrsize, abfd)
+ != sizeof extstrsize)
{
if (bfd_get_error () != bfd_error_file_truncated)
return NULL;
else
{
#if STRING_SIZE_SIZE == 4
- strsize = bfd_h_get_32 (abfd, (bfd_byte *) extstrsize);
+ strsize = H_GET_32 (abfd, extstrsize);
#else
- #error Change bfd_h_get_32
+ #error Change H_GET_32
#endif
}
if (strings == NULL)
return NULL;
- if (bfd_read (strings + STRING_SIZE_SIZE,
- strsize - STRING_SIZE_SIZE, 1, abfd)
+ if (bfd_bread (strings + STRING_SIZE_SIZE, strsize - STRING_SIZE_SIZE, abfd)
!= strsize - STRING_SIZE_SIZE)
{
free (strings);
combined_entry_type *internal_ptr;
combined_entry_type *symbol_ptr;
combined_entry_type *internal_end;
- bfd_size_type symesz;
+ size_t symesz;
char *raw_src;
char *raw_end;
const char *string_table = NULL;
char *debug_section = NULL;
- unsigned long size;
+ bfd_size_type size;
if (obj_raw_syments (abfd) != NULL)
return obj_raw_syments (abfd);
bfd_coff_swap_aux_in (abfd, (PTR) raw_src,
symbol_ptr->u.syment.n_type,
symbol_ptr->u.syment.n_sclass,
- i, symbol_ptr->u.syment.n_numaux,
+ (int) i, symbol_ptr->u.syment.n_numaux,
&(internal_ptr->u.auxent));
coff_pointerize_aux (abfd, internal, symbol_ptr, i,
internal_ptr);
((long)
copy_name (abfd,
(internal_ptr + 1)->u.auxent.x_file.x_fname,
- bfd_coff_filnmlen (abfd)));
+ (size_t) bfd_coff_filnmlen (abfd)));
}
}
}
if (internal_ptr->u.syment._n._n_n._n_zeroes != 0)
{
/* This is a "short" name. Make it long. */
- unsigned long i = 0;
- char *newstring = NULL;
+ size_t i;
+ char *newstring;
/* find the length of this string without walking into memory
that isn't ours. */
for (i = 0; i < 8; ++i)
- {
- if (internal_ptr->u.syment._n._n_name[i] == '\0')
- {
- break;
- } /* if end of string */
- } /* possible lengths of this string. */
+ if (internal_ptr->u.syment._n._n_name[i] == '\0')
+ break;
- if ((newstring = (PTR) bfd_alloc (abfd, ++i)) == NULL)
+ newstring = (PTR) bfd_alloc (abfd, (bfd_size_type) (i + 1));
+ if (newstring == NULL)
return (NULL);
- memset (newstring, 0, i);
- strncpy (newstring, internal_ptr->u.syment._n._n_name, i - 1);
+ memset (newstring, 0, i + 1);
+ strncpy (newstring, internal_ptr->u.syment._n._n_name, i);
internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring;
internal_ptr->u.syment._n._n_n._n_zeroes = 0;
}
coff_make_empty_symbol (abfd)
bfd *abfd;
{
- coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
+ bfd_size_type amt = sizeof (coff_symbol_type);
+ coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, amt);
if (new == NULL)
return (NULL);
memset (new, 0, sizeof *new);
PTR ptr ATTRIBUTE_UNUSED;
unsigned long sz ATTRIBUTE_UNUSED;
{
- coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, sizeof (coff_symbol_type));
+ bfd_size_type amt = sizeof (coff_symbol_type);
+ coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, amt);
if (new == NULL)
return (NULL);
/* @@ The 10 is a guess at a plausible maximum number of aux entries
(but shouldn't be a constant). */
- new->native = (combined_entry_type *) bfd_zalloc (abfd, sizeof (combined_entry_type) * 10);
+ amt = sizeof (combined_entry_type) * 10;
+ new->native = (combined_entry_type *) bfd_zalloc (abfd, amt);
if (!new->native)
return (NULL);
new->symbol.section = bfd_abs_section_ptr;
*psyment = csym->native->u.syment;
if (csym->native->fix_value)
- psyment->n_value = psyment->n_value -
+ psyment->n_value = psyment->n_value -
(unsigned long) obj_raw_syments (abfd);
/* FIXME: We should handle fix_line here. */
asection *section;
asymbol **symbols;
bfd_vma offset;
- CONST char **filename_ptr;
- CONST char **functionname_ptr;
+ const char **filename_ptr;
+ const char **functionname_ptr;
unsigned int *line_ptr;
{
boolean found;
combined_entry_type *pend;
alent *l;
struct coff_section_tdata *sec_data;
+ bfd_size_type amt;
/* Before looking through the symbol table, try to use a .stab
section to find the information. */
/* Cache the results for the next call. */
if (sec_data == NULL && section->owner == abfd)
{
- section->used_by_bfd =
- ((PTR) bfd_zalloc (abfd,
- sizeof (struct coff_section_tdata)));
+ amt = sizeof (struct coff_section_tdata);
+ section->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
sec_data = (struct coff_section_tdata *) section->used_by_bfd;
}
if (sec_data != NULL)
coff_write_alien_symbol(). */
combined_entry_type * native;
+ bfd_size_type amt = sizeof (* native);
- native = (combined_entry_type *) bfd_alloc (abfd, sizeof (* native));
+ native = (combined_entry_type *) bfd_alloc (abfd, amt);
if (native == NULL)
return false;
bfd *abfd;
{
struct coff_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct coff_link_hash_table);
- ret = ((struct coff_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct coff_link_hash_table)));
+ ret = (struct coff_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == NULL)
return NULL;
if (! _bfd_coff_link_hash_table_init (ret, abfd,
bfd_size_type symesz;
bfd_byte *esym;
bfd_byte *esym_end;
+ bfd_size_type amt;
/* Keep the symbols during this function, in case the linker needs
to read the generic symbols in order to report an error message. */
/* We keep a list of the linker hash table entries that correspond
to particular symbols. */
- sym_hash = ((struct coff_link_hash_entry **)
- bfd_alloc (abfd,
- ((size_t) symcount
- * sizeof (struct coff_link_hash_entry *))));
+ amt = symcount * sizeof (struct coff_link_hash_entry *);
+ sym_hash = (struct coff_link_hash_entry **) bfd_alloc (abfd, amt);
if (sym_hash == NULL && symcount != 0)
goto error_return;
obj_coff_sym_hashes (abfd) = sym_hash;
i < sym.n_numaux;
i++, eaux += symesz, iaux++)
bfd_coff_swap_aux_in (abfd, (PTR) eaux, sym.n_type,
- sym.n_sclass, i, sym.n_numaux,
- (PTR) iaux);
+ sym.n_sclass, (int) i,
+ sym.n_numaux, (PTR) iaux);
(*sym_hash)->aux = alloc;
}
}
secdata = coff_section_data (abfd, stab);
if (secdata == NULL)
{
- stab->used_by_bfd =
- (PTR) bfd_zalloc (abfd,
- sizeof (struct coff_section_tdata));
+ amt = sizeof (struct coff_section_tdata);
+ stab->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (stab->used_by_bfd == NULL)
goto error_return;
secdata = coff_section_data (abfd, stab);
boolean long_section_names;
asection *o;
struct bfd_link_order *p;
- size_t max_sym_count;
- size_t max_lineno_count;
- size_t max_reloc_count;
- size_t max_output_reloc_count;
- size_t max_contents_size;
+ bfd_size_type max_sym_count;
+ bfd_size_type max_lineno_count;
+ bfd_size_type max_reloc_count;
+ bfd_size_type max_output_reloc_count;
+ bfd_size_type max_contents_size;
file_ptr rel_filepos;
unsigned int relsz;
file_ptr line_filepos;
bfd *sub;
bfd_byte *external_relocs = NULL;
char strbuf[STRING_SIZE_SIZE];
+ bfd_size_type amt;
symesz = bfd_coff_symesz (abfd);
/* We use section_count + 1, rather than section_count, because
the target_index fields are 1 based. */
- finfo.section_info =
- ((struct coff_link_section_info *)
- bfd_malloc ((abfd->section_count + 1)
- * sizeof (struct coff_link_section_info)));
+ amt = abfd->section_count + 1;
+ amt *= sizeof (struct coff_link_section_info);
+ finfo.section_info = (struct coff_link_section_info *) bfd_malloc (amt);
if (finfo.section_info == NULL)
goto error_return;
for (i = 0; i <= abfd->section_count; i++)
but only when doing a relocateable link, which is not the
common case. */
BFD_ASSERT (info->relocateable);
+ amt = o->reloc_count;
+ amt *= sizeof (struct internal_reloc);
finfo.section_info[o->target_index].relocs =
- ((struct internal_reloc *)
- bfd_malloc (o->reloc_count * sizeof (struct internal_reloc)));
+ (struct internal_reloc *) bfd_malloc (amt);
+ amt = o->reloc_count;
+ amt *= sizeof (struct coff_link_hash_entry *);
finfo.section_info[o->target_index].rel_hashes =
- ((struct coff_link_hash_entry **)
- bfd_malloc (o->reloc_count
- * sizeof (struct coff_link_hash_entry *)));
+ (struct coff_link_hash_entry **) bfd_malloc (amt);
if (finfo.section_info[o->target_index].relocs == NULL
|| finfo.section_info[o->target_index].rel_hashes == NULL)
goto error_return;
}
/* Allocate some buffers used while linking. */
- finfo.internal_syms = ((struct internal_syment *)
- bfd_malloc (max_sym_count
- * sizeof (struct internal_syment)));
- finfo.sec_ptrs = (asection **) bfd_malloc (max_sym_count
- * sizeof (asection *));
- finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
- finfo.outsyms = ((bfd_byte *)
- bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
- finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
- * bfd_coff_linesz (abfd));
+ amt = max_sym_count * sizeof (struct internal_syment);
+ finfo.internal_syms = (struct internal_syment *) bfd_malloc (amt);
+ amt = max_sym_count * sizeof (asection *);
+ finfo.sec_ptrs = (asection **) bfd_malloc (amt);
+ amt = max_sym_count * sizeof (long);
+ finfo.sym_indices = (long *) bfd_malloc (amt);
+ finfo.outsyms = (bfd_byte *) bfd_malloc ((max_sym_count + 1) * symesz);
+ amt = max_lineno_count * bfd_coff_linesz (abfd);
+ finfo.linenos = (bfd_byte *) bfd_malloc (amt);
finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
- finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
+ amt = max_reloc_count * relsz;
+ finfo.external_relocs = (bfd_byte *) bfd_malloc (amt);
if (! info->relocateable)
- finfo.internal_relocs = ((struct internal_reloc *)
- bfd_malloc (max_reloc_count
- * sizeof (struct internal_reloc)));
+ {
+ amt = max_reloc_count * sizeof (struct internal_reloc);
+ finfo.internal_relocs = (struct internal_reloc *) bfd_malloc (amt);
+ }
if ((finfo.internal_syms == NULL && max_sym_count > 0)
|| (finfo.sec_ptrs == NULL && max_sym_count > 0)
|| (finfo.sym_indices == NULL && max_sym_count > 0)
if (finfo.last_file_index != -1
&& (unsigned int) finfo.last_file.n_value != obj_raw_syment_count (abfd))
{
+ file_ptr pos;
+
finfo.last_file.n_value = obj_raw_syment_count (abfd);
bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
(PTR) finfo.outsyms);
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + finfo.last_file_index * symesz),
- SEEK_SET) != 0
- || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz)
+
+ pos = obj_sym_filepos (abfd) + finfo.last_file_index * symesz;
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (finfo.outsyms, symesz, abfd) != symesz)
return false;
}
/* Now that we have written out all the global symbols, we know
the symbol indices to use for relocs against them, and we can
finally write out the relocs. */
- external_relocs = ((bfd_byte *)
- bfd_malloc (max_output_reloc_count * relsz));
+ amt = max_output_reloc_count * relsz;
+ external_relocs = (bfd_byte *) bfd_malloc (amt);
if (external_relocs == NULL)
goto error_return;
}
if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
- || bfd_write ((PTR) external_relocs, relsz, o->reloc_count,
- abfd) != relsz * o->reloc_count)
+ || (bfd_bwrite ((PTR) external_relocs,
+ (bfd_size_type) relsz * o->reloc_count, abfd)
+ != (bfd_size_type) relsz * o->reloc_count))
goto error_return;
}
/* Write out the string table. */
if (obj_raw_syment_count (abfd) != 0 || long_section_names)
{
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + obj_raw_syment_count (abfd) * symesz),
- SEEK_SET) != 0)
+ file_ptr pos;
+
+ pos = obj_sym_filepos (abfd) + obj_raw_syment_count (abfd) * symesz;
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0)
return false;
#if STRING_SIZE_SIZE == 4
- bfd_h_put_32 (abfd,
- _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
- (bfd_byte *) strbuf);
+ H_PUT_32 (abfd,
+ _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
+ strbuf);
#else
- #error Change bfd_h_put_32
+ #error Change H_PUT_32 above
#endif
- if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
+ if (bfd_bwrite (strbuf, (bfd_size_type) STRING_SIZE_SIZE, abfd)
+ != STRING_SIZE_SIZE)
return false;
if (! _bfd_stringtab_emit (abfd, finfo.strtab))
{
int val = strtoul (ptr, &ptr, 0);
if (heap)
- pe_data(output_bfd)->pe_opthdr.SizeOfHeapReserve =val;
+ pe_data(output_bfd)->pe_opthdr.SizeOfHeapReserve = val;
else
- pe_data(output_bfd)->pe_opthdr.SizeOfStackReserve =val;
+ pe_data(output_bfd)->pe_opthdr.SizeOfStackReserve = val;
if (ptr[0] == ',')
{
- int val = strtoul (ptr+1, &ptr, 0);
+ val = strtoul (ptr+1, &ptr, 0);
if (heap)
- pe_data(output_bfd)->pe_opthdr.SizeOfHeapCommit =val;
+ pe_data(output_bfd)->pe_opthdr.SizeOfHeapCommit = val;
else
- pe_data(output_bfd)->pe_opthdr.SizeOfStackCommit =val;
+ pe_data(output_bfd)->pe_opthdr.SizeOfStackCommit = val;
}
}
return ptr;
if (!sec)
return 1;
- copy = bfd_malloc ((size_t) sec->_raw_size);
+ copy = bfd_malloc (sec->_raw_size);
if (!copy)
return 0;
- if (! bfd_get_section_contents(abfd, sec, copy, 0, sec->_raw_size))
+ if (! bfd_get_section_contents(abfd, sec, copy, (bfd_vma) 0, sec->_raw_size))
{
free (copy);
return 0;
struct coff_debug_merge_element **epp;
bfd_byte *esl, *eslend;
struct internal_syment *islp;
+ bfd_size_type amt;
name = _bfd_coff_internal_syment_name (input_bfd, &isym, buf);
if (name == NULL)
/* Allocate memory to hold type information. If this turns
out to be a duplicate, we pass this address to
bfd_release. */
- mt = ((struct coff_debug_merge_type *)
- bfd_alloc (input_bfd,
- sizeof (struct coff_debug_merge_type)));
+ amt = sizeof (struct coff_debug_merge_type);
+ mt = (struct coff_debug_merge_type *) bfd_alloc (input_bfd, amt);
if (mt == NULL)
return false;
mt->class = isym.n_sclass;
bfd_coff_swap_sym_in (input_bfd, (PTR) esl, (PTR) islp);
+ amt = sizeof (struct coff_debug_merge_element);
*epp = ((struct coff_debug_merge_element *)
- bfd_alloc (input_bfd,
- sizeof (struct coff_debug_merge_element)));
+ bfd_alloc (input_bfd, amt));
if (*epp == NULL)
return false;
if (elename == NULL)
return false;
- name_copy = (char *) bfd_alloc (input_bfd,
- strlen (elename) + 1);
+ amt = strlen (elename) + 1;
+ name_copy = (char *) bfd_alloc (input_bfd, amt);
if (name_copy == NULL)
return false;
strcpy (name_copy, elename);
}
else
{
+ file_ptr pos;
+
/* We have already written out the last C_FILE
symbol. We need to write it out again. We
borrow *outsym temporarily. */
bfd_coff_swap_sym_out (output_bfd,
(PTR) &finfo->last_file,
(PTR) outsym);
- if (bfd_seek (output_bfd,
- (obj_sym_filepos (output_bfd)
- + finfo->last_file_index * osymesz),
- SEEK_SET) != 0
- || (bfd_write (outsym, osymesz, 1, output_bfd)
- != osymesz))
+ pos = obj_sym_filepos (output_bfd);
+ pos += finfo->last_file_index * osymesz;
+ if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (outsym, osymesz, output_bfd) != osymesz)
return false;
}
}
}
else
{
+ file_ptr pos;
+
/* We have already written out the last
.bf aux entry. We need to write it
out again. We borrow *outsym
isymp->n_sclass,
0, isymp->n_numaux,
(PTR) outsym);
- if (bfd_seek (output_bfd,
- (obj_sym_filepos (output_bfd)
- + finfo->last_bf_index * osymesz),
- SEEK_SET) != 0
- || bfd_write (outsym, osymesz, 1,
- output_bfd) != osymesz)
+ pos = obj_sym_filepos (output_bfd);
+ pos += finfo->last_bf_index * osymesz;
+ if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
+ || (bfd_bwrite (outsym, osymesz, output_bfd)
+ != osymesz))
return false;
}
}
bfd_byte *elineend;
bfd_byte *oeline;
boolean skipping;
+ file_ptr pos;
+ bfd_size_type amt;
/* FIXME: If SEC_HAS_CONTENTS is not for the section, then
build_link_order in ldwrite.c will not have created a
continue;
if (bfd_seek (input_bfd, o->line_filepos, SEEK_SET) != 0
- || bfd_read (finfo->linenos, linesz, o->lineno_count,
+ || bfd_bread (finfo->linenos, linesz * o->lineno_count,
input_bfd) != linesz * o->lineno_count)
return false;
}
}
- if (bfd_seek (output_bfd,
- (o->output_section->line_filepos
- + o->output_section->lineno_count * linesz),
- SEEK_SET) != 0
- || (bfd_write (finfo->linenos, 1, oeline - finfo->linenos,
- output_bfd)
- != (bfd_size_type) (oeline - finfo->linenos)))
+ pos = o->output_section->line_filepos;
+ pos += o->output_section->lineno_count * linesz;
+ amt = oeline - finfo->linenos;
+ if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (finfo->linenos, amt, output_bfd) != amt)
return false;
- o->output_section->lineno_count +=
- (oeline - finfo->linenos) / linesz;
+ o->output_section->lineno_count += amt / linesz;
}
}
/* Write the modified symbols to the output file. */
if (outsym > finfo->outsyms)
{
- if (bfd_seek (output_bfd,
- obj_sym_filepos (output_bfd) + syment_base * osymesz,
- SEEK_SET) != 0
- || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1,
- output_bfd)
- != (bfd_size_type) (outsym - finfo->outsyms)))
+ file_ptr pos;
+ bfd_size_type amt;
+
+ pos = obj_sym_filepos (output_bfd) + syment_base * osymesz;
+ amt = outsym - finfo->outsyms;
+ if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (finfo->outsyms, amt, output_bfd) != amt)
return false;
BFD_ASSERT ((obj_raw_syment_count (output_bfd)
/* Write out the modified section contents. */
if (secdata == NULL || secdata->stab_info == NULL)
{
+ file_ptr loc = o->output_offset * bfd_octets_per_byte (output_bfd);
+ bfd_size_type amt = (o->_cooked_size != 0
+ ? o->_cooked_size : o->_raw_size);
if (! bfd_set_section_contents (output_bfd, o->output_section,
- contents,
- (file_ptr)
- (o->output_offset *
- bfd_octets_per_byte (output_bfd)),
- (o->_cooked_size != 0
- ? o->_cooked_size
- : o->_raw_size)))
+ contents, loc, amt))
return false;
}
else
struct internal_syment isym;
bfd_size_type symesz;
unsigned int i;
+ file_ptr pos;
output_bfd = finfo->output_bfd;
symesz = bfd_coff_symesz (output_bfd);
- if (bfd_seek (output_bfd,
- (obj_sym_filepos (output_bfd)
- + obj_raw_syment_count (output_bfd) * symesz),
- SEEK_SET) != 0
- || bfd_write (finfo->outsyms, symesz, 1, output_bfd) != symesz)
+ pos = obj_sym_filepos (output_bfd);
+ pos += obj_raw_syment_count (output_bfd) * symesz;
+ if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (finfo->outsyms, symesz, output_bfd) != symesz)
{
finfo->failed = true;
return false;
}
bfd_coff_swap_aux_out (output_bfd, (PTR) auxp, isym.n_type,
- isym.n_sclass, i, isym.n_numaux,
+ isym.n_sclass, (int) i, isym.n_numaux,
(PTR) finfo->outsyms);
- if (bfd_write (finfo->outsyms, symesz, 1, output_bfd) != symesz)
+ if (bfd_bwrite (finfo->outsyms, symesz, output_bfd) != symesz)
{
finfo->failed = true;
return false;
bfd_byte *buf;
bfd_reloc_status_type rstat;
boolean ok;
+ file_ptr loc;
size = bfd_get_reloc_size (howto);
buf = (bfd_byte *) bfd_zmalloc (size);
return false;
rstat = _bfd_relocate_contents (howto, output_bfd,
- link_order->u.reloc.p->addend, buf);
+ (bfd_vma) link_order->u.reloc.p->addend,\
+ buf);
switch (rstat)
{
case bfd_reloc_ok:
}
break;
}
+ loc = link_order->offset * bfd_octets_per_byte (output_bfd);
ok = bfd_set_section_contents (output_bfd, output_section, (PTR) buf,
- (file_ptr)
- (link_order->offset *
- bfd_octets_per_byte (output_bfd)), size);
+ loc, size);
free (buf);
if (! ok)
return false;
/* Generic COFF swapping routines, for BFD.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000,
+ 2001
Free Software Foundation, Inc.
Written by Cygnus Support.
Any file which uses this must first include "coff/internal.h" and
"coff/CPU.h". The functions will then be correct for that CPU. */
-#define PUTWORD bfd_h_put_32
-#define PUTHALF bfd_h_put_16
-#define PUTBYTE bfd_h_put_8
-
#ifndef GET_FCN_LNNOPTR
-#define GET_FCN_LNNOPTR(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
+#define GET_FCN_LNNOPTR(abfd, ext) \
+ H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
#endif
#ifndef GET_FCN_ENDNDX
-#define GET_FCN_ENDNDX(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
+#define GET_FCN_ENDNDX(abfd, ext) \
+ H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx)
#endif
#ifndef PUT_FCN_LNNOPTR
-#define PUT_FCN_LNNOPTR(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
+#define PUT_FCN_LNNOPTR(abfd, in, ext) \
+ H_PUT_32 (abfd, in, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
#endif
#ifndef PUT_FCN_ENDNDX
-#define PUT_FCN_ENDNDX(abfd, in, ext) PUTWORD(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
+#define PUT_FCN_ENDNDX(abfd, in, ext) \
+ H_PUT_32 (abfd, in, ext->x_sym.x_fcnary.x_fcn.x_endndx)
#endif
#ifndef GET_LNSZ_LNNO
-#define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
+#define GET_LNSZ_LNNO(abfd, ext) \
+ H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_lnno)
#endif
#ifndef GET_LNSZ_SIZE
-#define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
+#define GET_LNSZ_SIZE(abfd, ext) \
+ H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_size)
#endif
#ifndef PUT_LNSZ_LNNO
-#define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno)
+#define PUT_LNSZ_LNNO(abfd, in, ext) \
+ H_PUT_16 (abfd, in, ext->x_sym.x_misc.x_lnsz.x_lnno)
#endif
#ifndef PUT_LNSZ_SIZE
-#define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size)
+#define PUT_LNSZ_SIZE(abfd, in, ext) \
+ H_PUT_16 (abfd, in, ext->x_sym.x_misc.x_lnsz.x_size)
#endif
#ifndef GET_SCN_SCNLEN
-#define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen)
+#define GET_SCN_SCNLEN(abfd, ext) \
+ H_GET_32 (abfd, ext->x_scn.x_scnlen)
#endif
#ifndef GET_SCN_NRELOC
-#define GET_SCN_NRELOC(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc)
+#define GET_SCN_NRELOC(abfd, ext) \
+ H_GET_16 (abfd, ext->x_scn.x_nreloc)
#endif
#ifndef GET_SCN_NLINNO
-#define GET_SCN_NLINNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno)
+#define GET_SCN_NLINNO(abfd, ext) \
+ H_GET_16 (abfd, ext->x_scn.x_nlinno)
#endif
#ifndef PUT_SCN_SCNLEN
-#define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen)
+#define PUT_SCN_SCNLEN(abfd, in, ext) \
+ H_PUT_32 (abfd, in, ext->x_scn.x_scnlen)
#endif
#ifndef PUT_SCN_NRELOC
-#define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc)
+#define PUT_SCN_NRELOC(abfd, in, ext) \
+ H_PUT_16 (abfd, in, ext->x_scn.x_nreloc)
#endif
#ifndef PUT_SCN_NLINNO
-#define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_16(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno)
+#define PUT_SCN_NLINNO(abfd, in, ext) \
+ H_PUT_16 (abfd, in, ext->x_scn.x_nlinno)
#endif
#ifndef GET_LINENO_LNNO
-#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
+#define GET_LINENO_LNNO(abfd, ext) \
+ H_GET_16 (abfd, ext->l_lnno);
#endif
#ifndef PUT_LINENO_LNNO
-#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
+#define PUT_LINENO_LNNO(abfd, val, ext) \
+ H_PUT_16 (abfd, val, ext->l_lnno);
#endif
/* The f_symptr field in the filehdr is sometimes 64 bits. */
#ifndef GET_FILEHDR_SYMPTR
-#define GET_FILEHDR_SYMPTR bfd_h_get_32
+#define GET_FILEHDR_SYMPTR H_GET_32
#endif
#ifndef PUT_FILEHDR_SYMPTR
-#define PUT_FILEHDR_SYMPTR bfd_h_put_32
+#define PUT_FILEHDR_SYMPTR H_PUT_32
#endif
/* Some fields in the aouthdr are sometimes 64 bits. */
#ifndef GET_AOUTHDR_TSIZE
-#define GET_AOUTHDR_TSIZE bfd_h_get_32
+#define GET_AOUTHDR_TSIZE H_GET_32
#endif
#ifndef PUT_AOUTHDR_TSIZE
-#define PUT_AOUTHDR_TSIZE bfd_h_put_32
+#define PUT_AOUTHDR_TSIZE H_PUT_32
#endif
#ifndef GET_AOUTHDR_DSIZE
-#define GET_AOUTHDR_DSIZE bfd_h_get_32
+#define GET_AOUTHDR_DSIZE H_GET_32
#endif
#ifndef PUT_AOUTHDR_DSIZE
-#define PUT_AOUTHDR_DSIZE bfd_h_put_32
+#define PUT_AOUTHDR_DSIZE H_PUT_32
#endif
#ifndef GET_AOUTHDR_BSIZE
-#define GET_AOUTHDR_BSIZE bfd_h_get_32
+#define GET_AOUTHDR_BSIZE H_GET_32
#endif
#ifndef PUT_AOUTHDR_BSIZE
-#define PUT_AOUTHDR_BSIZE bfd_h_put_32
+#define PUT_AOUTHDR_BSIZE H_PUT_32
#endif
#ifndef GET_AOUTHDR_ENTRY
-#define GET_AOUTHDR_ENTRY bfd_h_get_32
+#define GET_AOUTHDR_ENTRY H_GET_32
#endif
#ifndef PUT_AOUTHDR_ENTRY
-#define PUT_AOUTHDR_ENTRY bfd_h_put_32
+#define PUT_AOUTHDR_ENTRY H_PUT_32
#endif
#ifndef GET_AOUTHDR_TEXT_START
-#define GET_AOUTHDR_TEXT_START bfd_h_get_32
+#define GET_AOUTHDR_TEXT_START H_GET_32
#endif
#ifndef PUT_AOUTHDR_TEXT_START
-#define PUT_AOUTHDR_TEXT_START bfd_h_put_32
+#define PUT_AOUTHDR_TEXT_START H_PUT_32
#endif
#ifndef GET_AOUTHDR_DATA_START
-#define GET_AOUTHDR_DATA_START bfd_h_get_32
+#define GET_AOUTHDR_DATA_START H_GET_32
#endif
#ifndef PUT_AOUTHDR_DATA_START
-#define PUT_AOUTHDR_DATA_START bfd_h_put_32
+#define PUT_AOUTHDR_DATA_START H_PUT_32
#endif
/* Some fields in the scnhdr are sometimes 64 bits. */
#ifndef GET_SCNHDR_PADDR
-#define GET_SCNHDR_PADDR bfd_h_get_32
+#define GET_SCNHDR_PADDR H_GET_32
#endif
#ifndef PUT_SCNHDR_PADDR
-#define PUT_SCNHDR_PADDR bfd_h_put_32
+#define PUT_SCNHDR_PADDR H_PUT_32
#endif
#ifndef GET_SCNHDR_VADDR
-#define GET_SCNHDR_VADDR bfd_h_get_32
+#define GET_SCNHDR_VADDR H_GET_32
#endif
#ifndef PUT_SCNHDR_VADDR
-#define PUT_SCNHDR_VADDR bfd_h_put_32
+#define PUT_SCNHDR_VADDR H_PUT_32
#endif
#ifndef GET_SCNHDR_SIZE
-#define GET_SCNHDR_SIZE bfd_h_get_32
+#define GET_SCNHDR_SIZE H_GET_32
#endif
#ifndef PUT_SCNHDR_SIZE
-#define PUT_SCNHDR_SIZE bfd_h_put_32
+#define PUT_SCNHDR_SIZE H_PUT_32
#endif
#ifndef GET_SCNHDR_SCNPTR
-#define GET_SCNHDR_SCNPTR bfd_h_get_32
+#define GET_SCNHDR_SCNPTR H_GET_32
#endif
#ifndef PUT_SCNHDR_SCNPTR
-#define PUT_SCNHDR_SCNPTR bfd_h_put_32
+#define PUT_SCNHDR_SCNPTR H_PUT_32
#endif
#ifndef GET_SCNHDR_RELPTR
-#define GET_SCNHDR_RELPTR bfd_h_get_32
+#define GET_SCNHDR_RELPTR H_GET_32
#endif
#ifndef PUT_SCNHDR_RELPTR
-#define PUT_SCNHDR_RELPTR bfd_h_put_32
+#define PUT_SCNHDR_RELPTR H_PUT_32
#endif
#ifndef GET_SCNHDR_LNNOPTR
-#define GET_SCNHDR_LNNOPTR bfd_h_get_32
+#define GET_SCNHDR_LNNOPTR H_GET_32
#endif
#ifndef PUT_SCNHDR_LNNOPTR
-#define PUT_SCNHDR_LNNOPTR bfd_h_put_32
+#define PUT_SCNHDR_LNNOPTR H_PUT_32
#endif
#ifndef GET_SCNHDR_NRELOC
-#define GET_SCNHDR_NRELOC bfd_h_get_16
+#define GET_SCNHDR_NRELOC H_GET_16
#endif
#ifndef MAX_SCNHDR_NRELOC
#define MAX_SCNHDR_NRELOC 0xffff
#endif
#ifndef PUT_SCNHDR_NRELOC
-#define PUT_SCNHDR_NRELOC bfd_h_put_16
+#define PUT_SCNHDR_NRELOC H_PUT_16
#endif
#ifndef GET_SCNHDR_NLNNO
-#define GET_SCNHDR_NLNNO bfd_h_get_16
+#define GET_SCNHDR_NLNNO H_GET_16
#endif
#ifndef MAX_SCNHDR_NLNNO
#define MAX_SCNHDR_NLNNO 0xffff
#endif
#ifndef PUT_SCNHDR_NLNNO
-#define PUT_SCNHDR_NLNNO bfd_h_put_16
+#define PUT_SCNHDR_NLNNO H_PUT_16
#endif
#ifndef GET_SCNHDR_FLAGS
-#define GET_SCNHDR_FLAGS bfd_h_get_32
+#define GET_SCNHDR_FLAGS H_GET_32
#endif
#ifndef PUT_SCNHDR_FLAGS
-#define PUT_SCNHDR_FLAGS bfd_h_put_32
+#define PUT_SCNHDR_FLAGS H_PUT_32
#endif
#ifndef GET_RELOC_VADDR
-#define GET_RELOC_VADDR bfd_h_get_32
+#define GET_RELOC_VADDR H_GET_32
#endif
#ifndef PUT_RELOC_VADDR
-#define PUT_RELOC_VADDR bfd_h_put_32
+#define PUT_RELOC_VADDR H_PUT_32
#endif
static void coff_swap_aouthdr_in PARAMS ((bfd *, PTR, PTR));
RELOC *reloc_src = (RELOC *) src;
struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
- reloc_dst->r_vaddr = GET_RELOC_VADDR (abfd, (bfd_byte *)reloc_src->r_vaddr);
- reloc_dst->r_symndx = bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx);
+ reloc_dst->r_vaddr = GET_RELOC_VADDR (abfd, reloc_src->r_vaddr);
+ reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx);
#ifdef RS6000COFF_C
- reloc_dst->r_type = bfd_h_get_8(abfd, reloc_src->r_type);
- reloc_dst->r_size = bfd_h_get_8(abfd, reloc_src->r_size);
+ reloc_dst->r_type = H_GET_8 (abfd, reloc_src->r_type);
+ reloc_dst->r_size = H_GET_8 (abfd, reloc_src->r_size);
#else
- reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
+ reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type);
#endif
#ifdef SWAP_IN_RELOC_OFFSET
- reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
- (bfd_byte *) reloc_src->r_offset);
+ reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset);
#endif
}
static unsigned int
coff_swap_reloc_out (abfd, src, dst)
- bfd *abfd;
- PTR src;
- PTR dst;
+ bfd *abfd;
+ PTR src;
+ PTR dst;
{
- struct internal_reloc *reloc_src = (struct internal_reloc *)src;
- struct external_reloc *reloc_dst = (struct external_reloc *)dst;
- PUT_RELOC_VADDR (abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
- bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
+ struct internal_reloc *reloc_src = (struct internal_reloc *) src;
+ struct external_reloc *reloc_dst = (struct external_reloc *) dst;
+ PUT_RELOC_VADDR (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
+ H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
#ifdef RS6000COFF_C
- bfd_h_put_8 (abfd, reloc_src->r_type, (bfd_byte *) reloc_dst->r_type);
- bfd_h_put_8 (abfd, reloc_src->r_size, (bfd_byte *) reloc_dst->r_size);
+ H_PUT_8 (abfd, reloc_src->r_type, reloc_dst->r_type);
+ H_PUT_8 (abfd, reloc_src->r_size, reloc_dst->r_size);
#else
- bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
- reloc_dst->r_type);
+ H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type);
#endif
#ifdef SWAP_OUT_RELOC_OFFSET
- SWAP_OUT_RELOC_OFFSET(abfd,
- reloc_src->r_offset,
- (bfd_byte *) reloc_dst->r_offset);
+ SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset);
#endif
#ifdef SWAP_OUT_RELOC_EXTRA
- SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
+ SWAP_OUT_RELOC_EXTRA (abfd, reloc_src, reloc_dst);
#endif
return bfd_coff_relsz (abfd);
static void
coff_swap_filehdr_in (abfd, src, dst)
- bfd *abfd;
- PTR src;
- PTR dst;
+ bfd *abfd;
+ PTR src;
+ PTR dst;
{
FILHDR *filehdr_src = (FILHDR *) src;
struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
#ifdef COFF_ADJUST_FILEHDR_IN_PRE
COFF_ADJUST_FILEHDR_IN_PRE (abfd, src, dst);
#endif
- filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic);
- filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);
- filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);
- filehdr_dst->f_symptr =
- GET_FILEHDR_SYMPTR (abfd, (bfd_byte *) filehdr_src->f_symptr);
- filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
- filehdr_dst->f_opthdr = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_opthdr);
- filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
+ filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic);
+ filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src->f_nscns);
+ filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->f_timdat);
+ filehdr_dst->f_symptr = GET_FILEHDR_SYMPTR (abfd, filehdr_src->f_symptr);
+ filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->f_nsyms);
+ filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src->f_opthdr);
+ filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src->f_flags);
#ifdef TIC80_TARGET_ID
- filehdr_dst->f_target_id = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_target_id);
+ filehdr_dst->f_target_id = H_GET_16 (abfd, filehdr_src->f_target_id);
#endif
#ifdef COFF_ADJUST_FILEHDR_IN_POST
static unsigned int
coff_swap_filehdr_out (abfd, in, out)
- bfd *abfd;
- PTR in;
- PTR out;
+ bfd *abfd;
+ PTR in;
+ PTR out;
{
- struct internal_filehdr *filehdr_in = (struct internal_filehdr *)in;
- FILHDR *filehdr_out = (FILHDR *)out;
+ struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
+ FILHDR *filehdr_out = (FILHDR *) out;
#ifdef COFF_ADJUST_FILEHDR_OUT_PRE
COFF_ADJUST_FILEHDR_OUT_PRE (abfd, in, out);
#endif
- bfd_h_put_16(abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
- bfd_h_put_16(abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
- bfd_h_put_32(abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
- PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
- (bfd_byte *) filehdr_out->f_symptr);
- bfd_h_put_32(abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
- bfd_h_put_16(abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
- bfd_h_put_16(abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
+ H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic);
+ H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
+ H_PUT_32 (abfd, filehdr_in->f_timdat, filehdr_out->f_timdat);
+ PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, filehdr_out->f_symptr);
+ H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
+ H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
+ H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags);
#ifdef TIC80_TARGET_ID
- bfd_h_put_16(abfd, filehdr_in->f_target_id, (bfd_byte *) filehdr_out->f_target_id);
+ H_PUT_16 (abfd, filehdr_in->f_target_id, filehdr_out->f_target_id);
#endif
#ifdef COFF_ADJUST_FILEHDR_OUT_POST
static void
coff_swap_sym_in (abfd, ext1, in1)
- bfd *abfd;
+ bfd *abfd;
PTR ext1;
PTR in1;
{
- SYMENT *ext = (SYMENT *)ext1;
- struct internal_syment *in = (struct internal_syment *)in1;
-
- if( ext->e.e_name[0] == 0) {
- in->_n._n_n._n_zeroes = 0;
- in->_n._n_n._n_offset = bfd_h_get_32(abfd, (bfd_byte *) ext->e.e.e_offset);
- }
- else {
+ SYMENT *ext = (SYMENT *) ext1;
+ struct internal_syment *in = (struct internal_syment *) in1;
+
+ if (ext->e.e_name[0] == 0)
+ {
+ in->_n._n_n._n_zeroes = 0;
+ in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset);
+ }
+ else
+ {
#if SYMNMLEN != E_SYMNMLEN
- -> Error, we need to cope with truncating or extending SYMNMLEN!;
+ -> Error, we need to cope with truncating or extending SYMNMLEN!;
#else
- memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
-#endif
- }
- in->n_value = bfd_h_get_32(abfd, (bfd_byte *) ext->e_value);
- in->n_scnum = bfd_h_get_16(abfd, (bfd_byte *) ext->e_scnum);
- if (sizeof (ext->e_type) == 2){
- in->n_type = bfd_h_get_16(abfd, (bfd_byte *) ext->e_type);
- }
- else {
- in->n_type = bfd_h_get_32(abfd, (bfd_byte *) ext->e_type);
- }
- in->n_sclass = bfd_h_get_8(abfd, ext->e_sclass);
- in->n_numaux = bfd_h_get_8(abfd, ext->e_numaux);
+ memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
+#endif
+ }
+ in->n_value = H_GET_32 (abfd, ext->e_value);
+ in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
+ if (sizeof (ext->e_type) == 2)
+ {
+ in->n_type = H_GET_16 (abfd, ext->e_type);
+ }
+ else
+ {
+ in->n_type = H_GET_32 (abfd, ext->e_type);
+ }
+ in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
+ in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
#ifdef COFF_ADJUST_SYM_IN_POST
COFF_ADJUST_SYM_IN_POST (abfd, ext1, in1);
#endif
static unsigned int
coff_swap_sym_out (abfd, inp, extp)
- bfd *abfd;
- PTR inp;
- PTR extp;
+ bfd *abfd;
+ PTR inp;
+ PTR extp;
{
- struct internal_syment *in = (struct internal_syment *)inp;
- SYMENT *ext =(SYMENT *)extp;
- if(in->_n._n_name[0] == 0) {
- bfd_h_put_32(abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
- bfd_h_put_32(abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
- }
- else {
+ struct internal_syment *in = (struct internal_syment *) inp;
+ SYMENT *ext =(SYMENT *) extp;
+ if(in->_n._n_name[0] == 0)
+ {
+ H_PUT_32 (abfd, 0, ext->e.e.e_zeroes);
+ H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e.e.e_offset);
+ }
+ else
+ {
#if SYMNMLEN != E_SYMNMLEN
- -> Error, we need to cope with truncating or extending SYMNMLEN!;
+ -> Error, we need to cope with truncating or extending SYMNMLEN!;
#else
- memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
+ memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
#endif
- }
- bfd_h_put_32(abfd, in->n_value , (bfd_byte *) ext->e_value);
- bfd_h_put_16(abfd, in->n_scnum , (bfd_byte *) ext->e_scnum);
+ }
+ H_PUT_32 (abfd, in->n_value, ext->e_value);
+ H_PUT_16 (abfd, in->n_scnum, ext->e_scnum);
if (sizeof (ext->e_type) == 2)
- {
- bfd_h_put_16(abfd, in->n_type , (bfd_byte *) ext->e_type);
- }
+ {
+ H_PUT_16 (abfd, in->n_type, ext->e_type);
+ }
else
- {
- bfd_h_put_32(abfd, in->n_type , (bfd_byte *) ext->e_type);
- }
- bfd_h_put_8(abfd, in->n_sclass , ext->e_sclass);
- bfd_h_put_8(abfd, in->n_numaux , ext->e_numaux);
+ {
+ H_PUT_32 (abfd, in->n_type, ext->e_type);
+ }
+ H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
+ H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
#ifdef COFF_ADJUST_SYM_OUT_POST
COFF_ADJUST_SYM_OUT_POST (abfd, inp, extp);
#endif
static void
coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1)
- bfd *abfd;
- PTR ext1;
- int type;
- int class;
- int indx;
- int numaux;
- PTR in1;
+ bfd *abfd;
+ PTR ext1;
+ int type;
+ int class;
+ int indx;
+ int numaux;
+ PTR in1;
{
- AUXENT *ext = (AUXENT *)ext1;
- union internal_auxent *in = (union internal_auxent *)in1;
+ AUXENT *ext = (AUXENT *) ext1;
+ union internal_auxent *in = (union internal_auxent *) in1;
#ifdef COFF_ADJUST_AUX_IN_PRE
COFF_ADJUST_AUX_IN_PRE (abfd, ext1, type, class, indx, numaux, in1);
#endif
- switch (class) {
+ switch (class)
+ {
case C_FILE:
- if (ext->x_file.x_fname[0] == 0) {
+ if (ext->x_file.x_fname[0] == 0)
+ {
in->x_file.x_n.x_zeroes = 0;
- in->x_file.x_n.x_offset =
- bfd_h_get_32(abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
- } else {
+ in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
+ }
+ else
+ {
#if FILNMLEN != E_FILNMLEN
- -> Error, we need to cope with truncating or extending FILNMLEN!;
+ -> Error, we need to cope with truncating or extending FILNMLEN!;
#else
- if (numaux > 1)
- {
- if (indx == 0)
- memcpy (in->x_file.x_fname, ext->x_file.x_fname,
- numaux * sizeof (AUXENT));
- }
- else
- {
- memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
- }
-#endif
- }
+ if (numaux > 1)
+ {
+ if (indx == 0)
+ memcpy (in->x_file.x_fname, ext->x_file.x_fname,
+ numaux * sizeof (AUXENT));
+ }
+ else
+ {
+ memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
+ }
+#endif
+ }
goto end;
case C_STAT:
case C_LEAFSTAT:
#endif
case C_HIDDEN:
- if (type == T_NULL) {
- in->x_scn.x_scnlen = GET_SCN_SCNLEN(abfd, ext);
- in->x_scn.x_nreloc = GET_SCN_NRELOC(abfd, ext);
- in->x_scn.x_nlinno = GET_SCN_NLINNO(abfd, ext);
+ if (type == T_NULL)
+ {
+ in->x_scn.x_scnlen = GET_SCN_SCNLEN (abfd, ext);
+ in->x_scn.x_nreloc = GET_SCN_NRELOC (abfd, ext);
+ in->x_scn.x_nlinno = GET_SCN_NLINNO (abfd, ext);
/* PE defines some extra fields; we zero them out for
safety. */
break;
}
- in->x_sym.x_tagndx.l = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_tagndx);
+ in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->x_sym.x_tagndx);
#ifndef NO_TVNDX
- in->x_sym.x_tvndx = bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_tvndx);
+ in->x_sym.x_tvndx = H_GET_16 (abfd, ext->x_sym.x_tvndx);
#endif
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
else
{
#if DIMNUM != E_DIMNUM
- #error we need to cope with truncating or extending DIMNUM
+#error we need to cope with truncating or extending DIMNUM
#endif
in->x_sym.x_fcnary.x_ary.x_dimen[0] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+ H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
in->x_sym.x_fcnary.x_ary.x_dimen[1] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+ H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
in->x_sym.x_fcnary.x_ary.x_dimen[2] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+ H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
in->x_sym.x_fcnary.x_ary.x_dimen[3] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+ H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
}
- if (ISFCN(type)) {
- in->x_sym.x_misc.x_fsize = bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
- }
- else {
- in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO(abfd, ext);
- in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE(abfd, ext);
- }
+ if (ISFCN(type))
+ {
+ in->x_sym.x_misc.x_fsize = H_GET_32 (abfd, ext->x_sym.x_misc.x_fsize);
+ }
+ else
+ {
+ in->x_sym.x_misc.x_lnsz.x_lnno = GET_LNSZ_LNNO (abfd, ext);
+ in->x_sym.x_misc.x_lnsz.x_size = GET_LNSZ_SIZE (abfd, ext);
+ }
-end: ;
- /* the semicolon is because MSVC doesn't like labels at
- end of block. */
+ end: ;
#ifdef COFF_ADJUST_AUX_IN_POST
COFF_ADJUST_AUX_IN_POST (abfd, ext1, type, class, indx, numaux, in1);
static unsigned int
coff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp)
- bfd *abfd;
- PTR inp;
- int type;
- int class;
- int indx ATTRIBUTE_UNUSED;
- int numaux ATTRIBUTE_UNUSED;
- PTR extp;
+ bfd *abfd;
+ PTR inp;
+ int type;
+ int class;
+ int indx ATTRIBUTE_UNUSED;
+ int numaux ATTRIBUTE_UNUSED;
+ PTR extp;
{
- union internal_auxent *in = (union internal_auxent *)inp;
- AUXENT *ext = (AUXENT *)extp;
+ union internal_auxent *in = (union internal_auxent *) inp;
+ AUXENT *ext = (AUXENT *) extp;
#ifdef COFF_ADJUST_AUX_OUT_PRE
COFF_ADJUST_AUX_OUT_PRE (abfd, inp, type, class, indx, numaux, extp);
#endif
memset((PTR)ext, 0, AUXESZ);
- switch (class) {
- case C_FILE:
- if (in->x_file.x_fname[0] == 0) {
- PUTWORD(abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
- PUTWORD(abfd,
- in->x_file.x_n.x_offset,
- (bfd_byte *) ext->x_file.x_n.x_offset);
- }
- else {
+ switch (class)
+ {
+ case C_FILE:
+ if (in->x_file.x_fname[0] == 0)
+ {
+ H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
+ H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
+ }
+ else
+ {
#if FILNMLEN != E_FILNMLEN
- -> Error, we need to cope with truncating or extending FILNMLEN!;
+ -> Error, we need to cope with truncating or extending FILNMLEN!;
#else
- memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
+ memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
#endif
- }
- goto end;
+ }
+ goto end;
- case C_STAT:
+ case C_STAT:
#ifdef C_LEAFSTAT
- case C_LEAFSTAT:
+ case C_LEAFSTAT:
#endif
- case C_HIDDEN:
- if (type == T_NULL) {
- PUT_SCN_SCNLEN(abfd, in->x_scn.x_scnlen, ext);
- PUT_SCN_NRELOC(abfd, in->x_scn.x_nreloc, ext);
- PUT_SCN_NLINNO(abfd, in->x_scn.x_nlinno, ext);
- goto end;
+ case C_HIDDEN:
+ if (type == T_NULL)
+ {
+ PUT_SCN_SCNLEN (abfd, in->x_scn.x_scnlen, ext);
+ PUT_SCN_NRELOC (abfd, in->x_scn.x_nreloc, ext);
+ PUT_SCN_NLINNO (abfd, in->x_scn.x_nlinno, ext);
+ goto end;
+ }
+ break;
}
- break;
- }
- PUTWORD(abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
+ H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->x_sym.x_tagndx);
#ifndef NO_TVNDX
- bfd_h_put_16(abfd, in->x_sym.x_tvndx , (bfd_byte *) ext->x_sym.x_tvndx);
+ H_PUT_16 (abfd, in->x_sym.x_tvndx, ext->x_sym.x_tvndx);
#endif
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
{
- PUT_FCN_LNNOPTR(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
- PUT_FCN_ENDNDX(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
+ PUT_FCN_LNNOPTR (abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext);
+ PUT_FCN_ENDNDX (abfd, in->x_sym.x_fcnary.x_fcn.x_endndx.l, ext);
}
else
{
#if DIMNUM != E_DIMNUM
- #error we need to cope with truncating or extending DIMNUM
-#endif
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+#error we need to cope with truncating or extending DIMNUM
+#endif
+ H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
+ ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+ H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
+ ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+ H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
+ ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+ H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
+ ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
}
if (ISFCN (type))
- PUTWORD (abfd, in->x_sym.x_misc.x_fsize,
- (bfd_byte *) ext->x_sym.x_misc.x_fsize);
+ H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize);
else
{
PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
PUT_LNSZ_SIZE (abfd, in->x_sym.x_misc.x_lnsz.x_size, ext);
}
-end:
+ end:
#ifdef COFF_ADJUST_AUX_OUT_POST
COFF_ADJUST_AUX_OUT_POST (abfd, inp, type, class, indx, numaux, extp);
#endif
static void
coff_swap_lineno_in (abfd, ext1, in1)
- bfd *abfd;
+ bfd *abfd;
PTR ext1;
PTR in1;
{
- LINENO *ext = (LINENO *)ext1;
- struct internal_lineno *in = (struct internal_lineno *)in1;
+ LINENO *ext = (LINENO *) ext1;
+ struct internal_lineno *in = (struct internal_lineno *) in1;
- in->l_addr.l_symndx = bfd_h_get_32(abfd, (bfd_byte *) ext->l_addr.l_symndx);
- in->l_lnno = GET_LINENO_LNNO(abfd, ext);
+ in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx);
+ in->l_lnno = GET_LINENO_LNNO (abfd, ext);
}
static unsigned int
coff_swap_lineno_out (abfd, inp, outp)
- bfd *abfd;
- PTR inp;
- PTR outp;
+ bfd *abfd;
+ PTR inp;
+ PTR outp;
{
- struct internal_lineno *in = (struct internal_lineno *)inp;
- struct external_lineno *ext = (struct external_lineno *)outp;
- PUTWORD(abfd, in->l_addr.l_symndx, (bfd_byte *)
- ext->l_addr.l_symndx);
+ struct internal_lineno *in = (struct internal_lineno *) inp;
+ struct external_lineno *ext = (struct external_lineno *) outp;
+ H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
return LINESZ;
static void
coff_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1)
- bfd *abfd;
+ bfd *abfd;
PTR aouthdr_ext1;
PTR aouthdr_int1;
{
- AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
- struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
-
- aouthdr_int->magic = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->magic);
- aouthdr_int->vstamp = bfd_h_get_16(abfd, (bfd_byte *) aouthdr_ext->vstamp);
- aouthdr_int->tsize =
- GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize);
- aouthdr_int->dsize =
- GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize);
- aouthdr_int->bsize =
- GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize);
- aouthdr_int->entry =
- GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry);
+ AOUTHDR *aouthdr_ext;
+ struct internal_aouthdr *aouthdr_int;
+
+ aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
+ aouthdr_int = (struct internal_aouthdr *) aouthdr_int1;
+ aouthdr_int->magic = H_GET_16 (abfd, aouthdr_ext->magic);
+ aouthdr_int->vstamp = H_GET_16 (abfd, aouthdr_ext->vstamp);
+ aouthdr_int->tsize = GET_AOUTHDR_TSIZE (abfd, aouthdr_ext->tsize);
+ aouthdr_int->dsize = GET_AOUTHDR_DSIZE (abfd, aouthdr_ext->dsize);
+ aouthdr_int->bsize = GET_AOUTHDR_BSIZE (abfd, aouthdr_ext->bsize);
+ aouthdr_int->entry = GET_AOUTHDR_ENTRY (abfd, aouthdr_ext->entry);
aouthdr_int->text_start =
- GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start);
+ GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start);
aouthdr_int->data_start =
- GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start);
+ GET_AOUTHDR_DATA_START (abfd, aouthdr_ext->data_start);
#ifdef I960
- aouthdr_int->tagentries = bfd_h_get_32(abfd, (bfd_byte *) aouthdr_ext->tagentries);
+ aouthdr_int->tagentries = H_GET_32 (abfd, aouthdr_ext->tagentries);
#endif
#ifdef APOLLO_M68
- bfd_h_put_32(abfd, aouthdr_int->o_inlib, (bfd_byte *) aouthdr_ext->o_inlib);
- bfd_h_put_32(abfd, aouthdr_int->o_sri, (bfd_byte *) aouthdr_ext->o_sri);
- bfd_h_put_32(abfd, aouthdr_int->vid[0], (bfd_byte *) aouthdr_ext->vid);
- bfd_h_put_32(abfd, aouthdr_int->vid[1], (bfd_byte *) aouthdr_ext->vid + 4);
+ H_PUT_32 (abfd, aouthdr_int->o_inlib, aouthdr_ext->o_inlib);
+ H_PUT_32 (abfd, aouthdr_int->o_sri, aouthdr_ext->o_sri);
+ H_PUT_32 (abfd, aouthdr_int->vid[0], aouthdr_ext->vid);
+ H_PUT_32 (abfd, aouthdr_int->vid[1], aouthdr_ext->vid + 4);
#endif
#ifdef RS6000COFF_C
#ifdef XCOFF64
- aouthdr_int->o_toc = bfd_h_get_64(abfd, aouthdr_ext->o_toc);
+ aouthdr_int->o_toc = H_GET_64 (abfd, aouthdr_ext->o_toc);
#else
- aouthdr_int->o_toc = bfd_h_get_32(abfd, aouthdr_ext->o_toc);
-#endif
- aouthdr_int->o_snentry = bfd_h_get_16(abfd, aouthdr_ext->o_snentry);
- aouthdr_int->o_sntext = bfd_h_get_16(abfd, aouthdr_ext->o_sntext);
- aouthdr_int->o_sndata = bfd_h_get_16(abfd, aouthdr_ext->o_sndata);
- aouthdr_int->o_sntoc = bfd_h_get_16(abfd, aouthdr_ext->o_sntoc);
- aouthdr_int->o_snloader = bfd_h_get_16(abfd, aouthdr_ext->o_snloader);
- aouthdr_int->o_snbss = bfd_h_get_16(abfd, aouthdr_ext->o_snbss);
- aouthdr_int->o_algntext = bfd_h_get_16(abfd, aouthdr_ext->o_algntext);
- aouthdr_int->o_algndata = bfd_h_get_16(abfd, aouthdr_ext->o_algndata);
- aouthdr_int->o_modtype = bfd_h_get_16(abfd, aouthdr_ext->o_modtype);
- aouthdr_int->o_cputype = bfd_h_get_16(abfd, aouthdr_ext->o_cputype);
+ aouthdr_int->o_toc = H_GET_32 (abfd, aouthdr_ext->o_toc);
+#endif
+ aouthdr_int->o_snentry = H_GET_16 (abfd, aouthdr_ext->o_snentry);
+ aouthdr_int->o_sntext = H_GET_16 (abfd, aouthdr_ext->o_sntext);
+ aouthdr_int->o_sndata = H_GET_16 (abfd, aouthdr_ext->o_sndata);
+ aouthdr_int->o_sntoc = H_GET_16 (abfd, aouthdr_ext->o_sntoc);
+ aouthdr_int->o_snloader = H_GET_16 (abfd, aouthdr_ext->o_snloader);
+ aouthdr_int->o_snbss = H_GET_16 (abfd, aouthdr_ext->o_snbss);
+ aouthdr_int->o_algntext = H_GET_16 (abfd, aouthdr_ext->o_algntext);
+ aouthdr_int->o_algndata = H_GET_16 (abfd, aouthdr_ext->o_algndata);
+ aouthdr_int->o_modtype = H_GET_16 (abfd, aouthdr_ext->o_modtype);
+ aouthdr_int->o_cputype = H_GET_16 (abfd, aouthdr_ext->o_cputype);
#ifdef XCOFF64
- aouthdr_int->o_maxstack = bfd_h_get_64(abfd, aouthdr_ext->o_maxstack);
- aouthdr_int->o_maxdata = bfd_h_get_64(abfd, aouthdr_ext->o_maxdata);
+ aouthdr_int->o_maxstack = H_GET_64 (abfd, aouthdr_ext->o_maxstack);
+ aouthdr_int->o_maxdata = H_GET_64 (abfd, aouthdr_ext->o_maxdata);
#else
- aouthdr_int->o_maxstack = bfd_h_get_32(abfd, aouthdr_ext->o_maxstack);
- aouthdr_int->o_maxdata = bfd_h_get_32(abfd, aouthdr_ext->o_maxdata);
+ aouthdr_int->o_maxstack = H_GET_32 (abfd, aouthdr_ext->o_maxstack);
+ aouthdr_int->o_maxdata = H_GET_32 (abfd, aouthdr_ext->o_maxdata);
#endif
#endif
#ifdef MIPSECOFF
- aouthdr_int->bss_start = bfd_h_get_32(abfd, aouthdr_ext->bss_start);
- aouthdr_int->gp_value = bfd_h_get_32(abfd, aouthdr_ext->gp_value);
- aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
- aouthdr_int->cprmask[0] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[0]);
- aouthdr_int->cprmask[1] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[1]);
- aouthdr_int->cprmask[2] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[2]);
- aouthdr_int->cprmask[3] = bfd_h_get_32(abfd, aouthdr_ext->cprmask[3]);
+ aouthdr_int->bss_start = H_GET_32 (abfd, aouthdr_ext->bss_start);
+ aouthdr_int->gp_value = H_GET_32 (abfd, aouthdr_ext->gp_value);
+ aouthdr_int->gprmask = H_GET_32 (abfd, aouthdr_ext->gprmask);
+ aouthdr_int->cprmask[0] = H_GET_32 (abfd, aouthdr_ext->cprmask[0]);
+ aouthdr_int->cprmask[1] = H_GET_32 (abfd, aouthdr_ext->cprmask[1]);
+ aouthdr_int->cprmask[2] = H_GET_32 (abfd, aouthdr_ext->cprmask[2]);
+ aouthdr_int->cprmask[3] = H_GET_32 (abfd, aouthdr_ext->cprmask[3]);
#endif
#ifdef ALPHAECOFF
- aouthdr_int->bss_start = bfd_h_get_64(abfd, aouthdr_ext->bss_start);
- aouthdr_int->gp_value = bfd_h_get_64(abfd, aouthdr_ext->gp_value);
- aouthdr_int->gprmask = bfd_h_get_32(abfd, aouthdr_ext->gprmask);
- aouthdr_int->fprmask = bfd_h_get_32(abfd, aouthdr_ext->fprmask);
+ aouthdr_int->bss_start = H_GET_64 (abfd, aouthdr_ext->bss_start);
+ aouthdr_int->gp_value = H_GET_64 (abfd, aouthdr_ext->gp_value);
+ aouthdr_int->gprmask = H_GET_32 (abfd, aouthdr_ext->gprmask);
+ aouthdr_int->fprmask = H_GET_32 (abfd, aouthdr_ext->fprmask);
#endif
}
static unsigned int
coff_swap_aouthdr_out (abfd, in, out)
- bfd *abfd;
- PTR in;
- PTR out;
+ bfd *abfd;
+ PTR in;
+ PTR out;
{
- struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *)in;
- AOUTHDR *aouthdr_out = (AOUTHDR *)out;
-
- bfd_h_put_16(abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->magic);
- bfd_h_put_16(abfd, aouthdr_in->vstamp, (bfd_byte *) aouthdr_out->vstamp);
- PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->tsize);
- PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->dsize);
- PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->bsize);
- PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->entry);
+ struct internal_aouthdr *aouthdr_in = (struct internal_aouthdr *) in;
+ AOUTHDR *aouthdr_out = (AOUTHDR *) out;
+
+ H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->magic);
+ H_PUT_16 (abfd, aouthdr_in->vstamp, aouthdr_out->vstamp);
+ PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, aouthdr_out->tsize);
+ PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, aouthdr_out->dsize);
+ PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, aouthdr_out->bsize);
+ PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, aouthdr_out->entry);
PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
- (bfd_byte *) aouthdr_out->text_start);
+ aouthdr_out->text_start);
PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
- (bfd_byte *) aouthdr_out->data_start);
+ aouthdr_out->data_start);
#ifdef I960
- bfd_h_put_32(abfd, aouthdr_in->tagentries, (bfd_byte *) aouthdr_out->tagentries);
+ H_PUT_32 (abfd, aouthdr_in->tagentries, aouthdr_out->tagentries);
#endif
#ifdef RS6000COFF_C
#ifdef XCOFF64
- bfd_h_put_64 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
+ H_PUT_64 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
#else
- bfd_h_put_32 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
-#endif
- bfd_h_put_16 (abfd, aouthdr_in->o_snentry, aouthdr_out->o_snentry);
- bfd_h_put_16 (abfd, aouthdr_in->o_sntext, aouthdr_out->o_sntext);
- bfd_h_put_16 (abfd, aouthdr_in->o_sndata, aouthdr_out->o_sndata);
- bfd_h_put_16 (abfd, aouthdr_in->o_sntoc, aouthdr_out->o_sntoc);
- bfd_h_put_16 (abfd, aouthdr_in->o_snloader, aouthdr_out->o_snloader);
- bfd_h_put_16 (abfd, aouthdr_in->o_snbss, aouthdr_out->o_snbss);
- bfd_h_put_16 (abfd, aouthdr_in->o_algntext, aouthdr_out->o_algntext);
- bfd_h_put_16 (abfd, aouthdr_in->o_algndata, aouthdr_out->o_algndata);
- bfd_h_put_16 (abfd, aouthdr_in->o_modtype, aouthdr_out->o_modtype);
- bfd_h_put_16 (abfd, aouthdr_in->o_cputype, aouthdr_out->o_cputype);
+ H_PUT_32 (abfd, aouthdr_in->o_toc, aouthdr_out->o_toc);
+#endif
+ H_PUT_16 (abfd, aouthdr_in->o_snentry, aouthdr_out->o_snentry);
+ H_PUT_16 (abfd, aouthdr_in->o_sntext, aouthdr_out->o_sntext);
+ H_PUT_16 (abfd, aouthdr_in->o_sndata, aouthdr_out->o_sndata);
+ H_PUT_16 (abfd, aouthdr_in->o_sntoc, aouthdr_out->o_sntoc);
+ H_PUT_16 (abfd, aouthdr_in->o_snloader, aouthdr_out->o_snloader);
+ H_PUT_16 (abfd, aouthdr_in->o_snbss, aouthdr_out->o_snbss);
+ H_PUT_16 (abfd, aouthdr_in->o_algntext, aouthdr_out->o_algntext);
+ H_PUT_16 (abfd, aouthdr_in->o_algndata, aouthdr_out->o_algndata);
+ H_PUT_16 (abfd, aouthdr_in->o_modtype, aouthdr_out->o_modtype);
+ H_PUT_16 (abfd, aouthdr_in->o_cputype, aouthdr_out->o_cputype);
#ifdef XCOFF64
- bfd_h_put_64 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
- bfd_h_put_64 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
+ H_PUT_64 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
+ H_PUT_64 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
#else
- bfd_h_put_32 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
- bfd_h_put_32 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
+ H_PUT_32 (abfd, aouthdr_in->o_maxstack, aouthdr_out->o_maxstack);
+ H_PUT_32 (abfd, aouthdr_in->o_maxdata, aouthdr_out->o_maxdata);
#endif
memset (aouthdr_out->o_resv2, 0, sizeof aouthdr_out->o_resv2);
#ifdef XCOFF64
#endif
#ifdef MIPSECOFF
- bfd_h_put_32(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
- bfd_h_put_32(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
- bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
- bfd_h_put_32(abfd, aouthdr_in->cprmask[0], (bfd_byte *) aouthdr_out->cprmask[0]);
- bfd_h_put_32(abfd, aouthdr_in->cprmask[1], (bfd_byte *) aouthdr_out->cprmask[1]);
- bfd_h_put_32(abfd, aouthdr_in->cprmask[2], (bfd_byte *) aouthdr_out->cprmask[2]);
- bfd_h_put_32(abfd, aouthdr_in->cprmask[3], (bfd_byte *) aouthdr_out->cprmask[3]);
+ H_PUT_32 (abfd, aouthdr_in->bss_start, aouthdr_out->bss_start);
+ H_PUT_32 (abfd, aouthdr_in->gp_value, aouthdr_out->gp_value);
+ H_PUT_32 (abfd, aouthdr_in->gprmask, aouthdr_out->gprmask);
+ H_PUT_32 (abfd, aouthdr_in->cprmask[0], aouthdr_out->cprmask[0]);
+ H_PUT_32 (abfd, aouthdr_in->cprmask[1], aouthdr_out->cprmask[1]);
+ H_PUT_32 (abfd, aouthdr_in->cprmask[2], aouthdr_out->cprmask[2]);
+ H_PUT_32 (abfd, aouthdr_in->cprmask[3], aouthdr_out->cprmask[3]);
#endif
#ifdef ALPHAECOFF
/* FIXME: What does bldrev mean? */
- bfd_h_put_16(abfd, (bfd_vma) 2, (bfd_byte *) aouthdr_out->bldrev);
- bfd_h_put_16(abfd, (bfd_vma) 0, (bfd_byte *) aouthdr_out->padding);
- bfd_h_put_64(abfd, aouthdr_in->bss_start, (bfd_byte *) aouthdr_out->bss_start);
- bfd_h_put_64(abfd, aouthdr_in->gp_value, (bfd_byte *) aouthdr_out->gp_value);
- bfd_h_put_32(abfd, aouthdr_in->gprmask, (bfd_byte *) aouthdr_out->gprmask);
- bfd_h_put_32(abfd, aouthdr_in->fprmask, (bfd_byte *) aouthdr_out->fprmask);
+ H_PUT_16 (abfd, 2, aouthdr_out->bldrev);
+ H_PUT_16 (abfd, 0, aouthdr_out->padding);
+ H_PUT_64 (abfd, aouthdr_in->bss_start, aouthdr_out->bss_start);
+ H_PUT_64 (abfd, aouthdr_in->gp_value, aouthdr_out->gp_value);
+ H_PUT_32 (abfd, aouthdr_in->gprmask, aouthdr_out->gprmask);
+ H_PUT_32 (abfd, aouthdr_in->fprmask, aouthdr_out->fprmask);
#endif
return AOUTSZ;
static void
coff_swap_scnhdr_in (abfd, ext, in)
- bfd *abfd;
- PTR ext;
- PTR in;
+ bfd *abfd;
+ PTR ext;
+ PTR in;
{
SCNHDR *scnhdr_ext = (SCNHDR *) ext;
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
COFF_ADJUST_SCNHDR_IN_PRE (abfd, ext, in);
#endif
memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name));
- scnhdr_int->s_vaddr =
- GET_SCNHDR_VADDR (abfd, (bfd_byte *) scnhdr_ext->s_vaddr);
- scnhdr_int->s_paddr =
- GET_SCNHDR_PADDR (abfd, (bfd_byte *) scnhdr_ext->s_paddr);
- scnhdr_int->s_size =
- GET_SCNHDR_SIZE (abfd, (bfd_byte *) scnhdr_ext->s_size);
-
- scnhdr_int->s_scnptr =
- GET_SCNHDR_SCNPTR (abfd, (bfd_byte *) scnhdr_ext->s_scnptr);
- scnhdr_int->s_relptr =
- GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr);
- scnhdr_int->s_lnnoptr =
- GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
- scnhdr_int->s_flags =
- GET_SCNHDR_FLAGS (abfd, (bfd_byte *) scnhdr_ext->s_flags);
- scnhdr_int->s_nreloc =
- GET_SCNHDR_NRELOC (abfd, (bfd_byte *) scnhdr_ext->s_nreloc);
- scnhdr_int->s_nlnno =
- GET_SCNHDR_NLNNO (abfd, (bfd_byte *) scnhdr_ext->s_nlnno);
+ scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr);
+ scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr);
+ scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size);
+
+ scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr);
+ scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr);
+ scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr);
+ scnhdr_int->s_flags = GET_SCNHDR_FLAGS (abfd, scnhdr_ext->s_flags);
+ scnhdr_int->s_nreloc = GET_SCNHDR_NRELOC (abfd, scnhdr_ext->s_nreloc);
+ scnhdr_int->s_nlnno = GET_SCNHDR_NLNNO (abfd, scnhdr_ext->s_nlnno);
#ifdef I960
- scnhdr_int->s_align =
- GET_SCNHDR_ALIGN (abfd, (bfd_byte *) scnhdr_ext->s_align);
+ scnhdr_int->s_align = GET_SCNHDR_ALIGN (abfd, scnhdr_ext->s_align);
#endif
#ifdef COFF_ADJUST_SCNHDR_IN_POST
COFF_ADJUST_SCNHDR_IN_POST (abfd, ext, in);
static unsigned int
coff_swap_scnhdr_out (abfd, in, out)
- bfd *abfd;
- PTR in;
- PTR out;
+ bfd *abfd;
+ PTR in;
+ PTR out;
{
- struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *)in;
- SCNHDR *scnhdr_ext = (SCNHDR *)out;
+ struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
+ SCNHDR *scnhdr_ext = (SCNHDR *) out;
unsigned int ret = bfd_coff_scnhsz (abfd);
#ifdef COFF_ADJUST_SCNHDR_OUT_PRE
COFF_ADJUST_SCNHDR_OUT_PRE (abfd, in, out);
#endif
- memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
-
- PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr,
- (bfd_byte *) scnhdr_ext->s_vaddr);
-
- PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr,
- (bfd_byte *) scnhdr_ext->s_paddr);
- PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size,
- (bfd_byte *) scnhdr_ext->s_size);
+ memcpy (scnhdr_ext->s_name, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
- PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
- (bfd_byte *) scnhdr_ext->s_scnptr);
- PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
- (bfd_byte *) scnhdr_ext->s_relptr);
- PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
- (bfd_byte *) scnhdr_ext->s_lnnoptr);
- PUT_SCNHDR_FLAGS (abfd, scnhdr_int->s_flags,
- (bfd_byte *) scnhdr_ext->s_flags);
+ PUT_SCNHDR_VADDR (abfd, scnhdr_int->s_vaddr, scnhdr_ext->s_vaddr);
+ PUT_SCNHDR_PADDR (abfd, scnhdr_int->s_paddr, scnhdr_ext->s_paddr);
+ PUT_SCNHDR_SIZE (abfd, scnhdr_int->s_size, scnhdr_ext->s_size);
+ PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr, scnhdr_ext->s_scnptr);
+ PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr, scnhdr_ext->s_relptr);
+ PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr, scnhdr_ext->s_lnnoptr);
+ PUT_SCNHDR_FLAGS (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
#if defined(M88)
- PUTWORD(abfd, scnhdr_int->s_nlnno, (bfd_byte *) scnhdr_ext->s_nlnno);
- PUTWORD(abfd, scnhdr_int->s_nreloc, (bfd_byte *) scnhdr_ext->s_nreloc);
+ H_PUT_32 (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
+ H_PUT_32 (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
#else
if (scnhdr_int->s_nlnno <= MAX_SCNHDR_NLNNO)
- PUT_SCNHDR_NLNNO(abfd, scnhdr_int->s_nlnno,
- (bfd_byte *) scnhdr_ext->s_nlnno);
+ PUT_SCNHDR_NLNNO (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
else
{
char buf[sizeof (scnhdr_int->s_name) + 1];
(_("%s: warning: %s: line number overflow: 0x%lx > 0xffff"),
bfd_get_filename (abfd),
buf, scnhdr_int->s_nlnno);
- PUT_SCNHDR_NLNNO(abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno);
+ PUT_SCNHDR_NLNNO (abfd, 0xffff, scnhdr_ext->s_nlnno);
}
if (scnhdr_int->s_nreloc <= MAX_SCNHDR_NRELOC)
- PUT_SCNHDR_NRELOC(abfd, scnhdr_int->s_nreloc,
- (bfd_byte *) scnhdr_ext->s_nreloc);
+ PUT_SCNHDR_NRELOC (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
else
{
char buf[sizeof (scnhdr_int->s_name) + 1];
bfd_get_filename (abfd),
buf, scnhdr_int->s_nreloc);
bfd_set_error (bfd_error_file_truncated);
- PUT_SCNHDR_NRELOC(abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
+ PUT_SCNHDR_NRELOC (abfd, 0xffff, scnhdr_ext->s_nreloc);
ret = 0;
}
#endif
#ifdef I960
- PUT_SCNHDR_ALIGN (abfd, scnhdr_int->s_align, (bfd_byte *) scnhdr_ext->s_align);
+ PUT_SCNHDR_ALIGN (abfd, scnhdr_int->s_align, scnhdr_ext->s_align);
#endif
#ifdef COFF_ADJUST_SCNHDR_OUT_POST
COFF_ADJUST_SCNHDR_OUT_POST (abfd, in, out);
PACKAGE=bfd
-VERSION=2.11.90
+VERSION=2.11.91
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
hppa*-*-mpeix*) COREFILE=hpux-core.lo ;;
hppa*-*-bsd*) COREFILE="hpux-core.lo hppabsd-core.lo"
COREFLAG="-DHPUX_CORE -DHPPABSD_CORE" ;;
- i370-*-*)
+ i370-*-*)
COREFILE=trad-core.lo
TRAD_HEADER='"hosts/i370linux.h"'
;;
powerpc-*-freebsd*) COREFILE='' ;;
powerpc-*-netbsd*) COREFILE=netbsd-core.lo ;;
powerpc-*-*bsd*) COREFILE=netbsd-core.lo ;;
- s390*-*-*) COREFILE=trad-core.lo ;;
+ s390*-*-*) COREFILE=trad-core.lo ;;
sparc-*-netbsd* | sparc-*-openbsd*)
COREFILE=netbsd-core.lo
;;
target_size=32
case "$vec" in
# This list is alphabetized to make it easy to compare
- # with the two vector lists in targets.c.
+ # with the two vector lists in targets.c. For the same reason,
+ # use one entry per line, even though this leads to long lines.
a29kcoff_big_vec) tb="$tb coff-a29k.lo cofflink.lo" ;;
a_out_adobe_vec) tb="$tb aout-adobe.lo aout32.lo" ;;
- armcoff_little_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
- armcoff_big_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
- armnetbsd_vec) tb="$tb armnetbsd.lo aout32.lo" ;;
- armpe_little_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;;
- armpe_big_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;;
- armpei_little_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;;
- armpei_big_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;;
- arm_epoc_pe_little_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;;
- arm_epoc_pe_big_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;;
- arm_epoc_pei_little_vec) tb="$tb epoc-pei-arm.lo peigen.lo cofflink.lo " ;;
- arm_epoc_pei_big_vec) tb="$tb epoc-pei-arm.lo peigen.lo cofflink.lo " ;;
aout0_big_vec) tb="$tb aout0.lo aout32.lo" ;;
aout_arm_big_vec) tb="$tb aout-arm.lo aout32.lo" ;;
aout_arm_little_vec) tb="$tb aout-arm.lo aout32.lo" ;;
aout_mips_big_vec) tb="$tb mipsbsd.lo aout32.lo" ;;
aout_mips_little_vec) tb="$tb mipsbsd.lo aout32.lo" ;;
apollocoff_vec) tb="$tb coff-apollo.lo" ;;
+ arm_epoc_pe_big_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;;
+ arm_epoc_pe_little_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;;
+ arm_epoc_pei_big_vec) tb="$tb epoc-pei-arm.lo peigen.lo cofflink.lo " ;;
+ arm_epoc_pei_little_vec) tb="$tb epoc-pei-arm.lo peigen.lo cofflink.lo " ;;
+ armcoff_big_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
+ armcoff_little_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
+ armnetbsd_vec) tb="$tb armnetbsd.lo aout32.lo" ;;
+ armpe_big_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;;
+ armpe_little_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;;
+ armpei_big_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;;
+ armpei_little_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;;
b_out_vec_big_host) tb="$tb bout.lo aout32.lo" ;;
b_out_vec_little_host) tb="$tb bout.lo aout32.lo" ;;
bfd_efi_app_ia32_vec) tb="$tb efi-app-ia32.lo peigen.lo cofflink.lo" ;;
- bfd_efi_app_ia64_vec) tb="$tb efi-app-ia64.lo pepigen.lo cofflink.lo"
- target_size=64 ;;
- bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_hppa_vec | bfd_elf64_hppa_linux_vec)
- tb="$tb elf64-hppa.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_ia64_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_ia64_aix_little_vec)
- tb="$tb elf64-ia64.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_ia64_aix_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf32_ia64_big_vec) tb="$tb elf32-ia64.lo elf32.lo $elf" ;;
+ bfd_efi_app_ia64_vec) tb="$tb efi-app-ia64.lo pepigen.lo cofflink.lo"; target_size=64 ;;
bfd_elf32_avr_vec) tb="$tb elf32-avr.lo elf32.lo $elf" ;;
- bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
- bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
- bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
+ bfd_elf32_big_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
bfd_elf32_bigarc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
- bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
bfd_elf32_bigarm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
- bfd_elf32_big_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
+ bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
- bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"
- target_size=64 ;;
bfd_elf32_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;;
- bfd_elf32_us_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;;
bfd_elf32_d10v_vec) tb="$tb elf32-d10v.lo elf32.lo $elf" ;;
bfd_elf32_d30v_vec) tb="$tb elf32-d30v.lo elf32.lo $elf" ;;
bfd_elf32_fr30_vec) tb="$tb elf32-fr30.lo elf32.lo $elf" ;;
bfd_elf32_h8300_vec) tb="$tb elf32-h8300.lo elf32.lo $elf" ;;
- bfd_elf32_hppa_vec | bfd_elf32_hppa_linux_vec)
- tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
+ bfd_elf32_hppa_linux_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
+ bfd_elf32_hppa_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
bfd_elf32_i370_vec) tb="$tb elf32-i370.lo elf32.lo $elf" ;;
bfd_elf32_i386_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;;
- bfd_elf64_x86_64_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf32_i860_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;;
bfd_elf32_i860_little_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;;
+ bfd_elf32_i860_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;;
bfd_elf32_i960_vec) tb="$tb elf32-i960.lo elf32.lo $elf" ;;
+ bfd_elf32_ia64_big_vec) tb="$tb elf32-ia64.lo elf32.lo $elf" ;;
bfd_elf32_little_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
+ bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
+ bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
+ bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
- bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"
- target_size=64 ;;
bfd_elf32_m32r_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
bfd_elf32_m68hc11_vec) tb="$tb elf32-m68hc11.lo elf32.lo $elf" ;;
bfd_elf32_m68hc12_vec) tb="$tb elf32-m68hc12.lo elf32.lo $elf" ;;
bfd_elf32_pjl_vec) tb="$tb elf32-pj.lo elf32.lo $elf";;
bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
- bfd_elf64_powerpc_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_powerpcle_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"
- target_size=64 ;;
bfd_elf32_s390_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_shblin_vec) tb="$tb elf32-sh-lin.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
bfd_elf32_shlin_vec) tb="$tb elf32-sh-lin.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
- bfd_elf32_shblin_vec) tb="$tb elf32-sh-lin.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
bfd_elf32_sparc_vec) tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
+ bfd_elf32_us_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;;
bfd_elf32_v850_vec) tb="$tb elf32-v850.lo elf32.lo $elf" ;;
- bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_s390_vec) tb="$tb elf64-s390.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"
- target_size=64 ;;
- bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"
- target_size=64 ;;
+ bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+ bfd_elf64_hppa_linux_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_hppa_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_ia64_aix_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_ia64_aix_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_ia64_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+ bfd_elf64_powerpc_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_powerpcle_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
+ bfd_elf64_s390_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"; target_size=64 ;;
+ bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"; target_size=64 ;;
+ bfd_elf64_x86_64_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
+ bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
+ bfd_powerpcle_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
+ bfd_powerpcle_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
cisco_core_big_vec) tb="$tb cisco-core.lo" ;;
cisco_core_little_vec) tb="$tb cisco-core.lo" ;;
cris_aout_vec) tb="$tb aout-cris.lo" ;;
- demo_64_vec) tb="$tb demo64.lo aout64.lo"
- target_size=64 ;;
+ demo_64_vec) tb="$tb demo64.lo aout64.lo"; target_size=64 ;;
ecoff_big_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
- ecoff_little_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
ecoff_biglittle_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
- ecoffalpha_little_vec) tb="$tb coff-alpha.lo ecoff.lo ecofflink.lo"
- target_size=64 ;;
+ ecoff_little_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
+ ecoffalpha_little_vec) tb="$tb coff-alpha.lo ecoff.lo ecofflink.lo"; target_size=64 ;;
go32coff_vec) tb="$tb coff-go32.lo cofflink.lo" ;;
go32stubbedcoff_vec) tb="$tb coff-stgo32.lo cofflink.lo" ;;
h8300coff_vec) tb="$tb coff-h8300.lo reloc16.lo" ;;
i386coff_vec) tb="$tb coff-i386.lo cofflink.lo" ;;
i386dynix_vec) tb="$tb i386dynix.lo aout32.lo" ;;
i386freebsd_vec) tb="$tb i386freebsd.lo aout32.lo" ;;
- i386msdos_vec) tb="$tb i386msdos.lo" ;;
- i386pe_vec) tb="$tb pe-i386.lo peigen.lo cofflink.lo" ;;
- i386pei_vec) tb="$tb pei-i386.lo peigen.lo cofflink.lo" ;;
i386linux_vec) tb="$tb i386linux.lo aout32.lo" ;;
i386lynx_aout_vec) tb="$tb i386lynx.lo lynx-core.lo aout32.lo" ;;
i386lynx_coff_vec) tb="$tb cf-i386lynx.lo cofflink.lo lynx-core.lo" ;;
i386mach3_vec) tb="$tb i386mach3.lo aout32.lo" ;;
+ i386msdos_vec) tb="$tb i386msdos.lo" ;;
i386netbsd_vec) tb="$tb i386netbsd.lo aout32.lo" ;;
i386os9k_vec) tb="$tb i386os9k.lo aout32.lo" ;;
+ i386pe_vec) tb="$tb pe-i386.lo peigen.lo cofflink.lo" ;;
+ i386pei_vec) tb="$tb pei-i386.lo peigen.lo cofflink.lo" ;;
i860coff_vec) tb="$tb coff-i860.lo cofflink.lo" ;;
icoff_big_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
icoff_little_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
ieee_vec) tb="$tb ieee.lo" ;;
+ m68k4knetbsd_vec) tb="$tb m68k4knetbsd.lo aout32.lo" ;;
+ m68kaux_coff_vec) tb="$tb coff-aux.lo coff-m68k.lo cofflink.lo" ;;
m68kcoff_vec) tb="$tb coff-m68k.lo cofflink.lo" ;;
m68kcoffun_vec) tb="$tb coff-u68k.lo coff-m68k.lo cofflink.lo" ;;
m68klinux_vec) tb="$tb m68klinux.lo aout32.lo" ;;
m68klynx_aout_vec) tb="$tb m68klynx.lo lynx-core.lo aout32.lo" ;;
m68klynx_coff_vec) tb="$tb cf-m68klynx.lo coff-m68k.lo cofflink.lo lynx-core.lo" ;;
m68knetbsd_vec) tb="$tb m68knetbsd.lo aout32.lo" ;;
- m68k4knetbsd_vec) tb="$tb m68k4knetbsd.lo aout32.lo" ;;
- m68kaux_coff_vec) tb="$tb coff-aux.lo coff-m68k.lo cofflink.lo" ;;
m68ksysvcoff_vec) tb="$tb coff-svm68k.lo cofflink.lo" ;;
m88kbcs_vec) tb="$tb coff-m88k.lo" ;;
- mipslpe_vec) tb="$tb pe-mips.lo peigen.lo cofflink.lo" ;;
- mipslpei_vec) tb="$tb pei-mips.lo peigen.lo cofflink.lo" ;;
mcore_pe_big_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;;
mcore_pe_little_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;;
mcore_pei_big_vec) tb="$tb pei-mcore.lo peigen.lo cofflink.lo" ;;
mcore_pei_little_vec) tb="$tb pei-mcore.lo peigen.lo cofflink.lo" ;;
+ mipslpe_vec) tb="$tb pe-mips.lo peigen.lo cofflink.lo" ;;
+ mipslpei_vec) tb="$tb pei-mips.lo peigen.lo cofflink.lo" ;;
newsos3_vec) tb="$tb newsos3.lo aout32.lo" ;;
+ nlm32_alpha_vec) tb="$tb nlm32-alpha.lo nlm32.lo nlm.lo"; target_size=64 ;;
nlm32_i386_vec) tb="$tb nlm32-i386.lo nlm32.lo nlm.lo" ;;
- rs6000coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo"
- target_size=64 ;;
- nlm32_sparc_vec) tb="$tb nlm32-sparc.lo nlm32.lo nlm.lo" ;;
- nlm32_alpha_vec) tb="$tb nlm32-alpha.lo nlm32.lo nlm.lo"
- target_size=64 ;;
- riscix_vec) tb="$tb aout32.lo riscix.lo" ;;
nlm32_powerpc_vec) tb="$tb nlm32-ppc.lo nlm32.lo nlm.lo" ;;
- pc532netbsd_vec) tb="$tb ns32knetbsd.lo aout-ns32k.lo" ;;
+ nlm32_sparc_vec) tb="$tb nlm32-sparc.lo nlm32.lo nlm.lo" ;;
pc532machaout_vec) tb="$tb pc532-mach.lo aout-ns32k.lo" ;;
+ pc532netbsd_vec) tb="$tb ns32knetbsd.lo aout-ns32k.lo" ;;
pdp11_aout_vec) tb="$tb pdp11.lo" ;;
pmac_xcoff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;;
- rs6000coff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;;
- bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
- bfd_powerpcle_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
- bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
- bfd_powerpcle_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
ppcboot_vec) tb="$tb ppcboot.lo" ;;
- shcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
- shlcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ riscix_vec) tb="$tb aout32.lo riscix.lo" ;;
+ rs6000coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo"; target_size=64 ;;
+ rs6000coff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;;
shcoff_small_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ shcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
shlcoff_small_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ shlcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
shlpe_vec) tb="$tb pe-sh.lo coff-sh.lo peigen.lo cofflink.lo" ;;
shlpei_vec) tb="$tb pei-sh.lo coff-sh.lo peigen.lo cofflink.lo" ;;
som_vec) tb="$tb som.lo" ;;
+ sparccoff_vec) tb="$tb coff-sparc.lo" ;;
sparcle_aout_vec) tb="$tb aout-sparcle.lo aout32.lo" ;;
sparclinux_vec) tb="$tb sparclinux.lo aout32.lo" ;;
sparclynx_aout_vec) tb="$tb sparclynx.lo lynx-core.lo aout32.lo" ;;
sparclynx_coff_vec) tb="$tb cf-sparclynx.lo lynx-core.lo" ;;
sparcnetbsd_vec) tb="$tb sparcnetbsd.lo aout32.lo" ;;
- sparccoff_vec) tb="$tb coff-sparc.lo" ;;
srec_vec) tb="$tb srec.lo" ;;
sunos_big_vec) tb="$tb sunos.lo aout32.lo" ;;
symbolsrec_vec) tb="$tb srec.lo" ;;
tekhex_vec) tb="$tb tekhex.lo" ;;
tic30_aout_vec) tb="$tb aout-tic30.lo" ;;
tic30_coff_vec) tb="$tb coff-tic30.lo" ;;
- tic54x_coff0_vec) tb="$tb coff-tic54x.lo" ;;
tic54x_coff0_beh_vec) tb="$tb coff-tic54x.lo" ;;
- tic54x_coff1_vec) tb="$tb coff-tic54x.lo" ;;
+ tic54x_coff0_vec) tb="$tb coff-tic54x.lo" ;;
tic54x_coff1_beh_vec) tb="$tb coff-tic54x.lo" ;;
- tic54x_coff2_vec) tb="$tb coff-tic54x.lo" ;;
+ tic54x_coff1_vec) tb="$tb coff-tic54x.lo" ;;
tic54x_coff2_beh_vec) tb="$tb coff-tic54x.lo" ;;
+ tic54x_coff2_vec) tb="$tb coff-tic54x.lo" ;;
tic80coff_vec) tb="$tb coff-tic80.lo cofflink.lo" ;;
versados_vec) tb="$tb versados.lo" ;;
- vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo"
- target_size=64 ;;
+ vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo"; target_size=64 ;;
vms_vax_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo" ;;
w65_vec) tb="$tb coff-w65.lo reloc16.lo" ;;
we32kcoff_vec) tb="$tb coff-we32k.lo" ;;
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6201: checking for $ac_hdr" >&5
+echo "configure:6178: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6206 "configure"
+#line 6183 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6211: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6188: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
for ac_func in getpagesize
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6240: checking for $ac_func" >&5
+echo "configure:6217: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6245 "configure"
+#line 6222 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:6268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
done
echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:6293: checking for working mmap" >&5
+echo "configure:6270: checking for working mmap" >&5
if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_func_mmap_fixed_mapped=no
else
cat > conftest.$ac_ext <<EOF
-#line 6301 "configure"
+#line 6278 "configure"
#include "confdefs.h"
/* Thanks to Mike Haertel and Jim Avera for this test.
}
EOF
-if { (eval echo configure:6441: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_mmap_fixed_mapped=yes
else
for ac_func in madvise mprotect
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6466: checking for $ac_func" >&5
+echo "configure:6443: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6471 "configure"
+#line 6448 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:6494: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6471: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
# Split the substitutions into bite-sized pieces for seds with
# small command number limits, like on Digital OSF/1 and HP-UX.
-ac_max_sed_cmds=60 # Maximum number of lines to put in a sed script.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
ac_file=1 # Number of current file.
ac_beg=1 # First line for current file.
ac_end=$ac_max_sed_cmds # Line after last line for current file.
AC_CANONICAL_SYSTEM
AC_ISC_POSIX
-AM_INIT_AUTOMAKE(bfd, 2.11.90)
+AM_INIT_AUTOMAKE(bfd, 2.11.91)
dnl These must be called before AM_PROG_LIBTOOL, because it may want
dnl to call AC_CHECK_PROG.
hppa*-*-mpeix*) COREFILE=hpux-core.lo ;;
hppa*-*-bsd*) COREFILE="hpux-core.lo hppabsd-core.lo"
COREFLAG="-DHPUX_CORE -DHPPABSD_CORE" ;;
- i370-*-*)
+ i370-*-*)
COREFILE=trad-core.lo
TRAD_HEADER='"hosts/i370linux.h"'
;;
powerpc-*-freebsd*) COREFILE='' ;;
powerpc-*-netbsd*) COREFILE=netbsd-core.lo ;;
powerpc-*-*bsd*) COREFILE=netbsd-core.lo ;;
- s390*-*-*) COREFILE=trad-core.lo ;;
+ s390*-*-*) COREFILE=trad-core.lo ;;
sparc-*-netbsd* | sparc-*-openbsd*)
COREFILE=netbsd-core.lo
;;
target_size=32
case "$vec" in
# This list is alphabetized to make it easy to compare
- # with the two vector lists in targets.c.
+ # with the two vector lists in targets.c. For the same reason,
+ # use one entry per line, even though this leads to long lines.
a29kcoff_big_vec) tb="$tb coff-a29k.lo cofflink.lo" ;;
a_out_adobe_vec) tb="$tb aout-adobe.lo aout32.lo" ;;
- armcoff_little_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
- armcoff_big_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
- armnetbsd_vec) tb="$tb armnetbsd.lo aout32.lo" ;;
- armpe_little_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;;
- armpe_big_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;;
- armpei_little_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;;
- armpei_big_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;;
- arm_epoc_pe_little_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;;
- arm_epoc_pe_big_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;;
- arm_epoc_pei_little_vec) tb="$tb epoc-pei-arm.lo peigen.lo cofflink.lo " ;;
- arm_epoc_pei_big_vec) tb="$tb epoc-pei-arm.lo peigen.lo cofflink.lo " ;;
aout0_big_vec) tb="$tb aout0.lo aout32.lo" ;;
aout_arm_big_vec) tb="$tb aout-arm.lo aout32.lo" ;;
aout_arm_little_vec) tb="$tb aout-arm.lo aout32.lo" ;;
aout_mips_big_vec) tb="$tb mipsbsd.lo aout32.lo" ;;
aout_mips_little_vec) tb="$tb mipsbsd.lo aout32.lo" ;;
apollocoff_vec) tb="$tb coff-apollo.lo" ;;
+ arm_epoc_pe_big_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;;
+ arm_epoc_pe_little_vec) tb="$tb epoc-pe-arm.lo peigen.lo cofflink.lo " ;;
+ arm_epoc_pei_big_vec) tb="$tb epoc-pei-arm.lo peigen.lo cofflink.lo " ;;
+ arm_epoc_pei_little_vec) tb="$tb epoc-pei-arm.lo peigen.lo cofflink.lo " ;;
+ armcoff_big_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
+ armcoff_little_vec) tb="$tb coff-arm.lo cofflink.lo " ;;
+ armnetbsd_vec) tb="$tb armnetbsd.lo aout32.lo" ;;
+ armpe_big_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;;
+ armpe_little_vec) tb="$tb pe-arm.lo peigen.lo cofflink.lo " ;;
+ armpei_big_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;;
+ armpei_little_vec) tb="$tb pei-arm.lo peigen.lo cofflink.lo " ;;
b_out_vec_big_host) tb="$tb bout.lo aout32.lo" ;;
b_out_vec_little_host) tb="$tb bout.lo aout32.lo" ;;
bfd_efi_app_ia32_vec) tb="$tb efi-app-ia32.lo peigen.lo cofflink.lo" ;;
- bfd_efi_app_ia64_vec) tb="$tb efi-app-ia64.lo pepigen.lo cofflink.lo"
- target_size=64 ;;
- bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_hppa_vec | bfd_elf64_hppa_linux_vec)
- tb="$tb elf64-hppa.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_ia64_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_ia64_aix_little_vec)
- tb="$tb elf64-ia64.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_ia64_aix_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf32_ia64_big_vec) tb="$tb elf32-ia64.lo elf32.lo $elf" ;;
+ bfd_efi_app_ia64_vec) tb="$tb efi-app-ia64.lo pepigen.lo cofflink.lo"; target_size=64 ;;
bfd_elf32_avr_vec) tb="$tb elf32-avr.lo elf32.lo $elf" ;;
- bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
- bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
- bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
+ bfd_elf32_big_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
bfd_elf32_bigarc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
- bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
bfd_elf32_bigarm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
- bfd_elf32_big_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
+ bfd_elf32_bigarm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
- bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"
- target_size=64 ;;
bfd_elf32_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;;
- bfd_elf32_us_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;;
bfd_elf32_d10v_vec) tb="$tb elf32-d10v.lo elf32.lo $elf" ;;
bfd_elf32_d30v_vec) tb="$tb elf32-d30v.lo elf32.lo $elf" ;;
bfd_elf32_fr30_vec) tb="$tb elf32-fr30.lo elf32.lo $elf" ;;
bfd_elf32_h8300_vec) tb="$tb elf32-h8300.lo elf32.lo $elf" ;;
- bfd_elf32_hppa_vec | bfd_elf32_hppa_linux_vec)
- tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
+ bfd_elf32_hppa_linux_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
+ bfd_elf32_hppa_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
bfd_elf32_i370_vec) tb="$tb elf32-i370.lo elf32.lo $elf" ;;
bfd_elf32_i386_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;;
- bfd_elf64_x86_64_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf32_i860_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;;
bfd_elf32_i860_little_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;;
+ bfd_elf32_i860_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;;
bfd_elf32_i960_vec) tb="$tb elf32-i960.lo elf32.lo $elf" ;;
+ bfd_elf32_ia64_big_vec) tb="$tb elf32-ia64.lo elf32.lo $elf" ;;
bfd_elf32_little_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;;
+ bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;;
+ bfd_elf32_littlearm_oabi_vec) tb="$tb elfarm-oabi.lo elf32.lo $elf" ;;
+ bfd_elf32_littlearm_vec) tb="$tb elfarm-nabi.lo elf32.lo $elf" ;;
bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
- bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"
- target_size=64 ;;
bfd_elf32_m32r_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;;
bfd_elf32_m68hc11_vec) tb="$tb elf32-m68hc11.lo elf32.lo $elf" ;;
bfd_elf32_m68hc12_vec) tb="$tb elf32-m68hc12.lo elf32.lo $elf" ;;
bfd_elf32_pjl_vec) tb="$tb elf32-pj.lo elf32.lo $elf";;
bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;;
- bfd_elf64_powerpc_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_powerpcle_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"
- target_size=64 ;;
bfd_elf32_s390_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_shblin_vec) tb="$tb elf32-sh-lin.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
bfd_elf32_shlin_vec) tb="$tb elf32-sh-lin.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
- bfd_elf32_shblin_vec) tb="$tb elf32-sh-lin.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
bfd_elf32_sparc_vec) tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elf32.lo $elf ecofflink.lo" ;;
+ bfd_elf32_us_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;;
bfd_elf32_v850_vec) tb="$tb elf32-v850.lo elf32.lo $elf" ;;
- bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_s390_vec) tb="$tb elf64-s390.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elf64.lo $elf"
- target_size=64 ;;
- bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"
- target_size=64 ;;
- bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"
- target_size=64 ;;
+ bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+ bfd_elf64_hppa_linux_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_hppa_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_ia64_aix_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_ia64_aix_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_ia64_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elf32-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
+ bfd_elf64_powerpc_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_powerpcle_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;;
+ bfd_elf64_s390_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"; target_size=64 ;;
+ bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo $elf ecofflink.lo"; target_size=64 ;;
+ bfd_elf64_x86_64_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;;
+ bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
+ bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
+ bfd_powerpcle_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
+ bfd_powerpcle_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
cisco_core_big_vec) tb="$tb cisco-core.lo" ;;
cisco_core_little_vec) tb="$tb cisco-core.lo" ;;
cris_aout_vec) tb="$tb aout-cris.lo" ;;
- demo_64_vec) tb="$tb demo64.lo aout64.lo"
- target_size=64 ;;
+ demo_64_vec) tb="$tb demo64.lo aout64.lo"; target_size=64 ;;
ecoff_big_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
- ecoff_little_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
ecoff_biglittle_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
- ecoffalpha_little_vec) tb="$tb coff-alpha.lo ecoff.lo ecofflink.lo"
- target_size=64 ;;
+ ecoff_little_vec) tb="$tb coff-mips.lo ecoff.lo ecofflink.lo" ;;
+ ecoffalpha_little_vec) tb="$tb coff-alpha.lo ecoff.lo ecofflink.lo"; target_size=64 ;;
go32coff_vec) tb="$tb coff-go32.lo cofflink.lo" ;;
go32stubbedcoff_vec) tb="$tb coff-stgo32.lo cofflink.lo" ;;
h8300coff_vec) tb="$tb coff-h8300.lo reloc16.lo" ;;
i386coff_vec) tb="$tb coff-i386.lo cofflink.lo" ;;
i386dynix_vec) tb="$tb i386dynix.lo aout32.lo" ;;
i386freebsd_vec) tb="$tb i386freebsd.lo aout32.lo" ;;
- i386msdos_vec) tb="$tb i386msdos.lo" ;;
- i386pe_vec) tb="$tb pe-i386.lo peigen.lo cofflink.lo" ;;
- i386pei_vec) tb="$tb pei-i386.lo peigen.lo cofflink.lo" ;;
i386linux_vec) tb="$tb i386linux.lo aout32.lo" ;;
i386lynx_aout_vec) tb="$tb i386lynx.lo lynx-core.lo aout32.lo" ;;
i386lynx_coff_vec) tb="$tb cf-i386lynx.lo cofflink.lo lynx-core.lo" ;;
i386mach3_vec) tb="$tb i386mach3.lo aout32.lo" ;;
+ i386msdos_vec) tb="$tb i386msdos.lo" ;;
i386netbsd_vec) tb="$tb i386netbsd.lo aout32.lo" ;;
i386os9k_vec) tb="$tb i386os9k.lo aout32.lo" ;;
+ i386pe_vec) tb="$tb pe-i386.lo peigen.lo cofflink.lo" ;;
+ i386pei_vec) tb="$tb pei-i386.lo peigen.lo cofflink.lo" ;;
i860coff_vec) tb="$tb coff-i860.lo cofflink.lo" ;;
icoff_big_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
icoff_little_vec) tb="$tb coff-i960.lo cofflink.lo" ;;
ieee_vec) tb="$tb ieee.lo" ;;
+ m68k4knetbsd_vec) tb="$tb m68k4knetbsd.lo aout32.lo" ;;
+ m68kaux_coff_vec) tb="$tb coff-aux.lo coff-m68k.lo cofflink.lo" ;;
m68kcoff_vec) tb="$tb coff-m68k.lo cofflink.lo" ;;
m68kcoffun_vec) tb="$tb coff-u68k.lo coff-m68k.lo cofflink.lo" ;;
m68klinux_vec) tb="$tb m68klinux.lo aout32.lo" ;;
m68klynx_aout_vec) tb="$tb m68klynx.lo lynx-core.lo aout32.lo" ;;
m68klynx_coff_vec) tb="$tb cf-m68klynx.lo coff-m68k.lo cofflink.lo lynx-core.lo" ;;
m68knetbsd_vec) tb="$tb m68knetbsd.lo aout32.lo" ;;
- m68k4knetbsd_vec) tb="$tb m68k4knetbsd.lo aout32.lo" ;;
- m68kaux_coff_vec) tb="$tb coff-aux.lo coff-m68k.lo cofflink.lo" ;;
m68ksysvcoff_vec) tb="$tb coff-svm68k.lo cofflink.lo" ;;
m88kbcs_vec) tb="$tb coff-m88k.lo" ;;
- mipslpe_vec) tb="$tb pe-mips.lo peigen.lo cofflink.lo" ;;
- mipslpei_vec) tb="$tb pei-mips.lo peigen.lo cofflink.lo" ;;
mcore_pe_big_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;;
mcore_pe_little_vec) tb="$tb pe-mcore.lo peigen.lo cofflink.lo" ;;
mcore_pei_big_vec) tb="$tb pei-mcore.lo peigen.lo cofflink.lo" ;;
mcore_pei_little_vec) tb="$tb pei-mcore.lo peigen.lo cofflink.lo" ;;
+ mipslpe_vec) tb="$tb pe-mips.lo peigen.lo cofflink.lo" ;;
+ mipslpei_vec) tb="$tb pei-mips.lo peigen.lo cofflink.lo" ;;
newsos3_vec) tb="$tb newsos3.lo aout32.lo" ;;
+ nlm32_alpha_vec) tb="$tb nlm32-alpha.lo nlm32.lo nlm.lo"; target_size=64 ;;
nlm32_i386_vec) tb="$tb nlm32-i386.lo nlm32.lo nlm.lo" ;;
- rs6000coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo"
- target_size=64 ;;
- nlm32_sparc_vec) tb="$tb nlm32-sparc.lo nlm32.lo nlm.lo" ;;
- nlm32_alpha_vec) tb="$tb nlm32-alpha.lo nlm32.lo nlm.lo"
- target_size=64 ;;
- riscix_vec) tb="$tb aout32.lo riscix.lo" ;;
nlm32_powerpc_vec) tb="$tb nlm32-ppc.lo nlm32.lo nlm.lo" ;;
- pc532netbsd_vec) tb="$tb ns32knetbsd.lo aout-ns32k.lo" ;;
+ nlm32_sparc_vec) tb="$tb nlm32-sparc.lo nlm32.lo nlm.lo" ;;
pc532machaout_vec) tb="$tb pc532-mach.lo aout-ns32k.lo" ;;
+ pc532netbsd_vec) tb="$tb ns32knetbsd.lo aout-ns32k.lo" ;;
pdp11_aout_vec) tb="$tb pdp11.lo" ;;
pmac_xcoff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;;
- rs6000coff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;;
- bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
- bfd_powerpcle_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;;
- bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
- bfd_powerpcle_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;;
ppcboot_vec) tb="$tb ppcboot.lo" ;;
- shcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
- shlcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ riscix_vec) tb="$tb aout32.lo riscix.lo" ;;
+ rs6000coff64_vec) tb="$tb coff64-rs6000.lo xcofflink.lo"; target_size=64 ;;
+ rs6000coff_vec) tb="$tb coff-rs6000.lo xcofflink.lo" ;;
shcoff_small_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ shcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
shlcoff_small_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
+ shlcoff_vec) tb="$tb coff-sh.lo cofflink.lo" ;;
shlpe_vec) tb="$tb pe-sh.lo coff-sh.lo peigen.lo cofflink.lo" ;;
shlpei_vec) tb="$tb pei-sh.lo coff-sh.lo peigen.lo cofflink.lo" ;;
som_vec) tb="$tb som.lo" ;;
+ sparccoff_vec) tb="$tb coff-sparc.lo" ;;
sparcle_aout_vec) tb="$tb aout-sparcle.lo aout32.lo" ;;
sparclinux_vec) tb="$tb sparclinux.lo aout32.lo" ;;
sparclynx_aout_vec) tb="$tb sparclynx.lo lynx-core.lo aout32.lo" ;;
sparclynx_coff_vec) tb="$tb cf-sparclynx.lo lynx-core.lo" ;;
sparcnetbsd_vec) tb="$tb sparcnetbsd.lo aout32.lo" ;;
- sparccoff_vec) tb="$tb coff-sparc.lo" ;;
srec_vec) tb="$tb srec.lo" ;;
sunos_big_vec) tb="$tb sunos.lo aout32.lo" ;;
symbolsrec_vec) tb="$tb srec.lo" ;;
tekhex_vec) tb="$tb tekhex.lo" ;;
tic30_aout_vec) tb="$tb aout-tic30.lo" ;;
tic30_coff_vec) tb="$tb coff-tic30.lo" ;;
- tic54x_coff0_vec) tb="$tb coff-tic54x.lo" ;;
tic54x_coff0_beh_vec) tb="$tb coff-tic54x.lo" ;;
- tic54x_coff1_vec) tb="$tb coff-tic54x.lo" ;;
+ tic54x_coff0_vec) tb="$tb coff-tic54x.lo" ;;
tic54x_coff1_beh_vec) tb="$tb coff-tic54x.lo" ;;
- tic54x_coff2_vec) tb="$tb coff-tic54x.lo" ;;
+ tic54x_coff1_vec) tb="$tb coff-tic54x.lo" ;;
tic54x_coff2_beh_vec) tb="$tb coff-tic54x.lo" ;;
+ tic54x_coff2_vec) tb="$tb coff-tic54x.lo" ;;
tic80coff_vec) tb="$tb coff-tic80.lo cofflink.lo" ;;
versados_vec) tb="$tb versados.lo" ;;
- vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo"
- target_size=64 ;;
+ vms_alpha_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo"; target_size=64 ;;
vms_vax_vec) tb="$tb vms.lo vms-hdr.lo vms-gsd.lo vms-tir.lo vms-misc.lo" ;;
w65_vec) tb="$tb coff-w65.lo reloc16.lo" ;;
we32kcoff_vec) tb="$tb coff-we32k.lo" ;;
/* Core file generic interface routines for BFD.
- Copyright 1990, 1991, 1992, 1993, 1994, 2000
+ Copyright 1990, 1991, 1992, 1993, 1994, 2000, 2001
Free Software Foundation, Inc.
Written by Cygnus Support.
bfd_core_file_failing_command
SYNOPSIS
- CONST char *bfd_core_file_failing_command(bfd *abfd);
+ const char *bfd_core_file_failing_command(bfd *abfd);
DESCRIPTION
Return a read-only string explaining which program was running
/* Given cpu type NAME, return its bfd_mach_arc_xxx value.
Returns -1 if not found. */
+int arc_get_mach PARAMS ((char *));
+
int
arc_get_mach (name)
char *name;
#include "sysdep.h"
#include "libbfd.h"
-int bfd_default_scan_num_mach ();
-
static boolean h8300_scan
PARAMS ((const struct bfd_arch_info *, const char *));
static const bfd_arch_info_type * compatible
/* BFD library support routines for the H8/500 architecture.
- Copyright 1993, 1995, 2000 Free Software Foundation, Inc.
+ Copyright 1993, 1995, 2000, 2001 Free Software Foundation, Inc.
Hacked by Steve Chamberlain of Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
#include "sysdep.h"
#include "libbfd.h"
-#if 0
+static boolean scan_mach PARAMS ((const struct bfd_arch_info *, const char *));
+#if 0
/*
Relocations for the Z8K
}
#endif
-int bfd_default_scan_num_mach();
-
static boolean
scan_mach (info, string)
const struct bfd_arch_info *info ATTRIBUTE_UNUSED;
/* BFD library support routines for the i960 architecture.
- Copyright 1990, 1991, 1993, 1994, 1996, 1999, 2000
+ Copyright 1990, 1991, 1993, 1994, 1996, 1999, 2000, 2001
Free Software Foundation, Inc.
Hacked by Steve Chamberlain of Cygnus Support.
#include "sysdep.h"
#include "libbfd.h"
+static boolean scan_960_mach
+ PARAMS ((const bfd_arch_info_type *, const char *));
+static const bfd_arch_info_type *compatible
+ PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
+
/* This routine is provided a string, and tries to work out if it
could possibly refer to the i960 machine pointed at in the
info_struct pointer */
#define HX bfd_mach_i960_hx /*8*/
#define MAX_ARCH ((int)HX)
- static CONST unsigned long matrix[MAX_ARCH+1][MAX_ARCH+1] =
+ static const unsigned long matrix[MAX_ARCH+1][MAX_ARCH+1] =
{
{ ERROR, CORE, KA, KB, MC, XA, CA, JX, HX },
{ CORE, CORE, KA, KB, MC, XA, CA, JX, HX },
}
}
-int bfd_default_scan_num_mach();
#define N(a,b,d,n) \
{ 32, 32, 8,bfd_arch_i960,a,"i960",b,3,d,compatible,scan_960_mach,n,}
/* Logically, this code should be part of libopcode but since some of
the operand insertion/extraction functions help bfd to implement
- relocations, this code is included as part of elf64-ia64.c. This
+ relocations, this code is included as part of cpu-ia64.c. This
avoids circular dependencies between libopcode and libbfd and also
obviates the need for applications to link in libopcode when all
they really want is libbfd.
/* BFD support for the ns32k architecture.
- Copyright 1990, 1991, 1994, 1995, 1998, 2000
+ Copyright 1990, 1991, 1994, 1995, 1998, 2000, 2001
Free Software Foundation, Inc.
Almost totally rewritten by Ian Dall from initial work
by Andrew Cagney.
const bfd_arch_info_type bfd_ns32k_arch =
N(32032,"ns32k:32032",false, &arch_info_struct[0]);
-static long
-ns32k_sign_extend(value, bits)
- int value;
- int bits;
-{
- value = value & ((1 << bits) - 1);
- return (value & (1 << (bits-1))
- ? value | (~((1 << bits) - 1))
- : value);
-}
+static bfd_reloc_status_type do_ns32k_reloc
+ PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR, asection *,
+ bfd *, char **,
+ bfd_vma (*) (bfd_byte *, int),
+ int (*) (bfd_vma, bfd_byte *, int)));
-long
-_bfd_ns32k_get_displacement(buffer, offset, size)
+bfd_vma
+_bfd_ns32k_get_displacement (buffer, size)
bfd_byte *buffer;
- long offset;
- long size;
+ int size;
{
- long value;
- buffer += offset;
+ bfd_signed_vma value;
switch (size)
{
case 1:
- value = ns32k_sign_extend (*buffer, 7);
+ value = ((*buffer & 0x7f) ^ 0x40) - 0x40;
break;
+
case 2:
- value = ns32k_sign_extend(*buffer++, 6);
+ value = ((*buffer++ & 0x3f) ^ 0x20) - 0x20;
value = (value << 8) | (0xff & *buffer);
break;
+
case 4:
- value = ns32k_sign_extend(*buffer++, 6);
+ value = ((*buffer++ & 0x3f) ^ 0x20) - 0x20;
value = (value << 8) | (0xff & *buffer++);
value = (value << 8) | (0xff & *buffer++);
value = (value << 8) | (0xff & *buffer);
break;
+
default:
abort ();
return 0;
}
int
-_bfd_ns32k_put_displacement(value, buffer, offset, size)
- long value;
+_bfd_ns32k_put_displacement (value, buffer, size)
+ bfd_vma value;
bfd_byte *buffer;
- long offset;
- long size;
+ int size;
{
- buffer += offset;
switch (size)
{
case 1:
- if (value < -64 || value > 63)
+ if (value + 0x40 > 0x7f)
return -1;
- value&=0x7f;
- *buffer++=value;
+ value &= 0x7f;
+ *buffer++ = value;
break;
+
case 2:
- if (value < -8192 || value > 8191)
+ if (value + 0x2000 > 0x3fff)
return -1;
- value&=0x3fff;
- value|=0x8000;
- *buffer++=(value>>8);
- *buffer++=value;
+ value &= 0x3fff;
+ value |= 0x8000;
+ *buffer++ = (value >> 8);
+ *buffer++ = value;
break;
+
case 4:
- if (value < -0x1f000000 || value >= 0x20000000)
+ /* FIXME: is this correct? -0x1f000000 <= value < 0x2000000 */
+ if (value + 0x1f000000 > 0x3effffff)
return -1;
- value|=0xc0000000;
- *buffer++=(value>>24);
- *buffer++=(value>>16);
- *buffer++=(value>>8);
- *buffer++=value;
+ value |= (bfd_vma) 0xc0000000;
+ *buffer++ = (value >> 24);
+ *buffer++ = (value >> 16);
+ *buffer++ = (value >> 8);
+ *buffer++ = value;
break;
default:
return -1;
return 0;
}
-long
-_bfd_ns32k_get_immediate (buffer, offset, size)
+bfd_vma
+_bfd_ns32k_get_immediate (buffer, size)
bfd_byte *buffer;
- long offset;
- long size;
+ int size;
{
- long value = 0;
- buffer += offset;
+ bfd_vma value = 0;
switch (size)
{
+ case 8:
+ value = (value << 8) | (*buffer++ & 0xff);
+ value = (value << 8) | (*buffer++ & 0xff);
+ value = (value << 8) | (*buffer++ & 0xff);
+ value = (value << 8) | (*buffer++ & 0xff);
case 4:
value = (value << 8) | (*buffer++ & 0xff);
- case 3:
value = (value << 8) | (*buffer++ & 0xff);
case 2:
value = (value << 8) | (*buffer++ & 0xff);
}
int
-_bfd_ns32k_put_immediate (value, buffer, offset, size)
- long value;
+_bfd_ns32k_put_immediate (value, buffer, size)
+ bfd_vma value;
bfd_byte *buffer;
- long offset;
- long size;
+ int size;
{
- buffer += offset + size - 1;
+ buffer += size - 1;
switch (size)
{
+ case 8:
+ *buffer-- = (value & 0xff); value >>= 8;
+ *buffer-- = (value & 0xff); value >>= 8;
+ *buffer-- = (value & 0xff); value >>= 8;
+ *buffer-- = (value & 0xff); value >>= 8;
case 4:
*buffer-- = (value & 0xff); value >>= 8;
- case 3:
*buffer-- = (value & 0xff); value >>= 8;
case 2:
*buffer-- = (value & 0xff); value >>= 8;
asection *input_section;
bfd *output_bfd;
char **error_message ATTRIBUTE_UNUSED;
- long (*get_data) ();
- int (*put_data) ();
+ bfd_vma (*get_data) PARAMS ((bfd_byte *, int));
+ int (*put_data) PARAMS ((bfd_vma, bfd_byte *, int));
{
int overflow = 0;
bfd_vma relocation;
bfd_vma output_base = 0;
reloc_howto_type *howto = reloc_entry->howto;
asection *reloc_target_output_section;
+ bfd_byte *location;
if ((symbol->section == &bfd_abs_section)
&& output_bfd != (bfd *) NULL)
bfd_vma reloc_bits = (((1 << (howto->bitsize - 1)) - 1) << 1) | 1;
if (((bfd_vma) check & ~reloc_bits) != 0
- && ((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
+ && (((bfd_vma) check & ~reloc_bits)
+ != (-(bfd_vma) 1 & ~reloc_bits)))
{
/* The above right shift is incorrect for a signed
value. See if turning on the upper bits fixes the
check |= ((bfd_vma) - 1
& ~((bfd_vma) - 1
>> (howto->rightshift - howto->bitpos)));
- if (((bfd_vma) check & ~reloc_bits) != (-1 & ~reloc_bits))
+ if (((bfd_vma) check & ~reloc_bits)
+ != (-(bfd_vma) 1 & ~reloc_bits))
flag = bfd_reloc_overflow;
}
else
#define DOIT(x) \
x = ( (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask))
+ location = (bfd_byte *) data + addr;
switch (howto->size)
{
case 0:
{
- char x = get_data (data, addr, 1);
+ char x = get_data (location, 1);
DOIT (x);
- overflow = put_data(x, data, addr, 1);
+ overflow = put_data ((bfd_vma) x, location, 1);
}
break;
case 1:
if (relocation)
{
- short x = get_data (data, addr, 2);
+ short x = get_data (location, 2);
DOIT (x);
- overflow = put_data(x, (unsigned char *) data, addr, 2);
+ overflow = put_data ((bfd_vma) x, location, 2);
}
break;
case 2:
if (relocation)
{
- long x = get_data (data, addr, 4);
+ long x = get_data (location, 4);
DOIT (x);
- overflow = put_data(x, data, addr, 4);
+ overflow = put_data ((bfd_vma) x, location, 4);
}
break;
case -2:
{
- long x = get_data(data, addr, 4);
+ long x = get_data (location, 4);
relocation = -relocation;
DOIT(x);
- overflow = put_data(x, data , addr, 4);
+ overflow = put_data ((bfd_vma) x, location, 4);
}
break;
#ifdef BFD64
if (relocation)
{
- bfd_vma x = get_data (data, addr, 8);
+ bfd_vma x = get_data (location, 8);
DOIT (x);
- overflow = put_data(x, data, addr, 8);
+ overflow = put_data (x, location, 8);
}
#else
abort ();
/* Relocate a given location using a given value and howto. */
bfd_reloc_status_type
-_bfd_do_ns32k_reloc_contents ( howto, input_bfd, relocation, location,
+_bfd_do_ns32k_reloc_contents (howto, input_bfd, relocation, location,
get_data, put_data)
reloc_howto_type *howto;
bfd *input_bfd ATTRIBUTE_UNUSED;
bfd_vma relocation;
bfd_byte *location;
- long (*get_data) ();
- int (*put_data) ();
+ bfd_vma (*get_data) PARAMS ((bfd_byte *, int));
+ int (*put_data) PARAMS ((bfd_vma, bfd_byte *, int));
{
int size;
bfd_vma x;
#ifdef BFD64
case 8:
#endif
- x = get_data (location, 0, size);
+ x = get_data (location, size);
break;
}
if ((check & ~reloc_bits) != 0
&& (((bfd_vma) signed_check & ~reloc_bits)
- != (-1 & ~reloc_bits)))
+ != (-(bfd_vma) 1 & ~reloc_bits)))
overflow = true;
}
break;
#ifdef BFD64
case 8:
#endif
- put_data(x, location, 0, size);
+ put_data (x, location, size);
break;
}
"pdp11",
1, /* aligment = 16 bit */
true, /* the one and only */
- bfd_default_compatible,
+ bfd_default_compatible,
bfd_default_scan ,
0,
};
/* BFD library support routines for the Pico Java architecture.
- Copyright 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
Hacked by Steve Chamberlain of Transmeta. sac@pobox.com
This file is part of BFD, the Binary File Descriptor library.
#include "sysdep.h"
#include "libbfd.h"
+static boolean scan_mach
+ PARAMS ((const struct bfd_arch_info *, const char *));
+
static boolean
scan_mach (info, string)
const struct bfd_arch_info *info;
/* BFD library support routines for the Hitachi-SH architecture.
- Copyright 1993, 1994, 1997, 1998, 2000 Free Software Foundation, Inc.
+ Copyright 1993, 1994, 1997, 1998, 2000, 2001
+ Free Software Foundation, Inc.
Hacked by Steve Chamberlain of Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
#include "sysdep.h"
#include "libbfd.h"
+static boolean scan_mach
+ PARAMS ((const struct bfd_arch_info *, const char *));
+
static boolean
scan_mach (info, string)
const struct bfd_arch_info *info;
/* BFD library support routines for the WDC 65816 architecture.
- Copyright 1995, 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1995, 1999, 2000, 2001 Free Software Foundation, Inc.
Hacked by Steve Chamberlain of Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
#include "sysdep.h"
#include "libbfd.h"
-int bfd_default_scan_num_mach();
+static boolean scan_mach
+ PARAMS ((const struct bfd_arch_info *, const char *));
static boolean
scan_mach (info, string)
/* BFD library support routines for the Z800n architecture.
- Copyright 1992, 1993, 1994, 2000 Free Software Foundation, Inc.
+ Copyright 1992, 1993, 1994, 2000, 2001 Free Software Foundation, Inc.
Hacked by Steve Chamberlain of Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
#include "sysdep.h"
#include "libbfd.h"
+static boolean scan_mach
+ PARAMS ((const struct bfd_arch_info *, const char *));
+static const bfd_arch_info_type *compatible
+ PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
+
#if 0 /* not used currently */
/*
Relocations for the Z8K
}
#endif
-int bfd_default_scan_num_mach ();
-
static boolean
scan_mach (info, string)
const struct bfd_arch_info *info;
alloc_dwarf1_unit (stash)
struct dwarf1_debug* stash;
{
- struct dwarf1_unit* x =
- (struct dwarf1_unit*) bfd_zalloc (stash->abfd,
- sizeof (struct dwarf1_unit));
+ bfd_size_type amt = sizeof (struct dwarf1_unit);
+
+ struct dwarf1_unit* x = (struct dwarf1_unit*) bfd_zalloc (stash->abfd, amt);
x->prev = stash->lastUnit;
stash->lastUnit = x;
struct dwarf1_debug* stash;
struct dwarf1_unit* aUnit;
{
- struct dwarf1_func* x =
- (struct dwarf1_func*) bfd_zalloc (stash->abfd,
- sizeof (struct dwarf1_func));
+ bfd_size_type amt = sizeof (struct dwarf1_func);
+
+ struct dwarf1_func* x = (struct dwarf1_func*) bfd_zalloc (stash->abfd, amt);
x->prev = aUnit->func_list;
aUnit->func_list = x;
if (stash->line_section == 0)
{
asection *msec;
- unsigned long size;
+ bfd_size_type size;
msec = bfd_get_section_by_name (stash->abfd, ".line");
if (! msec)
if (! stash->line_section)
return false;
- if (! bfd_get_section_contents (stash->abfd, msec, stash->line_section, 0, size))
+ if (! bfd_get_section_contents (stash->abfd, msec, stash->line_section,
+ (bfd_vma) 0, size))
{
stash->line_section = 0;
return false;
if (xptr < stash->line_section_end)
{
unsigned long eachLine;
-
- char* tblend;
+ char *tblend;
unsigned long base;
+ bfd_size_type amt;
/* First comes the length. */
tblend = bfd_get_32 (stash->abfd, (bfd_byte *) xptr) + xptr;
aUnit->line_count = (tblend - xptr) / 10;
/* Allocate an array for the entries. */
- aUnit->linenumber_table = (struct linenumber *)
- bfd_alloc (stash->abfd,
- sizeof (struct linenumber) * aUnit->line_count);
+ amt = sizeof (struct linenumber) * aUnit->line_count;
+ aUnit->linenumber_table = ((struct linenumber *)
+ bfd_alloc (stash->abfd, amt));
for (eachLine = 0; eachLine < aUnit->line_count; eachLine++)
{
if (! stash)
{
asection *msec;
- unsigned long size;
+ bfd_size_type size = sizeof (struct dwarf1_debug);
- stash = elf_tdata (abfd)->dwarf1_find_line_info =
- (struct dwarf1_debug*) bfd_zalloc (abfd, sizeof (struct dwarf1_debug));
+ stash = elf_tdata (abfd)->dwarf1_find_line_info
+ = (struct dwarf1_debug *) bfd_zalloc (abfd, size);
if (! stash)
return false;
if (! stash->debug_section)
return false;
- if (! bfd_get_section_contents (abfd, msec, stash->debug_section, 0, size))
+ if (! bfd_get_section_contents (abfd, msec, stash->debug_section,
+ (bfd_vma) 0, size))
{
stash->debug_section = 0;
return false;
struct abbrev_info *cur_abbrev;
unsigned int abbrev_number, bytes_read, abbrev_name;
unsigned int abbrev_form, hash_number;
+ bfd_size_type amt;
if (! stash->dwarf_abbrev_buffer)
{
}
stash->dwarf_abbrev_size = msec->_raw_size;
- stash->dwarf_abbrev_buffer = (char*) bfd_alloc (abfd, stash->dwarf_abbrev_size);
+ stash->dwarf_abbrev_buffer = (char*) bfd_alloc (abfd, msec->_raw_size);
if (! stash->dwarf_abbrev_buffer)
return 0;
- if (! bfd_get_section_contents (abfd, msec,
- stash->dwarf_abbrev_buffer, 0,
- stash->dwarf_abbrev_size))
+ if (! bfd_get_section_contents (abfd, msec, stash->dwarf_abbrev_buffer,
+ (bfd_vma) 0, msec->_raw_size))
return 0;
}
return 0;
}
- abbrevs = (struct abbrev_info**) bfd_zalloc (abfd, sizeof (struct abbrev_info*) * ABBREV_HASH_SIZE);
+ amt = sizeof (struct abbrev_info*) * ABBREV_HASH_SIZE;
+ abbrevs = (struct abbrev_info**) bfd_zalloc (abfd, amt);
abbrev_ptr = stash->dwarf_abbrev_buffer + offset;
abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read);
/* Loop until we reach an abbrev number of 0. */
while (abbrev_number)
{
- cur_abbrev = (struct abbrev_info*)bfd_zalloc (abfd, sizeof (struct abbrev_info));
+ amt = sizeof (struct abbrev_info);
+ cur_abbrev = (struct abbrev_info *) bfd_zalloc (abfd, amt);
/* Read in abbrev header. */
cur_abbrev->number = abbrev_number;
{
if ((cur_abbrev->num_attrs % ATTR_ALLOC_CHUNK) == 0)
{
- cur_abbrev->attrs = (struct attr_abbrev *)
- bfd_realloc (cur_abbrev->attrs,
- (cur_abbrev->num_attrs + ATTR_ALLOC_CHUNK)
- * sizeof (struct attr_abbrev));
+ amt = cur_abbrev->num_attrs + ATTR_ALLOC_CHUNK;
+ amt *= sizeof (struct attr_abbrev);
+ cur_abbrev->attrs = ((struct attr_abbrev *)
+ bfd_realloc (cur_abbrev->attrs, amt));
if (! cur_abbrev->attrs)
return 0;
}
bfd *abfd = unit->abfd;
unsigned int bytes_read;
struct dwarf_block *blk;
+ bfd_size_type amt;
attr->name = abbrev->name;
attr->form = abbrev->form;
info_ptr += unit->addr_size;
break;
case DW_FORM_block2:
- blk = (struct dwarf_block *) bfd_alloc (abfd, sizeof (struct dwarf_block));
+ amt = sizeof (struct dwarf_block);
+ blk = (struct dwarf_block *) bfd_alloc (abfd, amt);
blk->size = read_2_bytes (abfd, info_ptr);
info_ptr += 2;
blk->data = read_n_bytes (abfd, info_ptr, blk->size);
DW_BLOCK (attr) = blk;
break;
case DW_FORM_block4:
- blk = (struct dwarf_block *) bfd_alloc (abfd, sizeof (struct dwarf_block));
+ amt = sizeof (struct dwarf_block);
+ blk = (struct dwarf_block *) bfd_alloc (abfd, amt);
blk->size = read_4_bytes (abfd, info_ptr);
info_ptr += 4;
blk->data = read_n_bytes (abfd, info_ptr, blk->size);
info_ptr += bytes_read;
break;
case DW_FORM_block:
- blk = (struct dwarf_block *) bfd_alloc (abfd, sizeof (struct dwarf_block));
+ amt = sizeof (struct dwarf_block);
+ blk = (struct dwarf_block *) bfd_alloc (abfd, amt);
blk->size = read_unsigned_leb128 (abfd, info_ptr, &bytes_read);
info_ptr += bytes_read;
blk->data = read_n_bytes (abfd, info_ptr, blk->size);
DW_BLOCK (attr) = blk;
break;
case DW_FORM_block1:
- blk = (struct dwarf_block *) bfd_alloc (abfd, sizeof (struct dwarf_block));
+ amt = sizeof (struct dwarf_block);
+ blk = (struct dwarf_block *) bfd_alloc (abfd, amt);
blk->size = read_1_byte (abfd, info_ptr);
info_ptr += 1;
blk->data = read_n_bytes (abfd, info_ptr, blk->size);
unsigned int column;
int end_sequence;
{
- struct line_info* info = (struct line_info*)
- bfd_alloc (table->abfd, sizeof (struct line_info));
+ bfd_size_type amt = sizeof (struct line_info);
+ struct line_info* info = (struct line_info*) bfd_alloc (table->abfd, amt);
info->prev_line = table->last_line;
table->last_line = info;
}
/* Need to allocate a new arange and insert it into the arange list. */
- arange = bfd_zalloc (unit->abfd, sizeof (*arange));
+ arange = bfd_zalloc (unit->abfd, (bfd_size_type) sizeof (*arange));
arange->low = low_pc;
arange->high = high_pc;
unsigned int i, bytes_read;
char *cur_file, *cur_dir;
unsigned char op_code, extended_op, adj_opcode;
+ bfd_size_type amt;
if (! stash->dwarf_line_buffer)
{
}
stash->dwarf_line_size = msec->_raw_size;
- stash->dwarf_line_buffer = (char *) bfd_alloc (abfd, stash->dwarf_line_size);
+ stash->dwarf_line_buffer = (char *) bfd_alloc (abfd, msec->_raw_size);
if (! stash->dwarf_line_buffer)
return 0;
- if (! bfd_get_section_contents (abfd, msec,
- stash->dwarf_line_buffer, 0,
- stash->dwarf_line_size))
+ if (! bfd_get_section_contents (abfd, msec, stash->dwarf_line_buffer,
+ (bfd_vma) 0, msec->_raw_size))
return 0;
/* FIXME: We ought to apply the relocs against this section before
return 0;
}
- table = (struct line_info_table*) bfd_alloc (abfd,
- sizeof (struct line_info_table));
+ amt = sizeof (struct line_info_table);
+ table = (struct line_info_table*) bfd_alloc (abfd, amt);
table->abfd = abfd;
table->comp_dir = unit->comp_dir;
line_ptr += 1;
lh.opcode_base = read_1_byte (abfd, line_ptr);
line_ptr += 1;
- lh.standard_opcode_lengths = (unsigned char *)
- bfd_alloc (abfd, lh.opcode_base * sizeof (unsigned char));
+ amt = lh.opcode_base * sizeof (unsigned char);
+ lh.standard_opcode_lengths = (unsigned char *) bfd_alloc (abfd, amt);
lh.standard_opcode_lengths[0] = 1;
if ((table->num_dirs % DIR_ALLOC_CHUNK) == 0)
{
- table->dirs = (char **)
- bfd_realloc (table->dirs,
- (table->num_dirs + DIR_ALLOC_CHUNK) * sizeof (char *));
+ amt = table->num_dirs + DIR_ALLOC_CHUNK;
+ amt *= sizeof (char *);
+ table->dirs = (char **) bfd_realloc (table->dirs, amt);
if (! table->dirs)
return 0;
}
if ((table->num_files % FILE_ALLOC_CHUNK) == 0)
{
- table->files = (struct fileinfo *)
- bfd_realloc (table->files,
- (table->num_files + FILE_ALLOC_CHUNK)
- * sizeof (struct fileinfo));
+ amt = table->num_files + FILE_ALLOC_CHUNK;
+ amt *= sizeof (struct fileinfo);
+ table->files = (struct fileinfo *) bfd_realloc (table->files, amt);
if (! table->files)
return 0;
}
line_ptr += bytes_read;
if ((table->num_files % FILE_ALLOC_CHUNK) == 0)
{
- table->files = (struct fileinfo *)
- bfd_realloc (table->files,
- (table->num_files + FILE_ALLOC_CHUNK)
- * sizeof (struct fileinfo));
+ amt = table->num_files + FILE_ALLOC_CHUNK;
+ amt *= sizeof (struct fileinfo);
+ table->files =
+ (struct fileinfo *) bfd_realloc (table->files, amt);
if (! table->files)
return 0;
}
if (abbrev->tag == DW_TAG_subprogram)
{
- func = (struct funcinfo*) bfd_zalloc (abfd, sizeof (struct funcinfo));
+ bfd_size_type amt = sizeof (struct funcinfo);
+ func = (struct funcinfo *) bfd_zalloc (abfd, amt);
func->prev_func = unit->function_table;
unit->function_table = func;
}
if (reloc_size <= 0)
return 0;
- relocs = (arelent **) bfd_malloc ((size_t) reloc_size);
+ relocs = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
if (relocs == NULL)
return 0;
free (relocs);
return addend;
}
-
+
free (relocs);
return 0;
}
char *info_ptr = stash->info_ptr;
char *end_ptr = info_ptr + unit_length;
+ bfd_size_type amt;
+ bfd_size_type off;
version = read_2_bytes (abfd, info_ptr);
info_ptr += 2;
.debug_abbrev+offset. On RELA targets, we have to find the
relocation and extract the addend to obtain the actual
abbrev_offset, so do it here. */
- abbrev_offset += find_rela_addend (abfd, stash->sec,
- info_ptr - stash->sec_info_ptr,
- stash->syms);
+ off = info_ptr - stash->sec_info_ptr;
+ abbrev_offset += find_rela_addend (abfd, stash->sec, off, stash->syms);
info_ptr += abbrev_length;
addr_size = read_1_byte (abfd, info_ptr);
info_ptr += 1;
return 0;
}
- unit = (struct comp_unit*) bfd_zalloc (abfd, sizeof (struct comp_unit));
+ amt = sizeof (struct comp_unit);
+ unit = (struct comp_unit*) bfd_zalloc (abfd, amt);
unit->abfd = abfd;
unit->addr_size = addr_size;
unit->abbrevs = abbrevs;
if (! stash)
{
- unsigned long total_size;
+ bfd_size_type total_size;
asection *msec;
+ bfd_size_type amt = sizeof (struct dwarf2_debug);
- stash =
- (struct dwarf2_debug*) bfd_zalloc (abfd, sizeof (struct dwarf2_debug));
+ stash = (struct dwarf2_debug*) bfd_zalloc (abfd, amt);
if (! stash)
return false;
msec;
msec = find_debug_info (abfd, msec))
{
- unsigned long size;
- unsigned long start;
+ bfd_size_type size;
+ bfd_size_type start;
size = msec->_raw_size;
if (size == 0)
start = stash->info_ptr_end - stash->info_ptr;
- if (! bfd_get_section_contents (abfd, msec, stash->info_ptr + start, 0, size))
+ if (! bfd_get_section_contents (abfd, msec, stash->info_ptr + start,
+ (bfd_vma) 0, size))
continue;
stash->info_ptr_end = stash->info_ptr + start + size;
/* Read each remaining comp. units checking each as they are read. */
while (stash->info_ptr < stash->info_ptr_end)
{
- struct comp_unit* each;
bfd_vma length;
boolean found;
static bfd_size_type ecoff_compute_reloc_file_positions PARAMS ((bfd *abfd));
static boolean ecoff_get_extr PARAMS ((asymbol *, EXTR *));
static void ecoff_set_index PARAMS ((asymbol *, bfd_size_type));
-static unsigned int ecoff_armap_hash PARAMS ((CONST char *s,
+static unsigned int ecoff_armap_hash PARAMS ((const char *s,
unsigned int *rehash,
unsigned int size,
unsigned int hlog));
"*DEBUG*", 0, 0, NULL, 0, 0, 0,
/* linker_mark, linker_has_input, gc_mark, segment_mark, */
0, 0, 0, 0,
- /* vma, lma, _cooked_size, _raw_size, */
+ /* vma, lma, _cooked_size, _raw_size, */
0, 0, 0, 0,
/* output_offset, output_section, alignment_power, */
0, NULL, 0,
_bfd_ecoff_mkobject (abfd)
bfd *abfd;
{
- abfd->tdata.ecoff_obj_data = ((struct ecoff_tdata *)
- bfd_zalloc (abfd, sizeof (ecoff_data_type)));
+ bfd_size_type amt = sizeof (ecoff_data_type);
+ abfd->tdata.ecoff_obj_data = (struct ecoff_tdata *) bfd_zalloc (abfd, amt);
if (abfd->tdata.ecoff_obj_data == NULL)
return false;
}
/* Read the symbolic information header. */
- raw = (PTR) bfd_malloc ((size_t) external_hdr_size);
+ raw = (PTR) bfd_malloc (external_hdr_size);
if (raw == NULL)
goto error_return;
- if (bfd_seek (abfd, ecoff_data (abfd)->sym_filepos, SEEK_SET) == -1
- || (bfd_read (raw, external_hdr_size, 1, abfd)
- != external_hdr_size))
+ if (bfd_seek (abfd, ecoff_data (abfd)->sym_filepos, SEEK_SET) != 0
+ || bfd_bread (raw, external_hdr_size, abfd) != external_hdr_size)
goto error_return;
internal_symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
(*backend->debug_swap.swap_hdr_in) (abfd, raw, internal_symhdr);
struct fdr *fdr_ptr;
bfd_size_type raw_end;
bfd_size_type cb_end;
+ bfd_size_type amt;
+ file_ptr pos;
BFD_ASSERT (debug == &ecoff_data (abfd)->debug_info);
raw = (PTR) bfd_alloc (abfd, raw_size);
if (raw == NULL)
return false;
- if (bfd_seek (abfd,
- (ecoff_data (abfd)->sym_filepos
- + backend->debug_swap.external_hdr_size),
- SEEK_SET) != 0
- || bfd_read (raw, raw_size, 1, abfd) != raw_size)
+
+ pos = ecoff_data (abfd)->sym_filepos;
+ pos += backend->debug_swap.external_hdr_size;
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0
+ || bfd_bread (raw, raw_size, abfd) != raw_size)
{
bfd_release (abfd, raw);
return false;
We need to look at the fdr to deal with a lot of information in
the symbols, so we swap them here. */
- debug->fdr = (struct fdr *) bfd_alloc (abfd,
- (internal_symhdr->ifdMax *
- sizeof (struct fdr)));
+ amt = internal_symhdr->ifdMax;
+ amt *= sizeof (struct fdr);
+ debug->fdr = (struct fdr *) bfd_alloc (abfd, amt);
if (debug->fdr == NULL)
return false;
external_fdr_size = backend->debug_swap.external_fdr_size;
bfd *abfd;
{
ecoff_symbol_type *new;
+ bfd_size_type amt = sizeof (ecoff_symbol_type);
- new = (ecoff_symbol_type *) bfd_alloc (abfd, sizeof (ecoff_symbol_type));
+ new = (ecoff_symbol_type *) bfd_alloc (abfd, amt);
if (new == (ecoff_symbol_type *) NULL)
return (asymbol *) NULL;
memset ((PTR) new, 0, sizeof *new);
asection *section;
arelent_chain *reloc_chain;
unsigned int bitsize;
+ bfd_size_type amt;
/* Get a section with the same name as the symbol (usually
__CTOR_LIST__ or __DTOR_LIST__). FIXME: gcc uses the
{
char *copy;
- copy = (char *) bfd_alloc (abfd, strlen (name) + 1);
+ amt = strlen (name) + 1;
+ copy = (char *) bfd_alloc (abfd, amt);
if (!copy)
return false;
strcpy (copy, name);
}
/* Build a reloc pointing to this constructor. */
- reloc_chain =
- (arelent_chain *) bfd_alloc (abfd, sizeof (arelent_chain));
+ amt = sizeof (arelent_chain);
+ reloc_chain = (arelent_chain *) bfd_alloc (abfd, amt);
if (!reloc_chain)
return false;
reloc_chain->relent.sym_ptr_ptr =
if (bfd_get_symcount (abfd) == 0)
return true;
- internal_size = bfd_get_symcount (abfd) * sizeof (ecoff_symbol_type);
+ internal_size = bfd_get_symcount (abfd);
+ internal_size *= sizeof (ecoff_symbol_type);
internal = (ecoff_symbol_type *) bfd_alloc (abfd, internal_size);
if (internal == NULL)
return false;
const struct ecoff_backend_data * const backend = ecoff_backend (abfd);
arelent *internal_relocs;
bfd_size_type external_reloc_size;
- bfd_size_type external_relocs_size;
+ bfd_size_type amt;
char *external_relocs;
arelent *rptr;
unsigned int i;
if (_bfd_ecoff_slurp_symbol_table (abfd) == false)
return false;
- internal_relocs = (arelent *) bfd_alloc (abfd,
- (sizeof (arelent)
- * section->reloc_count));
+ amt = section->reloc_count;
+ amt *= sizeof (arelent);
+ internal_relocs = (arelent *) bfd_alloc (abfd, amt);
+
external_reloc_size = backend->external_reloc_size;
- external_relocs_size = external_reloc_size * section->reloc_count;
- external_relocs = (char *) bfd_alloc (abfd, external_relocs_size);
+ amt = external_reloc_size * section->reloc_count;
+ external_relocs = (char *) bfd_alloc (abfd, amt);
if (internal_relocs == (arelent *) NULL
|| external_relocs == (char *) NULL)
return false;
if (bfd_seek (abfd, section->rel_filepos, SEEK_SET) != 0)
return false;
- if (bfd_read (external_relocs, 1, external_relocs_size, abfd)
- != external_relocs_size)
+ if (bfd_bread (external_relocs, amt, abfd) != amt)
return false;
for (i = 0, rptr = internal_relocs; i < section->reloc_count; i++, rptr++)
}
else
{
- CONST char *sec_name;
+ const char *sec_name;
asection *sec;
/* r_symndx is a section key. */
asection *section;
asymbol **ignore_symbols ATTRIBUTE_UNUSED;
bfd_vma offset;
- CONST char **filename_ptr;
- CONST char **functionname_ptr;
+ const char **filename_ptr;
+ const char **functionname_ptr;
unsigned int *retline_ptr;
{
const struct ecoff_debug_swap * const debug_swap
if (ecoff_data (abfd)->find_line_info == NULL)
{
- ecoff_data (abfd)->find_line_info =
- ((struct ecoff_find_line *)
- bfd_zalloc (abfd, sizeof (struct ecoff_find_line)));
+ bfd_size_type amt = sizeof (struct ecoff_find_line);
+ ecoff_data (abfd)->find_line_info
+ = (struct ecoff_find_line *) bfd_zalloc (abfd, amt);
if (ecoff_data (abfd)->find_line_info == NULL)
return false;
}
boolean rdata_in_text;
boolean first_data, first_nonalloc;
const bfd_vma round = ecoff_backend (abfd)->round;
+ bfd_size_type amt;
sofar = _bfd_ecoff_sizeof_headers (abfd, false);
file_sofar = sofar;
/* Sort the sections by VMA. */
- sorted_hdrs = (asection **) bfd_malloc (abfd->section_count
- * sizeof (asection *));
+ amt = abfd->section_count;
+ amt *= sizeof (asection *);
+ sorted_hdrs = (asection **) bfd_malloc (amt);
if (sorted_hdrs == NULL)
return false;
for (current = abfd->sections, i = 0;
file_ptr offset;
bfd_size_type count;
{
+ file_ptr pos;
+
/* This must be done first, because bfd_set_section_contents is
going to set output_has_begun to true. */
if (abfd->output_has_begun == false)
if (count == 0)
return true;
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
- || bfd_write (location, 1, count, abfd) != count)
+ pos = section->filepos + offset;
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (location, count, abfd) != count)
return false;
return true;
siz = filhsz;
if (siz < aoutsz)
siz = aoutsz;
- buff = (PTR) bfd_malloc ((size_t) siz);
+ buff = (PTR) bfd_malloc (siz);
if (buff == NULL)
goto error_return;
}
current->flags);
if (bfd_coff_swap_scnhdr_out (abfd, (PTR) §ion, buff) == 0
- || bfd_write (buff, 1, scnhsz, abfd) != scnhsz)
+ || bfd_bwrite (buff, scnhsz, abfd) != scnhsz)
goto error_return;
if ((section.s_flags & STYP_TEXT) != 0
goto error_return;
bfd_coff_swap_filehdr_out (abfd, (PTR) &internal_f, buff);
- if (bfd_write (buff, 1, filhsz, abfd) != filhsz)
+ if (bfd_bwrite (buff, filhsz, abfd) != filhsz)
goto error_return;
bfd_coff_swap_aouthdr_out (abfd, (PTR) &internal_a, buff);
- if (bfd_write (buff, 1, aoutsz, abfd) != aoutsz)
+ if (bfd_bwrite (buff, aoutsz, abfd) != aoutsz)
goto error_return;
/* Build the external symbol information. This must be done before
arelent **reloc_ptr_ptr;
arelent **reloc_end;
char *out_ptr;
+ bfd_size_type amt;
if (current->reloc_count == 0)
continue;
- reloc_buff =
- bfd_alloc (abfd, current->reloc_count * external_reloc_size);
+ amt = current->reloc_count * external_reloc_size;
+ reloc_buff = bfd_alloc (abfd, amt);
if (reloc_buff == NULL)
goto error_return;
}
else
{
- CONST char *name;
+ const char *name;
name = bfd_get_section_name (abfd, bfd_get_section (sym));
if (strcmp (name, ".text") == 0)
if (bfd_seek (abfd, current->rel_filepos, SEEK_SET) != 0)
goto error_return;
- if (bfd_write (reloc_buff,
- external_reloc_size, current->reloc_count, abfd)
- != external_reloc_size * current->reloc_count)
+ amt = current->reloc_count * external_reloc_size;
+ if (bfd_bwrite (reloc_buff, amt, abfd) != amt)
goto error_return;
bfd_release (abfd, reloc_buff);
reloc_buff = NULL;
if (bfd_seek (abfd, (file_ptr) ecoff_data (abfd)->sym_filepos - 1,
SEEK_SET) != 0)
goto error_return;
- if (bfd_read (&c, 1, 1, abfd) == 0)
+ if (bfd_bread (&c, (bfd_size_type) 1, abfd) == 0)
c = 0;
if (bfd_seek (abfd, (file_ptr) ecoff_data (abfd)->sym_filepos - 1,
SEEK_SET) != 0)
goto error_return;
- if (bfd_write (&c, 1, 1, abfd) != 1)
+ if (bfd_bwrite (&c, (bfd_size_type) 1, abfd) != 1)
goto error_return;
}
static unsigned int
ecoff_armap_hash (s, rehash, size, hlog)
- CONST char *s;
+ const char *s;
unsigned int *rehash;
unsigned int size;
unsigned int hlog;
char *raw_ptr;
struct symdef *symdef_ptr;
char *stringbase;
+ bfd_size_type amt;
/* Get the name of the first element. */
- i = bfd_read ((PTR) nextname, 1, 16, abfd);
+ i = bfd_bread ((PTR) nextname, (bfd_size_type) 16, abfd);
if (i == 0)
return true;
if (i != 16)
if (raw_armap == (char *) NULL)
return false;
- if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
+ if (bfd_bread ((PTR) raw_armap, parsed_size, abfd) != parsed_size)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
ardata->tdata = (PTR) raw_armap;
- count = bfd_h_get_32 (abfd, (PTR) raw_armap);
+ count = H_GET_32 (abfd, raw_armap);
ardata->symdef_count = 0;
ardata->cache = (struct ar_cache *) NULL;
unsigned int name_offset, file_offset;
unsigned int hash, rehash, srch;
- name_offset = bfd_h_get_32 (abfd, (PTR) raw_ptr);
- file_offset = bfd_h_get_32 (abfd, (PTR) (raw_ptr + 4));
+ name_offset = H_GET_32 (abfd, raw_ptr);
+ file_offset = H_GET_32 (abfd, (raw_ptr + 4));
if (file_offset == 0)
continue;
hash = ecoff_armap_hash (stringbase + name_offset, &rehash, count,
for (srch = (hash + rehash) & (count - 1);
srch != hash && srch != i;
srch = (srch + rehash) & (count - 1))
- BFD_ASSERT (bfd_h_get_32 (abfd, (PTR) (raw_armap + 8 + srch * 8))
- != 0);
+ BFD_ASSERT (H_GET_32 (abfd, (raw_armap + 8 + srch * 8)) != 0);
BFD_ASSERT (srch == i);
}
}
raw_ptr = raw_armap + 4;
for (i = 0; i < count; i++, raw_ptr += 8)
- if (bfd_h_get_32 (abfd, (PTR) (raw_ptr + 4)) != 0)
+ if (H_GET_32 (abfd, (raw_ptr + 4)) != 0)
++ardata->symdef_count;
- symdef_ptr = ((struct symdef *)
- bfd_alloc (abfd,
- ardata->symdef_count * sizeof (struct symdef)));
+ amt = ardata->symdef_count;
+ amt *= sizeof (struct symdef);
+ symdef_ptr = (struct symdef *) bfd_alloc (abfd, amt);
if (!symdef_ptr)
return false;
{
unsigned int name_offset, file_offset;
- file_offset = bfd_h_get_32 (abfd, (PTR) (raw_ptr + 4));
+ file_offset = H_GET_32 (abfd, (raw_ptr + 4));
if (file_offset == 0)
continue;
- name_offset = bfd_h_get_32 (abfd, (PTR) raw_ptr);
+ name_offset = H_GET_32 (abfd, raw_ptr);
symdef_ptr->s.name = stringbase + name_offset;
symdef_ptr->file_offset = file_offset;
++symdef_ptr;
int stridx;
{
unsigned int hashsize, hashlog;
- unsigned int symdefsize;
+ bfd_size_type symdefsize;
int padit;
unsigned int stringsize;
unsigned int mapsize;
if (((char *) (&hdr))[i] == '\0')
(((char *) (&hdr))[i]) = ' ';
- if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), abfd)
+ if (bfd_bwrite ((PTR) &hdr, (bfd_size_type) sizeof (struct ar_hdr), abfd)
!= sizeof (struct ar_hdr))
return false;
- bfd_h_put_32 (abfd, (bfd_vma) hashsize, temp);
- if (bfd_write ((PTR) temp, 1, 4, abfd) != 4)
+ H_PUT_32 (abfd, hashsize, temp);
+ if (bfd_bwrite ((PTR) temp, (bfd_size_type) 4, abfd) != 4)
return false;
hashtable = (bfd_byte *) bfd_zalloc (abfd, symdefsize);
/* Advance firstreal to the file position of this archive
element. */
- if (((bfd *) map[i].pos) != last_elt)
+ if (map[i].u.abfd != last_elt)
{
do
{
firstreal += firstreal % 2;
current = current->next;
}
- while (current != (bfd *) map[i].pos);
+ while (current != map[i].u.abfd);
}
last_elt = current;
hash = ecoff_armap_hash (*map[i].name, &rehash, hashsize, hashlog);
- if (bfd_h_get_32 (abfd, (PTR) (hashtable + (hash * 8) + 4)) != 0)
+ if (H_GET_32 (abfd, (hashtable + (hash * 8) + 4)) != 0)
{
unsigned int srch;
for (srch = (hash + rehash) & (hashsize - 1);
srch != hash;
srch = (srch + rehash) & (hashsize - 1))
- if (bfd_h_get_32 (abfd, (PTR) (hashtable + (srch * 8) + 4)) == 0)
+ if (H_GET_32 (abfd, (hashtable + (srch * 8) + 4)) == 0)
break;
BFD_ASSERT (srch != hash);
hash = srch;
}
- bfd_h_put_32 (abfd, (bfd_vma) map[i].namidx,
- (PTR) (hashtable + hash * 8));
- bfd_h_put_32 (abfd, (bfd_vma) firstreal,
- (PTR) (hashtable + hash * 8 + 4));
+ H_PUT_32 (abfd, map[i].namidx, (hashtable + hash * 8));
+ H_PUT_32 (abfd, firstreal, (hashtable + hash * 8 + 4));
}
- if (bfd_write ((PTR) hashtable, 1, symdefsize, abfd) != symdefsize)
+ if (bfd_bwrite ((PTR) hashtable, symdefsize, abfd) != symdefsize)
return false;
bfd_release (abfd, hashtable);
/* Now write the strings. */
- bfd_h_put_32 (abfd, (bfd_vma) stringsize, temp);
- if (bfd_write ((PTR) temp, 1, 4, abfd) != 4)
+ H_PUT_32 (abfd, stringsize, temp);
+ if (bfd_bwrite ((PTR) temp, (bfd_size_type) 4, abfd) != 4)
return false;
for (i = 0; i < orl_count; i++)
{
bfd_size_type len;
len = strlen (*map[i].name) + 1;
- if (bfd_write ((PTR) (*map[i].name), 1, len, abfd) != len)
+ if (bfd_bwrite ((PTR) (*map[i].name), len, abfd) != len)
return false;
}
bug-compatible for DECstation ar we use a null. */
if (padit)
{
- if (bfd_write ("", 1, 1, abfd) != 1)
+ if (bfd_bwrite ("", (bfd_size_type) 1, abfd) != 1)
return false;
}
{
struct artdata *tdata_hold;
char armag[SARMAG + 1];
+ bfd_size_type amt;
tdata_hold = abfd->tdata.aout_ar_data;
- if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
+ if (bfd_bread ((PTR) armag, (bfd_size_type) SARMAG, abfd) != SARMAG)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
/* We are setting bfd_ardata(abfd) here, but since bfd_ardata
involves a cast, we can't do it as the left operand of
assignment. */
- abfd->tdata.aout_ar_data =
- (struct artdata *) bfd_zalloc (abfd, sizeof (struct artdata));
+ amt = sizeof (struct artdata);
+ abfd->tdata.aout_ar_data = (struct artdata *) bfd_zalloc (abfd, amt);
if (bfd_ardata (abfd) == (struct artdata *) NULL)
{
bfd *abfd;
{
struct ecoff_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct ecoff_link_hash_table);
- ret = ((struct ecoff_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct ecoff_link_hash_table)));
+ ret = (struct ecoff_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == NULL)
return NULL;
if (! _bfd_link_hash_table_init (&ret->root, abfd,
return (_bfd_generic_link_add_archive_symbols
(abfd, info, ecoff_link_check_archive_element));
- armap_count = bfd_h_get_32 (abfd, raw_armap);
+ armap_count = H_GET_32 (abfd, raw_armap);
armap_log = 0;
for (i = 1; i < armap_count; i <<= 1)
hash = ecoff_armap_hash (h->root.string, &rehash, armap_count,
armap_log);
- file_offset = bfd_h_get_32 (abfd, hashtable + (hash * 8) + 4);
+ file_offset = H_GET_32 (abfd, hashtable + (hash * 8) + 4);
if (file_offset == 0)
{
/* Nothing in this slot. */
continue;
}
- name = stringbase + bfd_h_get_32 (abfd, hashtable + (hash * 8));
+ name = stringbase + H_GET_32 (abfd, hashtable + (hash * 8));
if (name[0] != h->root.string[0]
|| strcmp (name, h->root.string) != 0)
{
srch != hash;
srch = (srch + rehash) & (armap_count - 1))
{
- file_offset = bfd_h_get_32 (abfd, hashtable + (srch * 8) + 4);
+ file_offset = H_GET_32 (abfd, hashtable + (srch * 8) + 4);
if (file_offset == 0)
break;
- name = stringbase + bfd_h_get_32 (abfd, hashtable + (srch * 8));
+ name = stringbase + H_GET_32 (abfd, hashtable + (srch * 8));
if (name[0] == h->root.string[0]
&& strcmp (name, h->root.string) == 0)
{
hash = srch;
}
- element = (*backend->get_elt_at_filepos) (abfd, file_offset);
+ element = (*backend->get_elt_at_filepos) (abfd, (file_ptr) file_offset);
if (element == (bfd *) NULL)
return false;
HDRR *symhdr;
bfd_size_type external_ext_size;
PTR external_ext = NULL;
- size_t esize;
+ bfd_size_type esize;
char *ssext = NULL;
char *ext_ptr;
char *ext_end;
if (external_ext == NULL && esize != 0)
goto error_return;
- if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0
- || bfd_read (external_ext, 1, esize, abfd) != esize)
+ if (bfd_seek (abfd, (file_ptr) symhdr->cbExtOffset, SEEK_SET) != 0
+ || bfd_bread (external_ext, esize, abfd) != esize)
goto error_return;
- ssext = (char *) bfd_malloc (symhdr->issExtMax);
+ ssext = (char *) bfd_malloc ((bfd_size_type) symhdr->issExtMax);
if (ssext == NULL && symhdr->issExtMax != 0)
goto error_return;
- if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0
- || (bfd_read (ssext, 1, symhdr->issExtMax, abfd) !=
- (bfd_size_type) symhdr->issExtMax))
+ if (bfd_seek (abfd, (file_ptr) symhdr->cbSsExtOffset, SEEK_SET) != 0
+ || (bfd_bread (ssext, (bfd_size_type) symhdr->issExtMax, abfd)
+ != (bfd_size_type) symhdr->issExtMax))
goto error_return;
/* Look through the external symbols to see if they define some
HDRR *symhdr;
bfd_size_type external_ext_size;
PTR external_ext = NULL;
- size_t esize;
+ bfd_size_type esize;
char *ssext = NULL;
boolean result;
if (external_ext == NULL && esize != 0)
goto error_return;
- if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0
- || bfd_read (external_ext, 1, esize, abfd) != esize)
+ if (bfd_seek (abfd, (file_ptr) symhdr->cbExtOffset, SEEK_SET) != 0
+ || bfd_bread (external_ext, esize, abfd) != esize)
goto error_return;
- ssext = (char *) bfd_malloc (symhdr->issExtMax);
+ ssext = (char *) bfd_malloc ((bfd_size_type) symhdr->issExtMax);
if (ssext == NULL && symhdr->issExtMax != 0)
goto error_return;
- if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0
- || (bfd_read (ssext, 1, symhdr->issExtMax, abfd)
+ if (bfd_seek (abfd, (file_ptr) symhdr->cbSsExtOffset, SEEK_SET) != 0
+ || (bfd_bread (ssext, (bfd_size_type) symhdr->issExtMax, abfd)
!= (bfd_size_type) symhdr->issExtMax))
goto error_return;
struct ecoff_link_hash_entry **sym_hash;
char *ext_ptr;
char *ext_end;
+ bfd_size_type amt;
ext_count = ecoff_data (abfd)->debug_info.symbolic_header.iextMax;
- sym_hash = ((struct ecoff_link_hash_entry **)
- bfd_alloc (abfd,
- ext_count * sizeof (struct bfd_link_hash_entry *)));
+ amt = ext_count;
+ amt *= sizeof (struct bfd_link_hash_entry *);
+ sym_hash = (struct ecoff_link_hash_entry **) bfd_alloc (abfd, amt);
if (!sym_hash)
return false;
ecoff_data (abfd)->sym_hashes = sym_hash;
h = NULL;
if (! (_bfd_generic_link_add_one_symbol
(info, abfd, name,
- esym.weakext ? BSF_WEAK : BSF_GLOBAL,
+ (flagword) (esym.weakext ? BSF_WEAK : BSF_GLOBAL),
section, value, (const char *) NULL, true, true,
(struct bfd_link_hash_entry **) &h)))
return false;
HDRR *symhdr = &debug->symbolic_header;
boolean ret;
-#define READ(ptr, offset, count, size, type) \
- if (symhdr->count == 0) \
- debug->ptr = NULL; \
- else \
- { \
- debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \
- if (debug->ptr == NULL) \
- { \
- ret = false; \
- goto return_something; \
- } \
- if ((bfd_seek (input_bfd, (file_ptr) symhdr->offset, SEEK_SET) \
- != 0) \
- || (bfd_read (debug->ptr, size, symhdr->count, \
- input_bfd) != size * symhdr->count)) \
- { \
- ret = false; \
- goto return_something; \
- } \
+#define READ(ptr, offset, count, size, type) \
+ if (symhdr->count == 0) \
+ debug->ptr = NULL; \
+ else \
+ { \
+ bfd_size_type amt = (bfd_size_type) size * symhdr->count; \
+ debug->ptr = (type) bfd_malloc (amt); \
+ if (debug->ptr == NULL) \
+ { \
+ ret = false; \
+ goto return_something; \
+ } \
+ if (bfd_seek (input_bfd, (file_ptr) symhdr->offset, SEEK_SET) != 0 \
+ || bfd_bread (debug->ptr, amt, input_bfd) != amt) \
+ { \
+ ret = false; \
+ goto return_something; \
+ } \
}
/* If raw_syments is not NULL, then the data was already by read by
bfd_size_type external_reloc_size;
bfd_size_type external_relocs_size;
PTR external_relocs = NULL;
+ bfd_size_type amt;
BFD_ASSERT ((output_section->flags & SEC_HAS_CONTENTS) != 0);
/* Get the section contents. We allocate memory for the larger of
the size before relocating and the size after relocating. */
- contents = (bfd_byte *) bfd_malloc (raw_size >= cooked_size
- ? (size_t) raw_size
- : (size_t) cooked_size);
- if (contents == NULL && raw_size != 0)
+ amt = raw_size >= cooked_size ? raw_size : cooked_size;
+ contents = (bfd_byte *) bfd_malloc (amt);
+ if (contents == NULL && amt != 0)
goto error_return;
/* If we are relaxing, the contents may have already been read into
external_relocs = section_tdata->external_relocs;
else
{
- external_relocs = (PTR) bfd_malloc ((size_t) external_relocs_size);
+ external_relocs = (PTR) bfd_malloc (external_relocs_size);
if (external_relocs == NULL && external_relocs_size != 0)
goto error_return;
if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
- || (bfd_read (external_relocs, 1, external_relocs_size, input_bfd)
+ || (bfd_bread (external_relocs, external_relocs_size, input_bfd)
!= external_relocs_size))
goto error_return;
}
if (! bfd_set_section_contents (output_bfd,
output_section,
(PTR) contents,
- input_section->output_offset,
+ (file_ptr) input_section->output_offset,
cooked_size))
goto error_return;
have output so far. */
if (info->relocateable)
{
- if (bfd_seek (output_bfd,
- (output_section->rel_filepos +
- output_section->reloc_count * external_reloc_size),
- SEEK_SET) != 0
- || (bfd_write (external_relocs, 1, external_relocs_size, output_bfd)
+ file_ptr pos = (output_section->rel_filepos
+ + output_section->reloc_count * external_reloc_size);
+ if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
+ || (bfd_bwrite (external_relocs, external_relocs_size, output_bfd)
!= external_relocs_size))
goto error_return;
output_section->reloc_count += input_section->reloc_count;
bfd_size_type external_reloc_size;
bfd_byte *rbuf;
boolean ok;
+ file_ptr pos;
type = link_order->type;
section = NULL;
bfd_size_type size;
bfd_reloc_status_type rstat;
bfd_byte *buf;
- boolean ok;
size = bfd_get_reloc_size (rel.howto);
buf = (bfd_byte *) bfd_zmalloc (size);
if (buf == (bfd_byte *) NULL)
return false;
- rstat = _bfd_relocate_contents (rel.howto, output_bfd, addend, buf);
+ rstat = _bfd_relocate_contents (rel.howto, output_bfd,
+ (bfd_vma) addend, buf);
switch (rstat)
{
case bfd_reloc_ok:
}
else
{
- CONST char *name;
+ const char *name;
name = bfd_get_section_name (output_bfd, section);
if (strcmp (name, ".text") == 0)
/* Get some memory and swap out the reloc. */
external_reloc_size = ecoff_backend (output_bfd)->external_reloc_size;
- rbuf = (bfd_byte *) bfd_malloc ((size_t) external_reloc_size);
+ rbuf = (bfd_byte *) bfd_malloc (external_reloc_size);
if (rbuf == (bfd_byte *) NULL)
return false;
(*ecoff_backend (output_bfd)->swap_reloc_out) (output_bfd, &in, (PTR) rbuf);
- ok = (bfd_seek (output_bfd,
- (output_section->rel_filepos +
- output_section->reloc_count * external_reloc_size),
- SEEK_SET) == 0
- && (bfd_write ((PTR) rbuf, 1, external_reloc_size, output_bfd)
+ pos = (output_section->rel_filepos
+ + output_section->reloc_count * external_reloc_size);
+ ok = (bfd_seek (output_bfd, pos, SEEK_SET) == 0
+ && (bfd_bwrite ((PTR) rbuf, external_reloc_size, output_bfd)
== external_reloc_size));
if (ok)
/* Routines to link ECOFF debugging information.
- Copyright 1993, 1994, 1995, 1996, 1997, 2000
+ Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>.
if (want < ALLOC_SIZE)
want = ALLOC_SIZE;
}
- newbuf = (char *) bfd_realloc (*buf, have + want);
+ newbuf = (char *) bfd_realloc (*buf, (bfd_size_type) have + want);
if (newbuf == NULL)
return false;
*buf = newbuf;
struct bfd_link_info *info;
{
struct accumulate *ainfo;
+ bfd_size_type amt = sizeof (struct accumulate);
- ainfo = (struct accumulate *) bfd_malloc (sizeof (struct accumulate));
+ ainfo = (struct accumulate *) bfd_malloc (amt);
if (!ainfo)
return NULL;
if (! bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc,
long newrfdbase = 0;
long oldrfdbase = 0;
bfd_byte *fdr_out;
+ bfd_size_type amt;
/* Use section_adjust to hold the value to add to a symbol in a
particular section. */
}
fdr_end = fdr_start + input_symhdr->ifdMax * fdr_add;
- input_debug->ifdmap = (RFDT *) bfd_alloc (input_bfd,
- (input_symhdr->ifdMax
- * sizeof (RFDT)));
+ amt = input_symhdr->ifdMax;
+ amt *= sizeof (RFDT);
+ input_debug->ifdmap = (RFDT *) bfd_alloc (input_bfd, amt);
sz = (input_symhdr->crfd + input_symhdr->ifdMax) * external_rfd_size;
rfd_out = (bfd_byte *) objalloc_alloc (ainfo->memory, sz);
merged. */
name = input_debug->ss + fdr.issBase + fdr.rss;
- lookup = (char *) bfd_malloc (strlen (name) + 20);
+ lookup = (char *) bfd_malloc ((bfd_size_type) strlen (name) + 20);
if (lookup == NULL)
return false;
sprintf (lookup, "%s %lx %lx", name, fdr.csym, fdr.caux);
stabs are adjusted correctly. */
if (fdr.cbLine > 0)
{
+ file_ptr pos = input_symhdr->cbLineOffset + fdr.cbLineOffset;
if (!add_file_shuffle (ainfo, &ainfo->line, &ainfo->line_end,
- input_bfd,
- input_symhdr->cbLineOffset + fdr.cbLineOffset,
- fdr.cbLine))
+ input_bfd, pos, (unsigned long) fdr.cbLine))
return false;
fdr.ilineBase = output_symhdr->ilineMax;
fdr.cbLineOffset = output_symhdr->cbLine;
}
if (fdr.caux > 0)
{
+ file_ptr pos = (input_symhdr->cbAuxOffset
+ + fdr.iauxBase * sizeof (union aux_ext));
if (!add_file_shuffle (ainfo, &ainfo->aux, &ainfo->aux_end,
- input_bfd,
- (input_symhdr->cbAuxOffset
- + fdr.iauxBase * sizeof (union aux_ext)),
+ input_bfd, pos,
fdr.caux * sizeof (union aux_ext)))
return false;
fdr.iauxBase = output_symhdr->iauxMax;
}
else if (fdr.cbSs > 0)
{
+ file_ptr pos = input_symhdr->cbSsOffset + fdr.issBase;
if (!add_file_shuffle (ainfo, &ainfo->ss, &ainfo->ss_end,
- input_bfd,
- input_symhdr->cbSsOffset + fdr.issBase,
- fdr.cbSs))
+ input_bfd, pos, (unsigned long) fdr.cbSs))
return false;
fdr.issBase = output_symhdr->issMax;
output_symhdr->issMax += fdr.cbSs;
BFD_ASSERT (external_pdr_size == input_swap->external_pdr_size);
if (fdr.cpd > 0)
{
+ file_ptr pos = (input_symhdr->cbPdOffset
+ + fdr.ipdFirst * external_pdr_size);
+ unsigned long 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))
+ input_bfd, pos, size))
return false;
}
BFD_ASSERT (external_opt_size == input_swap->external_opt_size);
if (fdr.copt > 0)
{
+ file_ptr pos = (input_symhdr->cbOptOffset
+ + fdr.ioptBase * external_opt_size);
+ unsigned long 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))
+ input_bfd, pos, size))
return false;
}
}
symsize = bfd_get_symtab_upper_bound (input_bfd);
if (symsize < 0)
return false;
- symbols = (asymbol **) bfd_alloc (output_bfd, symsize);
+ symbols = (asymbol **) bfd_alloc (output_bfd, (bfd_size_type) symsize);
if (symbols == (asymbol **) NULL)
return false;
symcount = bfd_canonicalize_symtab (input_bfd, symbols);
}
(*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);
+ external_sym,
+ (unsigned long) output_swap->external_sym_size);
++fdr.csym;
++output_symhdr->isymMax;
}
}
(*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);
+ external_fdr,
+ (unsigned long) output_swap->external_fdr_size);
++output_symhdr->ifdMax;
{
if (ecoff_add_bytes ((char **) &debug->external_ext,
(char **) &debug->external_ext_end,
- (symhdr->iextMax + 1) * external_ext_size)
+ (symhdr->iextMax + 1) * (size_t) external_ext_size)
== false)
return false;
}
SET (cbExtOffset, iextMax, swap->external_ext_size);
#undef SET
- buff = (PTR) bfd_malloc ((size_t) swap->external_hdr_size);
+ buff = (PTR) bfd_malloc (swap->external_hdr_size);
if (buff == NULL && swap->external_hdr_size != 0)
goto error_return;
(*swap->swap_hdr_out) (abfd, symhdr, buff);
- if (bfd_write (buff, 1, swap->external_hdr_size, abfd)
+ if (bfd_bwrite (buff, swap->external_hdr_size, abfd)
!= swap->external_hdr_size)
goto error_return;
#define WRITE(ptr, count, size, offset) \
BFD_ASSERT (symhdr->offset == 0 \
|| (bfd_vma) bfd_tell (abfd) == symhdr->offset); \
- if (bfd_write ((PTR) debug->ptr, size, symhdr->count, abfd) \
+ if (bfd_bwrite ((PTR) debug->ptr, (bfd_size_type) size * symhdr->count, abfd)\
!= size * symhdr->count) \
return false;
WRITE (external_pdr, ipdMax, swap->external_pdr_size, cbPdOffset);
WRITE (external_sym, isymMax, swap->external_sym_size, cbSymOffset);
WRITE (external_opt, ioptMax, swap->external_opt_size, cbOptOffset);
- WRITE (external_aux, iauxMax, sizeof (union aux_ext), cbAuxOffset);
+ WRITE (external_aux, iauxMax, (bfd_size_type) sizeof (union aux_ext),
+ cbAuxOffset);
WRITE (ss, issMax, sizeof (char), cbSsOffset);
WRITE (ssext, issExtMax, sizeof (char), cbSsExtOffset);
WRITE (external_fdr, ifdMax, swap->external_fdr_size, cbFdOffset);
{
if (! l->filep)
{
- if (bfd_write (l->u.memory, 1, l->size, abfd) != l->size)
+ if (bfd_bwrite (l->u.memory, (bfd_size_type) l->size, abfd)
+ != l->size)
return false;
}
else
{
if (bfd_seek (l->u.file.input_bfd, l->u.file.offset, SEEK_SET) != 0
- || bfd_read (space, 1, l->size, l->u.file.input_bfd) != l->size
- || bfd_write (space, 1, l->size, abfd) != l->size)
+ || bfd_bread (space, (bfd_size_type) l->size,
+ l->u.file.input_bfd) != l->size
+ || bfd_bwrite (space, (bfd_size_type) l->size, abfd) != l->size)
return false;
}
total += l->size;
bfd_byte *s;
i = swap->debug_align - (total & (swap->debug_align - 1));
- s = (bfd_byte *) bfd_malloc (i);
+ s = (bfd_byte *) bfd_malloc ((bfd_size_type) i);
if (s == NULL && i != 0)
return false;
memset ((PTR) s, 0, i);
- if (bfd_write ((PTR) s, 1, i, abfd) != i)
+ if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i)
{
free (s);
return false;
{
struct accumulate *ainfo = (struct accumulate *) handle;
PTR space = NULL;
+ bfd_size_type amt;
if (! ecoff_write_symhdr (abfd, debug, swap, where))
goto error_return;
- space = (PTR) bfd_malloc (ainfo->largest_file_shuffle);
+ amt = ainfo->largest_file_shuffle;
+ space = (PTR) bfd_malloc (amt);
if (space == NULL && ainfo->largest_file_shuffle != 0)
goto error_return;
BFD_ASSERT (ainfo->ss == (struct shuffle *) NULL);
null = 0;
- if (bfd_write ((PTR) &null, 1, 1, abfd) != 1)
+ if (bfd_bwrite ((PTR) &null, (bfd_size_type) 1, abfd) != 1)
goto error_return;
total = 1;
BFD_ASSERT (ainfo->ss_hash == NULL || ainfo->ss_hash->val == 1);
size_t len;
len = strlen (sh->root.string);
- if (bfd_write ((PTR) sh->root.string, 1, len + 1, abfd) != len + 1)
+ amt = len + 1;
+ if (bfd_bwrite ((PTR) sh->root.string, amt, abfd) != amt)
goto error_return;
total += len + 1;
}
bfd_byte *s;
i = swap->debug_align - (total & (swap->debug_align - 1));
- s = (bfd_byte *) bfd_malloc (i);
+ s = (bfd_byte *) bfd_malloc ((bfd_size_type) i);
if (s == NULL && i != 0)
goto error_return;
memset ((PTR) s, 0, i);
- if (bfd_write ((PTR) s, 1, i, abfd) != i)
+ if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i)
{
free (s);
goto error_return;
/* The external strings and symbol are not converted over to using
shuffles. FIXME: They probably should be. */
- if (bfd_write (debug->ssext, 1, debug->symbolic_header.issExtMax, abfd)
- != (bfd_size_type) debug->symbolic_header.issExtMax)
+ amt = debug->symbolic_header.issExtMax;
+ if (bfd_bwrite (debug->ssext, amt, abfd) != amt)
goto error_return;
if ((debug->symbolic_header.issExtMax & (swap->debug_align - 1)) != 0)
{
i = (swap->debug_align
- (debug->symbolic_header.issExtMax & (swap->debug_align - 1)));
- s = (bfd_byte *) bfd_malloc (i);
+ s = (bfd_byte *) bfd_malloc ((bfd_size_type) i);
if (s == NULL && i != 0)
goto error_return;
memset ((PTR) s, 0, i);
- if (bfd_write ((PTR) s, 1, i, abfd) != i)
+ if (bfd_bwrite ((PTR) s, (bfd_size_type) i, abfd) != i)
{
free (s);
goto error_return;
|| (debug->symbolic_header.cbExtOffset
== (bfd_vma) bfd_tell (abfd)));
- if (bfd_write (debug->external_ext, swap->external_ext_size,
- debug->symbolic_header.iextMax, abfd)
- != debug->symbolic_header.iextMax * swap->external_ext_size)
+ amt = debug->symbolic_header.iextMax * swap->external_ext_size;
+ if (bfd_bwrite (debug->external_ext, amt, abfd) != amt)
goto error_return;
if (space != NULL)
FDR *fdr_end;
boolean stabs;
long len;
+ bfd_size_type amt;
fdr_start = debug_info->fdr;
fdr_end = fdr_start + debug_info->symbolic_header.ifdMax;
/* Now, create and fill in the table: */
- line_info->fdrtab = ((struct ecoff_fdrtab_entry*)
- bfd_zalloc (abfd,
- len * sizeof (struct ecoff_fdrtab_entry)));
+ amt = (bfd_size_type) len * sizeof (struct ecoff_fdrtab_entry);
+ line_info->fdrtab = (struct ecoff_fdrtab_entry*) bfd_zalloc (abfd, amt);
if (line_info->fdrtab == NULL)
return false;
line_info->fdrtab_len = len;
The table is mostly sorted already, but there are cases (e.g.,
static functions in include files), where this does not hold.
Use "odump -PFv" to verify... */
- qsort ((PTR) line_info->fdrtab, len,
+ qsort ((PTR) line_info->fdrtab, (size_t) len,
sizeof (struct ecoff_fdrtab_entry), cmp_fdrtab_entry);
return true;
char *pdr_ptr;
char *best_pdr = NULL;
FDR *best_fdr;
- bfd_vma best_dist = ~0;
+ bfd_vma best_dist = ~(bfd_vma) 0;
PDR pdr;
unsigned char *line_ptr;
unsigned char *line_end;
{
if (line_info->find_buffer != NULL)
free (line_info->find_buffer);
- buffer = (char *) bfd_malloc (len);
+ buffer = (char *) bfd_malloc ((bfd_size_type) len);
if (buffer == NULL)
return false;
line_info->find_buffer = buffer;
else
{
if (bfd_seek (l->u.file.input_bfd, l->u.file.offset, SEEK_SET) != 0
- || bfd_read (buff, 1, l->size, l->u.file.input_bfd) != l->size)
+ || (bfd_bread (buff, (bfd_size_type) l->size, l->u.file.input_bfd)
+ != l->size))
return false;
}
total += l->size;
with the proper byte sex and such. */
#ifdef ECOFF_32
-#define ecoff_get_off bfd_h_get_32
-#define ecoff_put_off bfd_h_put_32
+#define ECOFF_GET_OFF H_GET_32
+#define ECOFF_PUT_OFF H_PUT_32
#endif
#ifdef ECOFF_64
-#define ecoff_get_off bfd_h_get_64
-#define ecoff_put_off bfd_h_put_64
+#define ECOFF_GET_OFF H_GET_64
+#define ECOFF_PUT_OFF H_PUT_64
#endif
#ifdef ECOFF_SIGNED_32
-#define ecoff_get_off bfd_h_get_signed_32
-#define ecoff_put_off bfd_h_put_signed_32
+#define ECOFF_GET_OFF H_GET_S32
+#define ECOFF_PUT_OFF H_PUT_S32
#endif
#ifdef ECOFF_SIGNED_64
-#define ecoff_get_off bfd_h_get_signed_64
-#define ecoff_put_off bfd_h_put_signed_64
+#define ECOFF_GET_OFF H_GET_S64
+#define ECOFF_PUT_OFF H_PUT_S64
#endif
/* ECOFF auxiliary information swapping routines. These are the same
*ext = *(struct hdr_ext *) ext_copy;
- intern->magic = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_magic);
- intern->vstamp = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->h_vstamp);
- intern->ilineMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ilineMax);
- intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLine);
- intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbLineOffset);
- intern->idnMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_idnMax);
- intern->cbDnOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbDnOffset);
- intern->ipdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ipdMax);
- intern->cbPdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbPdOffset);
- intern->isymMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_isymMax);
- intern->cbSymOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSymOffset);
- intern->ioptMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ioptMax);
- intern->cbOptOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbOptOffset);
- intern->iauxMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iauxMax);
- intern->cbAuxOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbAuxOffset);
- intern->issMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issMax);
- intern->cbSsOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsOffset);
- intern->issExtMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_issExtMax);
- intern->cbSsExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbSsExtOffset);
- intern->ifdMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_ifdMax);
- intern->cbFdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbFdOffset);
- intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_crfd);
- intern->cbRfdOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbRfdOffset);
- intern->iextMax = bfd_h_get_32 (abfd, (bfd_byte *)ext->h_iextMax);
- intern->cbExtOffset = ecoff_get_off (abfd, (bfd_byte *)ext->h_cbExtOffset);
+ intern->magic = H_GET_S16 (abfd, ext->h_magic);
+ intern->vstamp = H_GET_S16 (abfd, ext->h_vstamp);
+ intern->ilineMax = H_GET_32 (abfd, ext->h_ilineMax);
+ intern->cbLine = ECOFF_GET_OFF (abfd, ext->h_cbLine);
+ intern->cbLineOffset = ECOFF_GET_OFF (abfd, ext->h_cbLineOffset);
+ intern->idnMax = H_GET_32 (abfd, ext->h_idnMax);
+ intern->cbDnOffset = ECOFF_GET_OFF (abfd, ext->h_cbDnOffset);
+ intern->ipdMax = H_GET_32 (abfd, ext->h_ipdMax);
+ intern->cbPdOffset = ECOFF_GET_OFF (abfd, ext->h_cbPdOffset);
+ intern->isymMax = H_GET_32 (abfd, ext->h_isymMax);
+ intern->cbSymOffset = ECOFF_GET_OFF (abfd, ext->h_cbSymOffset);
+ intern->ioptMax = H_GET_32 (abfd, ext->h_ioptMax);
+ intern->cbOptOffset = ECOFF_GET_OFF (abfd, ext->h_cbOptOffset);
+ intern->iauxMax = H_GET_32 (abfd, ext->h_iauxMax);
+ intern->cbAuxOffset = ECOFF_GET_OFF (abfd, ext->h_cbAuxOffset);
+ intern->issMax = H_GET_32 (abfd, ext->h_issMax);
+ intern->cbSsOffset = ECOFF_GET_OFF (abfd, ext->h_cbSsOffset);
+ intern->issExtMax = H_GET_32 (abfd, ext->h_issExtMax);
+ intern->cbSsExtOffset = ECOFF_GET_OFF (abfd, ext->h_cbSsExtOffset);
+ intern->ifdMax = H_GET_32 (abfd, ext->h_ifdMax);
+ intern->cbFdOffset = ECOFF_GET_OFF (abfd, ext->h_cbFdOffset);
+ intern->crfd = H_GET_32 (abfd, ext->h_crfd);
+ intern->cbRfdOffset = ECOFF_GET_OFF (abfd, ext->h_cbRfdOffset);
+ intern->iextMax = H_GET_32 (abfd, ext->h_iextMax);
+ intern->cbExtOffset = ECOFF_GET_OFF (abfd, ext->h_cbExtOffset);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
*intern = *intern_copy;
- bfd_h_put_signed_16 (abfd, intern->magic, (bfd_byte *)ext->h_magic);
- bfd_h_put_signed_16 (abfd, intern->vstamp, (bfd_byte *)ext->h_vstamp);
- bfd_h_put_32 (abfd, intern->ilineMax, (bfd_byte *)ext->h_ilineMax);
- ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->h_cbLine);
- ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->h_cbLineOffset);
- bfd_h_put_32 (abfd, intern->idnMax, (bfd_byte *)ext->h_idnMax);
- ecoff_put_off (abfd, intern->cbDnOffset, (bfd_byte *)ext->h_cbDnOffset);
- bfd_h_put_32 (abfd, intern->ipdMax, (bfd_byte *)ext->h_ipdMax);
- ecoff_put_off (abfd, intern->cbPdOffset, (bfd_byte *)ext->h_cbPdOffset);
- bfd_h_put_32 (abfd, intern->isymMax, (bfd_byte *)ext->h_isymMax);
- ecoff_put_off (abfd, intern->cbSymOffset, (bfd_byte *)ext->h_cbSymOffset);
- bfd_h_put_32 (abfd, intern->ioptMax, (bfd_byte *)ext->h_ioptMax);
- ecoff_put_off (abfd, intern->cbOptOffset, (bfd_byte *)ext->h_cbOptOffset);
- bfd_h_put_32 (abfd, intern->iauxMax, (bfd_byte *)ext->h_iauxMax);
- ecoff_put_off (abfd, intern->cbAuxOffset, (bfd_byte *)ext->h_cbAuxOffset);
- bfd_h_put_32 (abfd, intern->issMax, (bfd_byte *)ext->h_issMax);
- ecoff_put_off (abfd, intern->cbSsOffset, (bfd_byte *)ext->h_cbSsOffset);
- bfd_h_put_32 (abfd, intern->issExtMax, (bfd_byte *)ext->h_issExtMax);
- ecoff_put_off (abfd, intern->cbSsExtOffset, (bfd_byte *)ext->h_cbSsExtOffset);
- bfd_h_put_32 (abfd, intern->ifdMax, (bfd_byte *)ext->h_ifdMax);
- ecoff_put_off (abfd, intern->cbFdOffset, (bfd_byte *)ext->h_cbFdOffset);
- bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->h_crfd);
- ecoff_put_off (abfd, intern->cbRfdOffset, (bfd_byte *)ext->h_cbRfdOffset);
- bfd_h_put_32 (abfd, intern->iextMax, (bfd_byte *)ext->h_iextMax);
- ecoff_put_off (abfd, intern->cbExtOffset, (bfd_byte *)ext->h_cbExtOffset);
+ H_PUT_S16 (abfd, intern->magic, ext->h_magic);
+ H_PUT_S16 (abfd, intern->vstamp, ext->h_vstamp);
+ H_PUT_32 (abfd, intern->ilineMax, ext->h_ilineMax);
+ ECOFF_PUT_OFF (abfd, intern->cbLine, ext->h_cbLine);
+ ECOFF_PUT_OFF (abfd, intern->cbLineOffset, ext->h_cbLineOffset);
+ H_PUT_32 (abfd, intern->idnMax, ext->h_idnMax);
+ ECOFF_PUT_OFF (abfd, intern->cbDnOffset, ext->h_cbDnOffset);
+ H_PUT_32 (abfd, intern->ipdMax, ext->h_ipdMax);
+ ECOFF_PUT_OFF (abfd, intern->cbPdOffset, ext->h_cbPdOffset);
+ H_PUT_32 (abfd, intern->isymMax, ext->h_isymMax);
+ ECOFF_PUT_OFF (abfd, intern->cbSymOffset, ext->h_cbSymOffset);
+ H_PUT_32 (abfd, intern->ioptMax, ext->h_ioptMax);
+ ECOFF_PUT_OFF (abfd, intern->cbOptOffset, ext->h_cbOptOffset);
+ H_PUT_32 (abfd, intern->iauxMax, ext->h_iauxMax);
+ ECOFF_PUT_OFF (abfd, intern->cbAuxOffset, ext->h_cbAuxOffset);
+ H_PUT_32 (abfd, intern->issMax, ext->h_issMax);
+ ECOFF_PUT_OFF (abfd, intern->cbSsOffset, ext->h_cbSsOffset);
+ H_PUT_32 (abfd, intern->issExtMax, ext->h_issExtMax);
+ ECOFF_PUT_OFF (abfd, intern->cbSsExtOffset, ext->h_cbSsExtOffset);
+ H_PUT_32 (abfd, intern->ifdMax, ext->h_ifdMax);
+ ECOFF_PUT_OFF (abfd, intern->cbFdOffset, ext->h_cbFdOffset);
+ H_PUT_32 (abfd, intern->crfd, ext->h_crfd);
+ ECOFF_PUT_OFF (abfd, intern->cbRfdOffset, ext->h_cbRfdOffset);
+ H_PUT_32 (abfd, intern->iextMax, ext->h_iextMax);
+ ECOFF_PUT_OFF (abfd, intern->cbExtOffset, ext->h_cbExtOffset);
#ifdef TEST
- if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
+ if (memcmp ((char *) ext, (char *) intern, sizeof (*intern)) != 0)
abort ();
#endif
}
*ext = *(struct fdr_ext *) ext_copy;
- intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->f_adr);
- intern->rss = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rss);
+ intern->adr = ECOFF_GET_OFF (abfd, ext->f_adr);
+ intern->rss = H_GET_32 (abfd, ext->f_rss);
#if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
if (intern->rss == (signed long) 0xffffffff)
intern->rss = -1;
#endif
- intern->issBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_issBase);
- intern->cbSs = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbSs);
- intern->isymBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_isymBase);
- intern->csym = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_csym);
- intern->ilineBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ilineBase);
- intern->cline = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cline);
- intern->ioptBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ioptBase);
- intern->copt = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_copt);
+ intern->issBase = H_GET_32 (abfd, ext->f_issBase);
+ intern->cbSs = ECOFF_GET_OFF (abfd, ext->f_cbSs);
+ intern->isymBase = H_GET_32 (abfd, ext->f_isymBase);
+ intern->csym = H_GET_32 (abfd, ext->f_csym);
+ intern->ilineBase = H_GET_32 (abfd, ext->f_ilineBase);
+ intern->cline = H_GET_32 (abfd, ext->f_cline);
+ intern->ioptBase = H_GET_32 (abfd, ext->f_ioptBase);
+ intern->copt = H_GET_32 (abfd, ext->f_copt);
#if defined (ECOFF_32) || defined (ECOFF_SIGNED_32)
- intern->ipdFirst = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_ipdFirst);
- intern->cpd = bfd_h_get_16 (abfd, (bfd_byte *)ext->f_cpd);
+ intern->ipdFirst = H_GET_16 (abfd, ext->f_ipdFirst);
+ intern->cpd = H_GET_16 (abfd, ext->f_cpd);
#endif
#if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
- intern->ipdFirst = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_ipdFirst);
- intern->cpd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_cpd);
+ intern->ipdFirst = H_GET_32 (abfd, ext->f_ipdFirst);
+ intern->cpd = H_GET_32 (abfd, ext->f_cpd);
#endif
- intern->iauxBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_iauxBase);
- intern->caux = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_caux);
- intern->rfdBase = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_rfdBase);
- intern->crfd = bfd_h_get_32 (abfd, (bfd_byte *)ext->f_crfd);
+ intern->iauxBase = H_GET_32 (abfd, ext->f_iauxBase);
+ intern->caux = H_GET_32 (abfd, ext->f_caux);
+ intern->rfdBase = H_GET_32 (abfd, ext->f_rfdBase);
+ intern->crfd = H_GET_32 (abfd, ext->f_crfd);
/* now the fun stuff... */
- if (bfd_header_big_endian (abfd)) {
- intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_BIG)
- >> FDR_BITS1_LANG_SH_BIG;
- intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG);
- intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG);
- intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG);
- intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG)
- >> FDR_BITS2_GLEVEL_SH_BIG;
- } else {
- intern->lang = (ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE)
- >> FDR_BITS1_LANG_SH_LITTLE;
- intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE);
- intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE);
- intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE);
- intern->glevel = (ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE)
- >> FDR_BITS2_GLEVEL_SH_LITTLE;
- }
+ if (bfd_header_big_endian (abfd))
+ {
+ intern->lang = ((ext->f_bits1[0] & FDR_BITS1_LANG_BIG)
+ >> FDR_BITS1_LANG_SH_BIG);
+ intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_BIG);
+ intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_BIG);
+ intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_BIG);
+ intern->glevel = ((ext->f_bits2[0] & FDR_BITS2_GLEVEL_BIG)
+ >> FDR_BITS2_GLEVEL_SH_BIG);
+ }
+ else
+ {
+ intern->lang = ((ext->f_bits1[0] & FDR_BITS1_LANG_LITTLE)
+ >> FDR_BITS1_LANG_SH_LITTLE);
+ intern->fMerge = 0 != (ext->f_bits1[0] & FDR_BITS1_FMERGE_LITTLE);
+ intern->fReadin = 0 != (ext->f_bits1[0] & FDR_BITS1_FREADIN_LITTLE);
+ intern->fBigendian = 0 != (ext->f_bits1[0] & FDR_BITS1_FBIGENDIAN_LITTLE);
+ intern->glevel = ((ext->f_bits2[0] & FDR_BITS2_GLEVEL_LITTLE)
+ >> FDR_BITS2_GLEVEL_SH_LITTLE);
+ }
intern->reserved = 0;
- intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLineOffset);
- intern->cbLine = ecoff_get_off (abfd, (bfd_byte *)ext->f_cbLine);
+ intern->cbLineOffset = ECOFF_GET_OFF (abfd, ext->f_cbLineOffset);
+ intern->cbLine = ECOFF_GET_OFF (abfd, ext->f_cbLine);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
*intern = *intern_copy; /* Make it reasonable to do in-place. */
- ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->f_adr);
- bfd_h_put_32 (abfd, intern->rss, (bfd_byte *)ext->f_rss);
- bfd_h_put_32 (abfd, intern->issBase, (bfd_byte *)ext->f_issBase);
- ecoff_put_off (abfd, intern->cbSs, (bfd_byte *)ext->f_cbSs);
- bfd_h_put_32 (abfd, intern->isymBase, (bfd_byte *)ext->f_isymBase);
- bfd_h_put_32 (abfd, intern->csym, (bfd_byte *)ext->f_csym);
- bfd_h_put_32 (abfd, intern->ilineBase, (bfd_byte *)ext->f_ilineBase);
- bfd_h_put_32 (abfd, intern->cline, (bfd_byte *)ext->f_cline);
- bfd_h_put_32 (abfd, intern->ioptBase, (bfd_byte *)ext->f_ioptBase);
- bfd_h_put_32 (abfd, intern->copt, (bfd_byte *)ext->f_copt);
+ ECOFF_PUT_OFF (abfd, intern->adr, ext->f_adr);
+ H_PUT_32 (abfd, intern->rss, ext->f_rss);
+ H_PUT_32 (abfd, intern->issBase, ext->f_issBase);
+ ECOFF_PUT_OFF (abfd, intern->cbSs, ext->f_cbSs);
+ H_PUT_32 (abfd, intern->isymBase, ext->f_isymBase);
+ H_PUT_32 (abfd, intern->csym, ext->f_csym);
+ H_PUT_32 (abfd, intern->ilineBase, ext->f_ilineBase);
+ H_PUT_32 (abfd, intern->cline, ext->f_cline);
+ H_PUT_32 (abfd, intern->ioptBase, ext->f_ioptBase);
+ H_PUT_32 (abfd, intern->copt, ext->f_copt);
#if defined (ECOFF_32) || defined (ECOFF_SIGNED_32)
- bfd_h_put_16 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
- bfd_h_put_16 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
+ H_PUT_16 (abfd, intern->ipdFirst, ext->f_ipdFirst);
+ H_PUT_16 (abfd, intern->cpd, ext->f_cpd);
#endif
#if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
- bfd_h_put_32 (abfd, intern->ipdFirst, (bfd_byte *)ext->f_ipdFirst);
- bfd_h_put_32 (abfd, intern->cpd, (bfd_byte *)ext->f_cpd);
+ H_PUT_32 (abfd, intern->ipdFirst, ext->f_ipdFirst);
+ H_PUT_32 (abfd, intern->cpd, ext->f_cpd);
#endif
- bfd_h_put_32 (abfd, intern->iauxBase, (bfd_byte *)ext->f_iauxBase);
- bfd_h_put_32 (abfd, intern->caux, (bfd_byte *)ext->f_caux);
- bfd_h_put_32 (abfd, intern->rfdBase, (bfd_byte *)ext->f_rfdBase);
- bfd_h_put_32 (abfd, intern->crfd, (bfd_byte *)ext->f_crfd);
+ H_PUT_32 (abfd, intern->iauxBase, ext->f_iauxBase);
+ H_PUT_32 (abfd, intern->caux, ext->f_caux);
+ H_PUT_32 (abfd, intern->rfdBase, ext->f_rfdBase);
+ H_PUT_32 (abfd, intern->crfd, ext->f_crfd);
/* now the fun stuff... */
- if (bfd_header_big_endian (abfd)) {
- ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG)
- & FDR_BITS1_LANG_BIG)
- | (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0)
- | (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0)
- | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0));
- ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG)
- & FDR_BITS2_GLEVEL_BIG);
- ext->f_bits2[1] = 0;
- ext->f_bits2[2] = 0;
- } else {
- ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE)
- & FDR_BITS1_LANG_LITTLE)
- | (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0)
- | (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0)
- | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0));
- ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE)
- & FDR_BITS2_GLEVEL_LITTLE);
- ext->f_bits2[1] = 0;
- ext->f_bits2[2] = 0;
- }
+ if (bfd_header_big_endian (abfd))
+ {
+ ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_BIG)
+ & FDR_BITS1_LANG_BIG)
+ | (intern->fMerge ? FDR_BITS1_FMERGE_BIG : 0)
+ | (intern->fReadin ? FDR_BITS1_FREADIN_BIG : 0)
+ | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_BIG : 0));
+ ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_BIG)
+ & FDR_BITS2_GLEVEL_BIG);
+ ext->f_bits2[1] = 0;
+ ext->f_bits2[2] = 0;
+ }
+ else
+ {
+ ext->f_bits1[0] = (((intern->lang << FDR_BITS1_LANG_SH_LITTLE)
+ & FDR_BITS1_LANG_LITTLE)
+ | (intern->fMerge ? FDR_BITS1_FMERGE_LITTLE : 0)
+ | (intern->fReadin ? FDR_BITS1_FREADIN_LITTLE : 0)
+ | (intern->fBigendian ? FDR_BITS1_FBIGENDIAN_LITTLE : 0));
+ ext->f_bits2[0] = ((intern->glevel << FDR_BITS2_GLEVEL_SH_LITTLE)
+ & FDR_BITS2_GLEVEL_LITTLE);
+ ext->f_bits2[1] = 0;
+ ext->f_bits2[2] = 0;
+ }
- ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->f_cbLineOffset);
- ecoff_put_off (abfd, intern->cbLine, (bfd_byte *)ext->f_cbLine);
+ ECOFF_PUT_OFF (abfd, intern->cbLineOffset, ext->f_cbLineOffset);
+ ECOFF_PUT_OFF (abfd, intern->cbLine, ext->f_cbLine);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
memset ((PTR) intern, 0, sizeof (*intern));
- intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
- intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
- intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
- intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
- intern->regoffset = bfd_h_get_signed_32 (abfd,
- (bfd_byte *)ext->p_regoffset);
- intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
- intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
- intern->fregoffset = bfd_h_get_signed_32 (abfd,
- (bfd_byte *)ext->p_fregoffset);
- intern->frameoffset = bfd_h_get_signed_32 (abfd,
- (bfd_byte *)ext->p_frameoffset);
- intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
- intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
- intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
- intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
- intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
+ intern->adr = ECOFF_GET_OFF (abfd, ext->p_adr);
+ intern->isym = H_GET_32 (abfd, ext->p_isym);
+ intern->iline = H_GET_32 (abfd, ext->p_iline);
+ intern->regmask = H_GET_32 (abfd, ext->p_regmask);
+ intern->regoffset = H_GET_S32 (abfd, ext->p_regoffset);
+ intern->iopt = H_GET_S32 (abfd, ext->p_iopt);
+ intern->fregmask = H_GET_32 (abfd, ext->p_fregmask);
+ intern->fregoffset = H_GET_S32 (abfd, ext->p_fregoffset);
+ intern->frameoffset = H_GET_S32 (abfd, ext->p_frameoffset);
+ intern->framereg = H_GET_16 (abfd, ext->p_framereg);
+ intern->pcreg = H_GET_16 (abfd, ext->p_pcreg);
+ intern->lnLow = H_GET_32 (abfd, ext->p_lnLow);
+ intern->lnHigh = H_GET_32 (abfd, ext->p_lnHigh);
+ intern->cbLineOffset = ECOFF_GET_OFF (abfd, ext->p_cbLineOffset);
#if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
- intern->gp_prologue = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_gp_prologue);
+ intern->gp_prologue = H_GET_8 (abfd, ext->p_gp_prologue);
if (bfd_header_big_endian (abfd))
{
intern->gp_used = 0 != (ext->p_bits1[0] & PDR_BITS1_GP_USED_BIG);
| ((ext->p_bits2[0] & PDR_BITS2_RESERVED_LITTLE)
<< PDR_BITS2_RESERVED_SH_LEFT_LITTLE));
}
- intern->localoff = bfd_h_get_8 (abfd, (bfd_byte *) ext->p_localoff);
+ intern->localoff = H_GET_8 (abfd, ext->p_localoff);
#endif
#ifdef TEST
*intern = *intern_copy; /* Make it reasonable to do in-place. */
- ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
- bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
- bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
- bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
- bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
- bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
- bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
- bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
- bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
- bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
- bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
- bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
- bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
- ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
+ ECOFF_PUT_OFF (abfd, intern->adr, ext->p_adr);
+ H_PUT_32 (abfd, intern->isym, ext->p_isym);
+ H_PUT_32 (abfd, intern->iline, ext->p_iline);
+ H_PUT_32 (abfd, intern->regmask, ext->p_regmask);
+ H_PUT_32 (abfd, intern->regoffset, ext->p_regoffset);
+ H_PUT_32 (abfd, intern->iopt, ext->p_iopt);
+ H_PUT_32 (abfd, intern->fregmask, ext->p_fregmask);
+ H_PUT_32 (abfd, intern->fregoffset, ext->p_fregoffset);
+ H_PUT_32 (abfd, intern->frameoffset, ext->p_frameoffset);
+ H_PUT_16 (abfd, intern->framereg, ext->p_framereg);
+ H_PUT_16 (abfd, intern->pcreg, ext->p_pcreg);
+ H_PUT_32 (abfd, intern->lnLow, ext->p_lnLow);
+ H_PUT_32 (abfd, intern->lnHigh, ext->p_lnHigh);
+ ECOFF_PUT_OFF (abfd, intern->cbLineOffset, ext->p_cbLineOffset);
#if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
- bfd_h_put_8 (abfd, intern->gp_prologue, (bfd_byte *) ext->p_gp_prologue);
+ H_PUT_8 (abfd, intern->gp_prologue, ext->p_gp_prologue);
+
if (bfd_header_big_endian (abfd))
{
ext->p_bits1[0] = ((intern->gp_used ? PDR_BITS1_GP_USED_BIG : 0)
PDR_BITS2_RESERVED_SH_LEFT_LITTLE)
& PDR_BITS2_RESERVED_LITTLE);
}
- bfd_h_put_8 (abfd, intern->localoff, (bfd_byte *) ext->p_localoff);
+ H_PUT_8 (abfd, intern->localoff, ext->p_localoff);
#endif
#ifdef TEST
*ext = *(struct pdr_ext *) ext_copy;
- intern->adr = ecoff_get_off (abfd, (bfd_byte *)ext->p_adr);
- intern->isym = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_isym);
- intern->iline = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_iline);
- intern->regmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_regmask);
- intern->regoffset = bfd_h_get_signed_32 (abfd,
- (bfd_byte *)ext->p_regoffset);
- intern->iopt = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->p_iopt);
- intern->fregmask = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_fregmask);
- intern->fregoffset = bfd_h_get_signed_32 (abfd,
- (bfd_byte *)ext->p_fregoffset);
- intern->frameoffset = bfd_h_get_signed_32 (abfd,
- (bfd_byte *)ext->p_frameoffset);
- intern->framereg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_framereg);
- intern->pcreg = bfd_h_get_16 (abfd, (bfd_byte *)ext->p_pcreg);
- intern->lnLow = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnLow);
- intern->lnHigh = bfd_h_get_32 (abfd, (bfd_byte *)ext->p_lnHigh);
- intern->cbLineOffset = ecoff_get_off (abfd, (bfd_byte *)ext->p_cbLineOffset);
+ intern->adr = ECOFF_GET_OFF (abfd, ext->p_adr);
+ intern->isym = H_GET_32 (abfd, ext->p_isym);
+ intern->iline = H_GET_32 (abfd, ext->p_iline);
+ intern->regmask = H_GET_32 (abfd, ext->p_regmask);
+ intern->regoffset = H_GET_S32 (abfd, ext->p_regoffset);
+ intern->iopt = H_GET_S32 (abfd, ext->p_iopt);
+ intern->fregmask = H_GET_32 (abfd, ext->p_fregmask);
+ intern->fregoffset = H_GET_S32 (abfd, ext->p_fregoffset);
+ intern->frameoffset = H_GET_S32 (abfd, ext->p_frameoffset);
+ intern->framereg = H_GET_16 (abfd, ext->p_framereg);
+ intern->pcreg = H_GET_16 (abfd, ext->p_pcreg);
+ intern->lnLow = H_GET_32 (abfd, ext->p_lnLow);
+ intern->lnHigh = H_GET_32 (abfd, ext->p_lnHigh);
+ intern->cbLineOffset = ECOFF_GET_OFF (abfd, ext->p_cbLineOffset);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
*intern = *intern_copy; /* Make it reasonable to do in-place. */
- ecoff_put_off (abfd, intern->adr, (bfd_byte *)ext->p_adr);
- bfd_h_put_32 (abfd, intern->isym, (bfd_byte *)ext->p_isym);
- bfd_h_put_32 (abfd, intern->iline, (bfd_byte *)ext->p_iline);
- bfd_h_put_32 (abfd, intern->regmask, (bfd_byte *)ext->p_regmask);
- bfd_h_put_32 (abfd, intern->regoffset, (bfd_byte *)ext->p_regoffset);
- bfd_h_put_32 (abfd, intern->iopt, (bfd_byte *)ext->p_iopt);
- bfd_h_put_32 (abfd, intern->fregmask, (bfd_byte *)ext->p_fregmask);
- bfd_h_put_32 (abfd, intern->fregoffset, (bfd_byte *)ext->p_fregoffset);
- bfd_h_put_32 (abfd, intern->frameoffset, (bfd_byte *)ext->p_frameoffset);
- bfd_h_put_16 (abfd, intern->framereg, (bfd_byte *)ext->p_framereg);
- bfd_h_put_16 (abfd, intern->pcreg, (bfd_byte *)ext->p_pcreg);
- bfd_h_put_32 (abfd, intern->lnLow, (bfd_byte *)ext->p_lnLow);
- bfd_h_put_32 (abfd, intern->lnHigh, (bfd_byte *)ext->p_lnHigh);
- ecoff_put_off (abfd, intern->cbLineOffset, (bfd_byte *)ext->p_cbLineOffset);
+ ECOFF_PUT_OFF (abfd, intern->adr, ext->p_adr);
+ H_PUT_32 (abfd, intern->isym, ext->p_isym);
+ H_PUT_32 (abfd, intern->iline, ext->p_iline);
+ H_PUT_32 (abfd, intern->regmask, ext->p_regmask);
+ H_PUT_32 (abfd, intern->regoffset, ext->p_regoffset);
+ H_PUT_32 (abfd, intern->iopt, ext->p_iopt);
+ H_PUT_32 (abfd, intern->fregmask, ext->p_fregmask);
+ H_PUT_32 (abfd, intern->fregoffset, ext->p_fregoffset);
+ H_PUT_32 (abfd, intern->frameoffset, ext->p_frameoffset);
+ H_PUT_16 (abfd, intern->framereg, ext->p_framereg);
+ H_PUT_16 (abfd, intern->pcreg, ext->p_pcreg);
+ H_PUT_32 (abfd, intern->lnLow, ext->p_lnLow);
+ H_PUT_32 (abfd, intern->lnHigh, ext->p_lnHigh);
+ ECOFF_PUT_OFF (abfd, intern->cbLineOffset, ext->p_cbLineOffset);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
*ext = *(struct sym_ext *) ext_copy;
- intern->iss = bfd_h_get_32 (abfd, (bfd_byte *)ext->s_iss);
- intern->value = ecoff_get_off (abfd, (bfd_byte *)ext->s_value);
+ intern->iss = H_GET_32 (abfd, ext->s_iss);
+ intern->value = ECOFF_GET_OFF (abfd, ext->s_value);
/* now the fun stuff... */
if (bfd_header_big_endian (abfd)) {
*intern = *intern_copy; /* Make it reasonable to do in-place. */
- bfd_h_put_32 (abfd, intern->iss, (bfd_byte *)ext->s_iss);
- ecoff_put_off (abfd, intern->value, (bfd_byte *)ext->s_value);
+ H_PUT_32 (abfd, intern->iss, ext->s_iss);
+ ECOFF_PUT_OFF (abfd, intern->value, ext->s_value);
/* now the fun stuff... */
if (bfd_header_big_endian (abfd)) {
intern->reserved = 0;
#if defined (ECOFF_32) || defined (ECOFF_SIGNED_32)
- intern->ifd = bfd_h_get_signed_16 (abfd, (bfd_byte *)ext->es_ifd);
+ intern->ifd = H_GET_S16 (abfd, ext->es_ifd);
#endif
#if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
- intern->ifd = bfd_h_get_signed_32 (abfd, (bfd_byte *)ext->es_ifd);
+ intern->ifd = H_GET_S32 (abfd, ext->es_ifd);
#endif
ecoff_swap_sym_in (abfd, &ext->es_asym, &intern->asym);
}
#if defined (ECOFF_32) || defined (ECOFF_SIGNED_32)
- bfd_h_put_signed_16 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
+ H_PUT_S16 (abfd, intern->ifd, ext->es_ifd);
#endif
#if defined (ECOFF_64) || defined (ECOFF_SIGNED_64)
- bfd_h_put_signed_32 (abfd, intern->ifd, (bfd_byte *)ext->es_ifd);
+ H_PUT_S32 (abfd, intern->ifd, ext->es_ifd);
#endif
ecoff_swap_sym_out (abfd, &intern->asym, &ext->es_asym);
{
struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
- *intern = bfd_h_get_32 (abfd, (bfd_byte *)ext->rfd);
+ *intern = H_GET_32 (abfd, ext->rfd);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
{
struct rfd_ext *ext = (struct rfd_ext *) ext_ptr;
- bfd_h_put_32 (abfd, *intern, (bfd_byte *)ext->rfd);
+ H_PUT_32 (abfd, *intern, ext->rfd);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
_bfd_ecoff_swap_rndx_in (bfd_header_big_endian (abfd),
&ext->o_rndx, &intern->rndx);
- intern->offset = bfd_h_get_32 (abfd, (bfd_byte *) ext->o_offset);
+ intern->offset = H_GET_32 (abfd, ext->o_offset);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
_bfd_ecoff_swap_rndx_out (bfd_header_big_endian (abfd),
&intern->rndx, &ext->o_rndx);
- bfd_h_put_32 (abfd, intern->value, (bfd_byte *) ext->o_offset);
+ H_PUT_32 (abfd, intern->value, ext->o_offset);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
*ext = *(struct dnr_ext *) ext_copy;
- intern->rfd = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_rfd);
- intern->index = bfd_h_get_32 (abfd, (bfd_byte *) ext->d_index);
+ intern->rfd = H_GET_32 (abfd, ext->d_rfd);
+ intern->index = H_GET_32 (abfd, ext->d_index);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
*intern = *intern_copy; /* Make it reasonable to do in-place. */
- bfd_h_put_32 (abfd, intern->rfd, (bfd_byte *) ext->d_rfd);
- bfd_h_put_32 (abfd, intern->index, (bfd_byte *) ext->d_index);
+ H_PUT_32 (abfd, intern->rfd, ext->d_rfd);
+ H_PUT_32 (abfd, intern->index, ext->d_index);
#ifdef TEST
if (memcmp ((char *)ext, (char *)intern, sizeof (*intern)) != 0)
unsigned char arch_size, file_align;
unsigned char elfclass, ev_current;
- int (*write_out_phdrs) PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
- boolean (*write_shdrs_and_ehdr) PARAMS ((bfd *));
- void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
- void (*swap_symbol_out) PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
+ int (*write_out_phdrs)
+ PARAMS ((bfd *, const Elf_Internal_Phdr *, unsigned int));
+ boolean (*write_shdrs_and_ehdr)
+ PARAMS ((bfd *));
+ void (*write_relocs)
+ PARAMS ((bfd *, asection *, PTR));
+ void (*swap_symbol_out)
+ PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
boolean (*slurp_reloc_table)
PARAMS ((bfd *, asection *, asymbol **, boolean));
- long (*slurp_symbol_table) PARAMS ((bfd *, asymbol **, boolean));
- void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
- void (*swap_dyn_out) PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
+ long (*slurp_symbol_table)
+ PARAMS ((bfd *, asymbol **, boolean));
+ void (*swap_dyn_in)
+ PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
+ void (*swap_dyn_out)
+ PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
/* This function, if defined, is called to swap in a REL
relocation. If an external relocation corresponds to more than
/* A function to translate an ELF RELA relocation to a BFD arelent
structure. */
- void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
- Elf_Internal_Rela *));
+ void (*elf_info_to_howto)
+ PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
/* A function to translate an ELF REL relocation to a BFD arelent
structure. */
- void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
- Elf_Internal_Rel *));
+ void (*elf_info_to_howto_rel)
+ PARAMS ((bfd *, arelent *, Elf_Internal_Rel *));
/* A function to determine whether a symbol is global when
partitioning the symbol table into local and global symbols.
This should be NULL for most targets, in which case the correct
thing will be done. MIPS ELF, at least on the Irix 5, has
special requirements. */
- boolean (*elf_backend_sym_is_global) PARAMS ((bfd *, asymbol *));
+ boolean (*elf_backend_sym_is_global)
+ PARAMS ((bfd *, asymbol *));
/* The remaining functions are hooks which are called only if they
are not NULL. */
this is called elf_elfheader is set, but anything else should be
used with caution. If this returns false, the check_format
routine will return a bfd_error_wrong_format error. */
- boolean (*elf_backend_object_p) PARAMS ((bfd *));
+ boolean (*elf_backend_object_p)
+ PARAMS ((bfd *));
/* A function to do additional symbol processing when reading the
ELF symbol table. This is where any processor-specific special
section indices are handled. */
- void (*elf_backend_symbol_processing) PARAMS ((bfd *, asymbol *));
+ void (*elf_backend_symbol_processing)
+ PARAMS ((bfd *, asymbol *));
/* A function to do additional symbol processing after reading the
entire ELF symbol table. */
- boolean (*elf_backend_symbol_table_processing) PARAMS ((bfd *,
- elf_symbol_type *,
- unsigned int));
+ boolean (*elf_backend_symbol_table_processing)
+ PARAMS ((bfd *, elf_symbol_type *, unsigned int));
/* A function to set the type of the info field. Processor-specific
types should be handled here. */
- int (*elf_backend_get_symbol_type) PARAMS (( Elf_Internal_Sym *, int));
+ int (*elf_backend_get_symbol_type)
+ PARAMS (( Elf_Internal_Sym *, int));
/* A function to do additional processing on the ELF section header
just before writing it out. This is used to set the flags and
type fields for some sections, or to actually write out data for
unusual sections. */
- boolean (*elf_backend_section_processing) PARAMS ((bfd *,
- Elf32_Internal_Shdr *));
+ boolean (*elf_backend_section_processing)
+ PARAMS ((bfd *, Elf32_Internal_Shdr *));
/* A function to handle unusual section types when creating BFD
sections from ELF sections. */
- boolean (*elf_backend_section_from_shdr) PARAMS ((bfd *,
- Elf32_Internal_Shdr *,
- char *));
+ boolean (*elf_backend_section_from_shdr)
+ PARAMS ((bfd *, Elf32_Internal_Shdr *, char *));
/* A function to convert machine dependent section header flags to
BFD internal section header flags. */
- boolean (*elf_backend_section_flags) PARAMS ((flagword *,
- Elf32_Internal_Shdr *));
+ boolean (*elf_backend_section_flags)
+ PARAMS ((flagword *, Elf32_Internal_Shdr *));
/* A function to handle unusual program segment types when creating BFD
sections from ELF program segments. */
- boolean (*elf_backend_section_from_phdr) PARAMS ((bfd *,
- Elf32_Internal_Phdr *,
- int));
+ boolean (*elf_backend_section_from_phdr)
+ PARAMS ((bfd *, Elf32_Internal_Phdr *, int));
/* A function to set up the ELF section header for a BFD section in
preparation for writing it out. This is where the flags and type
fields are set for unusual sections. */
- boolean (*elf_backend_fake_sections) PARAMS ((bfd *, Elf32_Internal_Shdr *,
- asection *));
+ boolean (*elf_backend_fake_sections)
+ PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *));
/* A function to get the ELF section index for a BFD section. If
this returns true, the section was found. If it is a normal ELF
/* This function is called by get_program_header_size. It should
return the number of additional program segments which this BFD
will need. It should return -1 on error. */
- int (*elf_backend_additional_program_headers) PARAMS ((bfd *));
+ int (*elf_backend_additional_program_headers)
+ PARAMS ((bfd *));
/* This function is called to modify an existing segment map in a
backend specific fashion. */
- boolean (*elf_backend_modify_segment_map) PARAMS ((bfd *));
+ boolean (*elf_backend_modify_segment_map)
+ PARAMS ((bfd *));
/* This function is called during section gc to discover the section a
particular relocation refers to. It need not be defined for hosts
not handled in the hash table. */
boolean (*elf_backend_output_arch_syms)
PARAMS ((bfd *, struct bfd_link_info *, PTR,
- boolean (*) PARAMS ((PTR, const char *,
- Elf_Internal_Sym *, asection *))));
+ boolean (*) (PTR, const char *, Elf_Internal_Sym *, asection *)));
/* Copy any information related to dynamic linking from a pre-existing
symbol IND to a newly created symbol DIR. */
/* This function, if defined, is called when an NT_PRSTATUS note is found
in a core file. */
- boolean (*elf_backend_grok_prstatus) PARAMS ((bfd *, Elf_Internal_Note *));
+ boolean (*elf_backend_grok_prstatus)
+ PARAMS ((bfd *, Elf_Internal_Note *));
/* This function, if defined, is called when an NT_PSINFO or NT_PRPSINFO
note is found in a core file. */
- boolean (*elf_backend_grok_psinfo) PARAMS ((bfd *, Elf_Internal_Note *));
+ boolean (*elf_backend_grok_psinfo)
+ PARAMS ((bfd *, Elf_Internal_Note *));
/* Functions to print VMAs. Special code to handle 64 bit ELF files. */
- void (* elf_backend_sprintf_vma) PARAMS ((bfd *, char *, bfd_vma));
- void (* elf_backend_fprintf_vma) PARAMS ((bfd *, PTR, bfd_vma));
+ void (* elf_backend_sprintf_vma)
+ PARAMS ((bfd *, char *, bfd_vma));
+ void (* elf_backend_fprintf_vma)
+ PARAMS ((bfd *, PTR, bfd_vma));
/* This function returns class of a reloc type. */
- enum elf_reloc_type_class (* elf_backend_reloc_type_class) PARAMS ((int));
+ enum elf_reloc_type_class (* elf_backend_reloc_type_class)
+ PARAMS ((int));
/* The swapping table to use when dealing with ECOFF information.
Used for the MIPS ELF .mdebug section. */
{
struct elf_linker_section_pointers *next; /* next allocated pointer for this symbol */
bfd_vma offset; /* offset of pointer from beginning of section */
- bfd_signed_vma addend; /* addend used */
+ bfd_vma addend; /* addend used */
elf_linker_section_enum_t which; /* which linker section this is */
boolean written_address_p; /* whether address was written yet */
} elf_linker_section_pointers_t;
extern void _bfd_elf_swap_versym_out
PARAMS ((bfd *, const Elf_Internal_Versym *, Elf_External_Versym *));
-extern int _bfd_elf_section_from_bfd_section PARAMS ((bfd *, asection *));
+extern int _bfd_elf_section_from_bfd_section
+ PARAMS ((bfd *, asection *));
extern char *bfd_elf_string_from_elf_section
PARAMS ((bfd *, unsigned, unsigned));
-extern char *bfd_elf_get_str_section PARAMS ((bfd *, unsigned));
+extern char *bfd_elf_get_str_section
+ PARAMS ((bfd *, unsigned));
-extern boolean _bfd_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
-extern void bfd_elf_print_symbol PARAMS ((bfd *, PTR, asymbol *,
- bfd_print_symbol_type));
-#define elf_string_from_elf_strtab(abfd,strindex) \
- bfd_elf_string_from_elf_section(abfd,elf_elfheader(abfd)->e_shstrndx,strindex)
+extern boolean _bfd_elf_print_private_bfd_data
+ PARAMS ((bfd *, PTR));
+extern void bfd_elf_print_symbol
+ PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
+
+#define elf_string_from_elf_strtab(abfd, strindex) \
+ bfd_elf_string_from_elf_section(abfd, elf_elfheader(abfd)->e_shstrndx, \
+ strindex)
#define bfd_elf32_print_symbol bfd_elf_print_symbol
#define bfd_elf64_print_symbol bfd_elf_print_symbol
-extern void _bfd_elf_sprintf_vma PARAMS ((bfd *, char *, bfd_vma));
-extern void _bfd_elf_fprintf_vma PARAMS ((bfd *, PTR, bfd_vma));
+extern void _bfd_elf_sprintf_vma
+ PARAMS ((bfd *, char *, bfd_vma));
+extern void _bfd_elf_fprintf_vma
+ PARAMS ((bfd *, PTR, bfd_vma));
-extern enum elf_reloc_type_class _bfd_elf_reloc_type_class PARAMS ((int));
+extern enum elf_reloc_type_class _bfd_elf_reloc_type_class
+ PARAMS ((int));
-extern unsigned long bfd_elf_hash PARAMS ((const char *));
+extern unsigned long bfd_elf_hash
+ PARAMS ((const char *));
-extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
- arelent *,
- asymbol *,
- PTR,
- asection *,
- bfd *,
- char **));
-extern boolean bfd_elf_mkobject PARAMS ((bfd *));
-extern boolean bfd_elf_mkcorefile PARAMS ((bfd *));
-extern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *));
+extern bfd_reloc_status_type bfd_elf_generic_reloc
+ PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
+extern boolean bfd_elf_mkobject
+ PARAMS ((bfd *));
+extern boolean bfd_elf_mkcorefile
+ PARAMS ((bfd *));
+extern Elf_Internal_Shdr *bfd_elf_find_section
+ PARAMS ((bfd *, char *));
extern boolean _bfd_elf_make_section_from_shdr
- PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, const char *name));
+ PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
extern boolean _bfd_elf_make_section_from_phdr
- PARAMS ((bfd *abfd, Elf_Internal_Phdr *hdr, int index, const char *typename));
+ PARAMS ((bfd *, Elf_Internal_Phdr *, int, const char *));
extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
struct bfd_hash_table *,
const char *)));
-extern boolean _bfd_elf_slurp_version_tables PARAMS ((bfd *));
+extern boolean _bfd_elf_slurp_version_tables
+ PARAMS ((bfd *));
extern boolean _bfd_elf_merge_sections
PARAMS ((bfd *, struct bfd_link_info *));
PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
extern boolean _bfd_elf_copy_private_section_data
PARAMS ((bfd *, asection *, bfd *, asection *));
-extern boolean _bfd_elf_write_object_contents PARAMS ((bfd *));
-extern boolean _bfd_elf_write_corefile_contents PARAMS ((bfd *));
-extern boolean _bfd_elf_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
- file_ptr,
- bfd_size_type));
-extern long _bfd_elf_get_symtab_upper_bound PARAMS ((bfd *));
-extern long _bfd_elf_get_symtab PARAMS ((bfd *, asymbol **));
-extern long _bfd_elf_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
-extern long _bfd_elf_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
-extern long _bfd_elf_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
-extern long _bfd_elf_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
- arelent **, asymbol **));
-extern long _bfd_elf_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
-extern long _bfd_elf_canonicalize_dynamic_reloc PARAMS ((bfd *, arelent **,
- asymbol **));
-extern asymbol *_bfd_elf_make_empty_symbol PARAMS ((bfd *));
-extern void _bfd_elf_get_symbol_info PARAMS ((bfd *, asymbol *,
- symbol_info *));
-extern boolean _bfd_elf_is_local_label_name PARAMS ((bfd *, const char *));
-extern alent *_bfd_elf_get_lineno PARAMS ((bfd *, asymbol *));
-extern boolean _bfd_elf_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
- unsigned long));
-extern boolean _bfd_elf_find_nearest_line PARAMS ((bfd *, asection *,
- asymbol **,
- bfd_vma, const char **,
- const char **,
- unsigned int *));
+extern boolean _bfd_elf_write_object_contents
+ PARAMS ((bfd *));
+extern boolean _bfd_elf_write_corefile_contents
+ PARAMS ((bfd *));
+extern boolean _bfd_elf_set_section_contents
+ PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
+extern long _bfd_elf_get_symtab_upper_bound
+ PARAMS ((bfd *));
+extern long _bfd_elf_get_symtab
+ PARAMS ((bfd *, asymbol **));
+extern long _bfd_elf_get_dynamic_symtab_upper_bound
+ PARAMS ((bfd *));
+extern long _bfd_elf_canonicalize_dynamic_symtab
+ PARAMS ((bfd *, asymbol **));
+extern long _bfd_elf_get_reloc_upper_bound
+ PARAMS ((bfd *, sec_ptr));
+extern long _bfd_elf_canonicalize_reloc
+ PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
+extern long _bfd_elf_get_dynamic_reloc_upper_bound
+ PARAMS ((bfd *));
+extern long _bfd_elf_canonicalize_dynamic_reloc
+ PARAMS ((bfd *, arelent **, asymbol **));
+extern asymbol *_bfd_elf_make_empty_symbol
+ PARAMS ((bfd *));
+extern void _bfd_elf_get_symbol_info
+ PARAMS ((bfd *, asymbol *, symbol_info *));
+extern boolean _bfd_elf_is_local_label_name
+ PARAMS ((bfd *, const char *));
+extern alent *_bfd_elf_get_lineno
+ PARAMS ((bfd *, asymbol *));
+extern boolean _bfd_elf_set_arch_mach
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
+extern boolean _bfd_elf_find_nearest_line
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
+ const char **, unsigned int *));
#define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
#define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
-extern int _bfd_elf_sizeof_headers PARAMS ((bfd *, boolean));
-extern boolean _bfd_elf_new_section_hook PARAMS ((bfd *, asection *));
+extern int _bfd_elf_sizeof_headers
+ PARAMS ((bfd *, boolean));
+extern boolean _bfd_elf_new_section_hook
+ PARAMS ((bfd *, asection *));
extern boolean _bfd_elf_init_reloc_shdr
PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, boolean));
/* If the target doesn't have reloc handling written yet: */
-extern void _bfd_elf_no_info_to_howto PARAMS ((bfd *, arelent *,
- Elf_Internal_Rela *));
-
-extern boolean bfd_section_from_shdr PARAMS ((bfd *, unsigned int shindex));
-extern boolean bfd_section_from_phdr PARAMS ((bfd *, Elf_Internal_Phdr *, int));
-
-extern int _bfd_elf_symbol_from_bfd_symbol PARAMS ((bfd *, asymbol **));
-
-asection *bfd_section_from_elf_index PARAMS ((bfd *, unsigned int));
-boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
- struct bfd_link_info *));
-struct bfd_strtab_hash *_bfd_elf_stringtab_init PARAMS ((void));
-boolean
-_bfd_elf_link_record_dynamic_symbol PARAMS ((struct bfd_link_info *,
- struct elf_link_hash_entry *));
-long
-_bfd_elf_link_lookup_local_dynindx PARAMS ((struct bfd_link_info *,
- bfd *, long));
-boolean
-_bfd_elf_compute_section_file_positions PARAMS ((bfd *,
- struct bfd_link_info *));
-void _bfd_elf_assign_file_positions_for_relocs PARAMS ((bfd *));
-file_ptr _bfd_elf_assign_file_position_for_section PARAMS ((Elf_Internal_Shdr *,
- file_ptr,
- boolean));
-
-extern boolean _bfd_elf_validate_reloc PARAMS ((bfd *, arelent *));
-
-boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
- struct bfd_link_info *));
-boolean _bfd_elf_create_got_section PARAMS ((bfd *,
- struct bfd_link_info *));
-unsigned long _bfd_elf_link_renumber_dynsyms PARAMS ((bfd *,
- struct bfd_link_info *));
-
-boolean _bfd_elfcore_make_pseudosection PARAMS ((bfd *, char *, int, int));
-char *_bfd_elfcore_strndup PARAMS ((bfd *, char *, int));
-
-elf_linker_section_t *_bfd_elf_create_linker_section
- PARAMS ((bfd *abfd,
- struct bfd_link_info *info,
- enum elf_linker_section_enum,
- elf_linker_section_t *defaults));
-
-elf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
- PARAMS ((elf_linker_section_pointers_t *linker_pointers,
- bfd_signed_vma addend,
- elf_linker_section_enum_t which));
-
-boolean bfd_elf32_create_pointer_linker_section
- PARAMS ((bfd *abfd,
- struct bfd_link_info *info,
- elf_linker_section_t *lsect,
- struct elf_link_hash_entry *h,
- const Elf32_Internal_Rela *rel));
-
-bfd_vma bfd_elf32_finish_pointer_linker_section
- PARAMS ((bfd *output_abfd,
- bfd *input_bfd,
- struct bfd_link_info *info,
- elf_linker_section_t *lsect,
- struct elf_link_hash_entry *h,
- bfd_vma relocation,
- const Elf32_Internal_Rela *rel,
- int relative_reloc));
-
-boolean bfd_elf64_create_pointer_linker_section
- PARAMS ((bfd *abfd,
- struct bfd_link_info *info,
- elf_linker_section_t *lsect,
- struct elf_link_hash_entry *h,
- const Elf64_Internal_Rela *rel));
-
-bfd_vma bfd_elf64_finish_pointer_linker_section
- PARAMS ((bfd *output_abfd,
- bfd *input_bfd,
- struct bfd_link_info *info,
- elf_linker_section_t *lsect,
- struct elf_link_hash_entry *h,
- bfd_vma relocation,
- const Elf64_Internal_Rela *rel,
- int relative_reloc));
-
-boolean _bfd_elf_make_linker_section_rela
- PARAMS ((bfd *dynobj,
- elf_linker_section_t *lsect,
- int alignment));
-
-extern const bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
-extern const bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
-extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
-extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
-extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
- bfd *));
+extern void _bfd_elf_no_info_to_howto
+ PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
+
+extern boolean bfd_section_from_shdr
+ PARAMS ((bfd *, unsigned int shindex));
+extern boolean bfd_section_from_phdr
+ PARAMS ((bfd *, Elf_Internal_Phdr *, int));
+
+extern int _bfd_elf_symbol_from_bfd_symbol
+ PARAMS ((bfd *, asymbol **));
+
+extern asection *bfd_section_from_elf_index
+ PARAMS ((bfd *, unsigned int));
+extern boolean _bfd_elf_create_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern struct bfd_strtab_hash *_bfd_elf_stringtab_init
+ PARAMS ((void));
+extern boolean _bfd_elf_link_record_dynamic_symbol
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+extern long _bfd_elf_link_lookup_local_dynindx
+ PARAMS ((struct bfd_link_info *, bfd *, long));
+extern boolean _bfd_elf_compute_section_file_positions
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern void _bfd_elf_assign_file_positions_for_relocs
+ PARAMS ((bfd *));
+extern file_ptr _bfd_elf_assign_file_position_for_section
+ PARAMS ((Elf_Internal_Shdr *, file_ptr, boolean));
+
+extern boolean _bfd_elf_validate_reloc
+ PARAMS ((bfd *, arelent *));
+
+extern boolean _bfd_elf_create_dynamic_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_elf_create_got_section
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern unsigned long _bfd_elf_link_renumber_dynsyms
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+extern boolean _bfd_elfcore_make_pseudosection
+ PARAMS ((bfd *, char *, size_t, ufile_ptr));
+extern char *_bfd_elfcore_strndup
+ PARAMS ((bfd *, char *, size_t));
+
+extern elf_linker_section_t *_bfd_elf_create_linker_section
+ PARAMS ((bfd *, struct bfd_link_info *, enum elf_linker_section_enum,
+ elf_linker_section_t *));
+
+extern elf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
+ PARAMS ((elf_linker_section_pointers_t *, bfd_vma,
+ elf_linker_section_enum_t));
+
+extern boolean bfd_elf32_create_pointer_linker_section
+ PARAMS ((bfd *, struct bfd_link_info *, elf_linker_section_t *,
+ struct elf_link_hash_entry *, const Elf32_Internal_Rela *));
+
+extern bfd_vma bfd_elf32_finish_pointer_linker_section
+ PARAMS ((bfd *, bfd *, struct bfd_link_info *, elf_linker_section_t *,
+ struct elf_link_hash_entry *, bfd_vma,
+ const Elf32_Internal_Rela *, int));
+
+extern boolean bfd_elf64_create_pointer_linker_section
+ PARAMS ((bfd *, struct bfd_link_info *, elf_linker_section_t *,
+ struct elf_link_hash_entry *, const Elf64_Internal_Rela *));
+
+extern bfd_vma bfd_elf64_finish_pointer_linker_section
+ PARAMS ((bfd *, bfd *, struct bfd_link_info *, elf_linker_section_t *,
+ struct elf_link_hash_entry *, bfd_vma,
+ const Elf64_Internal_Rela *, int));
+
+extern boolean _bfd_elf_make_linker_section_rela
+ PARAMS ((bfd *, elf_linker_section_t *, int));
+
+extern const bfd_target *bfd_elf32_object_p
+ PARAMS ((bfd *));
+extern const bfd_target *bfd_elf32_core_file_p
+ PARAMS ((bfd *));
+extern char *bfd_elf32_core_file_failing_command
+ PARAMS ((bfd *));
+extern int bfd_elf32_core_file_failing_signal
+ PARAMS ((bfd *));
+extern boolean bfd_elf32_core_file_matches_executable_p
+ PARAMS ((bfd *, bfd *));
extern boolean bfd_elf32_bfd_link_add_symbols
PARAMS ((bfd *, struct bfd_link_info *));
PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
extern long bfd_elf32_slurp_symbol_table
PARAMS ((bfd *, asymbol **, boolean));
-extern boolean bfd_elf32_write_shdrs_and_ehdr PARAMS ((bfd *));
+extern boolean bfd_elf32_write_shdrs_and_ehdr
+ PARAMS ((bfd *));
extern int bfd_elf32_write_out_phdrs
- PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
+ PARAMS ((bfd *, const Elf_Internal_Phdr *, unsigned int));
extern void bfd_elf32_write_relocs
PARAMS ((bfd *, asection *, PTR));
extern boolean bfd_elf32_slurp_reloc_table
extern Elf_Internal_Rela *_bfd_elf32_link_read_relocs
PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
-extern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
-extern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
-extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
-extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
-extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
- bfd *));
+extern const bfd_target *bfd_elf64_object_p
+ PARAMS ((bfd *));
+extern const bfd_target *bfd_elf64_core_file_p
+ PARAMS ((bfd *));
+extern char *bfd_elf64_core_file_failing_command
+ PARAMS ((bfd *));
+extern int bfd_elf64_core_file_failing_signal
+ PARAMS ((bfd *));
+extern boolean bfd_elf64_core_file_matches_executable_p
+ PARAMS ((bfd *, bfd *));
extern boolean bfd_elf64_bfd_link_add_symbols
PARAMS ((bfd *, struct bfd_link_info *));
extern boolean bfd_elf64_bfd_final_link
PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
extern long bfd_elf64_slurp_symbol_table
PARAMS ((bfd *, asymbol **, boolean));
-extern boolean bfd_elf64_write_shdrs_and_ehdr PARAMS ((bfd *));
+extern boolean bfd_elf64_write_shdrs_and_ehdr
+ PARAMS ((bfd *));
extern int bfd_elf64_write_out_phdrs
- PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
+ PARAMS ((bfd *, const Elf_Internal_Phdr *, unsigned int));
extern void bfd_elf64_write_relocs
PARAMS ((bfd *, asection *, PTR));
extern boolean bfd_elf64_slurp_reloc_table
#define bfd_elf64_link_record_dynamic_symbol \
_bfd_elf_link_record_dynamic_symbol
-boolean _bfd_elf32_link_record_local_dynamic_symbol
+extern boolean _bfd_elf32_link_record_local_dynamic_symbol
PARAMS ((struct bfd_link_info *, bfd *, long));
-boolean _bfd_elf64_link_record_local_dynamic_symbol
+extern boolean _bfd_elf64_link_record_local_dynamic_symbol
PARAMS ((struct bfd_link_info *, bfd *, long));
-extern boolean _bfd_elf_close_and_cleanup PARAMS ((bfd *));
+extern boolean _bfd_elf_close_and_cleanup
+ PARAMS ((bfd *));
extern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR,
asection *, bfd *, char **));
-boolean _bfd_elf32_gc_sections
- PARAMS ((bfd *abfd, struct bfd_link_info *info));
-boolean _bfd_elf32_gc_common_finalize_got_offsets
- PARAMS ((bfd *abfd, struct bfd_link_info *info));
-boolean _bfd_elf32_gc_common_final_link
+extern boolean _bfd_elf32_gc_sections
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_elf32_gc_common_finalize_got_offsets
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_elf32_gc_common_final_link
PARAMS ((bfd *, struct bfd_link_info *));
-boolean _bfd_elf32_gc_record_vtinherit
+extern boolean _bfd_elf32_gc_record_vtinherit
PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
-boolean _bfd_elf32_gc_record_vtentry
+extern boolean _bfd_elf32_gc_record_vtentry
PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
-boolean _bfd_elf64_gc_sections
- PARAMS ((bfd *abfd, struct bfd_link_info *info));
-boolean _bfd_elf64_gc_common_finalize_got_offsets
- PARAMS ((bfd *abfd, struct bfd_link_info *info));
-boolean _bfd_elf64_gc_common_final_link
+extern boolean _bfd_elf64_gc_sections
PARAMS ((bfd *, struct bfd_link_info *));
-boolean _bfd_elf64_gc_record_vtinherit
+extern boolean _bfd_elf64_gc_common_finalize_got_offsets
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_elf64_gc_common_final_link
+ PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean _bfd_elf64_gc_record_vtinherit
PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
-boolean _bfd_elf64_gc_record_vtentry
+extern boolean _bfd_elf64_gc_record_vtentry
PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
/* MIPS ELF specific routines. */
-extern boolean _bfd_mips_elf_object_p PARAMS ((bfd *));
+extern boolean _bfd_mips_elf_object_p
+ PARAMS ((bfd *));
extern boolean _bfd_mips_elf_section_from_shdr
PARAMS ((bfd *, Elf_Internal_Shdr *, char *));
extern boolean _bfd_mips_elf_fake_sections
PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, int *));
extern boolean _bfd_mips_elf_section_processing
PARAMS ((bfd *, Elf_Internal_Shdr *));
-extern void _bfd_mips_elf_symbol_processing PARAMS ((bfd *, asymbol *));
+extern void _bfd_mips_elf_symbol_processing
+ PARAMS ((bfd *, asymbol *));
extern boolean _bfd_mips_elf_read_ecoff_info
PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
-extern void _bfd_mips_elf_final_write_processing PARAMS ((bfd *, boolean));
+extern void _bfd_mips_elf_final_write_processing
+ PARAMS ((bfd *, boolean));
extern bfd_reloc_status_type _bfd_mips_elf_hi16_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
extern bfd_reloc_status_type _bfd_mips_elf_lo16_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
extern bfd_reloc_status_type _bfd_mips_elf_gprel32_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
-extern boolean _bfd_mips_elf_set_private_flags PARAMS ((bfd *, flagword));
-extern boolean _bfd_mips_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
-extern boolean _bfd_mips_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
+extern boolean _bfd_mips_elf_set_private_flags
+ PARAMS ((bfd *, flagword));
+extern boolean _bfd_mips_elf_copy_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+extern boolean _bfd_mips_elf_merge_private_bfd_data
+ PARAMS ((bfd *, bfd *));
extern boolean _bfd_mips_elf_find_nearest_line
PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
const char **, unsigned int *));
asection *));
extern boolean _bfd_mips_elf_final_link
PARAMS ((bfd *, struct bfd_link_info *));
-extern int _bfd_mips_elf_additional_program_headers PARAMS ((bfd *));
-extern boolean _bfd_mips_elf_modify_segment_map PARAMS ((bfd *));
+extern int _bfd_mips_elf_additional_program_headers
+ PARAMS ((bfd *));
+extern boolean _bfd_mips_elf_modify_segment_map
+ PARAMS ((bfd *));
extern boolean _bfd_mips_elf_relocate_section
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
/* SH ELF specific routine. */
-extern boolean _sh_elf_set_mach_from_flags PARAMS ((bfd *));
+extern boolean _sh_elf_set_mach_from_flags
+ PARAMS ((bfd *));
#endif /* _LIBELF_H_ */
asection *, struct elf_link_hash_entry *,
struct elf64_hppa_dyn_hash_entry *));
-static unsigned int elf_hppa_relocate_insn
- PARAMS ((unsigned int, unsigned int, unsigned int));
+static int elf_hppa_relocate_insn
+ PARAMS ((int, int, unsigned int));
#endif
/* ELF/PA relocation howto entries. */
{
elf_hppa_reloc_type *finaltype;
elf_hppa_reloc_type **final_types;
+ bfd_size_type amt = sizeof (elf_hppa_reloc_type *) * 2;
/* Allocate slots for the BFD relocation. */
- final_types = ((elf_hppa_reloc_type **)
- bfd_alloc (abfd, sizeof (elf_hppa_reloc_type *) * 2));
+ final_types = (elf_hppa_reloc_type **) bfd_alloc (abfd, amt);
if (final_types == NULL)
return NULL;
/* Allocate space for the relocation itself. */
- finaltype = ((elf_hppa_reloc_type *)
- bfd_alloc (abfd, sizeof (elf_hppa_reloc_type)));
+ amt = sizeof (elf_hppa_reloc_type);
+ finaltype = (elf_hppa_reloc_type *) bfd_alloc (abfd, amt);
if (finaltype == NULL)
return NULL;
struct elf_link_hash_entry *h ATTRIBUTE_UNUSED;
struct elf64_hppa_dyn_hash_entry *dyn_h;
{
- unsigned int insn;
+ int insn;
bfd_vma offset = rel->r_offset;
- bfd_vma addend = rel->r_addend;
+ bfd_signed_vma addend = rel->r_addend;
reloc_howto_type *howto = elf_hppa_howto_table + ELF_R_TYPE (rel->r_info);
unsigned int r_type = howto->type;
bfd_byte *hit_data = contents + offset;
value = hppa_field_adjust (value, -8 + addend, e_rsel);
/* Apply the relocation to the given instruction. */
- insn = elf_hppa_relocate_insn (insn, value, r_type);
+ insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
break;
}
value >>= 2;
/* Apply the relocation to the given instruction. */
- insn = elf_hppa_relocate_insn (insn, value, r_type);
+ insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
break;
}
else
value = hppa_field_adjust (value, addend, e_rrsel);
- insn = elf_hppa_relocate_insn (insn, value, r_type);
+ insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
break;
}
else
value = hppa_field_adjust (value, addend, e_rrsel);
- insn = elf_hppa_relocate_insn (insn, value, r_type);
+ insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
break;
}
value >>= 2;
}
- insn = elf_hppa_relocate_insn (insn, value, r_type);
+ insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
break;
}
else
value = hppa_field_adjust (value, addend, e_rrsel);
- insn = elf_hppa_relocate_insn (insn, value, r_type);
+ insn = elf_hppa_relocate_insn (insn, (int) value, r_type);
break;
}
}
/* Update the instruction word. */
- bfd_put_32 (input_bfd, insn, hit_data);
+ bfd_put_32 (input_bfd, (bfd_vma) insn, hit_data);
return bfd_reloc_ok;
}
Instead this routine is meant to handle the bit manipulations needed
to insert the relocation into the given instruction. */
-static unsigned int
+static int
elf_hppa_relocate_insn (insn, sym_value, r_type)
- unsigned int insn;
- unsigned int sym_value;
+ int insn;
+ int sym_value;
unsigned int r_type;
{
switch (r_type)
the "B" instruction. */
case R_PARISC_PCREL22F:
case R_PARISC_PCREL22C:
- return (insn & ~ 0x3ff1ffd) | re_assemble_22 (sym_value);
+ return (insn & ~0x3ff1ffd) | re_assemble_22 (sym_value);
/* This is any 12 bit branch. */
case R_PARISC_PCREL12F:
- return (insn & ~ 0x1ffd) | re_assemble_12 (sym_value);
+ return (insn & ~0x1ffd) | re_assemble_12 (sym_value);
/* This is any 17 bit branch. In PA2.0 syntax it also corresponds
to the "B" instruction as well as BE. */
case R_PARISC_DIR17R:
case R_PARISC_PCREL17C:
case R_PARISC_PCREL17R:
- return (insn & ~ 0x1f1ffd) | re_assemble_17 (sym_value);
+ return (insn & ~0x1f1ffd) | re_assemble_17 (sym_value);
/* ADDIL or LDIL instructions. */
case R_PARISC_DLTREL21L:
case R_PARISC_DPREL21L:
case R_PARISC_PLTOFF21L:
case R_PARISC_DIR21L:
- return (insn & ~ 0x1fffff) | re_assemble_21 (sym_value);
+ return (insn & ~0x1fffff) | re_assemble_21 (sym_value);
/* LDO and integer loads/stores with 14 bit displacements. */
case R_PARISC_DLTREL14R:
case R_PARISC_DIR14F:
case R_PARISC_DIR16F:
case R_PARISC_LTOFF16F:
- return (insn & ~ 0x3fff) | low_sign_unext (sym_value, 14);
+ return (insn & ~0x3fff) | low_sign_unext (sym_value, 14);
/* Doubleword loads and stores with a 14 bit displacement. */
case R_PARISC_DLTREL14DR:
case R_PARISC_DIR14DR:
case R_PARISC_DIR16DF:
case R_PARISC_LTOFF16DF:
- return (insn & ~ 0x3ff1) | (((sym_value & 0x2000) >> 13)
- | ((sym_value & 0x1ff8) << 1));
+ return (insn & ~0x3ff1) | (((sym_value & 0x2000) >> 13)
+ | ((sym_value & 0x1ff8) << 1));
/* Floating point single word load/store instructions. */
case R_PARISC_DLTREL14WR:
case R_PARISC_DIR16WF:
case R_PARISC_DIR14WR:
case R_PARISC_LTOFF16WF:
- return (insn & ~ 0x3ff9) | (((sym_value & 0x2000) >> 13)
- | ((sym_value & 0x1ffc) << 1));
+ return (insn & ~0x3ff9) | (((sym_value & 0x2000) >> 13)
+ | ((sym_value & 0x1ffc) << 1));
default:
return insn;
else
{
/* Go get them off disk. */
- extsyms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_size));
+ bfd_size_type amt = symtab_hdr->sh_size;
+ extsyms = (Elf32_External_Sym *) bfd_malloc (amt);
if (extsyms == NULL)
goto error_return;
free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
- != symtab_hdr->sh_size))
+ || bfd_bread (extsyms, amt, abfd) != amt)
goto error_return;
}
}
irelend = irel + sec->reloc_count;
/* Actually delete the bytes. */
- memmove (contents + addr, contents + addr + count, toaddr - addr - count);
+ memmove (contents + addr, contents + addr + count,
+ (size_t) (toaddr - addr - count));
sec->_cooked_size -= count;
/* Adjust all the relocs. */
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
memcpy (data, elf_section_data (input_section)->this_hdr.contents,
- input_section->_raw_size);
+ (size_t) input_section->_raw_size);
if ((input_section->flags & SEC_RELOC) != 0
&& input_section->reloc_count > 0)
Elf_Internal_Sym *isymp;
asection **secpp;
Elf32_External_Sym *esym, *esymend;
+ bfd_size_type size;
if (symtab_hdr->contents != NULL)
external_syms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
- external_syms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf32_External_Sym)));
- if (external_syms == NULL && symtab_hdr->sh_info > 0)
+ size = symtab_hdr->sh_info;
+ size *= sizeof (Elf32_External_Sym);
+ external_syms = (Elf32_External_Sym *) bfd_malloc (size);
+ if (external_syms == NULL && size != 0)
goto error_return;
if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (external_syms, sizeof (Elf32_External_Sym),
- symtab_hdr->sh_info, input_bfd)
- != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))))
+ || bfd_bread (external_syms, size, input_bfd) != size)
goto error_return;
}
if (internal_relocs == NULL)
goto error_return;
- internal_syms = ((Elf_Internal_Sym *)
- bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf_Internal_Sym)));
- if (internal_syms == NULL && symtab_hdr->sh_info > 0)
+ size = symtab_hdr->sh_info;
+ size *= sizeof (Elf_Internal_Sym);
+ internal_syms = (Elf_Internal_Sym *) bfd_malloc (size);
+ if (internal_syms == NULL && size != 0)
goto error_return;
- sections = (asection **) bfd_malloc (symtab_hdr->sh_info
- * sizeof (asection *));
- if (sections == NULL && symtab_hdr->sh_info > 0)
+ size = symtab_hdr->sh_info;
+ size *= sizeof (asection *);
+ sections = (asection **) bfd_malloc (size);
+ if (sections == NULL && size != 0)
goto error_return;
isymp = internal_syms;
static bfd_byte * mn10300_elf_get_relocated_section_contents
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
bfd_byte *, boolean, asymbol **));
-static int elf_mn10300_mach PARAMS ((flagword));
+static unsigned long elf_mn10300_mach PARAMS ((flagword));
void _bfd_mn10300_elf_final_write_processing PARAMS ((bfd *, boolean));
boolean _bfd_mn10300_elf_object_p PARAMS ((bfd *));
extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
+ bfd_size_type amt = symtab_hdr->sh_size;
/* Go get them off disk. */
- extsyms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_size));
+ extsyms = (Elf32_External_Sym *) bfd_malloc (amt);
if (extsyms == NULL)
goto error_return;
free_extsyms = extsyms;
if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (extsyms, 1, symtab_hdr->sh_size, input_bfd)
- != symtab_hdr->sh_size))
+ || bfd_bread (extsyms, amt, input_bfd) != amt)
goto error_return;
}
{
/* A local symbol. */
Elf_Internal_Sym isym;
+ struct elf_link_hash_table *elftab;
+ bfd_size_type amt;
bfd_elf32_swap_symbol_in (input_bfd,
extsyms + r_index, &isym);
/* Tack on an ID so we can uniquely identify this
local symbol in the global hash table. */
- new_name = bfd_malloc (strlen (sym_name) + 10);
+ amt = strlen (sym_name) + 10;
+ new_name = bfd_malloc (amt);
if (new_name == 0)
goto error_return;
sym_name, (int) sym_sec);
sym_name = new_name;
- hash = (struct elf32_mn10300_link_hash_entry *)
- elf_link_hash_lookup (&hash_table->static_hash_table->root,
- sym_name, true,
- true, false);
+ elftab = &hash_table->static_hash_table->root;
+ hash = ((struct elf32_mn10300_link_hash_entry *)
+ elf_link_hash_lookup (elftab, sym_name,
+ true, true, false));
free (new_name);
}
else
if (isym.st_shndx == shndx
&& ELF_ST_TYPE (isym.st_info) == STT_FUNC)
{
+ struct elf_link_hash_table *elftab;
+ bfd_size_type amt;
+
if (isym.st_shndx == SHN_UNDEF)
sym_sec = bfd_und_section_ptr;
else if (isym.st_shndx > 0
else if (isym.st_shndx == SHN_COMMON)
sym_sec = bfd_com_section_ptr;
- sym_name = bfd_elf_string_from_elf_section (input_bfd,
- symtab_hdr->sh_link,
- isym.st_name);
+ sym_name = (bfd_elf_string_from_elf_section
+ (input_bfd, symtab_hdr->sh_link,
+ isym.st_name));
/* Tack on an ID so we can uniquely identify this
local symbol in the global hash table. */
- new_name = bfd_malloc (strlen (sym_name) + 10);
+ amt = strlen (sym_name) + 10;
+ new_name = bfd_malloc (amt);
if (new_name == 0)
goto error_return;
sym_name, (int) sym_sec);
sym_name = new_name;
- hash = (struct elf32_mn10300_link_hash_entry *)
- elf_link_hash_lookup (&hash_table->static_hash_table->root,
- sym_name, true,
- true, false);
+ elftab = &hash_table->static_hash_table->root;
+ hash = ((struct elf32_mn10300_link_hash_entry *)
+ elf_link_hash_lookup (elftab, sym_name,
+ true, true, false));
free (new_name);
compute_function_info (input_bfd, hash,
isym.st_value, contents);
extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
+ bfd_size_type amt = symtab_hdr->sh_size;
/* Go get them off disk. */
- extsyms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_size));
+ extsyms = (Elf32_External_Sym *) bfd_malloc (amt);
if (extsyms == NULL)
goto error_return;
free_extsyms = extsyms;
if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (extsyms, 1, symtab_hdr->sh_size, input_bfd)
- != symtab_hdr->sh_size))
+ || bfd_bread (extsyms, amt, input_bfd) != amt)
goto error_return;
}
asection *sym_sec = NULL;
const char *sym_name;
char *new_name;
+ struct elf_link_hash_table *elftab;
+ bfd_size_type amt;
bfd_elf32_swap_symbol_in (input_bfd, esym, &isym);
/* Tack on an ID so we can uniquely identify this
local symbol in the global hash table. */
- new_name = bfd_malloc (strlen (sym_name) + 10);
+ amt = strlen (sym_name) + 10;
+ new_name = bfd_malloc (amt);
if (new_name == 0)
goto error_return;
sprintf (new_name, "%s_%08x", sym_name, (int) sym_sec);
sym_name = new_name;
- sym_hash = (struct elf32_mn10300_link_hash_entry *)
- elf_link_hash_lookup (&hash_table->static_hash_table->root,
- sym_name, false,
- false, false);
+ elftab = &hash_table->static_hash_table->root;
+ sym_hash = ((struct elf32_mn10300_link_hash_entry *)
+ elf_link_hash_lookup (elftab, sym_name,
+ false, false, false));
free (new_name);
if (sym_hash == NULL)
extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
+ bfd_size_type amt = symtab_hdr->sh_size;
/* Go get them off disk. */
- extsyms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_size));
+ extsyms = (Elf32_External_Sym *) bfd_malloc (amt);
if (extsyms == NULL)
goto error_return;
free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
- != symtab_hdr->sh_size))
+ || bfd_bread (extsyms, amt, abfd) != amt)
goto error_return;
}
}
/* Tack on an ID so we can uniquely identify this
local symbol in the global hash table. */
- new_name = bfd_malloc (strlen (sym_name) + 10);
+ new_name = bfd_malloc ((bfd_size_type) strlen (sym_name) + 10);
if (new_name == 0)
goto error_return;
sprintf (new_name, "%s_%08x", sym_name, (int) sym_sec);
irelend = irel + sec->reloc_count;
/* Actually delete the bytes. */
- memmove (contents + addr, contents + addr + count, toaddr - addr - count);
+ memmove (contents + addr, contents + addr + count,
+ (size_t) (toaddr - addr - count));
sec->_cooked_size -= count;
/* Adjust all the relocs. */
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
memcpy (data, elf_section_data (input_section)->this_hdr.contents,
- input_section->_raw_size);
+ (size_t) input_section->_raw_size);
if ((input_section->flags & SEC_RELOC) != 0
&& input_section->reloc_count > 0)
Elf_Internal_Sym *isymp;
asection **secpp;
Elf32_External_Sym *esym, *esymend;
+ bfd_size_type size;
if (symtab_hdr->contents != NULL)
external_syms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
- external_syms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf32_External_Sym)));
- if (external_syms == NULL && symtab_hdr->sh_info > 0)
+ size = symtab_hdr->sh_info;
+ size *= sizeof (Elf32_External_Sym);
+ external_syms = (Elf32_External_Sym *) bfd_malloc (size);
+ if (external_syms == NULL && size != 0)
goto error_return;
if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (external_syms, sizeof (Elf32_External_Sym),
- symtab_hdr->sh_info, input_bfd)
- != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))))
+ || bfd_bread (external_syms, size, input_bfd) != size)
goto error_return;
}
if (internal_relocs == NULL)
goto error_return;
- internal_syms = ((Elf_Internal_Sym *)
- bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf_Internal_Sym)));
- if (internal_syms == NULL && symtab_hdr->sh_info > 0)
+ size = symtab_hdr->sh_info;
+ size *= sizeof (Elf_Internal_Sym);
+ internal_syms = (Elf_Internal_Sym *) bfd_malloc (size);
+ if (internal_syms == NULL && size != 0)
goto error_return;
- sections = (asection **) bfd_malloc (symtab_hdr->sh_info
- * sizeof (asection *));
- if (sections == NULL && symtab_hdr->sh_info > 0)
+ size = symtab_hdr->sh_info;
+ size *= sizeof (asection *);
+ sections = (asection **) bfd_malloc (size);
+ if (sections == NULL && size != 0)
goto error_return;
isymp = internal_syms;
bfd *abfd;
{
struct elf32_mn10300_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct elf32_mn10300_link_hash_table);
- ret = ((struct elf32_mn10300_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf32_mn10300_link_hash_table)));
+ ret = (struct elf32_mn10300_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct elf32_mn10300_link_hash_table *) NULL)
return NULL;
}
ret->flags = 0;
+ amt = sizeof (struct elf_link_hash_table);
ret->static_hash_table
- = ((struct elf32_mn10300_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf_link_hash_table)));
+ = (struct elf32_mn10300_link_hash_table *) bfd_alloc (abfd, amt);
if (ret->static_hash_table == NULL)
{
bfd_release (abfd, ret);
return &ret->root.root;
}
-static int
+static unsigned long
elf_mn10300_mach (flags)
flagword flags;
{
static boolean prep_headers PARAMS ((bfd *));
static boolean swap_out_syms PARAMS ((bfd *, struct bfd_strtab_hash **, int));
static boolean copy_private_bfd_data PARAMS ((bfd *, bfd *));
-static char *elf_read PARAMS ((bfd *, long, unsigned int));
+static char *elf_read PARAMS ((bfd *, file_ptr, bfd_size_type));
static void elf_fake_sections PARAMS ((bfd *, asection *, PTR));
static boolean assign_section_numbers PARAMS ((bfd *));
static INLINE int sym_is_global PARAMS ((bfd *, asymbol *));
static boolean elf_map_symbols PARAMS ((bfd *));
static bfd_size_type get_program_header_size PARAMS ((bfd *));
-static boolean elfcore_read_notes PARAMS ((bfd *, bfd_vma, bfd_vma));
+static boolean elfcore_read_notes PARAMS ((bfd *, file_ptr, bfd_size_type));
static boolean elf_find_function PARAMS ((bfd *, asection *, asymbol **,
bfd_vma, const char **,
const char **));
const Elf_External_Verdef *src;
Elf_Internal_Verdef *dst;
{
- dst->vd_version = bfd_h_get_16 (abfd, src->vd_version);
- dst->vd_flags = bfd_h_get_16 (abfd, src->vd_flags);
- dst->vd_ndx = bfd_h_get_16 (abfd, src->vd_ndx);
- dst->vd_cnt = bfd_h_get_16 (abfd, src->vd_cnt);
- dst->vd_hash = bfd_h_get_32 (abfd, src->vd_hash);
- dst->vd_aux = bfd_h_get_32 (abfd, src->vd_aux);
- dst->vd_next = bfd_h_get_32 (abfd, src->vd_next);
+ dst->vd_version = H_GET_16 (abfd, src->vd_version);
+ dst->vd_flags = H_GET_16 (abfd, src->vd_flags);
+ dst->vd_ndx = H_GET_16 (abfd, src->vd_ndx);
+ dst->vd_cnt = H_GET_16 (abfd, src->vd_cnt);
+ dst->vd_hash = H_GET_32 (abfd, src->vd_hash);
+ dst->vd_aux = H_GET_32 (abfd, src->vd_aux);
+ dst->vd_next = H_GET_32 (abfd, src->vd_next);
}
/* Swap out a Verdef structure. */
const Elf_Internal_Verdef *src;
Elf_External_Verdef *dst;
{
- bfd_h_put_16 (abfd, src->vd_version, dst->vd_version);
- bfd_h_put_16 (abfd, src->vd_flags, dst->vd_flags);
- bfd_h_put_16 (abfd, src->vd_ndx, dst->vd_ndx);
- bfd_h_put_16 (abfd, src->vd_cnt, dst->vd_cnt);
- bfd_h_put_32 (abfd, src->vd_hash, dst->vd_hash);
- bfd_h_put_32 (abfd, src->vd_aux, dst->vd_aux);
- bfd_h_put_32 (abfd, src->vd_next, dst->vd_next);
+ H_PUT_16 (abfd, src->vd_version, dst->vd_version);
+ H_PUT_16 (abfd, src->vd_flags, dst->vd_flags);
+ H_PUT_16 (abfd, src->vd_ndx, dst->vd_ndx);
+ H_PUT_16 (abfd, src->vd_cnt, dst->vd_cnt);
+ H_PUT_32 (abfd, src->vd_hash, dst->vd_hash);
+ H_PUT_32 (abfd, src->vd_aux, dst->vd_aux);
+ H_PUT_32 (abfd, src->vd_next, dst->vd_next);
}
/* Swap in a Verdaux structure. */
const Elf_External_Verdaux *src;
Elf_Internal_Verdaux *dst;
{
- dst->vda_name = bfd_h_get_32 (abfd, src->vda_name);
- dst->vda_next = bfd_h_get_32 (abfd, src->vda_next);
+ dst->vda_name = H_GET_32 (abfd, src->vda_name);
+ dst->vda_next = H_GET_32 (abfd, src->vda_next);
}
/* Swap out a Verdaux structure. */
const Elf_Internal_Verdaux *src;
Elf_External_Verdaux *dst;
{
- bfd_h_put_32 (abfd, src->vda_name, dst->vda_name);
- bfd_h_put_32 (abfd, src->vda_next, dst->vda_next);
+ H_PUT_32 (abfd, src->vda_name, dst->vda_name);
+ H_PUT_32 (abfd, src->vda_next, dst->vda_next);
}
/* Swap in a Verneed structure. */
const Elf_External_Verneed *src;
Elf_Internal_Verneed *dst;
{
- dst->vn_version = bfd_h_get_16 (abfd, src->vn_version);
- dst->vn_cnt = bfd_h_get_16 (abfd, src->vn_cnt);
- dst->vn_file = bfd_h_get_32 (abfd, src->vn_file);
- dst->vn_aux = bfd_h_get_32 (abfd, src->vn_aux);
- dst->vn_next = bfd_h_get_32 (abfd, src->vn_next);
+ dst->vn_version = H_GET_16 (abfd, src->vn_version);
+ dst->vn_cnt = H_GET_16 (abfd, src->vn_cnt);
+ dst->vn_file = H_GET_32 (abfd, src->vn_file);
+ dst->vn_aux = H_GET_32 (abfd, src->vn_aux);
+ dst->vn_next = H_GET_32 (abfd, src->vn_next);
}
/* Swap out a Verneed structure. */
const Elf_Internal_Verneed *src;
Elf_External_Verneed *dst;
{
- bfd_h_put_16 (abfd, src->vn_version, dst->vn_version);
- bfd_h_put_16 (abfd, src->vn_cnt, dst->vn_cnt);
- bfd_h_put_32 (abfd, src->vn_file, dst->vn_file);
- bfd_h_put_32 (abfd, src->vn_aux, dst->vn_aux);
- bfd_h_put_32 (abfd, src->vn_next, dst->vn_next);
+ H_PUT_16 (abfd, src->vn_version, dst->vn_version);
+ H_PUT_16 (abfd, src->vn_cnt, dst->vn_cnt);
+ H_PUT_32 (abfd, src->vn_file, dst->vn_file);
+ H_PUT_32 (abfd, src->vn_aux, dst->vn_aux);
+ H_PUT_32 (abfd, src->vn_next, dst->vn_next);
}
/* Swap in a Vernaux structure. */
const Elf_External_Vernaux *src;
Elf_Internal_Vernaux *dst;
{
- dst->vna_hash = bfd_h_get_32 (abfd, src->vna_hash);
- dst->vna_flags = bfd_h_get_16 (abfd, src->vna_flags);
- dst->vna_other = bfd_h_get_16 (abfd, src->vna_other);
- dst->vna_name = bfd_h_get_32 (abfd, src->vna_name);
- dst->vna_next = bfd_h_get_32 (abfd, src->vna_next);
+ dst->vna_hash = H_GET_32 (abfd, src->vna_hash);
+ dst->vna_flags = H_GET_16 (abfd, src->vna_flags);
+ dst->vna_other = H_GET_16 (abfd, src->vna_other);
+ dst->vna_name = H_GET_32 (abfd, src->vna_name);
+ dst->vna_next = H_GET_32 (abfd, src->vna_next);
}
/* Swap out a Vernaux structure. */
const Elf_Internal_Vernaux *src;
Elf_External_Vernaux *dst;
{
- bfd_h_put_32 (abfd, src->vna_hash, dst->vna_hash);
- bfd_h_put_16 (abfd, src->vna_flags, dst->vna_flags);
- bfd_h_put_16 (abfd, src->vna_other, dst->vna_other);
- bfd_h_put_32 (abfd, src->vna_name, dst->vna_name);
- bfd_h_put_32 (abfd, src->vna_next, dst->vna_next);
+ H_PUT_32 (abfd, src->vna_hash, dst->vna_hash);
+ H_PUT_16 (abfd, src->vna_flags, dst->vna_flags);
+ H_PUT_16 (abfd, src->vna_other, dst->vna_other);
+ H_PUT_32 (abfd, src->vna_name, dst->vna_name);
+ H_PUT_32 (abfd, src->vna_next, dst->vna_next);
}
/* Swap in a Versym structure. */
const Elf_External_Versym *src;
Elf_Internal_Versym *dst;
{
- dst->vs_vers = bfd_h_get_16 (abfd, src->vs_vers);
+ dst->vs_vers = H_GET_16 (abfd, src->vs_vers);
}
/* Swap out a Versym structure. */
const Elf_Internal_Versym *src;
Elf_External_Versym *dst;
{
- bfd_h_put_16 (abfd, src->vs_vers, dst->vs_vers);
+ H_PUT_16 (abfd, src->vs_vers, dst->vs_vers);
}
/* Standard ELF hash function. Do not change this function; you will
static char *
elf_read (abfd, offset, size)
bfd *abfd;
- long offset;
- unsigned int size;
+ file_ptr offset;
+ bfd_size_type size;
{
char *buf;
if ((buf = bfd_alloc (abfd, size)) == NULL)
return NULL;
- if (bfd_seek (abfd, offset, SEEK_SET) == -1)
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0)
return NULL;
- if (bfd_read ((PTR) buf, size, 1, abfd) != size)
+ if (bfd_bread ((PTR) buf, size, abfd) != size)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_file_truncated);
{
/* This just does initialization. */
/* coff_mkobject zalloc's space for tdata.coff_obj_data ... */
- elf_tdata (abfd) = (struct elf_obj_tdata *)
- bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
+ bfd_size_type amt = sizeof (struct elf_obj_tdata);
+ elf_tdata (abfd) = (struct elf_obj_tdata *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd) == 0)
return false;
/* Since everything is done at close time, do we need any
{
Elf_Internal_Shdr **i_shdrp;
char *shstrtab = NULL;
- unsigned int offset;
- unsigned int shstrtabsize;
+ file_ptr offset;
+ bfd_size_type shstrtabsize;
i_shdrp = elf_elfsections (abfd);
if (i_shdrp == 0 || i_shdrp[shindex] == 0)
if (! bfd_set_section_vma (abfd, newsect, hdr->sh_addr)
|| ! bfd_set_section_size (abfd, newsect, hdr->sh_size)
|| ! bfd_set_section_alignment (abfd, newsect,
- bfd_log2 (hdr->sh_addralign)))
+ bfd_log2 ((bfd_vma) hdr->sh_addralign)))
return false;
flags = SEC_NO_FLAGS;
c = elf_elfheader (abfd)->e_phnum;
for (i = 0; i < c; i++, p++)
{
- const char *s;
+ const char *pt;
char buf[20];
switch (p->p_type)
{
- case PT_NULL: s = "NULL"; break;
- case PT_LOAD: s = "LOAD"; break;
- case PT_DYNAMIC: s = "DYNAMIC"; break;
- case PT_INTERP: s = "INTERP"; break;
- case PT_NOTE: s = "NOTE"; break;
- case PT_SHLIB: s = "SHLIB"; break;
- case PT_PHDR: s = "PHDR"; break;
- default: sprintf (buf, "0x%lx", p->p_type); s = buf; break;
+ case PT_NULL: pt = "NULL"; break;
+ case PT_LOAD: pt = "LOAD"; break;
+ case PT_DYNAMIC: pt = "DYNAMIC"; break;
+ case PT_INTERP: pt = "INTERP"; break;
+ case PT_NOTE: pt = "NOTE"; break;
+ case PT_SHLIB: pt = "SHLIB"; break;
+ case PT_PHDR: pt = "PHDR"; break;
+ default: sprintf (buf, "0x%lx", p->p_type); pt = buf; break;
}
- fprintf (f, "%8s off 0x", s);
+ fprintf (f, "%8s off 0x", pt);
bfd_fprintf_vma (abfd, f, p->p_offset);
fprintf (f, " vaddr 0x");
bfd_fprintf_vma (abfd, f, p->p_vaddr);
(p->p_flags & PF_R) != 0 ? 'r' : '-',
(p->p_flags & PF_W) != 0 ? 'w' : '-',
(p->p_flags & PF_X) != 0 ? 'x' : '-');
- if ((p->p_flags &~ (PF_R | PF_W | PF_X)) != 0)
- fprintf (f, " %lx", p->p_flags &~ (PF_R | PF_W | PF_X));
+ if ((p->p_flags &~ (unsigned) (PF_R | PF_W | PF_X)) != 0)
+ fprintf (f, " %lx", p->p_flags &~ (unsigned) (PF_R | PF_W | PF_X));
fprintf (f, "\n");
}
}
if (s != NULL)
{
int elfsec;
- unsigned long link;
+ unsigned long shlink;
bfd_byte *extdyn, *extdynend;
size_t extdynsize;
void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
if (elfsec == -1)
goto error_return;
- link = elf_elfsections (abfd)[elfsec]->sh_link;
+ shlink = elf_elfsections (abfd)[elfsec]->sh_link;
extdynsize = get_elf_backend_data (abfd)->s->sizeof_dyn;
swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in;
else
{
const char *string;
+ unsigned int tagv = dyn.d_un.d_val;
- string = bfd_elf_string_from_elf_section (abfd, link,
- dyn.d_un.d_val);
+ string = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
if (string == NULL)
goto error_return;
fprintf (f, "%s", string);
bfd *abfd;
{
struct elf_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct elf_link_hash_table);
- ret = ((struct elf_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf_link_hash_table)));
+ ret = (struct elf_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct elf_link_hash_table *) NULL)
return NULL;
asection *s;
bfd_byte *dynbuf = NULL;
int elfsec;
- unsigned long link;
+ unsigned long shlink;
bfd_byte *extdyn, *extdynend;
size_t extdynsize;
void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
if (elfsec == -1)
goto error_return;
- link = elf_elfsections (abfd)[elfsec]->sh_link;
+ shlink = elf_elfsections (abfd)[elfsec]->sh_link;
extdynsize = get_elf_backend_data (abfd)->s->sizeof_dyn;
swap_dyn_in = get_elf_backend_data (abfd)->s->swap_dyn_in;
{
const char *string;
struct bfd_link_needed_list *l;
+ unsigned int tagv = dyn.d_un.d_val;
+ bfd_size_type amt;
- string = bfd_elf_string_from_elf_section (abfd, link,
- dyn.d_un.d_val);
+ string = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
if (string == NULL)
goto error_return;
- l = (struct bfd_link_needed_list *) bfd_alloc (abfd, sizeof *l);
+ amt = sizeof *l;
+ l = (struct bfd_link_needed_list *) bfd_alloc (abfd, amt);
if (l == NULL)
goto error_return;
hdr2 = &elf_section_data (target_sect)->rel_hdr;
else
{
+ bfd_size_type amt;
BFD_ASSERT (elf_section_data (target_sect)->rel_hdr2 == NULL);
- hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, sizeof (*hdr2));
+ amt = sizeof (*hdr2);
+ hdr2 = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt);
elf_section_data (target_sect)->rel_hdr2 = hdr2;
}
*hdr2 = *hdr;
asection *sec;
{
struct bfd_elf_section_data *sdata;
+ bfd_size_type amt = sizeof (*sdata);
- sdata = (struct bfd_elf_section_data *) bfd_zalloc (abfd, sizeof (*sdata));
+ sdata = (struct bfd_elf_section_data *) bfd_zalloc (abfd, amt);
if (!sdata)
return false;
sec->used_by_bfd = (PTR) sdata;
&& (hdr->p_filesz > 0)
&& (hdr->p_memsz > hdr->p_filesz));
sprintf (namebuf, "%s%d%s", typename, index, split ? "a" : "");
- name = bfd_alloc (abfd, strlen (namebuf) + 1);
+ name = bfd_alloc (abfd, (bfd_size_type) strlen (namebuf) + 1);
if (!name)
return false;
strcpy (name, namebuf);
if (split)
{
sprintf (namebuf, "%s%db", typename, index);
- name = bfd_alloc (abfd, strlen (namebuf) + 1);
+ name = bfd_alloc (abfd, (bfd_size_type) strlen (namebuf) + 1);
if (!name)
return false;
strcpy (name, namebuf);
case PT_NOTE:
if (! _bfd_elf_make_section_from_phdr (abfd, hdr, index, "note"))
return false;
- if (! elfcore_read_notes (abfd, hdr->p_offset, hdr->p_filesz))
+ if (! elfcore_read_notes (abfd, (file_ptr) hdr->p_offset, hdr->p_filesz))
return false;
return true;
boolean use_rela_p;
{
char *name;
- struct elf_backend_data *bed;
+ struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ bfd_size_type amt = sizeof ".rela" + strlen (asect->name);
- bed = get_elf_backend_data (abfd);
- name = bfd_alloc (abfd, sizeof ".rela" + strlen (asect->name));
+ name = bfd_alloc (abfd, amt);
if (name == NULL)
return false;
sprintf (name, "%s%s", use_rela_p ? ".rela" : ".rel", asect->name);
asection *sec;
unsigned int section_number;
Elf_Internal_Shdr **i_shdrp;
+ bfd_size_type amt;
section_number = 1;
/* Set up the list of section header pointers, in agreement with the
indices. */
- i_shdrp = ((Elf_Internal_Shdr **)
- bfd_alloc (abfd, section_number * sizeof (Elf_Internal_Shdr *)));
+ amt = section_number * sizeof (Elf_Internal_Shdr *);
+ i_shdrp = (Elf_Internal_Shdr **) bfd_alloc (abfd, amt);
if (i_shdrp == NULL)
return false;
- i_shdrp[0] = ((Elf_Internal_Shdr *)
- bfd_alloc (abfd, sizeof (Elf_Internal_Shdr)));
+ amt = sizeof (Elf_Internal_Shdr);
+ i_shdrp[0] = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt);
if (i_shdrp[0] == NULL)
{
bfd_release (abfd, i_shdrp);
char *alc;
len = strlen (sec->name);
- alc = (char *) bfd_malloc (len - 2);
+ alc = (char *) bfd_malloc ((bfd_size_type) len - 2);
if (alc == NULL)
return false;
strncpy (alc, sec->name, len - 3);
elf_map_symbols (abfd)
bfd *abfd;
{
- int symcount = bfd_get_symcount (abfd);
+ unsigned int symcount = bfd_get_symcount (abfd);
asymbol **syms = bfd_get_outsymbols (abfd);
asymbol **sect_syms;
- int num_locals = 0;
- int num_globals = 0;
- int num_locals2 = 0;
- int num_globals2 = 0;
+ unsigned int num_locals = 0;
+ unsigned int num_globals = 0;
+ unsigned int num_locals2 = 0;
+ unsigned int num_globals2 = 0;
int max_index = 0;
- int num_sections = 0;
- int idx;
+ unsigned int num_sections = 0;
+ unsigned int idx;
asection *asect;
asymbol **new_syms;
- asymbol *sym;
+ bfd_size_type amt;
#ifdef DEBUG
fprintf (stderr, "elf_map_symbols\n");
}
max_index++;
- sect_syms = (asymbol **) bfd_zalloc (abfd, max_index * sizeof (asymbol *));
+ amt = max_index * sizeof (asymbol *);
+ sect_syms = (asymbol **) bfd_zalloc (abfd, amt);
if (sect_syms == NULL)
return false;
elf_section_syms (abfd) = sect_syms;
for (idx = 0; idx < symcount; idx++)
{
- sym = syms[idx];
+ asymbol *sym = syms[idx];
if ((sym->flags & BSF_SECTION_SYM) != 0
&& sym->value == 0)
for (asect = abfd->sections; asect; asect = asect->next)
{
+ asymbol *sym;
+
if (sect_syms[asect->index] != NULL)
continue;
}
/* Now sort the symbols so the local symbols are first. */
- new_syms = ((asymbol **)
- bfd_alloc (abfd,
- (num_locals + num_globals) * sizeof (asymbol *)));
+ amt = (num_locals + num_globals) * sizeof (asymbol *);
+ new_syms = (asymbol **) bfd_alloc (abfd, amt);
+
if (new_syms == NULL)
return false;
for (idx = 0; idx < symcount; idx++)
{
asymbol *sym = syms[idx];
- int i;
+ unsigned int i;
if (!sym_is_global (abfd, sym))
i = num_locals2++;
&& sect_syms[asect->index]->flags == 0)
{
asymbol *sym = sect_syms[asect->index];
- int i;
+ unsigned int i;
sym->flags = BSF_SECTION_SYM;
if (!sym_is_global (abfd, sym))
struct elf_segment_map *m;
unsigned int i;
asection **hdrpp;
+ bfd_size_type amt;
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd,
- (sizeof (struct elf_segment_map)
- + (to - from - 1) * sizeof (asection *))));
+ amt = sizeof (struct elf_segment_map);
+ amt += (to - from - 1) * sizeof (asection *);
+ m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
if (m == NULL)
return NULL;
m->next = NULL;
boolean phdr_in_segment = true;
boolean writable;
asection *dynsec;
+ bfd_size_type amt;
if (elf_tdata (abfd)->segment_map != NULL)
return true;
/* Select the allocated sections, and sort them. */
- sections = (asection **) bfd_malloc (bfd_count_sections (abfd)
- * sizeof (asection *));
+ amt = bfd_count_sections (abfd) * sizeof (asection *);
+ sections = (asection **) bfd_malloc (amt);
if (sections == NULL)
goto error_return;
s = bfd_get_section_by_name (abfd, ".interp");
if (s != NULL && (s->flags & SEC_LOAD) != 0)
{
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
+ amt = sizeof (struct elf_segment_map);
+ m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
if (m == NULL)
goto error_return;
m->next = NULL;
*pm = m;
pm = &m->next;
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
+ amt = sizeof (struct elf_segment_map);
+ m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
if (m == NULL)
goto error_return;
m->next = NULL;
/* If there is a .dynamic section, throw in a PT_DYNAMIC segment. */
if (dynsec != NULL)
{
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
+ amt = sizeof (struct elf_segment_map);
+ m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
if (m == NULL)
goto error_return;
m->next = NULL;
if ((s->flags & SEC_LOAD) != 0
&& strncmp (s->name, ".note", 5) == 0)
{
- m = ((struct elf_segment_map *)
- bfd_zalloc (abfd, sizeof (struct elf_segment_map)));
+ amt = sizeof (struct elf_segment_map);
+ m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
if (m == NULL)
goto error_return;
m->next = NULL;
bfd_vma filehdr_vaddr, filehdr_paddr;
bfd_vma phdrs_vaddr, phdrs_paddr;
Elf_Internal_Phdr *p;
+ bfd_size_type amt;
if (elf_tdata (abfd)->segment_map == NULL)
{
if (alloc == 0)
alloc = count;
- phdrs = ((Elf_Internal_Phdr *)
- bfd_alloc (abfd, alloc * sizeof (Elf_Internal_Phdr)));
+ amt = alloc * sizeof (Elf_Internal_Phdr);
+ phdrs = (Elf_Internal_Phdr *) bfd_alloc (abfd, amt);
if (phdrs == NULL)
return false;
elf_tdata (abfd)->next_file_pos = off;
/* Write out the program headers. */
- if (bfd_seek (abfd, bed->s->sizeof_ehdr, SEEK_SET) != 0
+ if (bfd_seek (abfd, (bfd_signed_vma) bed->s->sizeof_ehdr, SEEK_SET) != 0
|| bed->s->write_out_phdrs (abfd, phdrs, alloc) != 0)
return false;
(*bed->elf_backend_section_processing) (abfd, i_shdrp[count]);
if (i_shdrp[count]->contents)
{
+ bfd_size_type amt = i_shdrp[count]->sh_size;
+
if (bfd_seek (abfd, i_shdrp[count]->sh_offset, SEEK_SET) != 0
- || (bfd_write (i_shdrp[count]->contents, i_shdrp[count]->sh_size,
- 1, abfd)
- != i_shdrp[count]->sh_size))
+ || bfd_bwrite (i_shdrp[count]->contents, amt, abfd) != amt)
return false;
}
}
bfd_vma matching_lma;
bfd_vma suggested_lma;
unsigned int j;
+ bfd_size_type amt;
if (segment->p_type == PT_NULL)
continue;
/* Allocate a segment map big enough to contain all of the
sections we have selected. */
- map = ((struct elf_segment_map *)
- bfd_alloc (obfd,
- (sizeof (struct elf_segment_map)
- + ((size_t) section_count - 1) * sizeof (asection *))));
+ amt = sizeof (struct elf_segment_map);
+ amt += ((bfd_size_type) section_count - 1) * sizeof (asection *);
+ map = (struct elf_segment_map *) bfd_alloc (obfd, amt);
if (map == NULL)
return false;
pointers that we are interested in. As these sections get assigned
to a segment, they are removed from this array. */
- sections = (asection **) bfd_malloc
- (sizeof (asection *) * section_count);
+ amt = (bfd_size_type) section_count * sizeof (asection *);
+ sections = (asection **) bfd_malloc (amt);
if (sections == NULL)
return false;
/* We still have not allocated all of the sections to
segments. Create a new segment here, initialise it
and carry on looping. */
- map = ((struct elf_segment_map *)
- bfd_alloc (obfd,
- (sizeof (struct elf_segment_map)
- + ((size_t) section_count - 1)
- * sizeof (asection *))));
+ amt = sizeof (struct elf_segment_map);
+ amt += ((bfd_size_type) section_count - 1) * sizeof (asection *);
+ map = (struct elf_segment_map *) bfd_alloc (obfd, amt);
if (map == NULL)
return false;
Elf_Internal_Shdr *symstrtab_hdr;
char *outbound_syms;
int idx;
+ bfd_size_type amt;
stt = _bfd_elf_stringtab_init ();
if (stt == NULL)
symstrtab_hdr = &elf_tdata (abfd)->strtab_hdr;
symstrtab_hdr->sh_type = SHT_STRTAB;
- outbound_syms = bfd_alloc (abfd,
- (1 + symcount) * bed->s->sizeof_sym);
+ amt = (bfd_size_type) (1 + symcount) * bed->s->sizeof_sym;
+ outbound_syms = bfd_alloc (abfd, amt);
if (outbound_syms == NULL)
return false;
symtab_hdr->contents = (PTR) outbound_syms;
bfd *abfd;
{
bfd_byte *contents = NULL;
+ bfd_size_type amt;
if (elf_dynverdef (abfd) != 0)
{
if (contents == NULL)
goto error_return;
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
- || bfd_read ((PTR) contents, 1, hdr->sh_size, abfd) != hdr->sh_size)
+ || bfd_bread ((PTR) contents, hdr->sh_size, abfd) != hdr->sh_size)
goto error_return;
/* We know the number of entries in the section but not the maximum
((bfd_byte *) everdef + iverdefmem.vd_next));
}
- elf_tdata (abfd)->verdef =
- ((Elf_Internal_Verdef *)
- bfd_zalloc (abfd, maxidx * sizeof (Elf_Internal_Verdef)));
+ amt = (bfd_size_type) maxidx * sizeof (Elf_Internal_Verdef);
+ elf_tdata (abfd)->verdef = (Elf_Internal_Verdef *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verdef == NULL)
goto error_return;
iverdef->vd_bfd = abfd;
- iverdef->vd_auxptr = ((Elf_Internal_Verdaux *)
- bfd_alloc (abfd,
- (iverdef->vd_cnt
- * sizeof (Elf_Internal_Verdaux))));
+ amt = (bfd_size_type) iverdef->vd_cnt * sizeof (Elf_Internal_Verdaux);
+ iverdef->vd_auxptr = (Elf_Internal_Verdaux *) bfd_alloc (abfd, amt);
if (iverdef->vd_auxptr == NULL)
goto error_return;
hdr = &elf_tdata (abfd)->dynverref_hdr;
+ amt = (bfd_size_type) hdr->sh_info * sizeof (Elf_Internal_Verneed);
elf_tdata (abfd)->verref =
- ((Elf_Internal_Verneed *)
- bfd_zalloc (abfd, hdr->sh_info * sizeof (Elf_Internal_Verneed)));
+ (Elf_Internal_Verneed *) bfd_zalloc (abfd, amt);
if (elf_tdata (abfd)->verref == NULL)
goto error_return;
if (contents == NULL)
goto error_return;
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
- || bfd_read ((PTR) contents, 1, hdr->sh_size, abfd) != hdr->sh_size)
+ || bfd_bread ((PTR) contents, hdr->sh_size, abfd) != hdr->sh_size)
goto error_return;
everneed = (Elf_External_Verneed *) contents;
if (iverneed->vn_filename == NULL)
goto error_return;
- iverneed->vn_auxptr =
- ((Elf_Internal_Vernaux *)
- bfd_alloc (abfd,
- iverneed->vn_cnt * sizeof (Elf_Internal_Vernaux)));
+ amt = iverneed->vn_cnt;
+ amt *= sizeof (Elf_Internal_Vernaux);
+ iverneed->vn_auxptr = (Elf_Internal_Vernaux *) bfd_alloc (abfd, amt);
evernaux = ((Elf_External_Vernaux *)
((bfd_byte *) everneed + iverneed->vn_aux));
bfd *abfd;
{
elf_symbol_type *newsym;
+ bfd_size_type amt = sizeof (elf_symbol_type);
- newsym = (elf_symbol_type *) bfd_zalloc (abfd, sizeof (elf_symbol_type));
+ newsym = (elf_symbol_type *) bfd_zalloc (abfd, amt);
if (!newsym)
return NULL;
else
bfd_size_type count;
{
Elf_Internal_Shdr *hdr;
+ bfd_signed_vma pos;
if (! abfd->output_has_begun
&& ! _bfd_elf_compute_section_file_positions
return false;
hdr = &elf_section_data (section)->this_hdr;
-
- if (bfd_seek (abfd, hdr->sh_offset + offset, SEEK_SET) == -1)
- return false;
- if (bfd_write (location, 1, count, abfd) != count)
+ pos = hdr->sh_offset + offset;
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (location, count, abfd) != count)
return false;
return true;
_bfd_elfcore_make_pseudosection (abfd, name, size, filepos)
bfd *abfd;
char *name;
- int size;
- int filepos;
+ size_t size;
+ ufile_ptr filepos;
{
char buf[100];
char *threaded_name;
/* Build the section name. */
sprintf (buf, "%s/%d", name, elfcore_make_pid (abfd));
- threaded_name = bfd_alloc (abfd, strlen (buf) + 1);
+ threaded_name = bfd_alloc (abfd, (bfd_size_type) strlen (buf) + 1);
if (threaded_name == NULL)
return false;
strcpy (threaded_name, buf);
bfd *abfd;
Elf_Internal_Note *note;
{
- int raw_size;
+ size_t raw_size;
int offset;
if (note->descsz == sizeof (prstatus_t))
_bfd_elfcore_strndup (abfd, start, max)
bfd *abfd;
char *start;
- int max;
+ size_t max;
{
- char *dup;
+ char *dups;
char *end = memchr (start, '\0', max);
- int len;
+ size_t len;
if (end == NULL)
len = max;
else
len = end - start;
- dup = bfd_alloc (abfd, len + 1);
- if (dup == NULL)
+ dups = bfd_alloc (abfd, (bfd_size_type) len + 1);
+ if (dups == NULL)
return NULL;
- memcpy (dup, start, len);
- dup[len] = '\0';
+ memcpy (dups, start, len);
+ dups[len] = '\0';
- return dup;
+ return dups;
}
#if defined (HAVE_PRPSINFO_T) || defined (HAVE_PSINFO_T)
/* Make a ".reg/999" section. */
sprintf (buf, ".reg/%d", elfcore_make_pid (abfd));
- name = bfd_alloc (abfd, strlen (buf) + 1);
+ name = bfd_alloc (abfd, (bfd_size_type) strlen (buf) + 1);
if (name == NULL)
return false;
strcpy (name, buf);
/* Make a ".reg2/999" section */
sprintf (buf, ".reg2/%d", elfcore_make_pid (abfd));
- name = bfd_alloc (abfd, strlen (buf) + 1);
+ name = bfd_alloc (abfd, (bfd_size_type) strlen (buf) + 1);
if (name == NULL)
return false;
strcpy (name, buf);
/* Make a ".reg/999" section. */
sprintf (buf, ".reg/%d", pstatus.data.thread_info.tid);
- name = bfd_alloc (abfd, strlen (buf) + 1);
+ name = bfd_alloc (abfd, (bfd_size_type) strlen (buf) + 1);
if (name == NULL)
return false;
/* Make a ".module/xxxxxxxx" section. */
sprintf (buf, ".module/%08x", pstatus.data.module_info.base_address);
- name = bfd_alloc (abfd, strlen (buf) + 1);
+ name = bfd_alloc (abfd, (bfd_size_type) strlen (buf) + 1);
if (name == NULL)
return false;
static boolean
elfcore_read_notes (abfd, offset, size)
bfd *abfd;
- bfd_vma offset;
- bfd_vma size;
+ file_ptr offset;
+ bfd_size_type size;
{
char *buf;
char *p;
if (size <= 0)
return true;
- if (bfd_seek (abfd, offset, SEEK_SET) == -1)
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0)
return false;
- buf = bfd_malloc ((size_t) size);
+ buf = bfd_malloc (size);
if (buf == NULL)
return false;
- if (bfd_read (buf, size, 1, abfd) != size)
+ if (bfd_bread (buf, size, abfd) != size)
{
error:
free (buf);
Elf_External_Note *xnp = (Elf_External_Note *) p;
Elf_Internal_Note in;
- in.type = bfd_h_get_32 (abfd, (bfd_byte *) xnp->type);
+ in.type = H_GET_32 (abfd, xnp->type);
- in.namesz = bfd_h_get_32 (abfd, (bfd_byte *) xnp->namesz);
+ in.namesz = H_GET_32 (abfd, xnp->namesz);
in.namedata = xnp->name;
- in.descsz = bfd_h_get_32 (abfd, (bfd_byte *) xnp->descsz);
+ in.descsz = H_GET_32 (abfd, xnp->descsz);
in.descdata = in.namedata + BFD_ALIGN (in.namesz, 4);
in.descpos = offset + (in.descdata - buf);
arc_elf_object_p (abfd)
bfd *abfd;
{
- int mach = bfd_mach_arc_6;
+ unsigned int mach = bfd_mach_arc_6;
if (elf_elfheader(abfd)->e_machine == EM_ARC)
{
static bfd_reloc_status_type elf32_arm_final_link_relocate
PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *, bfd_byte *,
Elf_Internal_Rela *, bfd_vma, struct bfd_link_info *, asection *,
- const char *, unsigned char, struct elf_link_hash_entry *));
+ const char *, int, struct elf_link_hash_entry *));
static insn32 insert_thumb_branch
PARAMS ((insn32, int));
static struct elf_link_hash_entry *find_thumb_glue
this. It is set up so that any shared library function that is
called before the relocation has been set up calls the dynamic
linker first. */
-static const unsigned long elf32_arm_plt0_entry [PLT_ENTRY_SIZE / 4] =
+static const bfd_vma elf32_arm_plt0_entry [PLT_ENTRY_SIZE / 4] =
{
0xe52de004, /* str lr, [sp, #-4]! */
0xe59fe010, /* ldr lr, [pc, #16] */
/* Subsequent entries in a procedure linkage table look like
this. */
-static const unsigned long elf32_arm_plt_entry [PLT_ENTRY_SIZE / 4] =
+static const bfd_vma elf32_arm_plt_entry [PLT_ENTRY_SIZE / 4] =
{
0xe59fc004, /* ldr ip, [pc, #4] */
0xe08fc00c, /* add ip, pc, ip */
struct elf_link_hash_table root;
/* The size in bytes of the section containg the Thumb-to-ARM glue. */
- long int thumb_glue_size;
+ bfd_size_type thumb_glue_size;
/* The size in bytes of the section containg the ARM-to-Thumb glue. */
- long int arm_glue_size;
+ bfd_size_type arm_glue_size;
/* An arbitary input BFD chosen to hold the glue sections. */
bfd * bfd_of_glue_owner;
bfd *abfd;
{
struct elf32_arm_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct elf32_arm_link_hash_table);
- ret = ((struct elf32_arm_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf32_arm_link_hash_table)));
+ ret = (struct elf32_arm_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct elf32_arm_link_hash_table *) NULL)
return NULL;
/* We need a pointer to the armelf specific hash table. */
hash_table = elf32_arm_hash_table (link_info);
- tmp_name = ((char *)
- bfd_malloc (strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1));
+ tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
+ + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
BFD_ASSERT (tmp_name);
/* We need a pointer to the elfarm specific hash table. */
hash_table = elf32_arm_hash_table (link_info);
- tmp_name = ((char *)
- bfd_malloc (strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1));
+ tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
+ + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
BFD_ASSERT (tmp_name);
{
BFD_ASSERT (globals->bfd_of_glue_owner != NULL);
- s = bfd_get_section_by_name
- (globals->bfd_of_glue_owner, ARM2THUMB_GLUE_SECTION_NAME);
+ s = bfd_get_section_by_name (globals->bfd_of_glue_owner,
+ ARM2THUMB_GLUE_SECTION_NAME);
BFD_ASSERT (s != NULL);
- foo = (bfd_byte *) bfd_alloc
- (globals->bfd_of_glue_owner, globals->arm_glue_size);
+ foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner,
+ globals->arm_glue_size);
s->_raw_size = s->_cooked_size = globals->arm_glue_size;
s->contents = foo;
BFD_ASSERT (s != NULL);
- foo = (bfd_byte *) bfd_alloc
- (globals->bfd_of_glue_owner, globals->thumb_glue_size);
+ foo = (bfd_byte *) bfd_alloc (globals->bfd_of_glue_owner,
+ globals->thumb_glue_size);
s->_raw_size = s->_cooked_size = globals->thumb_glue_size;
s->contents = foo;
char * tmp_name;
struct elf_link_hash_entry * myh;
struct elf32_arm_link_hash_table * globals;
+ bfd_vma val;
globals = elf32_arm_hash_table (link_info);
BFD_ASSERT (s != NULL);
- tmp_name = ((char *)
- bfd_malloc (strlen (name) + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1));
+ tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
+ + strlen (ARM2THUMB_GLUE_ENTRY_NAME) + 1);
BFD_ASSERT (tmp_name);
/* The only trick here is using hash_table->arm_glue_size as the value. Even
though the section isn't allocated yet, this is where we will be putting
it. */
- _bfd_generic_link_add_one_symbol (link_info, globals->bfd_of_glue_owner, tmp_name,
- BSF_GLOBAL,
- s, globals->arm_glue_size + 1,
+ val = globals->arm_glue_size + 1;
+ _bfd_generic_link_add_one_symbol (link_info, globals->bfd_of_glue_owner,
+ tmp_name, BSF_GLOBAL, s, val,
NULL, true, false,
(struct bfd_link_hash_entry **) &myh);
struct elf_link_hash_entry *myh;
struct elf32_arm_link_hash_table *hash_table;
char bind;
+ bfd_vma val;
hash_table = elf32_arm_hash_table (link_info);
BFD_ASSERT (s != NULL);
- tmp_name = (char *) bfd_malloc (strlen (name) + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
+ tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
+ + strlen (THUMB2ARM_GLUE_ENTRY_NAME) + 1);
BFD_ASSERT (tmp_name);
return;
}
- _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner, tmp_name,
- BSF_GLOBAL, s, hash_table->thumb_glue_size + 1,
+ val = hash_table->thumb_glue_size + 1;
+ _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner,
+ tmp_name, BSF_GLOBAL, s, val,
NULL, true, false,
(struct bfd_link_hash_entry **) &myh);
#define BACK_FROM_ARM "__%s_back_from_arm"
/* Allocate another symbol to mark where we switch to Arm mode. */
- tmp_name = (char *) bfd_malloc (strlen (name) + strlen (CHANGE_TO_ARM) + 1);
+ tmp_name = (char *) bfd_malloc ((bfd_size_type) strlen (name)
+ + strlen (CHANGE_TO_ARM) + 1);
BFD_ASSERT (tmp_name);
myh = NULL;
- _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner, tmp_name,
- BSF_LOCAL, s, hash_table->thumb_glue_size + 4,
+ val = hash_table->thumb_glue_size + 4,
+ _bfd_generic_link_add_one_symbol (link_info, hash_table->bfd_of_glue_owner,
+ tmp_name, BSF_LOCAL, s, val,
NULL, true, false,
(struct bfd_link_hash_entry **) &myh);
/* Load the relocs. */
irel = (_bfd_elf32_link_read_relocs (abfd, sec, (PTR) NULL,
- (Elf_Internal_Rela *) NULL, false));
+ (Elf_Internal_Rela *) NULL, false));
BFD_ASSERT (irel != 0);
free_contents = contents;
if (!bfd_get_section_contents (abfd, sec, contents,
- (file_ptr) 0, sec->_raw_size))
+ (file_ptr) 0, sec->_raw_size))
goto error_return;
}
}
free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
+ || (bfd_bread (extsyms, symtab_hdr->sh_size, abfd)
!= symtab_hdr->sh_size))
goto error_return;
}
bfd_vma val;
{
asection * s = 0;
- long int my_offset;
+ bfd_vma my_offset;
unsigned long int tmp;
long int ret_offset;
struct elf_link_hash_entry * myh;
--my_offset;
myh->root.u.def.value = my_offset;
- bfd_put_16 (output_bfd, t2a1_bx_pc_insn,
+ bfd_put_16 (output_bfd, (bfd_vma) t2a1_bx_pc_insn,
s->contents + my_offset);
- bfd_put_16 (output_bfd, t2a2_noop_insn,
+ bfd_put_16 (output_bfd, (bfd_vma) t2a2_noop_insn,
s->contents + my_offset + 2);
ret_offset =
+ 8);
bfd_put_32 (output_bfd,
- t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),
+ (bfd_vma) t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),
s->contents + my_offset + 4);
}
/* Now go back and fix up the original BL insn to point
to here. */
- ret_offset =
- s->output_offset
- + my_offset
- - (input_section->output_offset
- + offset + addend)
- - 8;
+ ret_offset = (s->output_offset
+ + my_offset
+ - (input_section->output_offset
+ + offset + addend)
+ - 8);
tmp = bfd_get_32 (input_bfd, hit_data
- input_section->vma);
bfd_put_32 (output_bfd,
- insert_thumb_branch (tmp, ret_offset),
+ (bfd_vma) insert_thumb_branch (tmp, ret_offset),
hit_data - input_section->vma);
return true;
bfd_vma val;
{
unsigned long int tmp;
- long int my_offset;
+ bfd_vma my_offset;
asection * s;
long int ret_offset;
struct elf_link_hash_entry * myh;
--my_offset;
myh->root.u.def.value = my_offset;
- bfd_put_32 (output_bfd, a2t1_ldr_insn,
+ bfd_put_32 (output_bfd, (bfd_vma) a2t1_ldr_insn,
s->contents + my_offset);
- bfd_put_32 (output_bfd, a2t2_bx_r12_insn,
+ bfd_put_32 (output_bfd, (bfd_vma) a2t2_bx_r12_insn,
s->contents + my_offset + 4);
/* It's a thumb address. Add the low order bit. */
tmp = tmp & 0xFF000000;
/* Somehow these are both 4 too far, so subtract 8. */
- ret_offset = s->output_offset
- + my_offset
- + s->output_section->vma
- - (input_section->output_offset
- + input_section->output_section->vma
- + offset + addend)
- - 8;
+ ret_offset = (s->output_offset
+ + my_offset
+ + s->output_section->vma
+ - (input_section->output_offset
+ + input_section->output_section->vma
+ + offset + addend)
+ - 8);
tmp = tmp | ((ret_offset >> 2) & 0x00FFFFFF);
- bfd_put_32 (output_bfd, tmp, hit_data
- - input_section->vma);
+ bfd_put_32 (output_bfd, (bfd_vma) tmp, hit_data - input_section->vma);
return true;
}
struct bfd_link_info * info;
asection * sym_sec;
const char * sym_name;
- unsigned char sym_flags;
+ int sym_flags;
struct elf_link_hash_entry * h;
{
unsigned long r_type = howto->type;
upper_insn = (upper_insn & 0xf800) | ((addend >> 11) & 0x7ff);
lower_insn = (lower_insn & 0xf800) | (addend & 0x7ff);
- bfd_put_16 (abfd, upper_insn, address);
- bfd_put_16 (abfd, lower_insn, address + 2);
+ bfd_put_16 (abfd, (bfd_vma) upper_insn, address);
+ bfd_put_16 (abfd, (bfd_vma) lower_insn, address + 2);
}
else
{
case R_ARM_PC24:
addend <<= howto->size;
- addend += increment;
+ addend += increment;
/* Should we check for overflow here ? */
|| r_type == R_ARM_GNU_VTINHERIT)
continue;
- elf32_arm_info_to_howto (input_bfd, & bfd_reloc, (Elf32_Internal_Rel *) rel);
+#ifdef USE_REL
+ elf32_arm_info_to_howto (input_bfd, & bfd_reloc,
+ (Elf_Internal_Rel *) rel);
+#else
+ elf32_arm_info_to_howto (input_bfd, & bfd_reloc, rel);
+#endif
howto = bfd_reloc.howto;
if (info->relocateable)
sec = local_sections[r_symndx];
#ifdef USE_REL
arm_add_to_rel (input_bfd, contents + rel->r_offset,
- howto, sec->output_offset + sym->st_value);
+ howto,
+ (bfd_signed_vma) (sec->output_offset
+ + sym->st_value));
#else
rel->r_addend += (sec->output_offset + sym->st_value);
#endif
symbol. */
if (local_got_offsets == NULL)
{
- size_t size;
+ bfd_size_type size;
register unsigned int i;
- size = symtab_hdr->sh_info * sizeof (bfd_vma);
+ size = symtab_hdr->sh_info;
+ size *= sizeof (bfd_vma);
local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
if (local_got_offsets == NULL)
return false;
if (p == NULL)
{
p = ((struct elf32_arm_pcrel_relocs_copied *)
- bfd_alloc (dynobj, sizeof * p));
-
+ bfd_alloc (dynobj, (bfd_size_type) sizeof * p));
if (p == NULL)
return false;
p->next = eh->pcrel_relocs_copied;
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
- if (! info->shared)
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
+ if (!info->shared)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (plt)
{
- if ( ! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_REL)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ if ( !add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_REL)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if ( ! bfd_elf32_add_dynamic_entry (info, DT_REL, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELENT,
- sizeof (Elf32_External_Rel)))
+ if ( !add_dynamic_entry (DT_REL, 0)
+ || !add_dynamic_entry (DT_RELSZ, 0)
+ || !add_dynamic_entry (DT_RELENT, sizeof (Elf32_External_Rel)))
return false;
}
if ((info->flags & DF_TEXTREL) != 0)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
info->flags |= DF_TEXTREL;
}
}
+#undef add_synamic_entry
return true;
}
rel.r_offset = (sgot->output_section->vma
+ sgot->output_offset
- + (h->got.offset &~ 1));
+ + (h->got.offset &~ (bfd_vma) 1));
/* If this is a -Bsymbolic link, and the symbol is defined
locally, we just want to emit a RELATIVE reloc. The entry in
#define bfd_elf32_bfd_set_private_flags elf32_arm_set_private_flags
#define bfd_elf32_bfd_print_private_bfd_data elf32_arm_print_private_bfd_data
#define bfd_elf32_bfd_link_hash_table_create elf32_arm_link_hash_table_create
-#define bfd_elf32_bfd_reloc_type_lookup elf32_arm_reloc_type_lookup
+#define bfd_elf32_bfd_reloc_type_lookup elf32_arm_reloc_type_lookup
#define bfd_elf32_find_nearest_line elf32_arm_find_nearest_line
#define elf_backend_get_symbol_type elf32_arm_get_symbol_type
#define elf_backend_gc_mark_hook elf32_arm_gc_mark_hook
#define elf_backend_gc_sweep_hook elf32_arm_gc_sweep_hook
#define elf_backend_check_relocs elf32_arm_check_relocs
-#define elf_backend_relocate_section elf32_arm_relocate_section
+#define elf_backend_relocate_section elf32_arm_relocate_section
#define elf_backend_adjust_dynamic_symbol elf32_arm_adjust_dynamic_symbol
#define elf_backend_create_dynamic_sections _bfd_elf_create_dynamic_sections
#define elf_backend_finish_dynamic_symbol elf32_arm_finish_dynamic_symbol
/* AVR-specific support for 32-bit ELF
- Copyright 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Denis Chertykov <denisc@overta.ru>
This file is part of BFD, the Binary File Descriptor library.
x = bfd_get_16 (input_bfd, contents);
x |= ((srel & 0x10000) | ((srel << 3) & 0x1f00000)) >> 16;
bfd_put_16 (input_bfd, x, contents);
- bfd_put_16 (input_bfd, srel & 0xffff, contents+2);
+ bfd_put_16 (input_bfd, (bfd_vma) srel & 0xffff, contents+2);
break;
default:
elf32_avr_object_p (abfd)
bfd *abfd;
{
- int e_set = bfd_mach_avr2;
+ unsigned int e_set = bfd_mach_avr2;
if (elf_elfheader (abfd)->e_machine == EM_AVR
|| elf_elfheader (abfd)->e_machine == EM_AVR_OLD)
{
bfd *abfd;
{
struct elf_cris_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct elf_cris_link_hash_table);
- ret = ((struct elf_cris_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf_cris_link_hash_table)));
+ ret = ((struct elf_cris_link_hash_table *) bfd_alloc (abfd, amt));
if (ret == (struct elf_cris_link_hash_table *) NULL)
return NULL;
struct elf_link_hash_entry * h;
bfd_vma relocation;
bfd_reloc_status_type r;
- const char * name = NULL;
+ const char * symname = NULL;
int r_type;
r_type = ELF32_R_TYPE (rel->r_info);
+ sec->output_offset
+ sym->st_value);
- name = bfd_elf_string_from_elf_section
- (input_bfd, symtab_hdr->sh_link, sym->st_name);
- name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
+ symname = (bfd_elf_string_from_elf_section
+ (input_bfd, symtab_hdr->sh_link, sym->st_name));
+ if (symname == NULL)
+ symname = bfd_section_name (input_bfd, sec);
}
else
{
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
- name = h->root.root.string;
+ symname = h->root.root.string;
if (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak)
bfd_get_filename (bfd_my_archive (input_bfd)),
bfd_get_filename (input_bfd),
cris_elf_howto_table[r_type].name,
- name,
+ symname,
bfd_get_section_name (input_bfd, input_section));
else
(*_bfd_error_handler)
(_("%s: unresolvable relocation %s against symbol `%s' from %s section"),
bfd_get_filename (input_bfd),
cris_elf_howto_table[r_type].name,
- name,
+ symname,
bfd_get_section_name (input_bfd, input_section));
bfd_set_error (bfd_error_bad_value);
return false;
else
{
if (!(info->callbacks->undefined_symbol
- (info, name, input_bfd,
+ (info, symname, input_bfd,
input_section, rel->r_offset,
(!info->shared || info->no_undefined
|| ELF_ST_VISIBILITY (h->other)))))
(_("%s: No PLT nor GOT for relocation %s against symbol `%s' from %s section"),
bfd_get_filename (input_bfd),
cris_elf_howto_table[r_type].name,
- name[0] != '\0' ? name : _("[whose name is lost]"),
+ symname[0] != '\0' ? symname : _("[whose name is lost]"),
bfd_get_section_name (input_bfd, input_section));
/* FIXME: Perhaps blaming input is not the right thing to
bfd_get_filename (input_bfd),
cris_elf_howto_table[r_type].name,
rel->r_addend,
- name[0] != '\0' ? name : _("[whose name is lost]"),
+ symname[0] != '\0' ? symname : _("[whose name is lost]"),
bfd_get_section_name (input_bfd, input_section));
bfd_set_error (bfd_error_bad_value);
(_("%s: relocation %s is not allowed for global symbol: `%s' from %s section"),
bfd_get_filename (input_bfd),
cris_elf_howto_table[r_type].name,
- name,
+ symname,
bfd_get_section_name (input_bfd, input_section));
bfd_set_error (bfd_error_bad_value);
return false;
{
case bfd_reloc_overflow:
r = info->callbacks->reloc_overflow
- (info, name, howto->name, (bfd_vma) 0,
+ (info, symname, howto->name, (bfd_vma) 0,
input_bfd, input_section, rel->r_offset);
break;
case bfd_reloc_undefined:
r = info->callbacks->undefined_symbol
- (info, name, input_bfd, input_section, rel->r_offset,
+ (info, symname, input_bfd, input_section, rel->r_offset,
true);
break;
if (msg)
r = info->callbacks->warning
- (info, msg, name, input_bfd, input_section, rel->r_offset);
+ (info, msg, symname, input_bfd, input_section, rel->r_offset);
if (! r)
return false;
asection *sgot;
asection *srela;
Elf_Internal_Rela rela;
+ bfd_byte *where;
/* This symbol has an entry in the global offset table. Set it up. */
rela.r_offset = (sgot->output_section->vma
+ sgot->output_offset
- + (h->got.offset &~ 1));
+ + (h->got.offset &~ (bfd_vma) 1));
/* If this is a static link, or it is a -Bsymbolic link and the
symbol is defined locally or was forced to be local because
of a version file, we just want to emit a RELATIVE reloc.
The entry in the global offset table will already have been
initialized in the relocate_section function. */
+ where = sgot->contents + (h->got.offset &~ (bfd_vma) 1);
if (! elf_hash_table (info)->dynamic_sections_created
|| (info->shared
&& (info->symbolic || h->dynindx == -1)
&& (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
{
rela.r_info = ELF32_R_INFO (0, R_CRIS_RELATIVE);
- rela.r_addend = bfd_get_signed_32 (output_bfd,
- (sgot->contents
- + (h->got.offset & ~1)));
+ rela.r_addend = bfd_get_signed_32 (output_bfd, where);
}
else
{
- bfd_put_32 (output_bfd, (bfd_vma) 0,
- sgot->contents + (h->got.offset & ~1));
+ bfd_put_32 (output_bfd, (bfd_vma) 0, where);
rela.r_info = ELF32_R_INFO (h->dynindx, R_CRIS_GLOB_DAT);
rela.r_addend = 0;
}
if (local_got_refcounts == NULL)
{
- size_t size;
+ bfd_size_type amt;
/* We use index local_got_refcounts[-1] to count all
GOT-relative relocations that do not have explicit
GOT entries. */
- size = (symtab_hdr->sh_info + 1) * sizeof (bfd_signed_vma);
- local_got_refcounts = ((bfd_signed_vma *)
- bfd_alloc (abfd, size));
+ amt = symtab_hdr->sh_info + 1;
+ amt *= sizeof (bfd_signed_vma);
+ local_got_refcounts = ((bfd_signed_vma *) bfd_alloc (abfd, amt));
if (local_got_refcounts == NULL)
return false;
- memset (local_got_refcounts, -1, size);
+ memset (local_got_refcounts, -1, (size_t) amt);
local_got_refcounts++;
elf_local_got_refcounts (abfd) = local_got_refcounts;
if (p == NULL)
{
p = ((struct elf_cris_pcrel_relocs_copied *)
- bfd_alloc (dynobj, sizeof *p));
+ bfd_alloc (dynobj, (bfd_size_type) sizeof *p));
if (p == NULL)
return false;
p->next = eh->pcrel_relocs_copied;
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
if (!info->shared)
{
- if (!bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (plt)
{
- if (!bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || !bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || !bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || !bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (!bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
- || !bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
- || !bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf32_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
return false;
}
if ((info->flags & DF_TEXTREL) != 0)
{
- if (!bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
info->flags |= DF_TEXTREL;
}
}
+#undef add_dynamic_entry
return true;
}
static void fr30_info_to_howto_rela
PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
static boolean fr30_elf_relocate_section
- PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
static bfd_reloc_status_type fr30_final_link_relocate
- PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, bfd_vma));
+ PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
+ Elf_Internal_Rela *, bfd_vma));
static boolean fr30_elf_gc_sweep_hook
- PARAMS ((bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *));
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ const Elf_Internal_Rela *));
static asection * fr30_elf_gc_mark_hook
- PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *));
+ PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
+ struct elf_link_hash_entry *, Elf_Internal_Sym *));
+static boolean fr30_elf_check_relocs
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ const Elf_Internal_Rela *));
static reloc_howto_type fr30_elf_howto_table [] =
{
x = bfd_get_32 (abfd, (char *) data + reloc_entry->address);
x = (x & 0xff0f0000) | (relocation & 0x0000ffff) | ((relocation & 0x000f0000) << 4);
- bfd_put_32 (abfd, x, (char *) data + reloc_entry->address);
+ bfd_put_32 (abfd, (bfd_vma) x, (char *) data + reloc_entry->address);
return bfd_reloc_ok;
}
bfd_reloc->howto = &dummy;
}
-static boolean
+static boolean
elf32_generic_link_add_symbols (abfd, info)
bfd *abfd;
struct bfd_link_info *info;
/* Generic support for 32-bit ELF
- Copyright 1993, 1995, 1998, 1999 Free Software Foundation, Inc.
+ Copyright 1993, 1995, 1998, 1999, 2001 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
static void elf32_h8_info_to_howto_rel
PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
-static int elf32_h8_mach
+static unsigned long elf32_h8_mach
PARAMS ((flagword));
+static void elf32_h8_final_write_processing
+ PARAMS ((bfd *, boolean));
+static boolean elf32_h8_object_p
+ PARAMS ((bfd *));
+static boolean elf32_h8_merge_private_bfd_data
+ PARAMS ((bfd *, bfd *));
+static boolean elf32_h8_relax_section
+ PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
+static boolean elf32_h8_relax_delete_bytes
+ PARAMS ((bfd *, asection *, bfd_vma, int));
+static boolean elf32_h8_symbol_address_p
+ PARAMS ((bfd *, asection *, Elf32_External_Sym *, bfd_vma));
+static bfd_byte *elf32_h8_get_relocated_section_contents
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
+ bfd_byte *, boolean, asymbol **));
static bfd_reloc_status_type elf32_h8_final_link_relocate
PARAMS ((unsigned long, bfd *, bfd *, asection *,
bfd_byte *, bfd_vma, bfd_vma, bfd_vma,
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
bfd_byte *, Elf_Internal_Rela *,
Elf_Internal_Sym *, asection **));
-static bfd_reloc_status_type special
+static bfd_reloc_status_type special
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
/* This does not include any relocation information, but should be
relend = relocs + input_section->reloc_count;
for (; rel < relend; rel++)
{
- int r_type;
+ unsigned int r_type;
unsigned long r_symndx;
Elf_Internal_Sym *sym;
asection *sec;
elf32_h8_info_to_howto (input_bfd, &bfd_reloc, rel);
howto = bfd_reloc.howto;
-
+
if (h != NULL)
name = h->root.root.string;
else
Examine that field and return the proper BFD machine type for
the object file. */
-static int
+static unsigned long
elf32_h8_mach (flags)
flagword flags;
{
file. We use this opportunity to encode the BFD machine type
into the flags field in the object file. */
-void
+static void
elf32_h8_final_write_processing (abfd, linker)
bfd *abfd;
boolean linker ATTRIBUTE_UNUSED;
/* Return nonzero if ABFD represents a valid H8 ELF object file; also
record the encoded machine type found in the ELF flags. */
-boolean
+static boolean
elf32_h8_object_p (abfd)
bfd *abfd;
{
object file when linking. The only data we need to copy at this
time is the architecture/machine information. */
-boolean
+static boolean
elf32_h8_merge_private_bfd_data (ibfd, obfd)
bfd *ibfd;
bfd *obfd;
mov.b:24/32 -> mov.b:8 4 bytes
mov.[bwl]:24/32 -> mov.[bwl]:16 2 bytes
-
+
*/
goto error_return;
free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
+ || (bfd_bread (extsyms, symtab_hdr->sh_size, abfd)
!= symtab_hdr->sh_size))
goto error_return;
}
/* If the distance is within -126..+130 inclusive, then we can
relax this jump. +130 is valid since the target will move
two bytes closer if we do relax this branch. */
- if ((int)gap >= -126 && (int)gap <= 130)
+ if ((int) gap >= -126 && (int) gap <= 130)
{
unsigned char code;
Such sequences are used by the compiler to deal with
long conditional branches. */
- if (gap <= 130
- && gap >= -128
+ if ((int) gap <= 130
+ && (int) gap >= -128
&& last_reloc
&& ELF32_R_TYPE (last_reloc->r_info) == R_H8_PCREL8
&& ELF32_R_SYM (last_reloc->r_info) < symtab_hdr->sh_info)
/* We will need to examine the symbol used by the
previous relocation. */
-
+
bfd_elf32_swap_symbol_in (abfd,
(extsyms + ELF32_R_SYM (last_reloc->r_info)),
&last_symbol);
dot = (sec->output_section->vma
+ sec->output_offset
+ irel->r_offset - 2);
-
+
gap = value - dot;
/* If the distance is within -126..+130 inclusive, then we can
irelend = irel + sec->reloc_count;
/* Actually delete the bytes. */
- memmove (contents + addr, contents + addr + count, toaddr - addr - count);
+ memmove (contents + addr, contents + addr + count,
+ (size_t) (toaddr - addr - count));
sec->_cooked_size -= count;
/* Adjust all the relocs. */
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
memcpy (data, elf_section_data (input_section)->this_hdr.contents,
- input_section->_raw_size);
+ (size_t) input_section->_raw_size);
if ((input_section->flags & SEC_RELOC) != 0
&& input_section->reloc_count > 0)
external_syms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
- external_syms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf32_External_Sym)));
+ bfd_size_type amt;
+
+ amt = symtab_hdr->sh_info;
+ amt *= sizeof (Elf32_External_Sym);
+ external_syms = (Elf32_External_Sym *) bfd_malloc (amt);
if (external_syms == NULL && symtab_hdr->sh_info > 0)
goto error_return;
if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (external_syms, sizeof (Elf32_External_Sym),
- symtab_hdr->sh_info, input_bfd)
- != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))))
+ || bfd_bread (external_syms, amt, input_bfd) != amt)
goto error_return;
}
goto error_return;
internal_syms = ((Elf_Internal_Sym *)
- bfd_malloc (symtab_hdr->sh_info
+ bfd_malloc ((bfd_size_type) symtab_hdr->sh_info
* sizeof (Elf_Internal_Sym)));
if (internal_syms == NULL && symtab_hdr->sh_info > 0)
goto error_return;
- sections = (asection **) bfd_malloc (symtab_hdr->sh_info
+ sections = (asection **) bfd_malloc ((bfd_size_type) symtab_hdr->sh_info
* sizeof (asection *));
if (sections == NULL && symtab_hdr->sh_info > 0)
goto error_return;
bfd *abfd;
{
struct elf32_hppa_link_hash_table *ret;
+ bfd_size_type amt = sizeof (*ret);
- ret = ((struct elf32_hppa_link_hash_table *) bfd_alloc (abfd, sizeof (*ret)));
+ ret = (struct elf32_hppa_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == NULL)
return NULL;
const Elf_Internal_Rela *rel;
{
char *stub_name;
- size_t len;
+ bfd_size_type len;
if (hash)
{
stub_sec = hplink->stub_group[link_sec->id].stub_sec;
if (stub_sec == NULL)
{
- size_t len;
+ bfd_size_type len;
char *s_name;
len = strlen (link_sec->name) + sizeof (STUB_SUFFIX);
/* This is a global offset table entry for a local symbol. */
if (local_got_refcounts == NULL)
{
- size_t size;
+ bfd_size_type size;
/* Allocate space for local got offsets and local
plt offsets. Done this way to save polluting
elf_obj_tdata with another target specific
pointer. */
- size = symtab_hdr->sh_info * 2 * sizeof (bfd_signed_vma);
+ size = symtab_hdr->sh_info;
+ size *= 2 * sizeof (bfd_signed_vma);
local_got_refcounts = ((bfd_signed_vma *)
bfd_alloc (abfd, size));
if (local_got_refcounts == NULL)
return false;
elf_local_got_refcounts (abfd) = local_got_refcounts;
- memset (local_got_refcounts, -1, size);
+ memset (local_got_refcounts, -1, (size_t) size);
}
if (local_got_refcounts[r_symndx] == -1)
local_got_refcounts[r_symndx] = 1;
if (local_got_refcounts == NULL)
{
- size_t size;
+ bfd_size_type size;
/* Allocate space for local got offsets and local
plt offsets. */
- size = symtab_hdr->sh_info * 2 * sizeof (bfd_signed_vma);
+ size = symtab_hdr->sh_info;
+ size *= 2 * sizeof (bfd_signed_vma);
local_got_refcounts = ((bfd_signed_vma *)
bfd_alloc (abfd, size));
if (local_got_refcounts == NULL)
return false;
elf_local_got_refcounts (abfd) = local_got_refcounts;
- memset (local_got_refcounts, -1, size);
+ memset (local_got_refcounts, -1, (size_t) size);
}
local_plt_refcounts = (local_got_refcounts
+ symtab_hdr->sh_info);
if ((need_entry & NEED_STUBREL))
{
- size_t len = strlen (name) + sizeof (STUB_SUFFIX);
+ bfd_size_type len = strlen (name) + sizeof (STUB_SUFFIX);
char *newname = bfd_malloc (len);
if (newname == NULL)
if (p == NULL)
{
p = ((struct elf32_hppa_dyn_reloc_entry *)
- bfd_alloc (dynobj, sizeof *p));
+ bfd_alloc (dynobj, (bfd_size_type) sizeof *p));
if (p == NULL)
return false;
p->next = h->reloc_entries;
actually has nothing to do with the PLT, it is how we
communicate the LTP value of a load module to the dynamic
linker. */
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0))
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
+ if (!add_dynamic_entry (DT_PLTGOT, 0))
return false;
/* Add some entries to the .dynamic section. We fill in the
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
- if (! info->shared)
+ if (!info->shared)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (hplink->srelplt->_raw_size != 0)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf32_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
return false;
}
if (reltext)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
info->flags |= DF_TEXTREL;
}
}
+#undef add_dynamic_entry
return true;
}
boolean stubs_always_before_branch;
boolean stub_changed = 0;
boolean ret = 0;
+ bfd_size_type amt;
hplink = hppa_link_hash_table (info);
}
}
- hplink->stub_group
- = (struct map_stub *) bfd_zmalloc (sizeof (struct map_stub) * (top_id + 1));
+ amt = sizeof (struct map_stub) * (top_id + 1);
+ hplink->stub_group = (struct map_stub *) bfd_zmalloc (amt);
if (hplink->stub_group == NULL)
return false;
top_index = section->index;
}
- input_list
- = (asection **) bfd_malloc (sizeof (asection *) * (top_index + 1));
+ amt = sizeof (asection *) * (top_index + 1);
+ input_list = (asection **) bfd_malloc (amt);
if (input_list == NULL)
return false;
/* We want to read in symbol extension records only once. To do this
we need to read in the local symbols in parallel and save them for
later use; so hold pointers to the local symbols in an array. */
- all_local_syms
- = (Elf_Internal_Sym **) bfd_zmalloc (sizeof (Elf_Internal_Sym *)
- * bfd_count);
+ amt = sizeof (Elf_Internal_Sym *) * bfd_count;
+ all_local_syms = (Elf_Internal_Sym **) bfd_zmalloc (amt);
if (all_local_syms == NULL)
return false;
Elf_Internal_Shdr *symtab_hdr;
Elf_Internal_Sym *isym;
Elf32_External_Sym *ext_syms, *esym, *end_sy;
+ bfd_size_type sec_size;
/* We'll need the symbol table in a second. */
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
/* We need an array of the local symbols attached to the input bfd.
Unfortunately, we're going to have to read & swap them in. */
- local_syms = (Elf_Internal_Sym *)
- bfd_malloc (symtab_hdr->sh_info * sizeof (Elf_Internal_Sym));
+ sec_size = symtab_hdr->sh_info;
+ sec_size *= sizeof (Elf_Internal_Sym);
+ local_syms = (Elf_Internal_Sym *) bfd_malloc (sec_size);
if (local_syms == NULL)
{
goto error_ret_free_local;
}
all_local_syms[bfd_indx] = local_syms;
- ext_syms = (Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_info * sizeof (Elf32_External_Sym));
+ sec_size = symtab_hdr->sh_info;
+ sec_size *= sizeof (Elf32_External_Sym);
+ ext_syms = (Elf32_External_Sym *) bfd_malloc (sec_size);
if (ext_syms == NULL)
{
goto error_ret_free_local;
}
if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (ext_syms, 1,
- (symtab_hdr->sh_info * sizeof (Elf32_External_Sym)),
- input_bfd)
- != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))))
+ || (bfd_bread (ext_syms, sec_size, input_bfd) != sec_size))
{
free (ext_syms);
goto error_ret_free_local;
char *name;
asection *reloc_sec;
- name = bfd_malloc (strlen (section->name)
+ name = bfd_malloc ((bfd_size_type) strlen (section->name)
+ sizeof STUB_SUFFIX
+ 5);
if (name == NULL)
continue;
/* Allocate space for the external relocations. */
- external_relocs
- = ((Elf32_External_Rela *)
- bfd_malloc (section->reloc_count
- * sizeof (Elf32_External_Rela)));
+ amt = section->reloc_count;
+ amt *= sizeof (Elf32_External_Rela);
+ external_relocs = (Elf32_External_Rela *) bfd_malloc (amt);
if (external_relocs == NULL)
{
goto error_ret_free_local;
}
/* Likewise for the internal relocations. */
- internal_relocs = ((Elf_Internal_Rela *)
- bfd_malloc (section->reloc_count
- * sizeof (Elf_Internal_Rela)));
+ amt = section->reloc_count;
+ amt *= sizeof (Elf_Internal_Rela);
+ internal_relocs = (Elf_Internal_Rela *) bfd_malloc (amt);
if (internal_relocs == NULL)
{
free (external_relocs);
/* Read in the external relocs. */
input_rel_hdr = &elf_section_data (section)->rel_hdr;
if (bfd_seek (input_bfd, input_rel_hdr->sh_offset, SEEK_SET) != 0
- || bfd_read (external_relocs, 1,
+ || bfd_bread (external_relocs,
input_rel_hdr->sh_size,
input_bfd) != input_rel_hdr->sh_size)
{
stub_sec != NULL;
stub_sec = stub_sec->next)
{
- size_t size;
+ bfd_size_type size;
/* Allocate memory to hold the linker stubs. */
size = stub_sec->_raw_size;
if (! bfd_get_section_contents (abfd, s, contents, (file_ptr) 0, size))
return false;
- qsort (contents, size / 16, 16, hppa_unwind_entry_compare);
+ qsort (contents, (size_t) (size / 16), 16, hppa_unwind_entry_compare);
if (! bfd_set_section_contents (abfd, s, contents, (file_ptr) 0, size))
return false;
{
/* In a non-shared link, adjust_dynamic_symbols
isn't called for symbols forced local. We
- need to write out the plt entry here. */
+ need to write out the plt entry here. */
if ((off & 1) != 0)
off &= ~1;
else
skip = false;
if (elf_section_data (input_section)->stab_info != NULL)
{
- bfd_vma off;
-
off = (_bfd_stab_section_offset
(output_bfd, &hplink->root.stab_info,
input_section,
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
- if (! info->shared)
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
+ if (!info->shared)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (plt)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf32_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
return false;
}
if (reltext)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
info->flags |= DF_TEXTREL;
}
}
+#undef add_dynamic_entry
/* If we are generating a shared library, we generate a section
symbol for each output section. These are local symbols, which
if (sgot)
{
unsigned char *contents = sgot->contents;
- bfd_put_32 (output_bfd, 0x4e800021 /* blrl */, contents);
+ bfd_put_32 (output_bfd, (bfd_vma) 0x4e800021 /* blrl */, contents);
if (sdyn == NULL)
bfd_put_32 (output_bfd, (bfd_vma) 0, contents+4);
#define elf_backend_post_process_headers i370_elf_post_process_headers
-int i370_noop()
+static int i370_noop PARAMS ((void));
+
+static int i370_noop ()
{
return 1;
}
bfd *abfd;
{
struct elf_i386_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct elf_i386_link_hash_table);
- ret = ((struct elf_i386_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf_i386_link_hash_table)));
+ ret = (struct elf_i386_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct elf_i386_link_hash_table *) NULL)
return NULL;
/* This is a global offset table entry for a local symbol. */
if (local_got_refcounts == NULL)
{
- size_t size;
+ bfd_size_type size;
- size = symtab_hdr->sh_info * sizeof (bfd_signed_vma);
+ size = symtab_hdr->sh_info;
+ size *= sizeof (bfd_signed_vma);
local_got_refcounts = ((bfd_signed_vma *)
bfd_alloc (abfd, size));
if (local_got_refcounts == NULL)
return false;
elf_local_got_refcounts (abfd) = local_got_refcounts;
- memset (local_got_refcounts, -1, size);
+ memset (local_got_refcounts, -1, (size_t) size);
}
if (local_got_refcounts[r_symndx] == -1)
local_got_refcounts[r_symndx] = 1;
if (p == NULL)
{
p = ((struct elf_i386_dyn_relocs *)
- bfd_alloc (dynobj, sizeof *p));
+ bfd_alloc (dynobj, (bfd_size_type) sizeof *p));
if (p == NULL)
return false;
p->next = eh->dyn_relocs;
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
if (! info->shared)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (htab->splt->_raw_size != 0)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_REL)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_REL)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_REL, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELENT,
- sizeof (Elf32_External_Rel)))
+ if (!add_dynamic_entry (DT_REL, 0)
+ || !add_dynamic_entry (DT_RELSZ, 0)
+ || !add_dynamic_entry (DT_RELENT, sizeof (Elf32_External_Rel)))
return false;
}
if ((info->flags & DF_TEXTREL) != 0)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
}
}
+#undef add_dynamic_entry
return true;
}
outrel.r_offset = rel->r_offset;
else
{
- bfd_vma off;
-
off = (_bfd_stab_section_offset
(output_bfd, htab->root.stab_info, input_section,
&elf_section_data (input_section)->stab_info,
rel.r_offset = (htab->sgot->output_section->vma
+ htab->sgot->output_offset
- + (h->got.offset &~ 1));
+ + (h->got.offset & ~(bfd_vma) 1));
/* If this is a static link, or it is a -Bsymbolic link and the
symbol is defined locally or was forced to be local because
Elf_Internal_Note *note;
{
int offset;
- int raw_size;
+ size_t raw_size;
switch (note->descsz)
{
arelent *bfd_reloc;
Elf64_Internal_Rela *elf_reloc;
{
- bfd_reloc->howto = lookup_howto (ELF32_R_TYPE (elf_reloc->r_info));
+ bfd_reloc->howto
+ = lookup_howto ((unsigned) ELF32_R_TYPE (elf_reloc->r_info));
}
\f
/* Specialized relocation handler for R_860_SPLITn. These relocations
{
bfd_vma insn;
reloc_howto_type *howto;
- howto = lookup_howto (ELF32_R_TYPE (rello->r_info));
+ howto = lookup_howto ((unsigned) ELF32_R_TYPE (rello->r_info));
insn = bfd_get_32 (input_bfd, contents + rello->r_offset);
/* Relocate. */
{
bfd_vma insn;
reloc_howto_type *howto;
- howto = lookup_howto (ELF32_R_TYPE (rello->r_info));
+ howto = lookup_howto ((unsigned) ELF32_R_TYPE (rello->r_info));
insn = bfd_get_32 (input_bfd, contents + rello->r_offset);
/* Adjust for PC-relative relocation. */
{
bfd_vma insn;
reloc_howto_type *howto;
- howto = lookup_howto (ELF32_R_TYPE (rello->r_info));
+ howto = lookup_howto ((unsigned) ELF32_R_TYPE (rello->r_info));
insn = bfd_get_32 (input_bfd, contents + rello->r_offset);
/* Adjust for PC-relative relocation. */
}
/* This is a final link. */
- howto = lookup_howto (ELF32_R_TYPE (rel->r_info));
- h = NULL;
- sym = NULL;
- sec = NULL;
+ howto = lookup_howto ((unsigned) ELF32_R_TYPE (rel->r_info));
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
if (r_symndx < symtab_hdr->sh_info)
{
+ input_section->output_offset);
/* These jumps mask off the lower two bits of the current address
before doing pcrel calculations. */
- relocation -= (offset & -4L);
+ relocation -= (offset & -(bfd_vma) 4);
if (relocation < -0x200 || relocation > 0x1ff)
status = bfd_reloc_overflow;
relocation >>= howto->rightshift;
relocation <<= howto->bitpos;
x = (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask);
- bfd_put_16 (abfd, x, data + offset);
+ bfd_put_16 (abfd, (bfd_vma) x, data + offset);
return status;
}
relocation += reloc_entry->addend;
/* Save the information, and let LO16 do the actual relocation. */
- n = (struct m32r_hi16 *) bfd_malloc (sizeof *n);
+ n = (struct m32r_hi16 *) bfd_malloc ((bfd_size_type) sizeof *n);
if (n == NULL)
return bfd_reloc_outofrange;
n->addr = (bfd_byte *) data + reloc_entry->address;
if ((val & 0x8000) != 0)
val += 0x10000;
- insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff);
- bfd_put_32 (input_bfd, insn, l->addr);
+ insn = (insn &~ (bfd_vma) 0xffff) | ((val >> 16) & 0xffff);
+ bfd_put_32 (input_bfd, (bfd_vma) insn, l->addr);
next = l->next;
free (l);
{
short x = bfd_get_16 (input_bfd, inplace_address);
DOIT (x);
- bfd_put_16 (input_bfd, x, inplace_address);
+ bfd_put_16 (input_bfd, (bfd_vma) x, inplace_address);
}
break;
case 2:
{
unsigned long x = bfd_get_32 (input_bfd, inplace_address);
DOIT (x);
- bfd_put_32 (input_bfd, x, inplace_address);
+ bfd_put_32 (input_bfd, (bfd_vma)x , inplace_address);
}
break;
default:
if (s == NULL)
{
- int flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+ flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY | SEC_LINKER_CREATED);
s = bfd_make_section_anyway (abfd, ".sdata");
if (s == NULL)
"_SDA_BASE_",
BSF_GLOBAL,
s,
- 32768,
+ (bfd_vma) 32768,
(const char *) NULL,
false,
get_elf_backend_data (abfd)->collect,
extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
+ bfd_size_type amt = symtab_hdr->sh_size;
/* Go get them off disk. */
- extsyms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_size));
+ extsyms = (Elf32_External_Sym *) bfd_malloc (amt);
if (extsyms == NULL)
goto error_return;
free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
- != symtab_hdr->sh_size))
+ || bfd_bread (extsyms, amt, abfd) != amt)
goto error_return;
}
}
Elf_Internal_Rela *internal_relocs = NULL;
Elf32_External_Sym *external_syms = NULL;
Elf_Internal_Sym *internal_syms = NULL;
+ bfd_size_type amt;
/* We only need to handle the case of relaxing, or of having a
particular set of section contents, specially. */
external_syms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
- external_syms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf32_External_Sym)));
+ amt = symtab_hdr->sh_info;
+ amt *= sizeof (Elf32_External_Sym);
+ external_syms = (Elf32_External_Sym *) bfd_malloc (amt);
if (external_syms == NULL && symtab_hdr->sh_info > 0)
goto error_return;
if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (external_syms, sizeof (Elf32_External_Sym),
- symtab_hdr->sh_info, input_bfd)
- != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))))
+ || bfd_bread (external_syms, amt, input_bfd) != amt)
goto error_return;
}
if (internal_relocs == NULL)
goto error_return;
- internal_syms = ((Elf_Internal_Sym *)
- bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf_Internal_Sym)));
+ amt = symtab_hdr->sh_info;
+ amt *= sizeof (Elf_Internal_Sym);
+ internal_syms = (Elf_Internal_Sym *) bfd_malloc (amt);
if (internal_syms == NULL && symtab_hdr->sh_info > 0)
goto error_return;
- sections = (asection **) bfd_malloc (symtab_hdr->sh_info
- * sizeof (asection *));
+ amt = symtab_hdr->sh_info;
+ amt *= sizeof (asection *);
+ sections = (asection **) bfd_malloc (amt);
if (sections == NULL && symtab_hdr->sh_info > 0)
goto error_return;
bfd *abfd;
{
struct elf_m68k_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct elf_m68k_link_hash_table);
- ret = ((struct elf_m68k_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf_m68k_link_hash_table)));
+ ret = (struct elf_m68k_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct elf_m68k_link_hash_table *) NULL)
return NULL;
/* This is a global offset table entry for a local symbol. */
if (local_got_refcounts == NULL)
{
- size_t size;
+ bfd_size_type size;
- size = symtab_hdr->sh_info * sizeof (bfd_signed_vma);
+ size = symtab_hdr->sh_info;
+ size *= sizeof (bfd_signed_vma);
local_got_refcounts = ((bfd_signed_vma *)
bfd_alloc (abfd, size));
if (local_got_refcounts == NULL)
return false;
elf_local_got_refcounts (abfd) = local_got_refcounts;
- memset (local_got_refcounts, -1, size);
+ memset (local_got_refcounts, -1, (size_t) size);
}
if (local_got_refcounts[r_symndx] == -1)
{
if (p == NULL)
{
p = ((struct elf_m68k_pcrel_relocs_copied *)
- bfd_alloc (dynobj, sizeof *p));
+ bfd_alloc (dynobj, (bfd_size_type) sizeof *p));
if (p == NULL)
return false;
p->next = eh->pcrel_relocs_copied;
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
if (!info->shared)
{
- if (!bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (plt)
{
- if (!bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || !bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || !bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || !bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (!bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
- || !bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
- || !bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf32_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
return false;
}
if ((info->flags & DF_TEXTREL) != 0)
{
- if (!bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
}
}
+#undef add_dynamic_entry
return true;
}
rela.r_offset = (sgot->output_section->vma
+ sgot->output_offset
- + (h->got.offset &~ 1));
+ + (h->got.offset &~ (bfd_vma) 1));
/* If this is a -Bsymbolic link, and the symbol is defined
locally, we just want to emit a RELATIVE reloc. Likewise if
rela.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
rela.r_addend = bfd_get_signed_32 (output_bfd,
(sgot->contents
- + (h->got.offset & ~1)));
+ + (h->got.offset &~ (bfd_vma) 1)));
}
else
{
bfd_put_32 (output_bfd, (bfd_vma) 0,
- sgot->contents + (h->got.offset & ~1));
+ sgot->contents + (h->got.offset &~ (bfd_vma) 1));
rela.r_info = ELF32_R_INFO (h->dynindx, R_68K_GLOB_DAT);
rela.r_addend = 0;
}
Elf_Internal_Rela *free_relocs = NULL;
Elf_Internal_Rela *irel, *irelend;
bfd_byte *p;
+ bfd_size_type amt;
BFD_ASSERT (! info->relocateable);
{
/* Go get them off disk. */
if (info->keep_memory)
- extsyms = ((Elf32_External_Sym *)
- bfd_alloc (abfd, symtab_hdr->sh_size));
+ extsyms = (Elf32_External_Sym *) bfd_alloc (abfd, symtab_hdr->sh_size);
else
- extsyms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_size));
+ extsyms = (Elf32_External_Sym *) bfd_malloc (symtab_hdr->sh_size);
if (extsyms == NULL)
goto error_return;
if (! info->keep_memory)
free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
+ || (bfd_bread (extsyms, symtab_hdr->sh_size, abfd)
!= symtab_hdr->sh_size))
goto error_return;
if (info->keep_memory)
if (! info->keep_memory)
free_relocs = internal_relocs;
- relsec->contents = (bfd_byte *) bfd_alloc (abfd, datasec->reloc_count * 12);
+ amt = (bfd_size_type) datasec->reloc_count * 12;
+ relsec->contents = (bfd_byte *) bfd_alloc (abfd, amt);
if (relsec->contents == NULL)
goto error_return;
case R_MCORE_PCRELJSR_IMM11BY2:
oldinst = bfd_get_16 (input_bfd, contents + offset);
#define MCORE_INST_BSR 0xF800
- bfd_put_16 (input_bfd, MCORE_INST_BSR, contents + offset);
+ bfd_put_16 (input_bfd, (bfd_vma) MCORE_INST_BSR, contents + offset);
break;
}
if (r != bfd_reloc_ok && r_type == R_MCORE_PCRELJSR_IMM11BY2)
{
/* Wasn't ok, back it out and give up. */
- bfd_put_16 (input_bfd, oldinst, contents + offset);
+ bfd_put_16 (input_bfd, (bfd_vma) oldinst, contents + offset);
r = bfd_reloc_ok;
}
PARAMS ((PTR, bfd *, struct bfd_link_info *, asection *,
struct ecoff_debug_info *));
static INLINE int elf_mips_isa PARAMS ((flagword));
-static INLINE int elf_mips_mach PARAMS ((flagword));
+static INLINE unsigned long elf_mips_mach PARAMS ((flagword));
static INLINE char* elf_mips_abi_name PARAMS ((bfd *));
static boolean mips_elf_is_local_label_name
PARAMS ((bfd *, const char *));
/* Add a dynamic symbol table-entry. */
#ifdef BFD64
-#define MIPS_ELF_ADD_DYNAMIC_ENTRY(info, tag, val) \
- (ABI_64_P (elf_hash_table (info)->dynobj) \
- ? bfd_elf64_add_dynamic_entry (info, tag, val) \
- : bfd_elf32_add_dynamic_entry (info, tag, val))
+#define MIPS_ELF_ADD_DYNAMIC_ENTRY(info, tag, val) \
+ (ABI_64_P (elf_hash_table (info)->dynobj) \
+ ? bfd_elf64_add_dynamic_entry (info, (bfd_vma) tag, (bfd_vma) val) \
+ : bfd_elf32_add_dynamic_entry (info, (bfd_vma) tag, (bfd_vma) val))
#else
-#define MIPS_ELF_ADD_DYNAMIC_ENTRY(info, tag, val) \
- (ABI_64_P (elf_hash_table (info)->dynobj) \
- ? (abort (), false) \
- : bfd_elf32_add_dynamic_entry (info, tag, val))
+#define MIPS_ELF_ADD_DYNAMIC_ENTRY(info, tag, val) \
+ (ABI_64_P (elf_hash_table (info)->dynobj) \
+ ? (abort (), false) \
+ : bfd_elf32_add_dynamic_entry (info, (bfd_vma) tag, (bfd_vma) val))
#endif
/* The number of local .got entries we reserve. */
return bfd_reloc_outofrange;
/* Save the information, and let LO16 do the actual relocation. */
- n = (struct mips_hi16 *) bfd_malloc (sizeof *n);
+ n = (struct mips_hi16 *) bfd_malloc ((bfd_size_type) sizeof *n);
if (n == NULL)
return bfd_reloc_outofrange;
n->addr = (bfd_byte *) data + reloc_entry->address;
if ((val & 0x8000) != 0)
val += 0x10000;
- insn = (insn & ~0xffff) | ((val >> 16) & 0xffff);
- bfd_put_32 (abfd, insn, l->addr);
+ insn = (insn &~ (bfd_vma) 0xffff) | ((val >> 16) & 0xffff);
+ bfd_put_32 (abfd, (bfd_vma) insn, l->addr);
if (strcmp (bfd_asymbol_name (symbol), "_gp_disp") == 0)
{
{
for (i = 0; i < count; i++, sym++)
{
- register CONST char *name;
+ register const char *name;
name = bfd_asymbol_name (*sym);
if (*name == '_' && strcmp (name, "_gp") == 0)
|| (symbol->flags & BSF_SECTION_SYM) != 0)
val += relocation - gp;
- insn = (insn & ~0xffff) | (val & 0xffff);
- bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
+ insn = (insn &~ (bfd_vma) 0xffff) | (val & 0xffff);
+ bfd_put_32 (abfd, (bfd_vma) insn, (bfd_byte *) data + reloc_entry->address);
if (relocateable)
reloc_entry->address += input_section->output_offset;
|| (symbol->flags & BSF_SECTION_SYM) != 0)
val += relocation - gp;
- bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
+ bfd_put_32 (abfd, (bfd_vma) val, (bfd_byte *) data + reloc_entry->address);
if (relocateable)
reloc_entry->address += input_section->output_offset;
addr = reloc_entry->address;
if (bfd_little_endian (abfd))
addr += 4;
- bfd_put_32 (abfd, val, (bfd_byte *) data + addr);
+ bfd_put_32 (abfd, (bfd_vma) val, (bfd_byte *) data + addr);
return r;
}
/* Stuff the current addend back as a 32 bit value, do the usual
relocation, and then clean up. */
bfd_put_32 (abfd,
- (((extend & 0x1f) << 11)
- | (extend & 0x7e0)
- | (insn & 0x1f)),
+ (bfd_vma) (((extend & 0x1f) << 11)
+ | (extend & 0x7e0)
+ | (insn & 0x1f)),
(bfd_byte *) data + reloc_entry->address);
ret = gprel16_with_gp (abfd, symbol, reloc_entry, input_section,
final = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
bfd_put_16 (abfd,
- ((extend & 0xf800)
- | ((final >> 11) & 0x1f)
- | (final & 0x7e0)),
+ (bfd_vma) ((extend & 0xf800)
+ | ((final >> 11) & 0x1f)
+ | (final & 0x7e0)),
(bfd_byte *) data + reloc_entry->address);
bfd_put_16 (abfd,
- ((insn & 0xffe0)
- | (final & 0x1f)),
+ (bfd_vma) ((insn & 0xffe0)
+ | (final & 0x1f)),
(bfd_byte *) data + reloc_entry->address + 2);
return ret;
/* Return the MACH for a MIPS e_flags value. */
-static INLINE int
+static INLINE unsigned long
elf_mips_mach (flags)
flagword flags;
{
enum elf_mips_reloc_type elf_reloc_val;
};
-static CONST struct elf_reloc_map mips_reloc_map[] =
+static const struct elf_reloc_map mips_reloc_map[] =
{
{ BFD_RELOC_NONE, R_MIPS_NONE, },
{ BFD_RELOC_16, R_MIPS_16 },
const Elf32_External_RegInfo *ex;
Elf32_RegInfo *in;
{
- in->ri_gprmask = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_gprmask);
- in->ri_cprmask[0] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[0]);
- in->ri_cprmask[1] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[1]);
- in->ri_cprmask[2] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[2]);
- in->ri_cprmask[3] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[3]);
- in->ri_gp_value = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_gp_value);
+ in->ri_gprmask = H_GET_32 (abfd, ex->ri_gprmask);
+ in->ri_cprmask[0] = H_GET_32 (abfd, ex->ri_cprmask[0]);
+ in->ri_cprmask[1] = H_GET_32 (abfd, ex->ri_cprmask[1]);
+ in->ri_cprmask[2] = H_GET_32 (abfd, ex->ri_cprmask[2]);
+ in->ri_cprmask[3] = H_GET_32 (abfd, ex->ri_cprmask[3]);
+ in->ri_gp_value = H_GET_32 (abfd, ex->ri_gp_value);
}
void
const Elf32_RegInfo *in;
Elf32_External_RegInfo *ex;
{
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_gprmask,
- (bfd_byte *) ex->ri_gprmask);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[0],
- (bfd_byte *) ex->ri_cprmask[0]);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[1],
- (bfd_byte *) ex->ri_cprmask[1]);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[2],
- (bfd_byte *) ex->ri_cprmask[2]);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[3],
- (bfd_byte *) ex->ri_cprmask[3]);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_gp_value,
- (bfd_byte *) ex->ri_gp_value);
+ H_PUT_32 (abfd, in->ri_gprmask, ex->ri_gprmask);
+ H_PUT_32 (abfd, in->ri_cprmask[0], ex->ri_cprmask[0]);
+ H_PUT_32 (abfd, in->ri_cprmask[1], ex->ri_cprmask[1]);
+ H_PUT_32 (abfd, in->ri_cprmask[2], ex->ri_cprmask[2]);
+ H_PUT_32 (abfd, in->ri_cprmask[3], ex->ri_cprmask[3]);
+ H_PUT_32 (abfd, in->ri_gp_value, ex->ri_gp_value);
}
/* In the 64 bit ABI, the .MIPS.options section holds register
const Elf64_External_RegInfo *ex;
Elf64_Internal_RegInfo *in;
{
- in->ri_gprmask = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_gprmask);
- in->ri_pad = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_pad);
- in->ri_cprmask[0] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[0]);
- in->ri_cprmask[1] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[1]);
- in->ri_cprmask[2] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[2]);
- in->ri_cprmask[3] = bfd_h_get_32 (abfd, (bfd_byte *) ex->ri_cprmask[3]);
- in->ri_gp_value = bfd_h_get_64 (abfd, (bfd_byte *) ex->ri_gp_value);
+ in->ri_gprmask = H_GET_32 (abfd, ex->ri_gprmask);
+ in->ri_pad = H_GET_32 (abfd, ex->ri_pad);
+ in->ri_cprmask[0] = H_GET_32 (abfd, ex->ri_cprmask[0]);
+ in->ri_cprmask[1] = H_GET_32 (abfd, ex->ri_cprmask[1]);
+ in->ri_cprmask[2] = H_GET_32 (abfd, ex->ri_cprmask[2]);
+ in->ri_cprmask[3] = H_GET_32 (abfd, ex->ri_cprmask[3]);
+ in->ri_gp_value = H_GET_64 (abfd, ex->ri_gp_value);
}
void
const Elf64_Internal_RegInfo *in;
Elf64_External_RegInfo *ex;
{
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_gprmask,
- (bfd_byte *) ex->ri_gprmask);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_pad,
- (bfd_byte *) ex->ri_pad);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[0],
- (bfd_byte *) ex->ri_cprmask[0]);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[1],
- (bfd_byte *) ex->ri_cprmask[1]);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[2],
- (bfd_byte *) ex->ri_cprmask[2]);
- bfd_h_put_32 (abfd, (bfd_vma) in->ri_cprmask[3],
- (bfd_byte *) ex->ri_cprmask[3]);
- bfd_h_put_64 (abfd, (bfd_vma) in->ri_gp_value,
- (bfd_byte *) ex->ri_gp_value);
+ H_PUT_32 (abfd, in->ri_gprmask, ex->ri_gprmask);
+ H_PUT_32 (abfd, in->ri_pad, ex->ri_pad);
+ H_PUT_32 (abfd, in->ri_cprmask[0], ex->ri_cprmask[0]);
+ H_PUT_32 (abfd, in->ri_cprmask[1], ex->ri_cprmask[1]);
+ H_PUT_32 (abfd, in->ri_cprmask[2], ex->ri_cprmask[2]);
+ H_PUT_32 (abfd, in->ri_cprmask[3], ex->ri_cprmask[3]);
+ H_PUT_64 (abfd, in->ri_gp_value, ex->ri_gp_value);
}
/* Swap an entry in a .gptab section. Note that these routines rely
const Elf32_External_gptab *ex;
Elf32_gptab *in;
{
- in->gt_entry.gt_g_value = bfd_h_get_32 (abfd, ex->gt_entry.gt_g_value);
- in->gt_entry.gt_bytes = bfd_h_get_32 (abfd, ex->gt_entry.gt_bytes);
+ in->gt_entry.gt_g_value = H_GET_32 (abfd, ex->gt_entry.gt_g_value);
+ in->gt_entry.gt_bytes = H_GET_32 (abfd, ex->gt_entry.gt_bytes);
}
static void
const Elf32_gptab *in;
Elf32_External_gptab *ex;
{
- bfd_h_put_32 (abfd, (bfd_vma) in->gt_entry.gt_g_value,
- ex->gt_entry.gt_g_value);
- bfd_h_put_32 (abfd, (bfd_vma) in->gt_entry.gt_bytes,
- ex->gt_entry.gt_bytes);
+ H_PUT_32 (abfd, in->gt_entry.gt_g_value, ex->gt_entry.gt_g_value);
+ H_PUT_32 (abfd, in->gt_entry.gt_bytes, ex->gt_entry.gt_bytes);
}
static void
const Elf32_compact_rel *in;
Elf32_External_compact_rel *ex;
{
- bfd_h_put_32 (abfd, (bfd_vma) in->id1, ex->id1);
- bfd_h_put_32 (abfd, (bfd_vma) in->num, ex->num);
- bfd_h_put_32 (abfd, (bfd_vma) in->id2, ex->id2);
- bfd_h_put_32 (abfd, (bfd_vma) in->offset, ex->offset);
- bfd_h_put_32 (abfd, (bfd_vma) in->reserved0, ex->reserved0);
- bfd_h_put_32 (abfd, (bfd_vma) in->reserved1, ex->reserved1);
+ H_PUT_32 (abfd, in->id1, ex->id1);
+ H_PUT_32 (abfd, in->num, ex->num);
+ H_PUT_32 (abfd, in->id2, ex->id2);
+ H_PUT_32 (abfd, in->offset, ex->offset);
+ H_PUT_32 (abfd, in->reserved0, ex->reserved0);
+ H_PUT_32 (abfd, in->reserved1, ex->reserved1);
}
static void
| ((in->rtype & CRINFO_RTYPE) << CRINFO_RTYPE_SH)
| ((in->dist2to & CRINFO_DIST2TO) << CRINFO_DIST2TO_SH)
| ((in->relvaddr & CRINFO_RELVADDR) << CRINFO_RELVADDR_SH));
- bfd_h_put_32 (abfd, (bfd_vma) l, ex->info);
- bfd_h_put_32 (abfd, (bfd_vma) in->konst, ex->konst);
- bfd_h_put_32 (abfd, (bfd_vma) in->vaddr, ex->vaddr);
+ H_PUT_32 (abfd, l, ex->info);
+ H_PUT_32 (abfd, in->konst, ex->konst);
+ H_PUT_32 (abfd, in->vaddr, ex->vaddr);
}
/* Swap in an options header. */
const Elf_External_Options *ex;
Elf_Internal_Options *in;
{
- in->kind = bfd_h_get_8 (abfd, ex->kind);
- in->size = bfd_h_get_8 (abfd, ex->size);
- in->section = bfd_h_get_16 (abfd, ex->section);
- in->info = bfd_h_get_32 (abfd, ex->info);
+ in->kind = H_GET_8 (abfd, ex->kind);
+ in->size = H_GET_8 (abfd, ex->size);
+ in->section = H_GET_16 (abfd, ex->section);
+ in->info = H_GET_32 (abfd, ex->info);
}
/* Swap out an options header. */
const Elf_Internal_Options *in;
Elf_External_Options *ex;
{
- bfd_h_put_8 (abfd, in->kind, ex->kind);
- bfd_h_put_8 (abfd, in->size, ex->size);
- bfd_h_put_16 (abfd, in->section, ex->section);
- bfd_h_put_32 (abfd, in->info, ex->info);
+ H_PUT_8 (abfd, in->kind, ex->kind);
+ H_PUT_8 (abfd, in->size, ex->size);
+ H_PUT_16 (abfd, in->section, ex->section);
+ H_PUT_32 (abfd, in->info, ex->info);
}
#if 0
/* Swap in an MSYM entry. */
const Elf32_External_Msym *ex;
Elf32_Internal_Msym *in;
{
- in->ms_hash_value = bfd_h_get_32 (abfd, ex->ms_hash_value);
- in->ms_info = bfd_h_get_32 (abfd, ex->ms_info);
+ in->ms_hash_value = H_GET_32 (abfd, ex->ms_hash_value);
+ in->ms_info = H_GET_32 (abfd, ex->ms_info);
}
#endif
/* Swap out an MSYM entry. */
const Elf32_Internal_Msym *in;
Elf32_External_Msym *ex;
{
- bfd_h_put_32 (abfd, in->ms_hash_value, ex->ms_hash_value);
- bfd_h_put_32 (abfd, in->ms_info, ex->ms_info);
+ H_PUT_32 (abfd, in->ms_hash_value, ex->ms_hash_value);
+ H_PUT_32 (abfd, in->ms_info, ex->ms_info);
}
\f
/* Determine whether a symbol is global for the purposes of splitting
Elf32_RegInfo s;
if (! bfd_get_section_contents (abfd, hdr->bfd_section, (PTR) &ext,
- (file_ptr) 0, sizeof ext))
+ (file_ptr) 0,
+ (bfd_size_type) sizeof ext))
return false;
bfd_mips_elf32_swap_reginfo_in (abfd, &ext, &s);
elf_gp (abfd) = s.ri_gp_value;
if ((sec->flags & SEC_RELOC) != 0)
{
struct bfd_elf_section_data *esd;
+ bfd_size_type amt = sizeof (Elf_Internal_Shdr);
esd = elf_section_data (sec);
BFD_ASSERT (esd->rel_hdr2 == NULL);
- esd->rel_hdr2
- = (Elf_Internal_Shdr *) bfd_zalloc (abfd, sizeof (Elf_Internal_Shdr));
+ esd->rel_hdr2 = (Elf_Internal_Shdr *) bfd_zalloc (abfd, amt);
if (!esd->rel_hdr2)
return false;
_bfd_elf_init_reloc_shdr (abfd, esd->rel_hdr2, sec,
if (elf_section_data (section) == NULL)
{
- section->used_by_bfd =
- (PTR) bfd_zalloc (abfd, sizeof (struct bfd_elf_section_data));
+ bfd_size_type amt = sizeof (struct bfd_elf_section_data);
+ section->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (elf_section_data (section) == NULL)
return false;
}
elf_section_data (section)->tdata = (PTR) c;
}
- memcpy (c + offset, location, count);
+ memcpy (c + offset, location, (size_t) count);
}
return _bfd_elf_set_section_contents (abfd, section, location, offset,
if (bfd_seek (abfd,
hdr->sh_offset + sizeof (Elf32_External_RegInfo) - 4,
- SEEK_SET) == -1)
+ SEEK_SET) != 0)
return false;
- bfd_h_put_32 (abfd, (bfd_vma) elf_gp (abfd), buf);
- if (bfd_write (buf, (bfd_size_type) 1, (bfd_size_type) 4, abfd) != 4)
+ H_PUT_32 (abfd, elf_gp (abfd), buf);
+ if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)
return false;
}
+ (l - contents)
+ sizeof (Elf_External_Options)
+ (sizeof (Elf64_External_RegInfo) - 8)),
- SEEK_SET) == -1)
+ SEEK_SET) != 0)
return false;
- bfd_h_put_64 (abfd, elf_gp (abfd), buf);
- if (bfd_write (buf, 1, 8, abfd) != 8)
+ H_PUT_64 (abfd, elf_gp (abfd), buf);
+ if (bfd_bwrite (buf, (bfd_size_type) 8, abfd) != 8)
return false;
}
else if (intopt.kind == ODK_REGINFO)
+ (l - contents)
+ sizeof (Elf_External_Options)
+ (sizeof (Elf32_External_RegInfo) - 4)),
- SEEK_SET) == -1)
+ SEEK_SET) != 0)
return false;
- bfd_h_put_32 (abfd, elf_gp (abfd), buf);
- if (bfd_write (buf, 1, 4, abfd) != 4)
+ H_PUT_32 (abfd, elf_gp (abfd), buf);
+ if (bfd_bwrite (buf, (bfd_size_type) 4, abfd) != 4)
return false;
}
l += intopt.size;
{
asection *s;
struct elf_segment_map *m, **pm;
+ bfd_size_type amt;
/* If there is a .reginfo section, we need a PT_MIPS_REGINFO
segment. */
break;
if (m == NULL)
{
- m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m);
+ amt = sizeof *m;
+ m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
if (m == NULL)
return false;
table. */
if (IRIX_COMPAT (abfd) == ict_irix6)
{
- asection *s;
-
for (s = abfd->sections; s; s = s->next)
if (elf_section_data (s)->this_hdr.sh_type == SHT_MIPS_OPTIONS)
break;
if ((*pm)->p_type == PT_PHDR)
break;
- options_segment = bfd_zalloc (abfd,
- sizeof (struct elf_segment_map));
+ amt = sizeof (struct elf_segment_map);
+ options_segment = bfd_zalloc (abfd, amt);
options_segment->next = *pm;
options_segment->p_type = PT_MIPS_OPTIONS;
options_segment->p_flags = PF_R;
break;
if (m == NULL)
{
- m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m);
+ amt = sizeof *m;
+ m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
if (m == NULL)
return false;
0 ? s->_cooked_size : s->_raw_size)) <= high))
++c;
- n = ((struct elf_segment_map *)
- bfd_zalloc (abfd, sizeof *n + (c - 1) * sizeof (asection *)));
+ amt = sizeof *n + (bfd_size_type) (c - 1) * sizeof (asection *);
+ n = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
if (n == NULL)
return false;
*n = *m;
const RPDR *in;
struct rpdr_ext *ex;
{
- /* ecoff_put_off was defined in ecoffswap.h. */
- ecoff_put_off (abfd, in->adr, (bfd_byte *) ex->p_adr);
- bfd_h_put_32 (abfd, in->regmask, (bfd_byte *) ex->p_regmask);
- bfd_h_put_32 (abfd, in->regoffset, (bfd_byte *) ex->p_regoffset);
- bfd_h_put_32 (abfd, in->fregmask, (bfd_byte *) ex->p_fregmask);
- bfd_h_put_32 (abfd, in->fregoffset, (bfd_byte *) ex->p_fregoffset);
- bfd_h_put_32 (abfd, in->frameoffset, (bfd_byte *) ex->p_frameoffset);
-
- bfd_h_put_16 (abfd, in->framereg, (bfd_byte *) ex->p_framereg);
- bfd_h_put_16 (abfd, in->pcreg, (bfd_byte *) ex->p_pcreg);
-
- bfd_h_put_32 (abfd, in->irpss, (bfd_byte *) ex->p_irpss);
+ /* ECOFF_PUT_OFF was defined in ecoffswap.h. */
+ ECOFF_PUT_OFF (abfd, in->adr, ex->p_adr);
+ H_PUT_32 (abfd, in->regmask, ex->p_regmask);
+ H_PUT_32 (abfd, in->regoffset, ex->p_regoffset);
+ H_PUT_32 (abfd, in->fregmask, ex->p_fregmask);
+ H_PUT_32 (abfd, in->fregoffset, ex->p_fregoffset);
+ H_PUT_32 (abfd, in->frameoffset, ex->p_frameoffset);
+
+ H_PUT_16 (abfd, in->framereg, ex->p_framereg);
+ H_PUT_16 (abfd, in->pcreg, ex->p_pcreg);
+
+ H_PUT_32 (abfd, in->irpss, ex->p_irpss);
#if 0 /* FIXME */
- ecoff_put_off (abfd, in->exception_info, (bfd_byte *) ex->p_exception_info);
+ ECOFF_PUT_OFF (abfd, in->exception_info, ex->p_exception_info);
#endif
}
\f
swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
memset (debug, 0, sizeof (*debug));
- ext_hdr = (char *) bfd_malloc ((size_t) swap->external_hdr_size);
+ ext_hdr = (char *) bfd_malloc (swap->external_hdr_size);
if (ext_hdr == NULL && swap->external_hdr_size != 0)
goto error_return;
debug->ptr = NULL; \
else \
{ \
- debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \
+ bfd_size_type amt = (bfd_size_type) size * symhdr->count; \
+ debug->ptr = (type) bfd_malloc (amt); \
if (debug->ptr == NULL) \
goto error_return; \
if (bfd_seek (abfd, (file_ptr) symhdr->offset, SEEK_SET) != 0 \
- || (bfd_read (debug->ptr, size, symhdr->count, \
- abfd) != size * symhdr->count)) \
+ || bfd_bread (debug->ptr, amt, abfd) != amt) \
goto error_return; \
}
if (_bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset,
filename_ptr, functionname_ptr,
line_ptr,
- ABI_64_P (abfd) ? 8 : 0,
+ (unsigned) (ABI_64_P (abfd) ? 8 : 0),
&elf_tdata (abfd)->dwarf2_find_line_info))
return true;
char *fraw_src;
char *fraw_end;
struct fdr *fdr_ptr;
+ bfd_size_type amt = sizeof (struct mips_elf_find_line);
- fi = ((struct mips_elf_find_line *)
- bfd_zalloc (abfd, sizeof (struct mips_elf_find_line)));
+ fi = (struct mips_elf_find_line *) bfd_zalloc (abfd, amt);
if (fi == NULL)
{
msec->flags = origflags;
}
/* Swap in the FDR information. */
- fi->d.fdr = ((struct fdr *)
- bfd_alloc (abfd,
- (fi->d.symbolic_header.ifdMax *
- sizeof (struct fdr))));
+ amt = fi->d.symbolic_header.ifdMax * sizeof (struct fdr);
+ fi->d.fdr = (struct fdr *) bfd_alloc (abfd, amt);
if (fi->d.fdr == NULL)
{
msec->flags = origflags;
bfd *abfd;
{
struct mips_elf_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct mips_elf_link_hash_table);
- ret = ((struct mips_elf_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct mips_elf_link_hash_table)));
+ ret = (struct mips_elf_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct mips_elf_link_hash_table *) NULL)
return NULL;
{
asymbol *elf_text_symbol;
asection *elf_text_section;
+ bfd_size_type amt = sizeof (asection);
- elf_text_section = bfd_zalloc (abfd, sizeof (asection));
+ elf_text_section = bfd_zalloc (abfd, amt);
if (elf_text_section == NULL)
return false;
- elf_text_symbol = bfd_zalloc (abfd, sizeof (asymbol));
+ amt = sizeof (asymbol);
+ elf_text_symbol = bfd_zalloc (abfd, amt);
if (elf_text_symbol == NULL)
return false;
{
asymbol *elf_data_symbol;
asection *elf_data_section;
+ bfd_size_type amt = sizeof (asection);
- elf_data_section = bfd_zalloc (abfd, sizeof (asection));
+ elf_data_section = bfd_zalloc (abfd, amt);
if (elf_data_section == NULL)
return false;
- elf_data_symbol = bfd_zalloc (abfd, sizeof (asymbol));
+ amt = sizeof (asymbol);
+ elf_data_symbol = bfd_zalloc (abfd, amt);
if (elf_data_symbol == NULL)
return false;
struct sym_ext *esym;
char *ss, **sv;
char *str;
- unsigned long size, count;
+ bfd_size_type size;
+ bfd_size_type count;
unsigned long sindex;
unsigned long i;
PDR pdr;
if (rpdr == NULL)
goto error_return;
- sv = (char **) bfd_malloc (sizeof (char *) * count);
+ size = sizeof (char *);
+ sv = (char **) bfd_malloc (size * count);
if (sv == NULL)
goto error_return;
goto error_return;
count = hdr->ipdMax;
- for (i = 0; i < count; i++, rp++)
+ for (i = 0; i < (unsigned long) count; i++, rp++)
{
(*swap->swap_pdr_in) (abfd, (PTR) (epdr + i), &pdr);
(*swap->swap_sym_in) (abfd, (PTR) &esym[pdr.isym], &sym);
strcpy (str, sv[i]);
str += strlen (sv[i]) + 1;
}
- ecoff_put_off (abfd, (bfd_vma) -1, (bfd_byte *) (erp + count)->p_adr);
+ ECOFF_PUT_OFF (abfd, -1, (erp + count)->p_adr);
/* Set the size and contents of .rtproc section. */
s->_raw_size = size;
PTR mdebug_handle = NULL;
asection *s;
EXTR esym;
- bfd_vma last;
unsigned int i;
- static const char * const name[] =
+ bfd_size_type amt;
+
+ static const char * const secname[] =
{
".text", ".init", ".fini", ".data",
".rodata", ".sdata", ".sbss", ".bss"
if (! bfd_get_section_contents (input_bfd, input_section,
(PTR) &ext,
(file_ptr) 0,
- sizeof ext))
+ (bfd_size_type) sizeof ext))
return false;
bfd_mips_elf32_swap_reginfo_in (input_bfd, &ext, &sub);
if (strcmp (o->name, ".mdebug") == 0)
{
struct extsym_info einfo;
+ bfd_vma last;
/* We have found the .mdebug section in the output file.
Look through all the link_orders comprising it and merge
esym.asym.reserved = 0;
esym.asym.index = indexNil;
last = 0;
- for (i = 0; i < 8; i++)
+ for (i = 0; i < sizeof (secname) / sizeof (secname[0]); i++)
{
esym.asym.sc = sc[i];
- s = bfd_get_section_by_name (abfd, name[i]);
+ s = bfd_get_section_by_name (abfd, secname[i]);
if (s != NULL)
{
esym.asym.value = s->vma;
else
esym.asym.value = last;
if (!bfd_ecoff_debug_one_external (abfd, &debug, swap,
- name[i], &esym))
+ secname[i], &esym))
return false;
}
unsigned int c;
Elf32_gptab *tab;
Elf32_External_gptab *ext_tab;
- unsigned int i;
+ unsigned int j;
/* The .gptab.sdata and .gptab.sbss sections hold
information describing how the small data area would
not used in executables files. */
if (! info->relocateable)
{
- asection **secpp;
-
for (p = o->link_order_head;
p != (struct bfd_link_order *) NULL;
p = p->next)
/* Set up the first entry. */
c = 1;
- tab = (Elf32_gptab *) bfd_malloc (c * sizeof (Elf32_gptab));
+ amt = c * sizeof (Elf32_gptab);
+ tab = (Elf32_gptab *) bfd_malloc (amt);
if (tab == NULL)
return false;
tab[0].gt_header.gt_current_g_value = elf_gp_size (abfd);
if (! (bfd_get_section_contents
(input_bfd, input_section, (PTR) &ext_gptab,
- gpentry, sizeof (Elf32_External_gptab))))
+ (file_ptr) gpentry,
+ (bfd_size_type) sizeof (Elf32_External_gptab))))
{
free (tab);
return false;
unsigned int max;
/* We need a new table entry. */
- new_tab = ((Elf32_gptab *)
- bfd_realloc ((PTR) tab,
- (c + 1) * sizeof (Elf32_gptab)));
+ amt = (bfd_size_type) (c + 1) * sizeof (Elf32_gptab);
+ new_tab = (Elf32_gptab *) bfd_realloc ((PTR) tab, amt);
if (new_tab == NULL)
{
free (tab);
qsort (tab + 1, c - 1, sizeof (tab[0]), gptab_compare);
/* Swap out the table. */
- ext_tab = ((Elf32_External_gptab *)
- bfd_alloc (abfd, c * sizeof (Elf32_External_gptab)));
+ amt = (bfd_size_type) c * sizeof (Elf32_External_gptab);
+ ext_tab = (Elf32_External_gptab *) bfd_alloc (abfd, amt);
if (ext_tab == NULL)
{
free (tab);
return false;
}
- for (i = 0; i < c; i++)
- bfd_mips_elf32_swap_gptab_out (abfd, tab + i, ext_tab + i);
+ for (j = 0; j < c; j++)
+ bfd_mips_elf32_swap_gptab_out (abfd, tab + j, ext_tab + j);
free (tab);
o->_raw_size = c * sizeof (Elf32_External_gptab);
bfd_mips_elf32_swap_reginfo_out (abfd, ®info, &ext);
if (! bfd_set_section_contents (abfd, reginfo_sec, (PTR) &ext,
- (file_ptr) 0, sizeof ext))
+ (file_ptr) 0, (bfd_size_type) sizeof ext))
return false;
}
/* True if the relocation is a RELA relocation, rather than a
REL relocation. */
boolean rela_relocation_p = true;
- int r_type = ELF32_R_TYPE (rel->r_info);
+ unsigned int r_type = ELF32_R_TYPE (rel->r_info);
const char * msg = (const char *) NULL;
/* Find the relocation howto for this relocation. */
bfd_vma l;
const Elf_Internal_Rela *lo16_relocation;
reloc_howto_type *lo16_howto;
- int lo;
+ unsigned int lo;
/* The combined value is the sum of the HI16 addend,
left-shifted by sixteen bits, and the LO16
{
s = bfd_make_section (abfd, ".rld_map");
if (s == NULL
- || ! bfd_set_section_flags (abfd, s, flags & ~SEC_READONLY)
+ || ! bfd_set_section_flags (abfd, s, flags &~ (flagword) SEC_READONLY)
|| ! bfd_set_section_alignment (abfd, s,
MIPS_ELF_LOG_FILE_ALIGN (abfd)))
return false;
register asection *s;
struct elf_link_hash_entry *h;
struct mips_got_info *g;
+ bfd_size_type amt;
/* This function may be called more than once. */
if (mips_elf_got_section (abfd))
/* The first several global offset table entries are reserved. */
s->_raw_size = MIPS_RESERVED_GOTNO * MIPS_ELF_GOT_SIZE (abfd);
- g = (struct mips_got_info *) bfd_alloc (abfd,
- sizeof (struct mips_got_info));
+ amt = sizeof (struct mips_got_info);
+ g = (struct mips_got_info *) bfd_alloc (abfd, amt);
if (g == NULL)
return false;
g->global_gotsym = NULL;
g->assigned_gotno = MIPS_RESERVED_GOTNO;
if (elf_section_data (s) == NULL)
{
- s->used_by_bfd =
- (PTR) bfd_zalloc (abfd, sizeof (struct bfd_elf_section_data));
+ amt = sizeof (struct bfd_elf_section_data);
+ s->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (elf_section_data (s) == NULL)
return false;
}
{
unsigned long symcount;
asection **n;
+ bfd_size_type amt;
if (elf_bad_symtab (abfd))
symcount = NUM_SHDR_ENTRIES (symtab_hdr);
else
symcount = symtab_hdr->sh_info;
- n = (asection **) bfd_zalloc (abfd,
- symcount * sizeof (asection *));
+ amt = symcount * sizeof (asection *);
+ n = (asection **) bfd_zalloc (abfd, amt);
if (n == NULL)
return false;
elf_tdata (abfd)->local_stubs = n;
for (rel = relocs; rel < rel_end; ++rel)
{
unsigned long r_symndx;
- int r_type;
+ unsigned int r_type;
struct elf_link_hash_entry *h;
r_symndx = ELF32_R_SYM (rel->r_info);
{
if (sreloc == NULL)
{
- const char *name = MIPS_ELF_REL_DYN_SECTION_NAME (dynobj);
+ const char *dname = MIPS_ELF_REL_DYN_SECTION_NAME (dynobj);
- sreloc = bfd_get_section_by_name (dynobj, name);
+ sreloc = bfd_get_section_by_name (dynobj, dname);
if (sreloc == NULL)
{
- sreloc = bfd_make_section (dynobj, name);
+ sreloc = bfd_make_section (dynobj, dname);
if (sreloc == NULL
|| ! bfd_set_section_flags (dynobj, sreloc,
(SEC_ALLOC
if (! info->relocateable
&& hmips->possibly_dynamic_relocs != 0
&& (h->root.type == bfd_link_hash_defweak
- || (h->elf_link_hash_flags
+ || (h->elf_link_hash_flags
& ELF_LINK_HASH_DEF_REGULAR) == 0))
{
mips_elf_allocate_dynamic_relocations (dynobj,
/* The .reginfo section has a fixed size. */
ri = bfd_get_section_by_name (output_bfd, ".reginfo");
if (ri != NULL)
- bfd_set_section_size (output_bfd, ri, sizeof (Elf32_External_RegInfo));
+ bfd_set_section_size (output_bfd, ri,
+ (bfd_size_type) sizeof (Elf32_External_RegInfo));
if (info->relocateable
|| ! mips_elf_hash_table (info)->mips16_stubs_seen)
{
if ((subsection->flags & SEC_ALLOC) == 0)
continue;
- loadable_size += (subsection->_raw_size + 0xf) & ~0xf;
+ loadable_size += ((subsection->_raw_size + 0xf)
+ &~ (bfd_size_type) 0xf);
}
}
loadable_size += MIPS_FUNCTION_STUB_SIZE;
/* Fill the stub. */
p = stub;
- bfd_put_32 (output_bfd, STUB_LW (output_bfd), p);
+ bfd_put_32 (output_bfd, (bfd_vma) STUB_LW (output_bfd), p);
p += 4;
- bfd_put_32 (output_bfd, STUB_MOVE (output_bfd), p);
+ bfd_put_32 (output_bfd, (bfd_vma) STUB_MOVE (output_bfd), p);
p += 4;
/* FIXME: Can h->dynindex be more than 64K? */
if (h->dynindx & 0xffff0000)
return false;
- bfd_put_32 (output_bfd, STUB_JALR, p);
+ bfd_put_32 (output_bfd, (bfd_vma) STUB_JALR, p);
p += 4;
- bfd_put_32 (output_bfd, STUB_LI16 (output_bfd) + h->dynindx, p);
+ bfd_put_32 (output_bfd, (bfd_vma) STUB_LI16 (output_bfd) + h->dynindx, p);
BFD_ASSERT (h->plt.offset <= s->_raw_size);
memcpy (s->contents + h->plt.offset, stub, MIPS_FUNCTION_STUB_SIZE);
case DT_MIPS_BASE_ADDRESS:
s = output_bfd->sections;
BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma & ~(0xffff);
+ dyn.d_un.d_ptr = s->vma & ~(bfd_vma) 0xffff;
break;
case DT_MIPS_LOCAL_GOTNO:
Elf_Internal_Note *note;
{
int offset;
- int raw_size;
+ unsigned int raw_size;
switch (note->descsz)
{
if (reloc_size < 0)
goto error_return;
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
+ reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
if (reloc_vector == NULL && reloc_size != 0)
goto error_return;
if (!bfd_get_section_contents (input_bfd,
input_section,
(PTR) data,
- 0,
+ (file_ptr) 0,
input_section->_raw_size))
goto error_return;
/* OpenRISC-specific support for 32-bit ELF.
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright 2001 Free Software Foundation, Inc.
Contributed by Johan Rydberg, jrydberg@opencores.org
This file is part of BFD, the Binary File Descriptor library.
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
static bfd_reloc_status_type openrisc_final_link_relocate
- PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
+ PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
Elf_Internal_Rela *, bfd_vma));
static boolean openrisc_elf_gc_sweep_hook
- PARAMS ((bfd *, struct bfd_link_info *, asection *,
+ PARAMS ((bfd *, struct bfd_link_info *, asection *,
const Elf_Internal_Rela *));
static asection * openrisc_elf_gc_mark_hook
PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
/* picoJava specific support for 32-bit ELF
- Copyright 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Steve Chamberlan of Transmeta (sac@pobox.com).
This file is part of BFD, the Binary File Descriptor library.
case R_PJ_DATA_DIR32:
insn = bfd_get_32 (abfd, hit_data);
insn += sym_value + reloc_entry->addend;
- bfd_put_32 (abfd, insn, hit_data);
+ bfd_put_32 (abfd, (bfd_vma) insn, hit_data);
break;
/* Relocations in code are always bigendian, no matter what the
case R_PJ_CODE_DIR32:
insn = bfd_getb32 (hit_data);
insn += sym_value + reloc_entry->addend;
- bfd_putb32 (insn, hit_data);
+ bfd_putb32 ((bfd_vma) insn, hit_data);
break;
case R_PJ_CODE_REL16:
insn += sym_value + reloc_entry->addend
- (input_section->output_section->vma
+ input_section->output_offset);
- bfd_putb16 (insn, hit_data);
+ bfd_putb16 ((bfd_vma) insn, hit_data);
break;
case R_PJ_CODE_LO16:
insn = bfd_getb16 (hit_data);
insn += sym_value + reloc_entry->addend;
- bfd_putb16 (insn, hit_data);
+ bfd_putb16 ((bfd_vma) insn, hit_data);
break;
case R_PJ_CODE_HI16:
insn = bfd_getb16 (hit_data);
insn += (sym_value + reloc_entry->addend) >> 16;
- bfd_putb16 (insn, hit_data);
+ bfd_putb16 ((bfd_vma) insn, hit_data);
break;
default:
if (isec->reloc_count)
{
unsigned n;
+ bfd_size_type amt;
/* Get a copy of the native relocations. */
internal_relocs = _bfd_elf32_link_read_relocs (
free_relocs = internal_relocs;
/* Setup a faster access method for the reloc info we need. */
- rela_comb = (Elf_Internal_Rela**)
- bfd_malloc (isec->reloc_count*sizeof (Elf_Internal_Rela*));
+ amt = isec->reloc_count;
+ amt *= sizeof (Elf_Internal_Rela*);
+ rela_comb = (Elf_Internal_Rela**) bfd_malloc (amt);
if (rela_comb == NULL)
goto error_return;
for (n = 0; n < isec->reloc_count; ++n)
#undef BO4
if (modified)
{
- bfd_put_32 (abfd, insn, contents + isec_offset);
+ bfd_put_32 (abfd, (bfd_vma) insn, contents + isec_offset);
section_modified = true;
}
}
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
- if (! info->shared)
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
+ if (!info->shared)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (plt)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf32_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
return false;
}
if ((info->flags & DF_TEXTREL) != 0)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
info->flags |= DF_TEXTREL;
}
}
+#undef add_dynamic_entry
return true;
}
/* This is a global offset table entry for a local symbol. */
if (local_got_refcounts == NULL)
{
- size_t size;
+ bfd_size_type size;
- size = symtab_hdr->sh_info * sizeof (bfd_signed_vma);
- local_got_refcounts = (bfd_signed_vma *)
- bfd_alloc (abfd, size);
+ size = symtab_hdr->sh_info;
+ size *= sizeof (bfd_signed_vma);
+ local_got_refcounts
+ = (bfd_signed_vma *) bfd_alloc (abfd, size);
if (local_got_refcounts == NULL)
return false;
elf_local_got_refcounts (abfd) = local_got_refcounts;
- memset (local_got_refcounts, -1, size);
+ memset (local_got_refcounts, -1, (size_t) size);
}
if (local_got_refcounts[r_symndx] == -1)
{
if (!sdata->bss_section)
{
+ bfd_size_type amt;
+
/* We don't go through bfd_make_section, because we don't
want to attach this common section to DYNOBJ. The linker
will move the symbols to the appropriate output section
when it defines common symbols. */
- sdata->bss_section = ((asection *)
- bfd_zalloc (abfd, sizeof (asection)));
+ amt = sizeof (asection);
+ sdata->bss_section = (asection *) bfd_zalloc (abfd, amt);
if (sdata->bss_section == NULL)
return false;
sdata->bss_section->name = sdata->bss_name;
sdata->bss_section->flags = SEC_IS_COMMON;
sdata->bss_section->output_section = sdata->bss_section;
- sdata->bss_section->symbol =
- (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ amt = sizeof (asymbol);
+ sdata->bss_section->symbol = (asymbol *) bfd_zalloc (abfd, amt);
+ amt = sizeof (asymbol *);
sdata->bss_section->symbol_ptr_ptr =
- (asymbol **) bfd_zalloc (abfd, sizeof (asymbol *));
+ (asymbol **) bfd_zalloc (abfd, amt);
if (sdata->bss_section->symbol == NULL
|| sdata->bss_section->symbol_ptr_ptr == NULL)
return false;
rela.r_offset = (sgot->output_section->vma
+ sgot->output_offset
- + (h->got.offset &~ 1));
+ + (h->got.offset &~ (bfd_vma) 1));
/* If this is a -Bsymbolic link, and the symbol is defined
locally, we just want to emit a RELATIVE reloc. The entry in
if (sgot)
{
unsigned char *contents = sgot->contents;
- bfd_put_32 (output_bfd, 0x4e800021 /* blrl */, contents);
+ bfd_put_32 (output_bfd, (bfd_vma) 0x4e800021 /* blrl */, contents);
if (sdyn == NULL)
bfd_put_32 (output_bfd, (bfd_vma) 0, contents+4);
insn &= ~BRANCH_PREDICT_BIT;
else
insn |= BRANCH_PREDICT_BIT;
- bfd_put_32 (output_bfd, insn, contents + offset);
+ bfd_put_32 (output_bfd, (bfd_vma) insn, contents + offset);
break;
/* branch not taken predicition relocations */
insn |= BRANCH_PREDICT_BIT;
else
insn &= ~BRANCH_PREDICT_BIT;
- bfd_put_32 (output_bfd, insn, contents + offset);
+ bfd_put_32 (output_bfd, (bfd_vma) insn, contents + offset);
break;
/* GOT16 relocations */
{ /* fill in register field */
insn = bfd_get_32 (output_bfd, contents + offset);
insn = (insn & ~RA_REGISTER_MASK) | (reg << RA_REGISTER_SHIFT);
- bfd_put_32 (output_bfd, insn, contents + offset);
+ bfd_put_32 (output_bfd, (bfd_vma) insn, contents + offset);
}
}
break;
Elf_Internal_Note *note;
{
int offset;
- int raw_size;
+ unsigned int raw_size;
switch (note->descsz)
{
static reloc_howto_type elf32_s390_vtinherit_howto =
HOWTO (R_390_GNU_VTINHERIT, 0,2,0,false,0,complain_overflow_dont, NULL, "R_390_GNU_VTINHERIT", false,0, 0, false);
static reloc_howto_type elf32_s390_vtentry_howto =
- HOWTO (R_390_GNU_VTENTRY, 0,2,0,false,0,complain_overflow_dont, _bfd_elf_rel_vtable_reloc_fn,"R_390_GNU_VTENTRY", false,0,0, false);
+ HOWTO (R_390_GNU_VTENTRY, 0,2,0,false,0,complain_overflow_dont, _bfd_elf_rel_vtable_reloc_fn,"R_390_GNU_VTENTRY", false,0,0, false);
static reloc_howto_type *
elf_s390_reloc_type_lookup (abfd, code)
case BFD_RELOC_VTABLE_ENTRY:
return &elf32_s390_vtentry_howto;
default:
- break;
+ break;
}
return 0;
}
default:
BFD_ASSERT (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_390_max);
cache_ptr->howto = &elf_howto_table[ELF32_R_TYPE(dst->r_info)];
- }
+ }
}
static boolean
/* The size in bytes of the first entry in the procedure linkage table. */
#define PLT_FIRST_ENTRY_SIZE 32
/* The size in bytes of an entry in the procedure linkage table. */
-#define PLT_ENTRY_SIZE 32
+#define PLT_ENTRY_SIZE 32
#define GOT_ENTRY_SIZE 4
are needed to load an address in a register and execute
a branch( or just saving the address)
- Furthermore, only r 0 and 1 are free to use!!! */
+ Furthermore, only r 0 and 1 are free to use!!! */
/* The first 3 words in the GOT are then reserved.
Word 0 is the address of the dynamic table.
The GOT holds the address in the PLT to be executed.
The loader then gets:
24(15) = Pointer to the structure describing the object.
- 28(15) = Offset in symbol table
+ 28(15) = Offset in symbol table
The loader must then find the module where the function is
and insert the address in the GOT.
PLT0:
ST 1,28(15) # R1 has offset into symbol table
L 1,4(12) # Get loader ino(object struct address)
- ST 1,24(15) # Store address
+ ST 1,24(15) # Store address
L 1,8(12) # Entry address of loader in R1
BR 1 # Jump to loader
bfd *abfd;
{
struct elf_s390_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct elf_s390_link_hash_table);
- ret = ((struct elf_s390_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf_s390_link_hash_table)));
+ ret = (struct elf_s390_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct elf_s390_link_hash_table *) NULL)
return NULL;
if (r_symndx < symtab_hdr->sh_info)
h = NULL;
else
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ h = sym_hashes[r_symndx - symtab_hdr->sh_info];
/* Some relocs require a global offset table. */
if (dynobj == NULL)
/* This is a global offset table entry for a local symbol. */
if (local_got_refcounts == NULL)
{
- size_t size;
+ bfd_size_type size;
- size = symtab_hdr->sh_info * sizeof (bfd_signed_vma);
+ size = symtab_hdr->sh_info;
+ size *= sizeof (bfd_signed_vma);
local_got_refcounts = (bfd_signed_vma *)
bfd_alloc (abfd, size);
if (local_got_refcounts == NULL)
return false;
elf_local_got_refcounts (abfd) = local_got_refcounts;
- memset (local_got_refcounts, -1, size);
+ memset (local_got_refcounts, -1, (size_t) size);
}
if (local_got_refcounts[r_symndx] == -1)
{
if (p == NULL)
{
p = ((struct elf_s390_pcrel_relocs_copied *)
- bfd_alloc (dynobj, sizeof *p));
+ bfd_alloc (dynobj, (bfd_size_type) sizeof *p));
if (p == NULL)
return false;
p->next = eh->pcrel_relocs_copied;
if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
return false;
break;
-
+
default:
break;
}
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
if (! info->shared)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (plt)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf32_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
return false;
}
if ((info->flags & DF_TEXTREL) != 0)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
info->flags |= DF_TEXTREL;
}
}
+#undef add_dynamic_entry
return true;
}
break;
-
+
case R_390_GOTOFF:
/* Relocation is relative to the start of the global offset
table. */
srela = bfd_get_section_by_name (dynobj, ".rela.plt");
BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
- /* Calc. index no.
+ /* Calc. index no.
Current offset - size first entry / entry size. */
plt_index = (h->plt.offset - PLT_FIRST_ENTRY_SIZE) / PLT_ENTRY_SIZE;
got_offset = (plt_index + 3) * GOT_ENTRY_SIZE;
/* S390 uses halfwords for relative branch calc! */
- relative_offset = - ((PLT_FIRST_ENTRY_SIZE +
- (PLT_ENTRY_SIZE * plt_index) + 18)/2);
+ relative_offset = - ((PLT_FIRST_ENTRY_SIZE +
+ (PLT_ENTRY_SIZE * plt_index) + 18) / 2);
/* If offset is > 32768, branch to a previous branch
390 can only handle +-64 K jumps. */
- if ( -32768 > (int)relative_offset )
- relative_offset = -(((65536/PLT_ENTRY_SIZE-1)*PLT_ENTRY_SIZE)/2);
+ if ( -32768 > (int) relative_offset )
+ relative_offset =
+ -(unsigned) (((65536 / PLT_ENTRY_SIZE - 1) * PLT_ENTRY_SIZE) / 2);
/* Fill in the entry in the procedure linkage table. */
if (!info->shared)
{
- bfd_put_32 (output_bfd, PLT_ENTRY_WORD0,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD0,
splt->contents + h->plt.offset);
- bfd_put_32 (output_bfd, PLT_ENTRY_WORD1,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD1,
splt->contents + h->plt.offset + 4);
- bfd_put_32 (output_bfd, PLT_ENTRY_WORD2,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD2,
splt->contents + h->plt.offset + 8);
- bfd_put_32 (output_bfd, PLT_ENTRY_WORD3,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD3,
splt->contents + h->plt.offset + 12);
- bfd_put_32 (output_bfd, PLT_ENTRY_WORD4,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD4,
splt->contents + h->plt.offset + 16);
- bfd_put_32 (output_bfd, 0+(relative_offset << 16),
+ bfd_put_32 (output_bfd, (bfd_vma) 0 + (relative_offset << 16),
splt->contents + h->plt.offset + 20);
bfd_put_32 (output_bfd,
- (sgot->output_section->vma +
- sgot->output_offset +
- got_offset),
+ (sgot->output_section->vma
+ + sgot->output_offset
+ + got_offset),
splt->contents + h->plt.offset + 24);
}
else if (got_offset < 4096)
{
- bfd_put_32 (output_bfd, PLT_PIC12_ENTRY_WORD0 + got_offset,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD0 + got_offset,
splt->contents + h->plt.offset);
- bfd_put_32 (output_bfd, PLT_PIC12_ENTRY_WORD1,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD1,
splt->contents + h->plt.offset + 4);
- bfd_put_32 (output_bfd, PLT_PIC12_ENTRY_WORD2,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD2,
splt->contents + h->plt.offset + 8);
- bfd_put_32 (output_bfd, PLT_PIC12_ENTRY_WORD3,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD3,
splt->contents + h->plt.offset + 12);
- bfd_put_32 (output_bfd, PLT_PIC12_ENTRY_WORD4,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC12_ENTRY_WORD4,
splt->contents + h->plt.offset + 16);
- bfd_put_32 (output_bfd, 0+(relative_offset << 16),
+ bfd_put_32 (output_bfd, (bfd_vma) 0 + (relative_offset << 16),
splt->contents + h->plt.offset + 20);
- bfd_put_32 (output_bfd, 0,
+ bfd_put_32 (output_bfd, (bfd_vma) 0,
splt->contents + h->plt.offset + 24);
}
else if (got_offset < 32768)
{
- bfd_put_32 (output_bfd, PLT_PIC16_ENTRY_WORD0 + got_offset,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD0 + got_offset,
splt->contents + h->plt.offset);
- bfd_put_32 (output_bfd, PLT_PIC16_ENTRY_WORD1,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD1,
splt->contents + h->plt.offset + 4);
- bfd_put_32 (output_bfd, PLT_PIC16_ENTRY_WORD2,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD2,
splt->contents + h->plt.offset + 8);
- bfd_put_32 (output_bfd, PLT_PIC16_ENTRY_WORD3,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD3,
splt->contents + h->plt.offset + 12);
- bfd_put_32 (output_bfd, PLT_PIC16_ENTRY_WORD4,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC16_ENTRY_WORD4,
splt->contents + h->plt.offset + 16);
- bfd_put_32 (output_bfd, 0+(relative_offset << 16),
+ bfd_put_32 (output_bfd, (bfd_vma) 0 + (relative_offset << 16),
splt->contents + h->plt.offset + 20);
- bfd_put_32 (output_bfd, 0,
+ bfd_put_32 (output_bfd, (bfd_vma) 0,
splt->contents + h->plt.offset + 24);
}
else
{
- bfd_put_32 (output_bfd, PLT_PIC_ENTRY_WORD0,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD0,
splt->contents + h->plt.offset);
- bfd_put_32 (output_bfd, PLT_PIC_ENTRY_WORD1,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD1,
splt->contents + h->plt.offset + 4);
- bfd_put_32 (output_bfd, PLT_PIC_ENTRY_WORD2,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD2,
splt->contents + h->plt.offset + 8);
- bfd_put_32 (output_bfd, PLT_PIC_ENTRY_WORD3,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD3,
splt->contents + h->plt.offset + 12);
- bfd_put_32 (output_bfd, PLT_PIC_ENTRY_WORD4,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD4,
splt->contents + h->plt.offset + 16);
- bfd_put_32 (output_bfd, 0+(relative_offset << 16),
+ bfd_put_32 (output_bfd, (bfd_vma) 0 + (relative_offset << 16),
splt->contents + h->plt.offset + 20);
bfd_put_32 (output_bfd, got_offset,
splt->contents + h->plt.offset + 24);
rela.r_offset = (sgot->output_section->vma
+ sgot->output_offset
- + (h->got.offset &~ 1));
+ + (h->got.offset &~ (bfd_vma) 1));
/* If this is a static link, or it is a -Bsymbolic link and the
symbol is defined locally or was forced to be local because
memset (splt->contents, 0, PLT_FIRST_ENTRY_SIZE);
if (info->shared)
{
- bfd_put_32 (output_bfd, PLT_PIC_FIRST_ENTRY_WORD0,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD0,
splt->contents );
- bfd_put_32 (output_bfd, PLT_PIC_FIRST_ENTRY_WORD1,
- splt->contents +4 );
- bfd_put_32 (output_bfd, PLT_PIC_FIRST_ENTRY_WORD2,
- splt->contents +8 );
- bfd_put_32 (output_bfd, PLT_PIC_FIRST_ENTRY_WORD3,
- splt->contents +12 );
- bfd_put_32 (output_bfd, PLT_PIC_FIRST_ENTRY_WORD4,
- splt->contents +16 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD1,
+ splt->contents + 4 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD2,
+ splt->contents + 8 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD3,
+ splt->contents + 12 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_FIRST_ENTRY_WORD4,
+ splt->contents + 16 );
}
else
{
- bfd_put_32 (output_bfd, PLT_FIRST_ENTRY_WORD0,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD0,
splt->contents );
- bfd_put_32 (output_bfd, PLT_FIRST_ENTRY_WORD1,
- splt->contents +4 );
- bfd_put_32 (output_bfd, PLT_FIRST_ENTRY_WORD2,
- splt->contents +8 );
- bfd_put_32 (output_bfd, PLT_FIRST_ENTRY_WORD3,
- splt->contents +12 );
- bfd_put_32 (output_bfd, PLT_FIRST_ENTRY_WORD4,
- splt->contents +16 );
- bfd_put_32 (output_bfd, PLT_FIRST_ENTRY_WORD5,
- splt->contents +20 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD1,
+ splt->contents + 4 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD2,
+ splt->contents + 8 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD3,
+ splt->contents + 12 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD4,
+ splt->contents + 16 );
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_FIRST_ENTRY_WORD5,
+ splt->contents + 20 );
bfd_put_32 (output_bfd,
sgot->output_section->vma + sgot->output_offset,
splt->contents + 24);
/* Hitachi SH specific support for 32-bit Linux
- Copyright 2000 Free Software Foundation, Inc.
+ Copyright 2000, 2001 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
Elf_Internal_Note *note;
{
int offset;
- int raw_size;
+ unsigned int raw_size;
switch (note->descsz)
{
contents = elf_section_data (symbol_section)->this_hdr.contents;
else
{
- free_contents = contents
- = (bfd_byte *) bfd_malloc (symbol_section->_raw_size);
+ contents = (bfd_byte *) bfd_malloc (symbol_section->_raw_size);
if (contents == NULL)
return bfd_reloc_outofrange;
+ free_contents = contents;
if (! bfd_get_section_contents (input_bfd, symbol_section, contents,
(file_ptr) 0,
symbol_section->_raw_size))
return bfd_reloc_overflow;
x = (insn & ~0xff) | (x & 0xff);
- bfd_put_16 (input_bfd, x, contents + addr);
+ bfd_put_16 (input_bfd, (bfd_vma) x, contents + addr);
return bfd_reloc_ok;
}
case R_SH_DIR32:
insn = bfd_get_32 (abfd, hit_data);
insn += sym_value + reloc_entry->addend;
- bfd_put_32 (abfd, insn, hit_data);
+ bfd_put_32 (abfd, (bfd_vma) insn, hit_data);
break;
case R_SH_IND12W:
insn = bfd_get_16 (abfd, hit_data);
if (insn & 0x800)
sym_value -= 0x1000;
insn = (insn & 0xf000) | (sym_value & 0xfff);
- bfd_put_16 (abfd, insn, hit_data);
+ bfd_put_16 (abfd, (bfd_vma) insn, hit_data);
if (sym_value < (bfd_vma) -0x1000 || sym_value >= 0x1000)
return bfd_reloc_overflow;
break;
on a four byte boundary. */
paddr = insn & 0xff;
paddr *= 4;
- paddr += (laddr + 4) & ~3;
+ paddr += (laddr + 4) &~ (bfd_vma) 3;
if (paddr >= sec->_raw_size)
{
((*_bfd_error_handler)
extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
- extsyms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_size));
+ extsyms = (Elf32_External_Sym *) bfd_malloc (symtab_hdr->sh_size);
if (extsyms == NULL)
goto error_return;
free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
+ || (bfd_bread (extsyms, symtab_hdr->sh_size, abfd)
!= symtab_hdr->sh_size))
goto error_return;
}
it will be handled here like other internal IND12W
relocs. */
bfd_put_16 (abfd,
- 0xb000 | ((foff >> 1) & 0xfff),
+ (bfd_vma) 0xb000 | ((foff >> 1) & 0xfff),
contents + irel->r_offset);
}
else
/* We can't fully resolve this yet, because the external
symbol value may be changed by future relaxing. We let
the final link phase handle it. */
- bfd_put_16 (abfd, 0xb000, contents + irel->r_offset);
+ bfd_put_16 (abfd, (bfd_vma) 0xb000, contents + irel->r_offset);
}
/* See if there is another R_SH_USES reloc referring to the same
}
/* Actually delete the bytes. */
- memmove (contents + addr, contents + addr + count, toaddr - addr - count);
+ memmove (contents + addr, contents + addr + count,
+ (size_t) (toaddr - addr - count));
if (irelalign == NULL)
sec->_cooked_size -= count;
else
BFD_ASSERT ((count & 1) == 0);
for (i = 0; i < count; i += 2)
- bfd_put_16 (abfd, NOP_OPCODE, contents + toaddr - count + i);
+ bfd_put_16 (abfd, (bfd_vma) NOP_OPCODE, contents + toaddr - count + i);
}
/* Adjust all the relocs. */
insn += adjust / 2;
if ((oinsn & 0xff00) != (insn & 0xff00))
overflow = true;
- bfd_put_16 (abfd, insn, contents + nraddr);
+ bfd_put_16 (abfd, (bfd_vma) insn, contents + nraddr);
break;
case R_SH_IND12W:
insn += adjust / 2;
if ((oinsn & 0xf000) != (insn & 0xf000))
overflow = true;
- bfd_put_16 (abfd, insn, contents + nraddr);
+ bfd_put_16 (abfd, (bfd_vma) insn, contents + nraddr);
break;
case R_SH_DIR8WPL:
}
if ((oinsn & 0xff00) != (insn & 0xff00))
overflow = true;
- bfd_put_16 (abfd, insn, contents + nraddr);
+ bfd_put_16 (abfd, (bfd_vma) insn, contents + nraddr);
break;
case R_SH_SWITCH8:
voff += adjust;
if (voff < - 0x8000 || voff >= 0x8000)
overflow = true;
- bfd_put_signed_16 (abfd, voff, contents + nraddr);
+ bfd_put_signed_16 (abfd, (bfd_vma) voff, contents + nraddr);
break;
case R_SH_SWITCH32:
voff += adjust;
- bfd_put_signed_32 (abfd, voff, contents + nraddr);
+ bfd_put_signed_32 (abfd, (bfd_vma) voff, contents + nraddr);
break;
case R_SH_USES:
if (start > addr
&& start < toaddr
&& (stop <= addr || stop >= toaddr))
- bfd_put_signed_32 (abfd, voff + count,
+ bfd_put_signed_32 (abfd, (bfd_vma) voff + count,
ocontents + irelscan->r_offset);
else if (stop > addr
&& stop < toaddr
&& (start <= addr || start >= toaddr))
- bfd_put_signed_32 (abfd, voff - count,
+ bfd_put_signed_32 (abfd, (bfd_vma) voff - count,
ocontents + irelscan->r_offset);
}
{
/* Tail recursion. */
return sh_elf_relax_delete_bytes (abfd, sec, alignaddr,
- alignto - alignaddr);
+ (int) (alignto - alignaddr));
}
}
Elf_Internal_Rela *irel, *irelend;
bfd_vma *labels = NULL;
bfd_vma *label, *label_end;
+ bfd_size_type amt;
*pswapped = false;
irelend = internal_relocs + sec->reloc_count;
/* Get all the addresses with labels on them. */
- labels = (bfd_vma *) bfd_malloc (sec->reloc_count * sizeof (bfd_vma));
+ amt = sec->reloc_count;
+ amt *= sizeof (bfd_vma);
+ labels = (bfd_vma *) bfd_malloc (amt);
if (labels == NULL)
goto error_return;
label_end = labels;
/* Swap the instructions themselves. */
i1 = bfd_get_16 (abfd, contents + addr);
i2 = bfd_get_16 (abfd, contents + addr + 2);
- bfd_put_16 (abfd, i2, contents + addr);
- bfd_put_16 (abfd, i1, contents + addr + 2);
+ bfd_put_16 (abfd, (bfd_vma) i2, contents + addr);
+ bfd_put_16 (abfd, (bfd_vma) i1, contents + addr + 2);
/* Adjust all reloc addresses. */
irelend = internal_relocs + sec->reloc_count;
insn += add / 2;
if ((oinsn & 0xff00) != (insn & 0xff00))
overflow = true;
- bfd_put_16 (abfd, insn, loc);
+ bfd_put_16 (abfd, (bfd_vma) insn, loc);
break;
case R_SH_IND12W:
insn += add / 2;
if ((oinsn & 0xf000) != (insn & 0xf000))
overflow = true;
- bfd_put_16 (abfd, insn, loc);
+ bfd_put_16 (abfd, (bfd_vma) insn, loc);
break;
case R_SH_DIR8WPL:
insn += add / 2;
if ((oinsn & 0xff00) != (insn & 0xff00))
overflow = true;
- bfd_put_16 (abfd, insn, loc);
+ bfd_put_16 (abfd, (bfd_vma) insn, loc);
}
break;
bfd *abfd;
{
struct elf_sh_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct elf_sh_link_hash_table);
- ret = ((struct elf_sh_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf_sh_link_hash_table)));
+ ret = (struct elf_sh_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct elf_sh_link_hash_table *) NULL)
return NULL;
|| ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
continue;
secname = bfd_get_section_name (abfd, sec);
- relname = (char *) bfd_malloc (strlen (secname) + 6);
+ relname = (char *) bfd_malloc ((bfd_size_type) strlen (secname) + 6);
strcpy (relname, ".rela");
strcat (relname, secname);
s = bfd_make_section (abfd, relname);
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
if (! info->shared)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (plt)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf32_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
return false;
}
if ((info->flags & DF_TEXTREL) != 0)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
}
}
+#undef add_dynamic_entry
return true;
}
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
memcpy (data, elf_section_data (input_section)->this_hdr.contents,
- input_section->_raw_size);
+ (size_t) input_section->_raw_size);
if ((input_section->flags & SEC_RELOC) != 0
&& input_section->reloc_count > 0)
Elf_Internal_Sym *isymp;
asection **secpp;
Elf32_External_Sym *esym, *esymend;
+ bfd_size_type size;
if (symtab_hdr->contents != NULL)
external_syms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
- external_syms = ((Elf32_External_Sym *)
- bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf32_External_Sym)));
- if (external_syms == NULL && symtab_hdr->sh_info > 0)
+ size = symtab_hdr->sh_info;
+ size *= sizeof (Elf32_External_Sym);
+ external_syms = (Elf32_External_Sym *) bfd_malloc (size);
+ if (external_syms == NULL && size != 0)
goto error_return;
if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (external_syms, sizeof (Elf32_External_Sym),
- symtab_hdr->sh_info, input_bfd)
- != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym))))
+ || bfd_bread (external_syms, size, input_bfd) != size)
goto error_return;
}
if (internal_relocs == NULL)
goto error_return;
- internal_syms = ((Elf_Internal_Sym *)
- bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf_Internal_Sym)));
+ size = symtab_hdr->sh_info;
+ size *= sizeof (Elf_Internal_Sym);
+ internal_syms = (Elf_Internal_Sym *) bfd_malloc (size);
if (internal_syms == NULL && symtab_hdr->sh_info > 0)
goto error_return;
- sections = (asection **) bfd_malloc (symtab_hdr->sh_info
- * sizeof (asection *));
+ size = symtab_hdr->sh_info;
+ size *= sizeof (asection *);
+ sections = (asection **) bfd_malloc (size);
if (sections == NULL && symtab_hdr->sh_info > 0)
goto error_return;
symbol. */
if (local_got_offsets == NULL)
{
- size_t size;
+ bfd_size_type size;
register unsigned int i;
- size = symtab_hdr->sh_info * sizeof (bfd_vma);
+ size = symtab_hdr->sh_info;
+ size *= sizeof (bfd_vma);
local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
if (local_got_offsets == NULL)
return false;
if (p == NULL)
{
p = ((struct elf_sh_pcrel_relocs_copied *)
- bfd_alloc (dynobj, sizeof *p));
+ bfd_alloc (dynobj, (bfd_size_type) sizeof *p));
if (p == NULL)
return false;
p->next = eh->pcrel_relocs_copied;
rel.r_offset = (sgot->output_section->vma
+ sgot->output_offset
- + (h->got.offset &~ 1));
+ + (h->got.offset &~ (bfd_vma) 1));
/* If this is a -Bsymbolic link, and the symbol is defined
locally, we just want to emit a RELATIVE reloc. Likewise if
unsigned char elf_reloc_val;
};
-static CONST struct elf_reloc_map sparc_reloc_map[] =
+static const struct elf_reloc_map sparc_reloc_map[] =
{
{ BFD_RELOC_NONE, R_SPARC_NONE, },
{ BFD_RELOC_16, R_SPARC_16, },
symbol. */
if (local_got_offsets == NULL)
{
- size_t size;
+ bfd_size_type size;
register unsigned int i;
- size = symtab_hdr->sh_info * sizeof (bfd_vma);
+ size = symtab_hdr->sh_info;
+ size *= sizeof (bfd_vma);
local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
if (local_got_offsets == NULL)
return false;
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
- if (! info->shared)
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
+ if (!info->shared)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (relplt)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
- if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf32_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
return false;
if (info->flags & DF_TEXTREL)
{
- if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
}
}
+#undef add_dynamic_entry
return true;
}
|| reg == G0 || reg == O7)
break;
- bfd_put_32 (input_bfd, INSN_NOP,
+ bfd_put_32 (input_bfd, (bfd_vma) INSN_NOP,
contents + rel->r_offset + 4);
}
(PLT_ENTRY_WORD1
+ (((- (h->plt.offset + 4)) >> 2) & 0x3fffff)),
splt->contents + h->plt.offset + 4);
- bfd_put_32 (output_bfd, PLT_ENTRY_WORD2,
+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD2,
splt->contents + h->plt.offset + 8);
/* Fill in the entry in the .rela.plt section. */
rela.r_offset = (sgot->output_section->vma
+ sgot->output_offset
- + (h->got.offset &~ 1));
+ + (h->got.offset &~ (bfd_vma) 1));
/* If this is a -Bsymbolic link, and the symbol is defined
locally, we just want to emit a RELATIVE reloc. Likewise if
if (splt->_raw_size > 0)
{
memset (splt->contents, 0, 4 * PLT_ENTRY_SIZE);
- bfd_put_32 (output_bfd, SPARC_NOP,
+ bfd_put_32 (output_bfd, (bfd_vma) SPARC_NOP,
splt->contents + splt->_raw_size - 4);
}
#include "libiberty.h"
/* Sign-extend a 24-bit number. */
-#define SEXT24(x) ((((x) & 0xffffff) ^ (~ 0x7fffff)) + 0x800000)
+#define SEXT24(x) ((((x) & 0xffffff) ^ 0x800000) - 0x800000)
static reloc_howto_type *v850_elf_reloc_type_lookup
PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
PARAMS((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
static bfd_reloc_status_type v850_elf_perform_relocation
- PARAMS ((bfd *, int, bfd_vma, bfd_byte *));
+ PARAMS ((bfd *, unsigned int, bfd_vma, bfd_byte *));
static boolean v850_elf_check_relocs
PARAMS ((bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *));
static void remember_hi16s_reloc
if (v850_elf_reloc_map[i].bfd_reloc_val == code)
{
unsigned int elf_reloc_val = v850_elf_reloc_map[i].elf_reloc_val;
-
+
BFD_ASSERT (v850_elf_howto_table[elf_reloc_val].type == elf_reloc_val);
return v850_elf_howto_table + elf_reloc_val;
sprintf (buff, msg, h->root.root.string);
info->callbacks->warning (info, buff, h->root.root.string,
- abfd, h->root.u.def.section, 0);
+ abfd, h->root.u.def.section,
+ (bfd_vma) 0);
bfd_set_error (bfd_error_bad_value);
h->other |= V850_OTHER_ERROR;
bfd_byte * address;
{
hi16s_location * entry = NULL;
+ bfd_size_type amt = sizeof (* free_hi16s);
/* Find a free structure. */
if (free_hi16s == NULL)
- free_hi16s = (hi16s_location *) bfd_zalloc (abfd, sizeof (* free_hi16s));
+ free_hi16s = (hi16s_location *) bfd_zalloc (abfd, amt);
entry = free_hi16s;
free_hi16s = free_hi16s->next;
static bfd_reloc_status_type
v850_elf_perform_relocation (abfd, r_type, addend, address)
- bfd * abfd;
- int r_type;
- bfd_vma addend;
- bfd_byte * address;
+ bfd *abfd;
+ unsigned int r_type;
+ bfd_vma addend;
+ bfd_byte *address;
{
unsigned long insn;
bfd_signed_vma saddend = (bfd_signed_vma) addend;
insn = bfd_get_32 (abfd, address);
insn &= ~0xfffe003f;
insn |= (((addend & 0xfffe) << 16) | ((addend & 0x3f0000) >> 16));
- bfd_put_32 (abfd, insn, address);
+ bfd_put_32 (abfd, (bfd_vma) insn, address);
return bfd_reloc_ok;
case R_V850_9_PCREL:
{
insn = bfd_get_16 (abfd, hi16s_address);
insn += 1;
- bfd_put_16 (abfd, insn, hi16s_address);
+ bfd_put_16 (abfd, (bfd_vma) insn, hi16s_address);
}
}
else
if (addend & 1)
return bfd_reloc_dangerous;
- insn = (addend & ~1) | (insn & 1);
+ insn = (addend &~ (bfd_vma) 1) | (insn & 1);
break;
case R_V850_TDA_6_8_OFFSET:
insn &= 0x0001ffdf;
insn |= (addend & 1) << 5;
- insn |= (addend & ~1) << 16;
+ insn |= (addend &~ (bfd_vma) 1) << 16;
- bfd_put_32 (abfd, insn, address);
+ bfd_put_32 (abfd, (bfd_vma) insn, address);
return bfd_reloc_ok;
case R_V850_CALLT_6_7_OFFSET:
}
- bfd_put_16 (abfd, insn, address);
+ bfd_put_16 (abfd, (bfd_vma) insn, address);
return bfd_reloc_ok;
}
\f
.text
.globl _start
nop
- _start:
+ _start:
jr foo
.section ".foo","ax"
asection * sym_sec;
int is_local ATTRIBUTE_UNUSED;
{
- unsigned long r_type = howto->type;
+ unsigned int r_type = howto->type;
bfd_byte * hit_data = contents + offset;
/* Adjust the value according to the relocation. */
if (sym_hashes == NULL)
{
info->callbacks->warning
- (info, "no hash table available", NULL, input_bfd, input_section, 0);
+ (info, "no hash table available",
+ NULL, input_bfd, input_section, (bfd_vma) 0);
return false;
}
bfd *gotobj;
/* the addend in effect for this entry. */
- bfd_signed_vma addend;
+ bfd_vma addend;
/* the .got offset for this entry. */
int got_offset;
bfd *abfd;
{
struct alpha_elf_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct alpha_elf_link_hash_table);
- ret = ((struct alpha_elf_link_hash_table *)
- bfd_zalloc (abfd, sizeof (struct alpha_elf_link_hash_table)));
+ ret = (struct alpha_elf_link_hash_table *) bfd_zalloc (abfd, amt);
if (ret == (struct alpha_elf_link_hash_table *) NULL)
return NULL;
elf64_alpha_mkobject (abfd)
bfd *abfd;
{
- abfd->tdata.any = bfd_zalloc (abfd, sizeof (struct alpha_elf_obj_tdata));
+ bfd_size_type amt = sizeof (struct alpha_elf_obj_tdata);
+ abfd->tdata.any = bfd_zalloc (abfd, amt);
if (abfd->tdata.any == NULL)
return false;
return true;
{
/* Allocate our special target data. */
struct alpha_elf_obj_tdata *new_tdata;
- new_tdata = bfd_zalloc (abfd, sizeof (struct alpha_elf_obj_tdata));
+ bfd_size_type amt = sizeof (struct alpha_elf_obj_tdata);
+ new_tdata = bfd_zalloc (abfd, amt);
if (new_tdata == NULL)
return false;
new_tdata->root = *abfd->tdata.elf_obj_data;
| (((gpdisp >> 16) + ((gpdisp >> 15) & 1)) & 0xffff));
i_lda = (i_lda & 0xffff0000) | (gpdisp & 0xffff);
- bfd_put_32 (abfd, i_ldah, p_ldah);
- bfd_put_32 (abfd, i_lda, p_lda);
+ bfd_put_32 (abfd, (bfd_vma) i_ldah, p_ldah);
+ bfd_put_32 (abfd, (bfd_vma) i_lda, p_lda);
return ret;
}
urel->r_addend = irel->r_addend;
info->changed_relocs = true;
- bfd_put_32 (info->abfd, insn, info->contents + urel->r_offset);
+ bfd_put_32 (info->abfd, (bfd_vma) insn,
+ info->contents + urel->r_offset);
info->changed_contents = true;
}
irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
R_ALPHA_GPRELHIGH);
lit_insn = (OP_LDAH << 26) | (lit_insn & 0x03ff0000);
- bfd_put_32 (info->abfd, lit_insn,
+ bfd_put_32 (info->abfd, (bfd_vma) lit_insn,
info->contents + irel->r_offset);
lit_reused = true;
info->changed_contents = true;
/* FIXME: sanity check the insn for byte op. Check that the
literal dest reg is indeed Rb in the byte insn. */
- insn = (insn & ~0x001ff000) | ((symval & 7) << 13) | 0x1000;
+ insn &= ~ (unsigned) 0x001ff000;
+ insn |= ((symval & 7) << 13) | 0x1000;
urel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
urel->r_addend = 0;
info->changed_relocs = true;
- bfd_put_32 (info->abfd, insn, info->contents + urel->r_offset);
+ bfd_put_32 (info->abfd, (bfd_vma) insn,
+ info->contents + urel->r_offset);
info->changed_contents = true;
break;
else
all_optimized = false;
- bfd_put_32 (info->abfd, insn, info->contents + urel->r_offset);
+ bfd_put_32 (info->abfd, (bfd_vma) insn,
+ info->contents + urel->r_offset);
/* Kill any HINT reloc that might exist for this insn. */
xrel = (elf64_alpha_find_reloc_at_ofs
In that case the insn would use $27 as the base. */
if (ldah == 0x27ba0000 && lda == 0x23bd0000)
{
- bfd_put_32 (info->abfd, INSN_UNOP, p_ldah);
- bfd_put_32 (info->abfd, INSN_UNOP, p_lda);
+ bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, p_ldah);
+ bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP, p_lda);
gpdisp->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
info->changed_contents = true;
irel->r_info = ELF64_R_INFO (0, R_ALPHA_NONE);
info->changed_relocs = true;
- bfd_put_32 (info->abfd, INSN_UNOP, info->contents + irel->r_offset);
+ bfd_put_32 (info->abfd, (bfd_vma) INSN_UNOP,
+ info->contents + irel->r_offset);
info->changed_contents = true;
}
}
`ldq R,X(gp)' for `lda R,Y(gp)'. */
insn = (OP_LDA << 26) | (insn & 0x03ff0000);
- bfd_put_32 (info->abfd, insn, info->contents + irel->r_offset);
+ bfd_put_32 (info->abfd, (bfd_vma) insn, info->contents + irel->r_offset);
info->changed_contents = true;
irel->r_info = ELF64_R_INFO (ELF64_R_SYM (irel->r_info), R_ALPHA_GPREL16);
extsyms = (Elf64_External_Sym *) symtab_hdr->contents;
else
{
- extsyms = ((Elf64_External_Sym *)
- bfd_malloc (symtab_hdr->sh_size));
+ extsyms = (Elf64_External_Sym *) bfd_malloc (symtab_hdr->sh_size);
if (extsyms == NULL)
goto error_return;
free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
+ || (bfd_bread (extsyms, symtab_hdr->sh_size, abfd)
!= symtab_hdr->sh_size))
goto error_return;
}
\f
/* PLT/GOT Stuff */
#define PLT_HEADER_SIZE 32
-#define PLT_HEADER_WORD1 0xc3600000 /* br $27,.+4 */
-#define PLT_HEADER_WORD2 0xa77b000c /* ldq $27,12($27) */
-#define PLT_HEADER_WORD3 0x47ff041f /* nop */
-#define PLT_HEADER_WORD4 0x6b7b0000 /* jmp $27,($27) */
+#define PLT_HEADER_WORD1 (bfd_vma) 0xc3600000 /* br $27,.+4 */
+#define PLT_HEADER_WORD2 (bfd_vma) 0xa77b000c /* ldq $27,12($27) */
+#define PLT_HEADER_WORD3 (bfd_vma) 0x47ff041f /* nop */
+#define PLT_HEADER_WORD4 (bfd_vma) 0x6b7b0000 /* jmp $27,($27) */
#define PLT_ENTRY_SIZE 12
#define PLT_ENTRY_WORD1 0xc3800000 /* br $28, plt0 */
swap = get_elf_backend_data (abfd)->elf_backend_ecoff_debug_swap;
memset (debug, 0, sizeof (*debug));
- ext_hdr = (char *) bfd_malloc ((size_t) swap->external_hdr_size);
+ ext_hdr = (char *) bfd_malloc (swap->external_hdr_size);
if (ext_hdr == NULL && swap->external_hdr_size != 0)
goto error_return;
debug->ptr = NULL; \
else \
{ \
- debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \
+ bfd_size_type amt = (bfd_size_type) size * symhdr->count; \
+ debug->ptr = (type) bfd_malloc (amt); \
if (debug->ptr == NULL) \
goto error_return; \
if (bfd_seek (abfd, (file_ptr) symhdr->offset, SEEK_SET) != 0 \
- || (bfd_read (debug->ptr, size, symhdr->count, \
- abfd) != size * symhdr->count)) \
+ || bfd_bread (debug->ptr, amt, abfd) != amt) \
goto error_return; \
}
char *fraw_src;
char *fraw_end;
struct fdr *fdr_ptr;
+ bfd_size_type amt = sizeof (struct mips_elf_find_line);
- fi = ((struct mips_elf_find_line *)
- bfd_zalloc (abfd, sizeof (struct mips_elf_find_line)));
+ fi = (struct mips_elf_find_line *) bfd_zalloc (abfd, amt);
if (fi == NULL)
{
msec->flags = origflags;
}
/* Swap in the FDR information. */
- fi->d.fdr = ((struct fdr *)
- bfd_alloc (abfd,
- (fi->d.symbolic_header.ifdMax *
- sizeof (struct fdr))));
+ amt = fi->d.symbolic_header.ifdMax * sizeof (struct fdr);
+ fi->d.fdr = (struct fdr *) bfd_alloc (abfd, amt);
if (fi->d.fdr == NULL)
{
msec->flags = origflags;
struct alpha_elf_got_entry **local_got_entries;
const Elf_Internal_Rela *rel, *relend;
int got_created;
+ bfd_size_type amt;
if (info->relocateable)
return true;
if (!gotent)
{
+ amt = sizeof (struct alpha_elf_got_entry);
gotent = ((struct alpha_elf_got_entry *)
- bfd_alloc (abfd,
- sizeof (struct alpha_elf_got_entry)));
+ bfd_alloc (abfd, amt));
if (!gotent)
return false;
/* This is a local .got entry -- record for merge. */
if (!local_got_entries)
{
- size_t size;
- size = (symtab_hdr->sh_info
- * sizeof (struct alpha_elf_got_entry *));
+ bfd_size_type size;
+ size = symtab_hdr->sh_info;
+ size *= sizeof (struct alpha_elf_got_entry *);
local_got_entries = ((struct alpha_elf_got_entry **)
bfd_alloc (abfd, size));
if (!local_got_entries)
return false;
- memset (local_got_entries, 0, size);
+ memset (local_got_entries, 0, (size_t) size);
alpha_elf_tdata (abfd)->local_got_entries =
local_got_entries;
}
continue;
if (!gotent)
{
+ amt = sizeof (struct alpha_elf_got_entry);
gotent = ((struct alpha_elf_got_entry *)
- bfd_alloc (abfd,
- sizeof (struct alpha_elf_got_entry)));
+ bfd_alloc (abfd, amt));
if (!gotent)
return false;
sreloc = bfd_get_section_by_name (dynobj, rel_sec_name);
if (sreloc == NULL)
{
+ flagword flags;
+
sreloc = bfd_make_section (dynobj, rel_sec_name);
+ flags = (SEC_HAS_CONTENTS | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED | SEC_READONLY);
+ if (sec->flags & SEC_ALLOC)
+ flags |= SEC_ALLOC | SEC_LOAD;
if (sreloc == NULL
- || !bfd_set_section_flags (dynobj, sreloc,
- (((sec->flags
- & SEC_ALLOC)
- ? (SEC_ALLOC
- | SEC_LOAD) : 0)
- | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY
- | SEC_LINKER_CREATED
- | SEC_READONLY))
+ || !bfd_set_section_flags (dynobj, sreloc, flags)
|| !bfd_set_section_alignment (dynobj, sreloc, 3))
return false;
}
if (!rent)
{
- rent = ((struct alpha_elf_reloc_entry *)
- bfd_alloc (abfd,
- sizeof (struct alpha_elf_reloc_entry)));
+ amt = sizeof (struct alpha_elf_reloc_entry);
+ rent = (struct alpha_elf_reloc_entry *) bfd_alloc (abfd, amt);
if (!rent)
return false;
else
{
/* Allocate memory for the section contents. */
- s->contents = (bfd_byte *) bfd_zalloc(dynobj, s->_raw_size);
+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
if (s->contents == NULL && s->_raw_size != 0)
return false;
}
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
if (!info->shared)
{
- if (!bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
- if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0))
return false;
if (relplt)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
- if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf64_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
return false;
if (info->flags & DF_TEXTREL)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
}
}
+#undef add_dynamic_entry
return true;
}
struct alpha_elf_link_hash_entry *h;
Elf_Internal_Sym *sym;
bfd_vma relocation;
- bfd_signed_vma addend;
+ bfd_vma addend;
bfd_reloc_status_type r;
r_type = ELF64_R_TYPE(rel->r_info);
/* Initialize the .got entry's value. */
if (!(gotent->flags & ALPHA_ELF_GOT_ENTRY_RELOCS_DONE))
{
- bfd_put_64 (output_bfd, relocation+addend,
+ bfd_put_64 (output_bfd, relocation + addend,
sgot->contents + gotent->got_offset);
/* If the symbol has been forced local, output a
+ sgot->output_offset
+ gotent->got_offset);
outrel.r_info = ELF64_R_INFO(0, R_ALPHA_RELATIVE);
- outrel.r_addend = relocation+addend;
+ outrel.r_addend = relocation + addend;
bfd_elf64_swap_reloca_out (output_bfd, &outrel,
((Elf64_External_Rela *)
/* Fill in the entry in the procedure linkage table. */
{
- unsigned insn1, insn2, insn3;
+ bfd_vma insn1, insn2, insn3;
insn1 = PLT_ENTRY_WORD1 | ((-(h->plt.offset + 4) >> 2) & 0x1fffff);
insn2 = PLT_ENTRY_WORD2;
bfd_put_32 (output_bfd, PLT_HEADER_WORD4, splt->contents + 12);
/* The next two words will be filled in by ld.so */
- bfd_put_64 (output_bfd, 0, splt->contents + 16);
- bfd_put_64 (output_bfd, 0, splt->contents + 24);
+ bfd_put_64 (output_bfd, (bfd_vma) 0, splt->contents + 16);
+ bfd_put_64 (output_bfd, (bfd_vma) 0, splt->contents + 24);
elf_section_data (splt->output_section)->this_hdr.sh_entsize =
PLT_HEADER_SIZE;
sgot = alpha_elf_tdata(i)->got;
if (! bfd_set_section_contents (abfd, sgot->output_section,
- sgot->contents, sgot->output_offset,
+ sgot->contents,
+ (file_ptr) sgot->output_offset,
sgot->_raw_size))
return false;
}
/* The index of the (possibly local) symbol in the input bfd and its
associated BFD. Needed so that we can have relocs against local
symbols in shared libraries. */
- unsigned long sym_indx;
+ long sym_indx;
bfd *owner;
/* Dynamic symbols may need to have two different values. One for
{
struct elf64_hppa_link_hash_table *ret;
- ret = bfd_zalloc (abfd, sizeof (*ret));
+ ret = bfd_zalloc (abfd, (bfd_size_type) sizeof (*ret));
if (!ret)
return 0;
if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
struct elf64_hppa_dyn_reloc_entry *rent;
rent = (struct elf64_hppa_dyn_reloc_entry *)
- bfd_alloc (abfd, sizeof (*rent));
+ bfd_alloc (abfd, (bfd_size_type) sizeof (*rent));
if (!rent)
return false;
int highest_shndx;
Elf_Internal_Sym *local_syms, *isym;
Elf64_External_Sym *ext_syms, *esym;
+ bfd_size_type amt;
/* We're done with the old cache of section index to section symbol
index information. Free it.
free (hppa_info->section_syms);
/* Allocate memory for the internal and external symbols. */
- local_syms
- = (Elf_Internal_Sym *) bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf_Internal_Sym));
+ amt = symtab_hdr->sh_info;
+ amt *= sizeof (Elf_Internal_Sym);
+ local_syms = (Elf_Internal_Sym *) bfd_malloc (amt);
if (local_syms == NULL)
return false;
- ext_syms
- = (Elf64_External_Sym *) bfd_malloc (symtab_hdr->sh_info
- * sizeof (Elf64_External_Sym));
+ amt = symtab_hdr->sh_info;
+ amt *= sizeof (Elf64_External_Sym);
+ ext_syms = (Elf64_External_Sym *) bfd_malloc (amt);
if (ext_syms == NULL)
{
free (local_syms);
/* Read in the local symbols. */
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || bfd_read (ext_syms, 1,
- (symtab_hdr->sh_info
- * sizeof (Elf64_External_Sym)), abfd)
- != (symtab_hdr->sh_info * sizeof (Elf64_External_Sym)))
+ || bfd_bread (ext_syms, amt, abfd) != amt)
{
free (local_syms);
free (ext_syms);
/* Allocate an array to hold the section index to section symbol index
mapping. Bump by one since we start counting at zero. */
highest_shndx++;
- hppa_info->section_syms = (int *) bfd_malloc (highest_shndx
- * sizeof (int));
+ amt = highest_shndx;
+ amt *= sizeof (int);
+ hppa_info->section_syms = (int *) bfd_malloc (amt);
/* Now walk the local symbols again. If we find a section symbol,
record the index of the symbol into the section_syms array. */
bfd *owner;
owner = (h ? h->root.u.def.section->owner : dyn_h->owner);
- if (!_bfd_elf64_link_record_local_dynamic_symbol
- (x->info, owner, dyn_h->sym_indx))
+ if (! (_bfd_elf64_link_record_local_dynamic_symbol
+ (x->info, owner, dyn_h->sym_indx)))
return false;
}
}
/* Always create a DT_PLTGOT. It actually has nothing to do with
the PLT, it is how we communicate the __gp value of a load
module to the dynamic linker. */
- if (! bfd_elf64_add_dynamic_entry (info, DT_HP_DLD_FLAGS, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0))
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
+ if (!add_dynamic_entry (DT_HP_DLD_FLAGS, 0)
+ || !add_dynamic_entry (DT_PLTGOT, 0))
return false;
/* Add some entries to the .dynamic section. We fill in the
dynamic linker and used by the debugger. */
if (! info->shared)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_HP_DLD_HOOK, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_HP_LOAD_MAP, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0)
+ || !add_dynamic_entry (DT_HP_DLD_HOOK, 0)
+ || !add_dynamic_entry (DT_HP_LOAD_MAP, 0))
return false;
}
if (plt)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf64_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
return false;
}
if (reltext)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
info->flags |= DF_TEXTREL;
}
}
+#undef add_dynamic_entry
return true;
}
/* Wide mode allows 16 bit offsets. */
max_offset = 32768;
insn &= ~ 0xfff1;
- insn |= re_assemble_16 (value);
+ insn |= re_assemble_16 ((int) value);
}
else
{
max_offset = 8192;
insn &= ~ 0x3ff1;
- insn |= re_assemble_14 (value);
+ insn |= re_assemble_14 ((int) value);
}
if ((value & 7) || value + max_offset >= 2*max_offset - 8)
return false;
}
- bfd_put_32 (stub->owner, insn,
+ bfd_put_32 (stub->owner, (bfd_vma) insn,
stub->contents + dyn_h->stub_offset);
/* Fix up the second ldd instruction. */
if (output_bfd->arch_info->mach >= 25)
{
insn &= ~ 0xfff1;
- insn |= re_assemble_16 (value);
+ insn |= re_assemble_16 ((int) value);
}
else
{
insn &= ~ 0x3ff1;
- insn |= re_assemble_14 (value);
+ insn |= re_assemble_14 ((int) value);
}
- bfd_put_32 (stub->owner, insn,
+ bfd_put_32 (stub->owner, (bfd_vma) insn,
stub->contents + dyn_h->stub_offset + 8);
}
break;
if (m == NULL)
{
- m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m);
+ m = ((struct elf_segment_map *)
+ bfd_zalloc (abfd, (bfd_size_type) sizeof *m));
if (m == NULL)
return false;
const Elf64_Mips_External_Rel *src;
Elf64_Mips_Internal_Rel *dst;
{
- dst->r_offset = bfd_h_get_64 (abfd, (bfd_byte *) src->r_offset);
- dst->r_sym = bfd_h_get_32 (abfd, (bfd_byte *) src->r_sym);
- dst->r_ssym = bfd_h_get_8 (abfd, (bfd_byte *) src->r_ssym);
- dst->r_type3 = bfd_h_get_8 (abfd, (bfd_byte *) src->r_type3);
- dst->r_type2 = bfd_h_get_8 (abfd, (bfd_byte *) src->r_type2);
- dst->r_type = bfd_h_get_8 (abfd, (bfd_byte *) src->r_type);
+ dst->r_offset = H_GET_64 (abfd, src->r_offset);
+ dst->r_sym = H_GET_32 (abfd, src->r_sym);
+ dst->r_ssym = H_GET_8 (abfd, src->r_ssym);
+ dst->r_type3 = H_GET_8 (abfd, src->r_type3);
+ dst->r_type2 = H_GET_8 (abfd, src->r_type2);
+ dst->r_type = H_GET_8 (abfd, src->r_type);
}
/* Swap in a MIPS 64-bit Rela reloc. */
const Elf64_Mips_External_Rela *src;
Elf64_Mips_Internal_Rela *dst;
{
- dst->r_offset = bfd_h_get_64 (abfd, (bfd_byte *) src->r_offset);
- dst->r_sym = bfd_h_get_32 (abfd, (bfd_byte *) src->r_sym);
- dst->r_ssym = bfd_h_get_8 (abfd, (bfd_byte *) src->r_ssym);
- dst->r_type3 = bfd_h_get_8 (abfd, (bfd_byte *) src->r_type3);
- dst->r_type2 = bfd_h_get_8 (abfd, (bfd_byte *) src->r_type2);
- dst->r_type = bfd_h_get_8 (abfd, (bfd_byte *) src->r_type);
- dst->r_addend = bfd_h_get_signed_64 (abfd, (bfd_byte *) src->r_addend);
+ dst->r_offset = H_GET_64 (abfd, src->r_offset);
+ dst->r_sym = H_GET_32 (abfd, src->r_sym);
+ dst->r_ssym = H_GET_8 (abfd, src->r_ssym);
+ dst->r_type3 = H_GET_8 (abfd, src->r_type3);
+ dst->r_type2 = H_GET_8 (abfd, src->r_type2);
+ dst->r_type = H_GET_8 (abfd, src->r_type);
+ dst->r_addend = H_GET_S64 (abfd, src->r_addend);
}
/* Swap out a MIPS 64-bit Rel reloc. */
const Elf64_Mips_Internal_Rel *src;
Elf64_Mips_External_Rel *dst;
{
- bfd_h_put_64 (abfd, src->r_offset, (bfd_byte *) dst->r_offset);
- bfd_h_put_32 (abfd, src->r_sym, (bfd_byte *) dst->r_sym);
- bfd_h_put_8 (abfd, src->r_ssym, (bfd_byte *) dst->r_ssym);
- bfd_h_put_8 (abfd, src->r_type3, (bfd_byte *) dst->r_type3);
- bfd_h_put_8 (abfd, src->r_type2, (bfd_byte *) dst->r_type2);
- bfd_h_put_8 (abfd, src->r_type, (bfd_byte *) dst->r_type);
+ H_PUT_64 (abfd, src->r_offset, dst->r_offset);
+ H_PUT_32 (abfd, src->r_sym, dst->r_sym);
+ H_PUT_8 (abfd, src->r_ssym, dst->r_ssym);
+ H_PUT_8 (abfd, src->r_type3, dst->r_type3);
+ H_PUT_8 (abfd, src->r_type2, dst->r_type2);
+ H_PUT_8 (abfd, src->r_type, dst->r_type);
}
/* Swap out a MIPS 64-bit Rela reloc. */
const Elf64_Mips_Internal_Rela *src;
Elf64_Mips_External_Rela *dst;
{
- bfd_h_put_64 (abfd, src->r_offset, (bfd_byte *) dst->r_offset);
- bfd_h_put_32 (abfd, src->r_sym, (bfd_byte *) dst->r_sym);
- bfd_h_put_8 (abfd, src->r_ssym, (bfd_byte *) dst->r_ssym);
- bfd_h_put_8 (abfd, src->r_type3, (bfd_byte *) dst->r_type3);
- bfd_h_put_8 (abfd, src->r_type2, (bfd_byte *) dst->r_type2);
- bfd_h_put_8 (abfd, src->r_type, (bfd_byte *) dst->r_type);
- bfd_h_put_64 (abfd, src->r_addend, (bfd_byte *) dst->r_addend);
+ H_PUT_64 (abfd, src->r_offset, dst->r_offset);
+ H_PUT_32 (abfd, src->r_sym, dst->r_sym);
+ H_PUT_8 (abfd, src->r_ssym, dst->r_ssym);
+ H_PUT_8 (abfd, src->r_type3, dst->r_type3);
+ H_PUT_8 (abfd, src->r_type2, dst->r_type2);
+ H_PUT_8 (abfd, src->r_type, dst->r_type);
+ H_PUT_64 (abfd, src->r_addend, dst->r_addend);
}
/* Swap in a MIPS 64-bit Rel reloc. */
enum elf_mips_reloc_type elf_reloc_val;
};
-static CONST struct elf_reloc_map mips_reloc_map[] =
+static const struct elf_reloc_map mips_reloc_map[] =
{
{ BFD_RELOC_NONE, R_MIPS_NONE, },
{ BFD_RELOC_16, R_MIPS_16 },
allocated = (PTR) bfd_malloc (rel_hdr->sh_size);
if (allocated == NULL)
- goto error_return;
+ return false;
if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (allocated, 1, rel_hdr->sh_size, abfd) != rel_hdr->sh_size))
+ || (bfd_bread (allocated, rel_hdr->sh_size, abfd) != rel_hdr->sh_size))
goto error_return;
native_relocs = (bfd_byte *) allocated;
asymbol **symbols;
boolean dynamic;
{
+ bfd_size_type amt;
struct bfd_elf_section_data * const d = elf_section_data (asect);
if (dynamic)
return true;
/* Allocate space for 3 arelent structures for each Rel structure. */
- asect->relocation = ((arelent *)
- bfd_alloc (abfd,
- asect->reloc_count * 3 * sizeof (arelent)));
+ amt = asect->reloc_count;
+ amt *= 3 * sizeof (arelent);
+ asect->relocation = (arelent *) bfd_alloc (abfd, amt);
if (asect->relocation == NULL)
return false;
char *stringbase;
bfd_byte *raw_armap = NULL;
carsym *carsyms;
+ bfd_size_type amt;
ardata->symdefs = NULL;
/* Get the name of the first element. */
arhdrpos = bfd_tell (abfd);
- i = bfd_read ((PTR) nextname, 1, 16, abfd);
+ i = bfd_bread ((PTR) nextname, (bfd_size_type) 16, abfd);
if (i == 0)
return true;
if (i != 16)
return false;
- if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
+ if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
return false;
/* Archives with traditional armaps are still permitted. */
parsed_size = mapdata->parsed_size;
bfd_release (abfd, (PTR) mapdata);
- if (bfd_read (int_buf, 1, 8, abfd) != 8)
+ if (bfd_bread (int_buf, (bfd_size_type) 8, abfd) != 8)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
carsym_size = nsymz * sizeof (carsym);
ptrsize = 8 * nsymz;
- ardata->symdefs = (carsym *) bfd_zalloc (abfd, carsym_size + stringsize + 1);
+ amt = carsym_size + stringsize + 1;
+ ardata->symdefs = (carsym *) bfd_zalloc (abfd, amt);
if (ardata->symdefs == NULL)
return false;
carsyms = ardata->symdefs;
if (raw_armap == NULL)
goto error_return;
- if (bfd_read (raw_armap, 1, ptrsize, abfd) != ptrsize
- || bfd_read (stringbase, 1, stringsize, abfd) != stringsize)
+ if (bfd_bread (raw_armap, ptrsize, abfd) != ptrsize
+ || bfd_bread (stringbase, stringsize, abfd) != stringsize)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
/* Write the ar header for this item and the number of symbols */
- if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), arch)
+ if (bfd_bwrite ((PTR) &hdr, (bfd_size_type) sizeof (struct ar_hdr), arch)
!= sizeof (struct ar_hdr))
return false;
- bfd_putb64 (symbol_count, buf);
- if (bfd_write (buf, 1, 8, arch) != 8)
+ bfd_putb64 ((bfd_vma) symbol_count, buf);
+ if (bfd_bwrite (buf, (bfd_size_type) 8, arch) != 8)
return false;
/* Two passes, first write the file offsets for each symbol -
/* For each symbol which is used defined in this object, write out
the object file's address in the archive */
- while (((bfd *) (map[count]).pos) == current)
+ while (map[count].u.abfd == current)
{
- bfd_putb64 (archive_member_file_ptr, buf);
- if (bfd_write (buf, 1, 8, arch) != 8)
+ bfd_putb64 ((bfd_vma) archive_member_file_ptr, buf);
+ if (bfd_bwrite (buf, (bfd_size_type) 8, arch) != 8)
return false;
count++;
}
{
size_t len = strlen (*map[count].name) + 1;
- if (bfd_write (*map[count].name, 1, len, arch) != len)
+ if (bfd_bwrite (*map[count].name, (bfd_size_type) len, arch) != len)
return false;
}
However, the Irix 6.2 tools do not appear to do this. */
while (padding != 0)
{
- if (bfd_write ("", 1, 1, arch) != 1)
+ if (bfd_bwrite ("", (bfd_size_type) 1, arch) != 1)
return false;
--padding;
}
/* This is a global offset table entry for a local symbol. */
if (local_got_refcounts == NULL)
{
- size_t size;
+ bfd_size_type size;
- size = symtab_hdr->sh_info * sizeof (bfd_signed_vma);
- local_got_refcounts = (bfd_signed_vma *)
- bfd_alloc (abfd, size);
+ size = symtab_hdr->sh_info;
+ size *= sizeof (bfd_signed_vma);
+ local_got_refcounts = ((bfd_signed_vma *)
+ bfd_alloc (abfd, size));
if (local_got_refcounts == NULL)
return false;
elf_local_got_refcounts (abfd) = local_got_refcounts;
- memset (local_got_refcounts, -1, size);
+ memset (local_got_refcounts, -1, (size_t) size);
}
if (local_got_refcounts[r_symndx] == -1)
{
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
- if (! info->shared)
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
+ if (!info->shared)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (plt)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf64_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
return false;
}
if (reltext)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
}
}
+#undef add_dynamic_entry
/* If we are generating a shared library, we generate a section
symbol for each output section. These are local symbols, which
bfd_vma *local_got_offsets;
bfd_vma TOCstart;
boolean ret = true;
- long insn;
#ifdef DEBUG
fprintf (stderr, "ppc64_elf_relocate_section called for %s section %s, %ld relocations%s\n",
reloc_howto_type *howto;
unsigned long r_symndx;
bfd_vma relocation;
+ long insn;
r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info);
offset = rel->r_offset;
<= input_section->_cooked_size))
{
bfd_byte *pnext;
- unsigned long insn;
pnext = contents + (rel->r_offset - input_section->vma) + 4;
insn = bfd_get_32 (input_bfd, pnext);
if (insn == 0x60000000 /* nop (ori r0,r0,0) */
|| insn == 0x4def7b82 /* cror 15,15,15 */
- || insn == 0x4ffffb82) /* cror 31,31,31 */
+ || insn == 0x4ffffb82) /* cror 31,31,31 */
{
- bfd_put_32 (input_bfd, 0xe8410028, pnext); /* ld r2,40(r1) */
+ bfd_put_32 (input_bfd,
+ (bfd_vma) 0xe8410028, /* ld r2,40(r1) */
+ pnext);
#ifdef DEBUG
fprintf (stderr, "ppc64_elf_relocate_section: " \
"patched nop after call to %s\n", sym_name);
insn &= ~BRANCH_PREDICT_BIT;
else
insn |= BRANCH_PREDICT_BIT;
- bfd_put_32 (output_bfd, insn, contents + offset);
+ bfd_put_32 (output_bfd, (bfd_vma) insn, contents + offset);
break;
/* Branch not taken predicition relocations. */
insn |= BRANCH_PREDICT_BIT;
else
insn &= ~BRANCH_PREDICT_BIT;
- bfd_put_32 (output_bfd, insn, contents + offset);
+ bfd_put_32 (output_bfd, (bfd_vma) insn, contents + offset);
break;
+ (sizeof (ppc64_elf_glink_code)
/ sizeof (*ppc64_elf_glink_code))));
{
- bfd_put_32 (output_bfd, *stub, p);
+ bfd_put_32 (output_bfd, (bfd_vma) *stub, p);
}
#ifdef DEBUG
fprintf (stderr, ", linkage function");
rela.r_offset = (sgot->output_section->vma
+ sgot->output_offset
- + (h->got.offset &~ 1));
+ + (h->got.offset &~ (bfd_vma) 1));
/* If this is a -Bsymbolic link, and the symbol is defined
locally, we just want to emit a RELATIVE reloc. The entry in
the program that manages to have a symbol table of more than 2 GB with a
total size of at max 4 GB. */
-#define PLT_ENTRY_WORD0 0xc0100000
-#define PLT_ENTRY_WORD1 0x0000e310
-#define PLT_ENTRY_WORD2 0x10000004
-#define PLT_ENTRY_WORD3 0x07f10d10
-#define PLT_ENTRY_WORD4 0xe310100c
-#define PLT_ENTRY_WORD5 0x0014c0f4
-#define PLT_ENTRY_WORD6 0x00000000
-#define PLT_ENTRY_WORD7 0x00000000
+#define PLT_ENTRY_WORD0 (bfd_vma) 0xc0100000
+#define PLT_ENTRY_WORD1 (bfd_vma) 0x0000e310
+#define PLT_ENTRY_WORD2 (bfd_vma) 0x10000004
+#define PLT_ENTRY_WORD3 (bfd_vma) 0x07f10d10
+#define PLT_ENTRY_WORD4 (bfd_vma) 0xe310100c
+#define PLT_ENTRY_WORD5 (bfd_vma) 0x0014c0f4
+#define PLT_ENTRY_WORD6 (bfd_vma) 0x00000000
+#define PLT_ENTRY_WORD7 (bfd_vma) 0x00000000
/* The first PLT entry pushes the offset into the symbol table
from R1 onto the stack at 8(15) and the loader object info
Fixup at offset 8: relative address to start of GOT. */
-#define PLT_FIRST_ENTRY_WORD0 0xe310f038
-#define PLT_FIRST_ENTRY_WORD1 0x0024c010
-#define PLT_FIRST_ENTRY_WORD2 0x00000000
-#define PLT_FIRST_ENTRY_WORD3 0xd207f030
-#define PLT_FIRST_ENTRY_WORD4 0x1008e310
-#define PLT_FIRST_ENTRY_WORD5 0x10100004
-#define PLT_FIRST_ENTRY_WORD6 0x07f10700
-#define PLT_FIRST_ENTRY_WORD7 0x07000700
+#define PLT_FIRST_ENTRY_WORD0 (bfd_vma) 0xe310f038
+#define PLT_FIRST_ENTRY_WORD1 (bfd_vma) 0x0024c010
+#define PLT_FIRST_ENTRY_WORD2 (bfd_vma) 0x00000000
+#define PLT_FIRST_ENTRY_WORD3 (bfd_vma) 0xd207f030
+#define PLT_FIRST_ENTRY_WORD4 (bfd_vma) 0x1008e310
+#define PLT_FIRST_ENTRY_WORD5 (bfd_vma) 0x10100004
+#define PLT_FIRST_ENTRY_WORD6 (bfd_vma) 0x07f10700
+#define PLT_FIRST_ENTRY_WORD7 (bfd_vma) 0x07000700
/* The s390 linker needs to keep track of the number of relocs that it
decides to copy in check_relocs for each symbol. This is so that
bfd *abfd;
{
struct elf_s390_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct elf_s390_link_hash_table);
- ret = ((struct elf_s390_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf_s390_link_hash_table)));
+ ret = ((struct elf_s390_link_hash_table *) bfd_alloc (abfd, amt));
if (ret == (struct elf_s390_link_hash_table *) NULL)
return NULL;
/* This is a global offset table entry for a local symbol. */
if (local_got_refcounts == NULL)
{
- size_t size;
+ bfd_size_type size;
size = symtab_hdr->sh_info * sizeof (bfd_vma);
- local_got_refcounts = (bfd_signed_vma *)
- bfd_alloc (abfd, size);
+ local_got_refcounts = ((bfd_signed_vma *)
+ bfd_alloc (abfd, size));
if (local_got_refcounts == NULL)
return false;
elf_local_got_refcounts (abfd) = local_got_refcounts;
- memset (local_got_refcounts, -1, size);
+ memset (local_got_refcounts, -1, (size_t) size);
}
if (local_got_refcounts[r_symndx] == -1)
{
if (p == NULL)
{
p = ((struct elf_s390_pcrel_relocs_copied *)
- bfd_alloc (dynobj, sizeof *p));
+ bfd_alloc (dynobj, (bfd_size_type) sizeof *p));
if (p == NULL)
return false;
p->next = eh->pcrel_relocs_copied;
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
if (! info->shared)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (plt)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf64_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
return false;
}
if ((info->flags & DF_TEXTREL) != 0)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
info->flags |= DF_TEXTREL;
}
}
+#undef add_dynamic_entry
return true;
}
rela.r_offset = (sgot->output_section->vma
+ sgot->output_offset
- + (h->got.offset &~ 1));
+ + (h->got.offset &~ (bfd_vma) 1));
/* If this is a static link, or it is a -Bsymbolic link and the
symbol is defined locally or was forced to be local because
static void sparc64_elf_build_plt
PARAMS ((bfd *, unsigned char *, int));
static bfd_vma sparc64_elf_plt_entry_offset
- PARAMS ((int));
+ PARAMS ((bfd_vma));
static bfd_vma sparc64_elf_plt_ptr_offset
- PARAMS ((int, int));
+ PARAMS ((bfd_vma, bfd_vma));
static boolean sparc64_elf_check_relocs
PARAMS ((bfd *, struct bfd_link_info *, asection *sec,
unsigned char elf_reloc_val;
};
-static CONST struct elf_reloc_map sparc_reloc_map[] =
+static const struct elf_reloc_map sparc_reloc_map[] =
{
{ BFD_RELOC_NONE, R_SPARC_NONE, },
{ BFD_RELOC_16, R_SPARC_16, },
bfd_size_type count;
arelent *relents;
- allocated = (PTR) bfd_malloc ((size_t) rel_hdr->sh_size);
+ allocated = (PTR) bfd_malloc (rel_hdr->sh_size);
if (allocated == NULL)
goto error_return;
if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (allocated, 1, rel_hdr->sh_size, abfd)
- != rel_hdr->sh_size))
+ || bfd_bread (allocated, rel_hdr->sh_size, abfd) != rel_hdr->sh_size)
goto error_return;
native_relocs = (bfd_byte *) allocated;
struct bfd_elf_section_data * const d = elf_section_data (asect);
Elf_Internal_Shdr *rel_hdr;
Elf_Internal_Shdr *rel_hdr2;
+ bfd_size_type amt;
if (asect->relocation != NULL)
return true;
rel_hdr2 = NULL;
}
- asect->relocation = ((arelent *)
- bfd_alloc (abfd,
- asect->reloc_count * 2 * sizeof (arelent)));
+ amt = asect->reloc_count;
+ amt *= 2 * sizeof (arelent);
+ asect->relocation = (arelent *) bfd_alloc (abfd, amt);
if (asect->relocation == NULL)
return false;
bfd *abfd;
{
struct sparc64_elf_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct sparc64_elf_link_hash_table);
- ret = ((struct sparc64_elf_link_hash_table *)
- bfd_zalloc (abfd, sizeof (struct sparc64_elf_link_hash_table)));
+ ret = (struct sparc64_elf_link_hash_table *) bfd_zalloc (abfd, amt);
if (ret == (struct sparc64_elf_link_hash_table *) NULL)
return NULL;
if (status != bfd_reloc_other)
return status;
- insn = (insn & ~0x303fff) | ((((relocation >> 2) & 0xc000) << 6)
- | ((relocation >> 2) & 0x3fff));
+ insn &= ~ (bfd_vma) 0x303fff;
+ insn |= (((relocation >> 2) & 0xc000) << 6) | ((relocation >> 2) & 0x3fff);
bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
if ((bfd_signed_vma) relocation < - 0x40000
return status;
relocation ^= MINUS_ONE;
- insn = (insn & ~0x3fffff) | ((relocation >> 10) & 0x3fffff);
+ insn = (insn &~ (bfd_vma) 0x3fffff) | ((relocation >> 10) & 0x3fffff);
bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
if ((relocation & ~ (bfd_vma) 0xffffffff) != 0)
if (status != bfd_reloc_other)
return status;
- insn = (insn & ~0x1fff) | 0x1c00 | (relocation & 0x3ff);
+ insn = (insn &~ (bfd_vma) 0x1fff) | 0x1c00 | (relocation & 0x3ff);
bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
return bfd_reloc_ok;
We fill them with `illtrap 0' to force ld.so to do something. */
for (i = 0; i < PLT_HEADER_SIZE/4; ++i)
- bfd_put_32 (output_bfd, 0, contents+i*4);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, contents+i*4);
/* The first 32768 entries are close enough to plt1 to get there via
a straight branch. */
/* ba,a,pt %xcc, plt1 */
ba = 0x30680000 | (((contents+PLT_ENTRY_SIZE) - (entry+4)) / 4 & 0x7ffff);
- bfd_put_32 (output_bfd, sethi, entry);
- bfd_put_32 (output_bfd, ba, entry+4);
- bfd_put_32 (output_bfd, nop, entry+8);
- bfd_put_32 (output_bfd, nop, entry+12);
- bfd_put_32 (output_bfd, nop, entry+16);
- bfd_put_32 (output_bfd, nop, entry+20);
- bfd_put_32 (output_bfd, nop, entry+24);
- bfd_put_32 (output_bfd, nop, entry+28);
+ bfd_put_32 (output_bfd, (bfd_vma) sethi, entry);
+ bfd_put_32 (output_bfd, (bfd_vma) ba, entry + 4);
+ bfd_put_32 (output_bfd, (bfd_vma) nop, entry + 8);
+ bfd_put_32 (output_bfd, (bfd_vma) nop, entry + 12);
+ bfd_put_32 (output_bfd, (bfd_vma) nop, entry + 16);
+ bfd_put_32 (output_bfd, (bfd_vma) nop, entry + 20);
+ bfd_put_32 (output_bfd, (bfd_vma) nop, entry + 24);
+ bfd_put_32 (output_bfd, (bfd_vma) nop, entry + 28);
}
/* Now the tricky bit. Entries 32768 and higher are grouped in blocks of
/* ldx [%o7 + ptr - entry+4], %g1 */
ldx = 0xc25be000 | ((ptr - entry+4) & 0x1fff);
- bfd_put_32 (output_bfd, 0x8a10000f, entry); /* mov %o7,%g5 */
- bfd_put_32 (output_bfd, 0x40000002, entry+4); /* call .+8 */
- bfd_put_32 (output_bfd, nop, entry+8); /* nop */
- bfd_put_32 (output_bfd, ldx, entry+12); /* ldx [%o7+P],%g1 */
- bfd_put_32 (output_bfd, 0x83c3c001, entry+16); /* jmpl %o7+%g1,%g1 */
- bfd_put_32 (output_bfd, 0x9e100005, entry+20); /* mov %g5,%o7 */
-
- bfd_put_64 (output_bfd, contents - (entry+4), ptr);
+ /* mov %o7,%g5
+ call .+8
+ nop
+ ldx [%o7+P],%g1
+ jmpl %o7+%g1,%g1
+ mov %g5,%o7 */
+ bfd_put_32 (output_bfd, (bfd_vma) 0x8a10000f, entry);
+ bfd_put_32 (output_bfd, (bfd_vma) 0x40000002, entry + 4);
+ bfd_put_32 (output_bfd, (bfd_vma) nop, entry + 8);
+ bfd_put_32 (output_bfd, (bfd_vma) ldx, entry + 12);
+ bfd_put_32 (output_bfd, (bfd_vma) 0x83c3c001, entry + 16);
+ bfd_put_32 (output_bfd, (bfd_vma) 0x9e100005, entry + 20);
+
+ bfd_put_64 (output_bfd, (bfd_vma) (contents - (entry + 4)), ptr);
}
}
}
static bfd_vma
sparc64_elf_plt_entry_offset (index)
- int index;
+ bfd_vma index;
{
- int block, ofs;
+ bfd_vma block, ofs;
if (index < LARGE_PLT_THRESHOLD)
return index * PLT_ENTRY_SIZE;
block = (index - LARGE_PLT_THRESHOLD) / 160;
ofs = (index - LARGE_PLT_THRESHOLD) % 160;
- return ((bfd_vma) (LARGE_PLT_THRESHOLD + block*160) * PLT_ENTRY_SIZE
- + ofs * 6*4);
+ return (LARGE_PLT_THRESHOLD + block * 160) * PLT_ENTRY_SIZE + ofs * 6 * 4;
}
static bfd_vma
sparc64_elf_plt_ptr_offset (index, max)
- int index, max;
+ bfd_vma index;
+ bfd_vma max;
{
- int block, ofs, last;
+ bfd_vma block, ofs, last;
BFD_ASSERT(index >= LARGE_PLT_THRESHOLD);
/* See above for details. */
- block = (((index - LARGE_PLT_THRESHOLD) / 160) * 160)
- + LARGE_PLT_THRESHOLD;
+ block = (((index - LARGE_PLT_THRESHOLD) / 160) * 160) + LARGE_PLT_THRESHOLD;
ofs = index - block;
if (block + 160 > max)
last = (max - LARGE_PLT_THRESHOLD) % 160;
symbol. */
if (local_got_offsets == NULL)
{
- size_t size;
+ bfd_size_type size;
register unsigned int i;
- size = symtab_hdr->sh_info * sizeof (bfd_vma);
+ size = symtab_hdr->sh_info;
+ size *= sizeof (bfd_vma);
local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
if (local_got_offsets == NULL)
return false;
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
int reg;
struct sparc64_elf_app_reg * app_regs;
struct bfd_strtab_hash *dynstr;
struct elf_link_hash_table *eht = elf_hash_table (info);
- if (! info->shared)
+ if (!info->shared)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (relplt)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
- if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf64_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
return false;
if (info->flags & DF_TEXTREL)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
}
{
struct elf_link_local_dynamic_entry *entry, *e;
- if (! bfd_elf64_add_dynamic_entry (info, DT_SPARC_REGISTER, 0))
+ if (!add_dynamic_entry (DT_SPARC_REGISTER, 0))
return false;
entry = (struct elf_link_local_dynamic_entry *)
eht->dynsymcount++;
}
}
+#undef add_dynamic_entry
return true;
}
Note this is different behaviour to the
32-bit linker, which both adds the contents
and ignores the addend. So clear the location. */
- bfd_put_64 (output_bfd, 0, sgot->contents + off);
+ bfd_put_64 (output_bfd, (bfd_vma) 0,
+ sgot->contents + off);
/* We need to generate a R_SPARC_RELATIVE reloc
for the dynamic linker. */
relocation = (relocation & 0x3ff) + ELF64_R_TYPE_DATA (rel->r_info);
x = bfd_get_32 (input_bfd, contents + rel->r_offset);
- x = (x & ~0x1fff) | (relocation & 0x1fff);
+ x = (x & ~(bfd_vma) 0x1fff) | (relocation & 0x1fff);
bfd_put_32 (input_bfd, x, contents + rel->r_offset);
r = bfd_check_overflow (howto->complain_on_overflow,
relocation -= rel->r_offset;
x = bfd_get_32 (input_bfd, contents + rel->r_offset);
- x = (x & ~0x303fff) | ((((relocation >> 2) & 0xc000) << 6)
- | ((relocation >> 2) & 0x3fff));
+ x &= ~(bfd_vma) 0x303fff;
+ x |= ((((relocation >> 2) & 0xc000) << 6)
+ | ((relocation >> 2) & 0x3fff));
bfd_put_32 (input_bfd, x, contents + rel->r_offset);
r = bfd_check_overflow (howto->complain_on_overflow,
relocation = relocation ^ MINUS_ONE;
x = bfd_get_32 (input_bfd, contents + rel->r_offset);
- x = (x & ~0x3fffff) | ((relocation >> 10) & 0x3fffff);
+ x = (x & ~(bfd_vma) 0x3fffff) | ((relocation >> 10) & 0x3fffff);
bfd_put_32 (input_bfd, x, contents + rel->r_offset);
r = bfd_check_overflow (howto->complain_on_overflow,
relocation = (relocation & 0x3ff) | 0x1c00;
x = bfd_get_32 (input_bfd, contents + rel->r_offset);
- x = (x & ~0x1fff) | relocation;
+ x = (x & ~(bfd_vma) 0x1fff) | relocation;
bfd_put_32 (input_bfd, x, contents + rel->r_offset);
r = bfd_reloc_ok;
|| reg == G0 || reg == O7)
break;
- bfd_put_32 (input_bfd, INSN_NOP,
+ bfd_put_32 (input_bfd, (bfd_vma) INSN_NOP,
contents + rel->r_offset + 4);
}
break;
}
else
{
- int max = splt->_raw_size / PLT_ENTRY_SIZE;
+ bfd_vma max = splt->_raw_size / PLT_ENTRY_SIZE;
rela.r_offset = sparc64_elf_plt_ptr_offset (h->plt.offset, max);
rela.r_addend = -(sparc64_elf_plt_entry_offset (h->plt.offset) + 4)
-(splt->output_section->vma + splt->output_offset);
rela.r_offset = (sgot->output_section->vma
+ sgot->output_offset
- + (h->got.offset &~ 1));
+ + (h->got.offset &~ (bfd_vma) 1));
/* If this is a -Bsymbolic link, and the symbol is defined
locally, we just want to emit a RELATIVE reloc. Likewise if
/* Initialize the contents of the .plt section. */
if (splt->_raw_size > 0)
{
- sparc64_elf_build_plt(output_bfd, splt->contents,
- splt->_raw_size / PLT_ENTRY_SIZE);
+ sparc64_elf_build_plt (output_bfd, splt->contents,
+ (int) (splt->_raw_size / PLT_ENTRY_SIZE));
}
elf_section_data (splt->output_section)->this_hdr.sh_entsize =
unsigned char elf_reloc_val;
};
-static CONST struct elf_reloc_map x86_64_reloc_map[] =
+static const struct elf_reloc_map x86_64_reloc_map[] =
{
{ BFD_RELOC_NONE, R_X86_64_NONE, },
{ BFD_RELOC_64, R_X86_64_64, },
bfd *abfd;
{
struct elf64_x86_64_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct elf64_x86_64_link_hash_table);
- ret = ((struct elf64_x86_64_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct elf64_x86_64_link_hash_table)));
+ ret = ((struct elf64_x86_64_link_hash_table *) bfd_alloc (abfd, amt));
if (ret == (struct elf64_x86_64_link_hash_table *) NULL)
return NULL;
/* This is a global offset table entry for a local symbol. */
if (local_got_refcounts == NULL)
{
- size_t size;
+ bfd_size_type size;
- size = symtab_hdr->sh_info * sizeof (bfd_signed_vma);
+ size = symtab_hdr->sh_info;
+ size *= sizeof (bfd_signed_vma);
local_got_refcounts = ((bfd_signed_vma *)
bfd_alloc (abfd, size));
if (local_got_refcounts == NULL)
return false;
elf_local_got_refcounts (abfd) = local_got_refcounts;
- memset (local_got_refcounts, -1, size);
+ memset (local_got_refcounts, -1, (size_t) size);
}
if (local_got_refcounts[r_symndx] == -1)
{
if (p == NULL)
{
p = ((struct elf64_x86_64_pcrel_relocs_copied *)
- bfd_alloc (dynobj, sizeof *p));
+ bfd_alloc (dynobj, (bfd_size_type) sizeof *p));
if (p == NULL)
return false;
p->next = eh->pcrel_relocs_copied;
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
if (! info->shared)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
if (plt)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0)
+ || !add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
if (relocs)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
- sizeof (Elf64_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (Elf64_External_Rela)))
return false;
}
if ((info->flags & DF_TEXTREL) != 0)
{
- if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
}
}
+#undef add_dynamic_entry
return true;
}
}
else
{
- long indx;
+ long sindx;
if (h == NULL)
sec = local_sections[r_symndx];
sec = h->root.u.def.section;
}
if (sec != NULL && bfd_is_abs_section (sec))
- indx = 0;
+ sindx = 0;
else if (sec == NULL || sec->owner == NULL)
{
bfd_set_error (bfd_error_bad_value);
asection *osec;
osec = sec->output_section;
- indx = elf_section_data (osec)->dynindx;
- BFD_ASSERT (indx > 0);
+ sindx = elf_section_data (osec)->dynindx;
+ BFD_ASSERT (sindx > 0);
}
relocate = false;
- outrel.r_info = ELF64_R_INFO (indx, r_type);
+ outrel.r_info = ELF64_R_INFO (sindx, r_type);
outrel.r_addend = relocation + rela->r_addend;
}
rela.r_offset = (sgot->output_section->vma
+ sgot->output_offset
- + (h->got.offset &~ 1));
+ + (h->got.offset &~ (bfd_vma) 1));
/* If this is a static link, or it is a -Bsymbolic link and the
symbol is defined locally or was forced to be local because
Elf_Internal_Note *note;
{
int offset;
- int raw_size;
+ size_t raw_size;
switch (note->descsz)
{
/* Should perhaps use put_offset, put_word, etc. For now, the two versions
can be handled by explicitly specifying 32 bits or "the long type". */
#if ARCH_SIZE == 64
-#define put_word bfd_h_put_64
-#define put_signed_word bfd_h_put_signed_64
-#define get_word bfd_h_get_64
-#define get_signed_word bfd_h_get_signed_64
+#define H_PUT_WORD H_PUT_64
+#define H_PUT_SIGNED_WORD H_PUT_S64
+#define H_GET_WORD H_GET_64
+#define H_GET_SIGNED_WORD H_GET_S64
#endif
#if ARCH_SIZE == 32
-#define put_word bfd_h_put_32
-#define put_signed_word bfd_h_put_signed_32
-#define get_word bfd_h_get_32
-#define get_signed_word bfd_h_get_signed_32
+#define H_PUT_WORD H_PUT_32
+#define H_PUT_SIGNED_WORD H_PUT_S32
+#define H_GET_WORD H_GET_32
+#define H_GET_SIGNED_WORD H_GET_S32
#endif
/* Translate an ELF symbol in external format into an ELF symbol in internal
{
int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
- dst->st_name = bfd_h_get_32 (abfd, (bfd_byte *) src->st_name);
+ dst->st_name = H_GET_32 (abfd, src->st_name);
if (signed_vma)
- dst->st_value = get_signed_word (abfd, (bfd_byte *) src->st_value);
+ dst->st_value = H_GET_SIGNED_WORD (abfd, src->st_value);
else
- dst->st_value = get_word (abfd, (bfd_byte *) src->st_value);
- dst->st_size = get_word (abfd, (bfd_byte *) src->st_size);
- dst->st_info = bfd_h_get_8 (abfd, (bfd_byte *) src->st_info);
- dst->st_other = bfd_h_get_8 (abfd, (bfd_byte *) src->st_other);
- dst->st_shndx = bfd_h_get_16 (abfd, (bfd_byte *) src->st_shndx);
+ dst->st_value = H_GET_WORD (abfd, src->st_value);
+ dst->st_size = H_GET_WORD (abfd, src->st_size);
+ dst->st_info = H_GET_8 (abfd, src->st_info);
+ dst->st_other = H_GET_8 (abfd, src->st_other);
+ dst->st_shndx = H_GET_16 (abfd, src->st_shndx);
}
/* Translate an ELF symbol in internal format into an ELF symbol in external
PTR cdst;
{
Elf_External_Sym *dst = (Elf_External_Sym *) cdst;
- bfd_h_put_32 (abfd, src->st_name, dst->st_name);
- put_word (abfd, src->st_value, dst->st_value);
- put_word (abfd, src->st_size, dst->st_size);
- bfd_h_put_8 (abfd, src->st_info, dst->st_info);
- bfd_h_put_8 (abfd, src->st_other, dst->st_other);
- bfd_h_put_16 (abfd, src->st_shndx, dst->st_shndx);
+ H_PUT_32 (abfd, src->st_name, dst->st_name);
+ H_PUT_WORD (abfd, src->st_value, dst->st_value);
+ H_PUT_WORD (abfd, src->st_size, dst->st_size);
+ H_PUT_8 (abfd, src->st_info, dst->st_info);
+ H_PUT_8 (abfd, src->st_other, dst->st_other);
+ H_PUT_16 (abfd, src->st_shndx, dst->st_shndx);
}
/* Translate an ELF file header in external format into an ELF file header in
{
int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
memcpy (dst->e_ident, src->e_ident, EI_NIDENT);
- dst->e_type = bfd_h_get_16 (abfd, (bfd_byte *) src->e_type);
- dst->e_machine = bfd_h_get_16 (abfd, (bfd_byte *) src->e_machine);
- dst->e_version = bfd_h_get_32 (abfd, (bfd_byte *) src->e_version);
+ dst->e_type = H_GET_16 (abfd, src->e_type);
+ dst->e_machine = H_GET_16 (abfd, src->e_machine);
+ dst->e_version = H_GET_32 (abfd, src->e_version);
if (signed_vma)
- dst->e_entry = get_signed_word (abfd, (bfd_byte *) src->e_entry);
+ dst->e_entry = H_GET_SIGNED_WORD (abfd, src->e_entry);
else
- dst->e_entry = get_word (abfd, (bfd_byte *) src->e_entry);
- dst->e_phoff = get_word (abfd, (bfd_byte *) src->e_phoff);
- dst->e_shoff = get_word (abfd, (bfd_byte *) src->e_shoff);
- dst->e_flags = bfd_h_get_32 (abfd, (bfd_byte *) src->e_flags);
- dst->e_ehsize = bfd_h_get_16 (abfd, (bfd_byte *) src->e_ehsize);
- dst->e_phentsize = bfd_h_get_16 (abfd, (bfd_byte *) src->e_phentsize);
- dst->e_phnum = bfd_h_get_16 (abfd, (bfd_byte *) src->e_phnum);
- dst->e_shentsize = bfd_h_get_16 (abfd, (bfd_byte *) src->e_shentsize);
- dst->e_shnum = bfd_h_get_16 (abfd, (bfd_byte *) src->e_shnum);
- dst->e_shstrndx = bfd_h_get_16 (abfd, (bfd_byte *) src->e_shstrndx);
+ dst->e_entry = H_GET_WORD (abfd, src->e_entry);
+ dst->e_phoff = H_GET_WORD (abfd, src->e_phoff);
+ dst->e_shoff = H_GET_WORD (abfd, src->e_shoff);
+ dst->e_flags = H_GET_32 (abfd, src->e_flags);
+ dst->e_ehsize = H_GET_16 (abfd, src->e_ehsize);
+ dst->e_phentsize = H_GET_16 (abfd, src->e_phentsize);
+ dst->e_phnum = H_GET_16 (abfd, src->e_phnum);
+ dst->e_shentsize = H_GET_16 (abfd, src->e_shentsize);
+ dst->e_shnum = H_GET_16 (abfd, src->e_shnum);
+ dst->e_shstrndx = H_GET_16 (abfd, src->e_shstrndx);
}
/* Translate an ELF file header in internal format into an ELF file header in
int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
memcpy (dst->e_ident, src->e_ident, EI_NIDENT);
/* note that all elements of dst are *arrays of unsigned char* already... */
- bfd_h_put_16 (abfd, src->e_type, dst->e_type);
- bfd_h_put_16 (abfd, src->e_machine, dst->e_machine);
- bfd_h_put_32 (abfd, src->e_version, dst->e_version);
+ H_PUT_16 (abfd, src->e_type, dst->e_type);
+ H_PUT_16 (abfd, src->e_machine, dst->e_machine);
+ H_PUT_32 (abfd, src->e_version, dst->e_version);
if (signed_vma)
- put_signed_word (abfd, src->e_entry, dst->e_entry);
+ H_PUT_SIGNED_WORD (abfd, src->e_entry, dst->e_entry);
else
- put_word (abfd, src->e_entry, dst->e_entry);
- put_word (abfd, src->e_phoff, dst->e_phoff);
- put_word (abfd, src->e_shoff, dst->e_shoff);
- bfd_h_put_32 (abfd, src->e_flags, dst->e_flags);
- bfd_h_put_16 (abfd, src->e_ehsize, dst->e_ehsize);
- bfd_h_put_16 (abfd, src->e_phentsize, dst->e_phentsize);
- bfd_h_put_16 (abfd, src->e_phnum, dst->e_phnum);
- bfd_h_put_16 (abfd, src->e_shentsize, dst->e_shentsize);
- bfd_h_put_16 (abfd, src->e_shnum, dst->e_shnum);
- bfd_h_put_16 (abfd, src->e_shstrndx, dst->e_shstrndx);
+ H_PUT_WORD (abfd, src->e_entry, dst->e_entry);
+ H_PUT_WORD (abfd, src->e_phoff, dst->e_phoff);
+ H_PUT_WORD (abfd, src->e_shoff, dst->e_shoff);
+ H_PUT_32 (abfd, src->e_flags, dst->e_flags);
+ H_PUT_16 (abfd, src->e_ehsize, dst->e_ehsize);
+ H_PUT_16 (abfd, src->e_phentsize, dst->e_phentsize);
+ H_PUT_16 (abfd, src->e_phnum, dst->e_phnum);
+ H_PUT_16 (abfd, src->e_shentsize, dst->e_shentsize);
+ H_PUT_16 (abfd, src->e_shnum, dst->e_shnum);
+ H_PUT_16 (abfd, src->e_shstrndx, dst->e_shstrndx);
}
/* Translate an ELF section header table entry in external format into an
{
int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
- dst->sh_name = bfd_h_get_32 (abfd, (bfd_byte *) src->sh_name);
- dst->sh_type = bfd_h_get_32 (abfd, (bfd_byte *) src->sh_type);
- dst->sh_flags = get_word (abfd, (bfd_byte *) src->sh_flags);
+ dst->sh_name = H_GET_32 (abfd, src->sh_name);
+ dst->sh_type = H_GET_32 (abfd, src->sh_type);
+ dst->sh_flags = H_GET_WORD (abfd, src->sh_flags);
if (signed_vma)
- dst->sh_addr = get_signed_word (abfd, (bfd_byte *) src->sh_addr);
+ dst->sh_addr = H_GET_SIGNED_WORD (abfd, src->sh_addr);
else
- dst->sh_addr = get_word (abfd, (bfd_byte *) src->sh_addr);
- dst->sh_offset = get_word (abfd, (bfd_byte *) src->sh_offset);
- dst->sh_size = get_word (abfd, (bfd_byte *) src->sh_size);
- dst->sh_link = bfd_h_get_32 (abfd, (bfd_byte *) src->sh_link);
- dst->sh_info = bfd_h_get_32 (abfd, (bfd_byte *) src->sh_info);
- dst->sh_addralign = get_word (abfd, (bfd_byte *) src->sh_addralign);
- dst->sh_entsize = get_word (abfd, (bfd_byte *) src->sh_entsize);
+ dst->sh_addr = H_GET_WORD (abfd, src->sh_addr);
+ dst->sh_offset = H_GET_WORD (abfd, src->sh_offset);
+ dst->sh_size = H_GET_WORD (abfd, src->sh_size);
+ dst->sh_link = H_GET_32 (abfd, src->sh_link);
+ dst->sh_info = H_GET_32 (abfd, src->sh_info);
+ dst->sh_addralign = H_GET_WORD (abfd, src->sh_addralign);
+ dst->sh_entsize = H_GET_WORD (abfd, src->sh_entsize);
dst->bfd_section = NULL;
dst->contents = NULL;
}
Elf_External_Shdr *dst;
{
/* note that all elements of dst are *arrays of unsigned char* already... */
- bfd_h_put_32 (abfd, src->sh_name, dst->sh_name);
- bfd_h_put_32 (abfd, src->sh_type, dst->sh_type);
- put_word (abfd, src->sh_flags, dst->sh_flags);
- put_word (abfd, src->sh_addr, dst->sh_addr);
- put_word (abfd, src->sh_offset, dst->sh_offset);
- put_word (abfd, src->sh_size, dst->sh_size);
- bfd_h_put_32 (abfd, src->sh_link, dst->sh_link);
- bfd_h_put_32 (abfd, src->sh_info, dst->sh_info);
- put_word (abfd, src->sh_addralign, dst->sh_addralign);
- put_word (abfd, src->sh_entsize, dst->sh_entsize);
+ H_PUT_32 (abfd, src->sh_name, dst->sh_name);
+ H_PUT_32 (abfd, src->sh_type, dst->sh_type);
+ H_PUT_WORD (abfd, src->sh_flags, dst->sh_flags);
+ H_PUT_WORD (abfd, src->sh_addr, dst->sh_addr);
+ H_PUT_WORD (abfd, src->sh_offset, dst->sh_offset);
+ H_PUT_WORD (abfd, src->sh_size, dst->sh_size);
+ H_PUT_32 (abfd, src->sh_link, dst->sh_link);
+ H_PUT_32 (abfd, src->sh_info, dst->sh_info);
+ H_PUT_WORD (abfd, src->sh_addralign, dst->sh_addralign);
+ H_PUT_WORD (abfd, src->sh_entsize, dst->sh_entsize);
}
/* Translate an ELF program header table entry in external format into an
{
int signed_vma = get_elf_backend_data (abfd)->sign_extend_vma;
- dst->p_type = bfd_h_get_32 (abfd, (bfd_byte *) src->p_type);
- dst->p_flags = bfd_h_get_32 (abfd, (bfd_byte *) src->p_flags);
- dst->p_offset = get_word (abfd, (bfd_byte *) src->p_offset);
+ dst->p_type = H_GET_32 (abfd, src->p_type);
+ dst->p_flags = H_GET_32 (abfd, src->p_flags);
+ dst->p_offset = H_GET_WORD (abfd, src->p_offset);
if (signed_vma)
{
- dst->p_vaddr = get_signed_word (abfd, (bfd_byte *) src->p_vaddr);
- dst->p_paddr = get_signed_word (abfd, (bfd_byte *) src->p_paddr);
+ dst->p_vaddr = H_GET_SIGNED_WORD (abfd, src->p_vaddr);
+ dst->p_paddr = H_GET_SIGNED_WORD (abfd, src->p_paddr);
}
else
{
- dst->p_vaddr = get_word (abfd, (bfd_byte *) src->p_vaddr);
- dst->p_paddr = get_word (abfd, (bfd_byte *) src->p_paddr);
+ dst->p_vaddr = H_GET_WORD (abfd, src->p_vaddr);
+ dst->p_paddr = H_GET_WORD (abfd, src->p_paddr);
}
- dst->p_filesz = get_word (abfd, (bfd_byte *) src->p_filesz);
- dst->p_memsz = get_word (abfd, (bfd_byte *) src->p_memsz);
- dst->p_align = get_word (abfd, (bfd_byte *) src->p_align);
+ dst->p_filesz = H_GET_WORD (abfd, src->p_filesz);
+ dst->p_memsz = H_GET_WORD (abfd, src->p_memsz);
+ dst->p_align = H_GET_WORD (abfd, src->p_align);
}
void
Elf_External_Phdr *dst;
{
/* note that all elements of dst are *arrays of unsigned char* already... */
- bfd_h_put_32 (abfd, src->p_type, dst->p_type);
- put_word (abfd, src->p_offset, dst->p_offset);
- put_word (abfd, src->p_vaddr, dst->p_vaddr);
- put_word (abfd, src->p_paddr, dst->p_paddr);
- put_word (abfd, src->p_filesz, dst->p_filesz);
- put_word (abfd, src->p_memsz, dst->p_memsz);
- bfd_h_put_32 (abfd, src->p_flags, dst->p_flags);
- put_word (abfd, src->p_align, dst->p_align);
+ H_PUT_32 (abfd, src->p_type, dst->p_type);
+ H_PUT_WORD (abfd, src->p_offset, dst->p_offset);
+ H_PUT_WORD (abfd, src->p_vaddr, dst->p_vaddr);
+ H_PUT_WORD (abfd, src->p_paddr, dst->p_paddr);
+ H_PUT_WORD (abfd, src->p_filesz, dst->p_filesz);
+ H_PUT_WORD (abfd, src->p_memsz, dst->p_memsz);
+ H_PUT_32 (abfd, src->p_flags, dst->p_flags);
+ H_PUT_WORD (abfd, src->p_align, dst->p_align);
}
/* Translate an ELF reloc from external format to internal format. */
const Elf_External_Rel *src;
Elf_Internal_Rel *dst;
{
- dst->r_offset = get_word (abfd, (bfd_byte *) src->r_offset);
- dst->r_info = get_word (abfd, (bfd_byte *) src->r_info);
+ dst->r_offset = H_GET_WORD (abfd, src->r_offset);
+ dst->r_info = H_GET_WORD (abfd, src->r_info);
}
INLINE void
const Elf_External_Rela *src;
Elf_Internal_Rela *dst;
{
- dst->r_offset = get_word (abfd, (bfd_byte *) src->r_offset);
- dst->r_info = get_word (abfd, (bfd_byte *) src->r_info);
- dst->r_addend = get_signed_word (abfd, (bfd_byte *) src->r_addend);
+ dst->r_offset = H_GET_WORD (abfd, src->r_offset);
+ dst->r_info = H_GET_WORD (abfd, src->r_info);
+ dst->r_addend = H_GET_SIGNED_WORD (abfd, src->r_addend);
}
/* Translate an ELF reloc from internal format to external format. */
const Elf_Internal_Rel *src;
Elf_External_Rel *dst;
{
- put_word (abfd, src->r_offset, dst->r_offset);
- put_word (abfd, src->r_info, dst->r_info);
+ H_PUT_WORD (abfd, src->r_offset, dst->r_offset);
+ H_PUT_WORD (abfd, src->r_info, dst->r_info);
}
INLINE void
const Elf_Internal_Rela *src;
Elf_External_Rela *dst;
{
- put_word (abfd, src->r_offset, dst->r_offset);
- put_word (abfd, src->r_info, dst->r_info);
- put_signed_word (abfd, src->r_addend, dst->r_addend);
+ H_PUT_WORD (abfd, src->r_offset, dst->r_offset);
+ H_PUT_WORD (abfd, src->r_info, dst->r_info);
+ H_PUT_SIGNED_WORD (abfd, src->r_addend, dst->r_addend);
}
INLINE void
{
const Elf_External_Dyn *src = (const Elf_External_Dyn *) p;
- dst->d_tag = get_word (abfd, src->d_tag);
- dst->d_un.d_val = get_word (abfd, src->d_un.d_val);
+ dst->d_tag = H_GET_WORD (abfd, src->d_tag);
+ dst->d_un.d_val = H_GET_WORD (abfd, src->d_un.d_val);
}
INLINE void
{
Elf_External_Dyn *dst = (Elf_External_Dyn *) p;
- put_word (abfd, src->d_tag, dst->d_tag);
- put_word (abfd, src->d_un.d_val, dst->d_un.d_val);
+ H_PUT_WORD (abfd, src->d_tag, dst->d_tag);
+ H_PUT_WORD (abfd, src->d_un.d_val, dst->d_un.d_val);
}
\f
/* ELF .o/exec file reading */
unsigned long previous_mach = bfd_get_mach (abfd);
struct elf_obj_tdata *new_tdata = NULL;
asection *s;
+ bfd_size_type amt;
/* Clear section information, since there might be a recognized bfd that
we now check if we can replace, and we don't want to append to it. */
/* Read in the ELF header in external format. */
- if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
+ if (bfd_bread ((PTR) & x_ehdr, (bfd_size_type) sizeof (x_ehdr), abfd)
+ != sizeof (x_ehdr))
{
if (bfd_get_error () != bfd_error_system_call)
goto got_wrong_format_error;
/* Allocate an instance of the elf_obj_tdata structure and hook it up to
the tdata pointer in the bfd. */
- new_tdata = ((struct elf_obj_tdata *)
- bfd_zalloc (abfd, sizeof (struct elf_obj_tdata)));
+ amt = sizeof (struct elf_obj_tdata);
+ new_tdata = (struct elf_obj_tdata *) bfd_zalloc (abfd, amt);
if (new_tdata == NULL)
goto got_no_match;
elf_tdata (abfd) = new_tdata;
/* Allocate space for a copy of the section header table in
internal form, seek to the section header table in the file,
read it in, and convert it to internal form. */
- i_shdrp = ((Elf_Internal_Shdr *)
- bfd_alloc (abfd, sizeof (*i_shdrp) * i_ehdrp->e_shnum));
- elf_elfsections (abfd) = ((Elf_Internal_Shdr **)
- bfd_alloc (abfd,
- sizeof (i_shdrp) * i_ehdrp->e_shnum));
+ amt = sizeof (*i_shdrp) * i_ehdrp->e_shnum;
+ i_shdrp = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt);
+ amt = sizeof (i_shdrp) * i_ehdrp->e_shnum;
+ elf_elfsections (abfd) = (Elf_Internal_Shdr **) bfd_alloc (abfd, amt);
if (!i_shdrp || !elf_elfsections (abfd))
goto got_no_match;
- if (bfd_seek (abfd, i_ehdrp->e_shoff, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0)
goto got_no_match;
for (shindex = 0; shindex < i_ehdrp->e_shnum; shindex++)
{
- if (bfd_read ((PTR) & x_shdr, sizeof x_shdr, 1, abfd) != sizeof (x_shdr))
+ if (bfd_bread ((PTR) & x_shdr, (bfd_size_type) sizeof x_shdr, abfd)
+ != sizeof (x_shdr))
goto got_no_match;
elf_swap_shdr_in (abfd, &x_shdr, i_shdrp + shindex);
elf_elfsections (abfd)[shindex] = i_shdrp + shindex;
Elf_Internal_Phdr *i_phdr;
unsigned int i;
- elf_tdata (abfd)->phdr = ((Elf_Internal_Phdr *)
- bfd_alloc (abfd,
- (i_ehdrp->e_phnum
- * sizeof (Elf_Internal_Phdr))));
+ amt = i_ehdrp->e_phnum * sizeof (Elf_Internal_Phdr);
+ elf_tdata (abfd)->phdr = (Elf_Internal_Phdr *) bfd_alloc (abfd, amt);
if (elf_tdata (abfd)->phdr == NULL)
goto got_no_match;
- if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_phoff, SEEK_SET) != 0)
goto got_no_match;
i_phdr = elf_tdata (abfd)->phdr;
for (i = 0; i < i_ehdrp->e_phnum; i++, i_phdr++)
{
Elf_External_Phdr x_phdr;
- if (bfd_read ((PTR) &x_phdr, sizeof x_phdr, 1, abfd)
+ if (bfd_bread ((PTR) &x_phdr, (bfd_size_type) sizeof x_phdr, abfd)
!= sizeof x_phdr)
goto got_no_match;
elf_swap_phdr_in (abfd, &x_phdr, i_phdr);
elf_write_out_phdrs (abfd, phdr, count)
bfd *abfd;
const Elf_Internal_Phdr *phdr;
- int count;
+ unsigned int count;
{
while (count--)
{
Elf_External_Phdr extphdr;
elf_swap_phdr_out (abfd, phdr, &extphdr);
- if (bfd_write (&extphdr, sizeof (Elf_External_Phdr), 1, abfd)
- != sizeof (Elf_External_Phdr))
+ if (bfd_bwrite (&extphdr, (bfd_size_type) sizeof (Elf_External_Phdr),
+ abfd) != sizeof (Elf_External_Phdr))
return -1;
phdr++;
}
Elf_External_Shdr *x_shdrp; /* Section header table, external form */
Elf_Internal_Shdr **i_shdrp; /* Section header table, internal form */
unsigned int count;
+ bfd_size_type amt;
i_ehdrp = elf_elfheader (abfd);
i_shdrp = elf_elfsections (abfd);
elf_debug_file (i_ehdrp);
#endif
elf_swap_ehdr_out (abfd, i_ehdrp, &x_ehdr);
+ amt = sizeof (x_ehdr);
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || (bfd_write ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd)
- != sizeof (x_ehdr)))
+ || bfd_bwrite ((PTR) & x_ehdr, amt, abfd) != amt)
return false;
/* at this point we've concocted all the ELF sections... */
- x_shdrp = (Elf_External_Shdr *)
- bfd_alloc (abfd, sizeof (*x_shdrp) * (i_ehdrp->e_shnum));
+ amt = sizeof (*x_shdrp) * i_ehdrp->e_shnum;
+ x_shdrp = (Elf_External_Shdr *) bfd_alloc (abfd, amt);
if (!x_shdrp)
return false;
#endif
elf_swap_shdr_out (abfd, i_shdrp[count], x_shdrp + count);
}
+ amt = i_ehdrp->e_shnum;
+ amt *= sizeof (*x_shdrp);
if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0
- || (bfd_write ((PTR) x_shdrp, sizeof (*x_shdrp), i_ehdrp->e_shnum, abfd)
- != sizeof (*x_shdrp) * i_ehdrp->e_shnum))
+ || bfd_bwrite ((PTR) x_shdrp, amt, abfd) != amt)
return false;
/* need to dump the string table too... */
Elf_Internal_Sym i_sym;
Elf_External_Sym *x_symp = NULL;
Elf_External_Versym *x_versymp = NULL;
+ bfd_size_type amt;
/* Read each raw ELF symbol, converting from external ELF form to
internal ELF form, and then using the information to create a
}
}
- if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
+ if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0)
return -1;
symcount = hdr->sh_size / sizeof (Elf_External_Sym);
{
unsigned long i;
- if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) == -1)
+ if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0)
return -1;
- symbase = ((elf_symbol_type *)
- bfd_zalloc (abfd, symcount * sizeof (elf_symbol_type)));
+ amt = symcount;
+ amt *= sizeof (elf_symbol_type);
+ symbase = (elf_symbol_type *) bfd_zalloc (abfd, amt);
if (symbase == (elf_symbol_type *) NULL)
return -1;
sym = symbase;
/* Temporarily allocate room for the raw ELF symbols. */
- x_symp = ((Elf_External_Sym *)
- bfd_malloc (symcount * sizeof (Elf_External_Sym)));
+ amt = symcount;
+ amt *= sizeof (Elf_External_Sym);
+ x_symp = (Elf_External_Sym *) bfd_malloc (amt);
if (x_symp == NULL && symcount != 0)
goto error_return;
- if (bfd_read ((PTR) x_symp, sizeof (Elf_External_Sym), symcount, abfd)
+ if (bfd_bread ((PTR) x_symp,
+ (bfd_size_type) (symcount * sizeof (Elf_External_Sym)),
+ abfd)
!= symcount * sizeof (Elf_External_Sym))
goto error_return;
if (x_versymp == NULL && verhdr->sh_size != 0)
goto error_return;
- if (bfd_read ((PTR) x_versymp, 1, verhdr->sh_size, abfd)
+ if (bfd_bread ((PTR) x_versymp, (bfd_size_type) verhdr->sh_size, abfd)
!= verhdr->sh_size)
goto error_return;
}
unsigned int i;
int entsize;
- allocated = (PTR) bfd_malloc ((size_t) rel_hdr->sh_size);
+ allocated = (PTR) bfd_malloc (rel_hdr->sh_size);
if (allocated == NULL)
goto error_return;
if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (allocated, 1, rel_hdr->sh_size, abfd)
+ || (bfd_bread (allocated, rel_hdr->sh_size, abfd)
!= rel_hdr->sh_size))
goto error_return;
bfd_size_type reloc_count;
bfd_size_type reloc_count2;
arelent *relents;
+ bfd_size_type amt;
if (asect->relocation != NULL)
return true;
reloc_count2 = 0;
}
- relents = ((arelent *)
- bfd_alloc (abfd,
- (reloc_count + reloc_count2) * sizeof (arelent)));
+ amt = (reloc_count + reloc_count2) * sizeof (arelent);
+ relents = (arelent *) bfd_alloc (abfd, amt);
if (relents == NULL)
return false;
struct elf_backend_data *ebd;
struct elf_obj_tdata *preserved_tdata = elf_tdata (abfd);
struct elf_obj_tdata *new_tdata = NULL;
+ bfd_size_type amt;
/* Read in the ELF header in external format. */
- if (bfd_read ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd) != sizeof (x_ehdr))
+ if (bfd_bread ((PTR) &x_ehdr, (bfd_size_type) sizeof (x_ehdr), abfd)
+ != sizeof (x_ehdr))
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
}
/* Give abfd an elf_obj_tdata. */
- new_tdata =
- (struct elf_obj_tdata *) bfd_zalloc (abfd, sizeof (struct elf_obj_tdata));
+ amt = sizeof (struct elf_obj_tdata);
+ new_tdata = (struct elf_obj_tdata *) bfd_zalloc (abfd, amt);
if (new_tdata == NULL)
return NULL;
elf_tdata (abfd) = new_tdata;
goto wrong;
/* Move to the start of the program headers. */
- if (bfd_seek (abfd, i_ehdrp->e_phoff, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_phoff, SEEK_SET) != 0)
goto wrong;
/* Allocate space for the program headers. */
- i_phdrp = (Elf_Internal_Phdr *)
- bfd_alloc (abfd, sizeof (*i_phdrp) * i_ehdrp->e_phnum);
+ amt = sizeof (*i_phdrp) * i_ehdrp->e_phnum;
+ i_phdrp = (Elf_Internal_Phdr *) bfd_alloc (abfd, amt);
if (!i_phdrp)
goto fail;
for (phindex = 0; phindex < i_ehdrp->e_phnum; ++phindex)
{
Elf_External_Phdr x_phdr;
- if (bfd_read ((PTR) &x_phdr, sizeof (x_phdr), 1, abfd)
+ if (bfd_bread ((PTR) &x_phdr, (bfd_size_type) sizeof (x_phdr), abfd)
!= sizeof (x_phdr))
goto fail;
/* Process each program header. */
for (phindex = 0; phindex < i_ehdrp->e_phnum; ++phindex)
{
- if (! bfd_section_from_phdr (abfd, i_phdrp + phindex, phindex))
+ if (! bfd_section_from_phdr (abfd, i_phdrp + phindex, (int) phindex))
goto fail;
}
}
else
{
- alc = bfd_malloc (p - name + 1);
+ alc = bfd_malloc ((bfd_size_type) (p - name + 1));
if (alc == NULL)
return false;
- strncpy (alc, name, p - name);
+ strncpy (alc, name, (size_t) (p - name));
alc[p - name] = '\0';
name = alc;
copy = true;
if (!lsect)
{
asection *s;
+ bfd_size_type amt = sizeof (elf_linker_section_t);
- lsect = (elf_linker_section_t *)
- bfd_alloc (dynobj, sizeof (elf_linker_section_t));
+ lsect = (elf_linker_section_t *) bfd_alloc (dynobj, amt);
*lsect = *defaults;
elf_linker_section (dynobj, which) = lsect;
elf_linker_section_pointers_t *
_bfd_elf_find_pointer_linker_section (linker_pointers, addend, which)
elf_linker_section_pointers_t *linker_pointers;
- bfd_signed_vma addend;
+ bfd_vma addend;
elf_linker_section_enum_t which;
{
for ( ; linker_pointers != NULL; linker_pointers = linker_pointers->next)
Elf_External_Sym * esym;
Elf_External_Sym * esymend;
Elf_External_Sym * buf = NULL;
- size_t symcount;
- size_t extsymcount;
- size_t extsymoff;
+ bfd_size_type symcount;
+ bfd_size_type extsymcount;
+ bfd_size_type extsymoff;
boolean result = false;
+ file_ptr pos;
+ bfd_size_type amt;
abfd = _bfd_get_elt_at_filepos (abfd, symdef->file_offset);
if (abfd == (bfd *) NULL)
extsymoff = hdr->sh_info;
}
- buf = ((Elf_External_Sym *)
- bfd_malloc (extsymcount * sizeof (Elf_External_Sym)));
+ amt = extsymcount * sizeof (Elf_External_Sym);
+ buf = (Elf_External_Sym *) bfd_malloc (amt);
if (buf == NULL && extsymcount != 0)
return false;
/* Read in the symbol table.
FIXME: This ought to be cached somewhere. */
- if (bfd_seek (abfd,
- hdr->sh_offset + extsymoff * sizeof (Elf_External_Sym),
- SEEK_SET) != 0
- || (bfd_read ((PTR) buf, sizeof (Elf_External_Sym), extsymcount, abfd)
- != extsymcount * sizeof (Elf_External_Sym)))
+ pos = hdr->sh_offset + extsymoff * sizeof (Elf_External_Sym);
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0
+ || bfd_bread ((PTR) buf, amt, abfd) != amt)
{
free (buf);
return false;
boolean *included = NULL;
carsym *symdefs;
boolean loop;
+ bfd_size_type amt;
if (! bfd_has_map (abfd))
{
c = bfd_ardata (abfd)->symdef_count;
if (c == 0)
return true;
- defined = (boolean *) bfd_malloc (c * sizeof (boolean));
- included = (boolean *) bfd_malloc (c * sizeof (boolean));
+ amt = c;
+ amt *= sizeof (boolean);
+ defined = (boolean *) bfd_malloc (amt);
+ included = (boolean *) bfd_malloc (amt);
if (defined == (boolean *) NULL || included == (boolean *) NULL)
goto error_return;
- memset (defined, 0, c * sizeof (boolean));
- memset (included, 0, c * sizeof (boolean));
+ memset (defined, 0, (size_t) amt);
+ memset (included, 0, (size_t) amt);
symdefs = bfd_ardata (abfd)->symdefs;
if (p == NULL || p[1] != ELF_VER_CHR)
continue;
- copy = bfd_alloc (abfd, p - symdef->name + 1);
+ copy = bfd_alloc (abfd, (bfd_size_type) (p - symdef->name + 1));
if (copy == NULL)
goto error_return;
- memcpy (copy, symdef->name, p - symdef->name);
+ memcpy (copy, symdef->name, (size_t) (p - symdef->name));
copy[p - symdef->name] = '\0';
h = elf_link_hash_lookup (elf_hash_table (info), copy,
asection *, const Elf_Internal_Rela *));
boolean collect;
Elf_Internal_Shdr *hdr;
- size_t symcount;
- size_t extsymcount;
- size_t extsymoff;
+ bfd_size_type symcount;
+ bfd_size_type extsymcount;
+ bfd_size_type extsymoff;
Elf_External_Sym *buf = NULL;
struct elf_link_hash_entry **sym_hash;
boolean dynamic;
struct elf_backend_data *bed;
boolean dt_needed;
struct elf_link_hash_table * hash_table;
+ file_ptr pos;
+ bfd_size_type amt;
hash_table = elf_hash_table (info);
extversym = (Elf_External_Versym *) bfd_malloc (versymhdr->sh_size);
if (extversym == NULL)
goto error_return;
+ amt = versymhdr->sh_size;
if (bfd_seek (abfd, versymhdr->sh_offset, SEEK_SET) != 0
- || (bfd_read ((PTR) extversym, 1, versymhdr->sh_size, abfd)
- != versymhdr->sh_size))
+ || bfd_bread ((PTR) extversym, amt, abfd) != amt)
goto error_return;
}
}
extsymoff = hdr->sh_info;
}
- buf = ((Elf_External_Sym *)
- bfd_malloc (extsymcount * sizeof (Elf_External_Sym)));
+ amt = extsymcount * sizeof (Elf_External_Sym);
+ buf = (Elf_External_Sym *) bfd_malloc (amt);
if (buf == NULL && extsymcount != 0)
goto error_return;
/* We store a pointer to the hash table entry for each external
symbol. */
- sym_hash = ((struct elf_link_hash_entry **)
- bfd_alloc (abfd,
- extsymcount * sizeof (struct elf_link_hash_entry *)));
+ amt = extsymcount * sizeof (struct elf_link_hash_entry *);
+ sym_hash = (struct elf_link_hash_entry **) bfd_alloc (abfd, amt);
if (sym_hash == NULL)
goto error_return;
elf_sym_hashes (abfd) = sym_hash;
Elf_External_Dyn *extdyn;
Elf_External_Dyn *extdynend;
int elfsec;
- unsigned long link;
+ unsigned long shlink;
int rpath;
int runpath;
- dynbuf = (Elf_External_Dyn *) bfd_malloc ((size_t) s->_raw_size);
+ dynbuf = (Elf_External_Dyn *) bfd_malloc (s->_raw_size);
if (dynbuf == NULL)
goto error_return;
elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
if (elfsec == -1)
goto error_return;
- link = elf_elfsections (abfd)[elfsec]->sh_link;
+ shlink = elf_elfsections (abfd)[elfsec]->sh_link;
{
/* The shared libraries distributed with hpux11 have a bogus
sh_link field for the ".dynamic" section. This code detects
- when LINK refers to a section that is not a string table and
- tries to find the string table for the ".dynsym" section
+ when SHLINK refers to a section that is not a string table
+ and tries to find the string table for the ".dynsym" section
instead. */
- Elf_Internal_Shdr *hdr = elf_elfsections (abfd)[link];
- if (hdr->sh_type != SHT_STRTAB)
+ Elf_Internal_Shdr *shdr = elf_elfsections (abfd)[shlink];
+ if (shdr->sh_type != SHT_STRTAB)
{
- asection *s = bfd_get_section_by_name (abfd, ".dynsym");
- int elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
- if (elfsec == -1)
+ asection *ds = bfd_get_section_by_name (abfd, ".dynsym");
+ int elfdsec = _bfd_elf_section_from_bfd_section (abfd, ds);
+ if (elfdsec == -1)
goto error_return;
- link = elf_elfsections (abfd)[elfsec]->sh_link;
+ shlink = elf_elfsections (abfd)[elfdsec]->sh_link;
}
}
elf_swap_dyn_in (abfd, extdyn, &dyn);
if (dyn.d_tag == DT_SONAME)
{
- name = bfd_elf_string_from_elf_section (abfd, link,
- dyn.d_un.d_val);
+ unsigned int tagv = dyn.d_un.d_val;
+ name = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
if (name == NULL)
goto error_return;
}
{
struct bfd_link_needed_list *n, **pn;
char *fnm, *anm;
+ unsigned int tagv = dyn.d_un.d_val;
- n = ((struct bfd_link_needed_list *)
- bfd_alloc (abfd, sizeof (struct bfd_link_needed_list)));
- fnm = bfd_elf_string_from_elf_section (abfd, link,
- dyn.d_un.d_val);
+ amt = sizeof (struct bfd_link_needed_list);
+ n = (struct bfd_link_needed_list *) bfd_alloc (abfd, amt);
+ fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
if (n == NULL || fnm == NULL)
goto error_return;
- anm = bfd_alloc (abfd, strlen (fnm) + 1);
+ anm = bfd_alloc (abfd, (bfd_size_type) strlen (fnm) + 1);
if (anm == NULL)
goto error_return;
strcpy (anm, fnm);
{
struct bfd_link_needed_list *n, **pn;
char *fnm, *anm;
+ unsigned int tagv = dyn.d_un.d_val;
/* When we see DT_RPATH before DT_RUNPATH, we have
to clear runpath. Do _NOT_ bfd_release, as that
if (rpath && hash_table->runpath)
hash_table->runpath = NULL;
- n = ((struct bfd_link_needed_list *)
- bfd_alloc (abfd, sizeof (struct bfd_link_needed_list)));
- fnm = bfd_elf_string_from_elf_section (abfd, link,
- dyn.d_un.d_val);
+ amt = sizeof (struct bfd_link_needed_list);
+ n = (struct bfd_link_needed_list *) bfd_alloc (abfd, amt);
+ fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
if (n == NULL || fnm == NULL)
goto error_return;
- anm = bfd_alloc (abfd, strlen (fnm) + 1);
+ anm = bfd_alloc (abfd, (bfd_size_type) strlen (fnm) + 1);
if (anm == NULL)
goto error_return;
strcpy (anm, fnm);
{
struct bfd_link_needed_list *n, **pn;
char *fnm, *anm;
+ unsigned int tagv = dyn.d_un.d_val;
- n = ((struct bfd_link_needed_list *)
- bfd_alloc (abfd, sizeof (struct bfd_link_needed_list)));
- fnm = bfd_elf_string_from_elf_section (abfd, link,
- dyn.d_un.d_val);
+ amt = sizeof (struct bfd_link_needed_list);
+ n = (struct bfd_link_needed_list *) bfd_alloc (abfd, amt);
+ fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
if (n == NULL || fnm == NULL)
goto error_return;
- anm = bfd_alloc (abfd, strlen (fnm) + 1);
+ anm = bfd_alloc (abfd, (bfd_size_type) strlen (fnm) + 1);
if (anm == NULL)
goto error_return;
strcpy (anm, fnm);
}
}
- if (! elf_add_dynamic_entry (info, DT_NEEDED, strindex))
+ if (! elf_add_dynamic_entry (info, (bfd_vma) DT_NEEDED, strindex))
goto error_return;
}
elf_dt_name (abfd) = name;
}
- if (bfd_seek (abfd,
- hdr->sh_offset + extsymoff * sizeof (Elf_External_Sym),
- SEEK_SET) != 0
- || (bfd_read ((PTR) buf, sizeof (Elf_External_Sym), extsymcount, abfd)
- != extsymcount * sizeof (Elf_External_Sym)))
+ pos = hdr->sh_offset + extsymoff * sizeof (Elf_External_Sym);
+ amt = extsymcount * sizeof (Elf_External_Sym);
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0
+ || bfd_bread ((PTR) buf, amt, abfd) != amt)
goto error_return;
weaks = NULL;
|| (vernum > 1 && ! bfd_is_abs_section (sec)))
{
const char *verstr;
- int namelen, newlen;
+ unsigned int namelen;
+ bfd_size_type newlen;
char *newname, *p;
if (sym.st_shndx != SHN_UNDEF)
boolean override;
shortname = bfd_hash_allocate (&info->hash->table,
- p - name + 1);
+ (size_t) (p - name + 1));
if (shortname == NULL)
goto error_return;
- strncpy (shortname, name, p - name);
+ strncpy (shortname, name, (size_t) (p - name));
shortname[p - name] = '\0';
/* We are going to create a new symbol. Merge it
strlen (name));
if (shortname == NULL)
goto error_return;
- strncpy (shortname, name, p - name);
+ strncpy (shortname, name, (size_t) (p - name));
strcpy (shortname + (p - name), p + 1);
/* Once again, merge with any existing symbol. */
}
}
- if (! elf_add_dynamic_entry (info, DT_NEEDED, strindex))
+ if (! elf_add_dynamic_entry (info, (bfd_vma) DT_NEEDED, strindex))
goto error_return;
}
}
Elf_Internal_Dyn dyn;
bfd *dynobj;
asection *s;
- size_t newsize;
+ bfd_size_type newsize;
bfd_byte *newcontents;
if (! is_elf_hash_table (info))
Elf_External_Sym esym;
unsigned long dynstr_index;
char *name;
+ file_ptr pos;
+ bfd_size_type amt;
if (! is_elf_hash_table (info))
return false;
return true;
entry = (struct elf_link_local_dynamic_entry *)
- bfd_alloc (input_bfd, sizeof (*entry));
+ bfd_alloc (input_bfd, (bfd_size_type) sizeof (*entry));
if (entry == NULL)
return false;
/* Go find the symbol, so that we can find it's name. */
- if (bfd_seek (input_bfd,
- (elf_tdata (input_bfd)->symtab_hdr.sh_offset
- + input_indx * sizeof (Elf_External_Sym)),
- SEEK_SET) != 0
- || (bfd_read (&esym, sizeof (Elf_External_Sym), 1, input_bfd)
- != sizeof (Elf_External_Sym)))
+ amt = sizeof (Elf_External_Sym);
+ pos = elf_tdata (input_bfd)->symtab_hdr.sh_offset + input_indx * amt;
+ if (bfd_seek (input_bfd, pos, SEEK_SET) != 0
+ || bfd_bread (&esym, amt, input_bfd) != amt)
return false;
elf_swap_symbol_in (input_bfd, &esym, &entry->isym);
Elf_Internal_Rela *internal_relocs;
{
struct elf_backend_data *bed;
+ bfd_size_type amt;
/* If there aren't any relocations, that's OK. */
if (!shdr)
return false;
/* Read the relocations. */
- if (bfd_read (external_relocs, 1, shdr->sh_size, abfd)
- != shdr->sh_size)
+ if (bfd_bread (external_relocs, shdr->sh_size, abfd) != shdr->sh_size)
return false;
bed = get_elf_backend_data (abfd);
erel = (Elf_External_Rel *) external_relocs;
erelend = erel + NUM_SHDR_ENTRIES (shdr);
irela = internal_relocs;
- irel = bfd_alloc (abfd, (bed->s->int_rels_per_ext_rel
- * sizeof (Elf_Internal_Rel)));
+ amt = bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rel);
+ irel = bfd_alloc (abfd, amt);
for (; erel < erelend; erel++, irela += bed->s->int_rels_per_ext_rel)
{
unsigned int i;
if (internal_relocs == NULL)
{
- size_t size;
+ bfd_size_type size;
- size = (o->reloc_count * bed->s->int_rels_per_ext_rel
- * sizeof (Elf_Internal_Rela));
+ size = o->reloc_count;
+ size *= bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rela);
if (keep_memory)
internal_relocs = (Elf_Internal_Rela *) bfd_alloc (abfd, size);
else
if (external_relocs == NULL)
{
- size_t size = (size_t) rel_hdr->sh_size;
+ bfd_size_type size = rel_hdr->sh_size;
if (elf_section_data (o)->rel_hdr2)
- size += (size_t) elf_section_data (o)->rel_hdr2->sh_size;
+ size += elf_section_data (o)->rel_hdr2->sh_size;
alloc1 = (PTR) bfd_malloc (size);
if (alloc1 == NULL)
goto error_return;
unsigned long int *hashcodes;
unsigned long int *hashcodesp;
unsigned long int i;
+ bfd_size_type amt;
/* Compute the hash values for all exported symbols. At the same
time store the values in an array so that we could use them for
optimizations. */
- hashcodes = (unsigned long int *) bfd_malloc (dynsymcount
- * sizeof (unsigned long int));
+ amt = dynsymcount;
+ amt *= sizeof (unsigned long int);
+ hashcodes = (unsigned long int *) bfd_malloc (amt);
if (hashcodes == NULL)
return 0;
hashcodesp = hashcodes;
/* Create array where we count the collisions in. We must use bfd_malloc
since the size could be large. */
- counts = (unsigned long int *) bfd_malloc (maxsize
- * sizeof (unsigned long int));
+ amt = maxsize;
+ amt *= sizeof (unsigned long int);
+ counts = (unsigned long int *) bfd_malloc (amt);
if (counts == NULL)
{
free (hashcodes);
soname_indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr,
soname, true, true);
if (soname_indx == (bfd_size_type) -1
- || ! elf_add_dynamic_entry (info, DT_SONAME, soname_indx))
+ || ! elf_add_dynamic_entry (info, (bfd_vma) DT_SONAME,
+ soname_indx))
return false;
}
if (info->symbolic)
{
- if (! elf_add_dynamic_entry (info, DT_SYMBOLIC, 0))
+ if (! elf_add_dynamic_entry (info, (bfd_vma) DT_SYMBOLIC,
+ (bfd_vma) 0))
return false;
info->flags |= DF_SYMBOLIC;
}
indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr, rpath,
true, true);
if (indx == (bfd_size_type) -1
- || ! elf_add_dynamic_entry (info, DT_RPATH, indx)
+ || ! elf_add_dynamic_entry (info, (bfd_vma) DT_RPATH, indx)
|| (info->new_dtags
- && ! elf_add_dynamic_entry (info, DT_RUNPATH, indx)))
+ && ! elf_add_dynamic_entry (info, (bfd_vma) DT_RUNPATH,
+ indx)))
return false;
}
indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr,
filter_shlib, true, true);
if (indx == (bfd_size_type) -1
- || ! elf_add_dynamic_entry (info, DT_FILTER, indx))
+ || ! elf_add_dynamic_entry (info, (bfd_vma) DT_FILTER, indx))
return false;
}
indx = _bfd_stringtab_add (elf_hash_table (info)->dynstr,
*p, true, true);
if (indx == (bfd_size_type) -1
- || ! elf_add_dynamic_entry (info, DT_AUXILIARY, indx))
+ || ! elf_add_dynamic_entry (info, (bfd_vma) DT_AUXILIARY,
+ indx))
return false;
}
}
&& (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR
| ELF_LINK_HASH_DEF_REGULAR)) != 0)
{
- if (! elf_add_dynamic_entry (info, DT_INIT, 0))
+ if (! elf_add_dynamic_entry (info, (bfd_vma) DT_INIT, (bfd_vma) 0))
return false;
}
h = (info->fini_function
&& (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR
| ELF_LINK_HASH_DEF_REGULAR)) != 0)
{
- if (! elf_add_dynamic_entry (info, DT_FINI, 0))
+ if (! elf_add_dynamic_entry (info, (bfd_vma) DT_FINI, (bfd_vma) 0))
return false;
}
bfd_size_type strsize;
strsize = _bfd_stringtab_size (elf_hash_table (info)->dynstr);
- if (! elf_add_dynamic_entry (info, DT_HASH, 0)
- || ! elf_add_dynamic_entry (info, DT_STRTAB, 0)
- || ! elf_add_dynamic_entry (info, DT_SYMTAB, 0)
- || ! elf_add_dynamic_entry (info, DT_STRSZ, strsize)
- || ! elf_add_dynamic_entry (info, DT_SYMENT,
- sizeof (Elf_External_Sym)))
+ if (! elf_add_dynamic_entry (info, (bfd_vma) DT_HASH, (bfd_vma) 0)
+ || ! elf_add_dynamic_entry (info, (bfd_vma) DT_STRTAB, (bfd_vma) 0)
+ || ! elf_add_dynamic_entry (info, (bfd_vma) DT_SYMTAB, (bfd_vma) 0)
+ || ! elf_add_dynamic_entry (info, (bfd_vma) DT_STRSZ, strsize)
+ || ! elf_add_dynamic_entry (info, (bfd_vma) DT_SYMENT,
+ (bfd_vma) sizeof (Elf_External_Sym)))
return false;
}
}
if (elf_hash_table (info)->dynamic_sections_created)
{
- size_t dynsymcount;
+ bfd_size_type dynsymcount;
asection *s;
size_t bucketcount = 0;
size_t hash_entry_size;
}
}
- if (! elf_add_dynamic_entry (info, DT_VERDEF, 0)
- || ! elf_add_dynamic_entry (info, DT_VERDEFNUM, cdefs))
+ if (! elf_add_dynamic_entry (info, (bfd_vma) DT_VERDEF, (bfd_vma) 0)
+ || ! elf_add_dynamic_entry (info, (bfd_vma) DT_VERDEFNUM,
+ (bfd_vma) cdefs))
return false;
elf_tdata (output_bfd)->cverdefs = cdefs;
if (info->new_dtags && info->flags)
{
- if (! elf_add_dynamic_entry (info, DT_FLAGS, info->flags))
+ if (! elf_add_dynamic_entry (info, (bfd_vma) DT_FLAGS, info->flags))
return false;
}
info->flags_1 &= ~ (DF_1_INITFIRST
| DF_1_NODELETE
| DF_1_NOOPEN);
- if (! elf_add_dynamic_entry (info, DT_FLAGS_1, info->flags_1))
+ if (! elf_add_dynamic_entry (info, (bfd_vma) DT_FLAGS_1,
+ info->flags_1))
return false;
}
}
s->_raw_size = size;
- s->contents = (bfd_byte *) bfd_alloc (output_bfd, size);
+ s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
if (s->contents == NULL)
return false;
}
}
- if (! elf_add_dynamic_entry (info, DT_VERNEED, 0)
- || ! elf_add_dynamic_entry (info, DT_VERNEEDNUM, crefs))
+ if (! elf_add_dynamic_entry (info, (bfd_vma) DT_VERNEED,
+ (bfd_vma) 0)
+ || ! elf_add_dynamic_entry (info, (bfd_vma) DT_VERNEEDNUM,
+ (bfd_vma) crefs))
return false;
elf_tdata (output_bfd)->cverrefs = crefs;
if (s->contents == NULL)
return false;
- if (! elf_add_dynamic_entry (info, DT_VERSYM, 0))
+ if (! elf_add_dynamic_entry (info, (bfd_vma) DT_VERSYM, (bfd_vma) 0))
return false;
}
return false;
memset (s->contents, 0, (size_t) s->_raw_size);
- bfd_put (8 * hash_entry_size, output_bfd, bucketcount, s->contents);
- bfd_put (8 * hash_entry_size, output_bfd, dynsymcount,
+ bfd_put (8 * hash_entry_size, output_bfd, (bfd_vma) bucketcount,
+ s->contents);
+ bfd_put (8 * hash_entry_size, output_bfd, (bfd_vma) dynsymcount,
s->contents + hash_entry_size);
elf_hash_table (info)->bucketcount = bucketcount;
s->_raw_size = _bfd_stringtab_size (elf_hash_table (info)->dynstr);
for (dtagcount = 0; dtagcount <= info->spare_dynamic_tags; ++dtagcount)
- if (! elf_add_dynamic_entry (info, DT_NULL, 0))
+ if (! elf_add_dynamic_entry (info, (bfd_vma) DT_NULL, (bfd_vma) 0))
return false;
}
struct elf_find_verdep_info *rinfo = (struct elf_find_verdep_info *) data;
Elf_Internal_Verneed *t;
Elf_Internal_Vernaux *a;
+ bfd_size_type amt;
/* We only care about symbols defined in shared objects with version
information. */
if (t == NULL)
{
- t = (Elf_Internal_Verneed *) bfd_zalloc (rinfo->output_bfd, sizeof *t);
+ amt = sizeof *t;
+ t = (Elf_Internal_Verneed *) bfd_zalloc (rinfo->output_bfd, amt);
if (t == NULL)
{
rinfo->failed = true;
elf_tdata (rinfo->output_bfd)->verref = t;
}
- a = (Elf_Internal_Vernaux *) bfd_zalloc (rinfo->output_bfd, sizeof *a);
+ amt = sizeof *a;
+ a = (Elf_Internal_Vernaux *) bfd_zalloc (rinfo->output_bfd, amt);
/* Note that we are copying a string pointer here, and testing it
above. If bfd_elf_string_from_elf_section is ever changed to
struct elf_link_hash_entry *h;
PTR data;
{
- struct elf_assign_sym_version_info *sinfo =
- (struct elf_assign_sym_version_info *) data;
- struct bfd_link_info *info = sinfo->info;
+ struct elf_assign_sym_version_info *sinfo;
+ struct bfd_link_info *info;
struct elf_backend_data *bed;
struct elf_info_failed eif;
char *p;
+ bfd_size_type amt;
+
+ sinfo = (struct elf_assign_sym_version_info *) data;
+ info = sinfo->info;
/* Fix the symbol flags. */
eif.failed = false;
{
if (strcmp (t->name, p) == 0)
{
- int len;
+ size_t len;
char *alc;
struct bfd_elf_version_expr *d;
len = p - h->root.root.string;
- alc = bfd_alloc (sinfo->output_bfd, len);
+ alc = bfd_alloc (sinfo->output_bfd, (bfd_size_type) len);
if (alc == NULL)
return false;
strncpy (alc, h->root.root.string, len - 1);
if (h->dynindx == -1)
return true;
+ amt = sizeof *t;
t = ((struct bfd_elf_version_tree *)
- bfd_alloc (sinfo->output_bfd, sizeof *t));
+ bfd_alloc (sinfo->output_bfd, amt));
if (t == NULL)
{
sinfo->failed = true;
Elf_Internal_Shdr *rel_hdr;
asection *o;
{
- unsigned reloc_count;
- unsigned num_rel_hashes;
+ bfd_size_type reloc_count;
+ bfd_size_type num_rel_hashes;
/* Figure out how many relocations there will be. */
if (rel_hdr == &elf_section_data (o)->rel_hdr)
num_rel_hashes = o->reloc_count;
if (num_rel_hashes < reloc_count)
num_rel_hashes = reloc_count;
-
+
/* That allows us to calculate the size of the section. */
rel_hdr->sh_size = rel_hdr->sh_entsize * reloc_count;
struct elf_backend_data *bed = get_elf_backend_data (abfd);
Elf_Internal_Rel *irel;
Elf_Internal_Rela *irela;
+ bfd_size_type amt = sizeof (Elf_Internal_Rel) * bed->s->int_rels_per_ext_rel;
- irel = (Elf_Internal_Rel *) bfd_zmalloc (sizeof (Elf_Internal_Rel)
- * bed->s->int_rels_per_ext_rel);
+ irel = (Elf_Internal_Rel *) bfd_zmalloc (amt);
if (irel == NULL)
{
(*_bfd_error_handler) (_("Error: out of memory"));
abort ();
}
- irela = (Elf_Internal_Rela *) bfd_zmalloc (sizeof (Elf_Internal_Rela)
- * bed->s->int_rels_per_ext_rel);
+ amt = sizeof (Elf_Internal_Rela) * bed->s->int_rels_per_ext_rel;
+ irela = (Elf_Internal_Rela *) bfd_zmalloc (amt);
if (irela == NULL)
{
(*_bfd_error_handler) (_("Error: out of memory"));
if (rela == NULL)
{
(*info->callbacks->warning)
- (info, _("Not enough memory to sort relocations"), 0, abfd, 0, 0);
+ (info, _("Not enough memory to sort relocations"), 0, abfd, 0,
+ (bfd_vma) 0);
return 0;
}
else
elf_swap_reloc_in (abfd, erel, &s->u.rel);
- s->type = (*bed->elf_backend_reloc_type_class)
- (ELF_R_TYPE (s->u.rel.r_info));
- }
+ s->type = ((*bed->elf_backend_reloc_type_class)
+ ((int) ELF_R_TYPE (s->u.rel.r_info)));
+ }
}
else
{
for (; erela < erelaend; erela++, s++)
{
if (bed->s->swap_reloca_in)
- (*bed->s->swap_reloca_in) (dynobj, (bfd_byte *) erela, &s->u.rela);
+ (*bed->s->swap_reloca_in) (dynobj, (bfd_byte *) erela,
+ &s->u.rela);
else
elf_swap_reloca_in (dynobj, erela, &s->u.rela);
- s->type = (*bed->elf_backend_reloc_type_class)
- (ELF_R_TYPE (s->u.rel.r_info));
- }
+ s->type = ((*bed->elf_backend_reloc_type_class)
+ ((int) ELF_R_TYPE (s->u.rel.r_info)));
+ }
}
}
rela[i].offset = rela[j].u.rel.r_offset;
}
qsort (rela + ret, count - ret, sizeof (*rela), elf_link_sort_cmp2);
-
+
for (o = dynobj->sections; o != NULL; o = o->next)
if ((o->flags & (SEC_HAS_CONTENTS|SEC_LINKER_CREATED))
== (SEC_HAS_CONTENTS|SEC_LINKER_CREATED)
for (; erel < erelend; erel++, s++)
{
if (bed->s->swap_reloc_out)
- (*bed->s->swap_reloc_out) (abfd, &s->u.rel, (bfd_byte *) erel);
+ (*bed->s->swap_reloc_out) (abfd, &s->u.rel,
+ (bfd_byte *) erel);
else
elf_swap_reloc_out (abfd, &s->u.rel, erel);
}
for (; erela < erelaend; erela++, s++)
{
if (bed->s->swap_reloca_out)
- (*bed->s->swap_reloca_out) (dynobj, &s->u.rela, (bfd_byte *) erela);
+ (*bed->s->swap_reloca_out) (dynobj, &s->u.rela,
+ (bfd_byte *) erela);
else
elf_swap_reloca_out (dynobj, &s->u.rela, erela);
- }
+ }
}
}
register asection *o;
register struct bfd_link_order *p;
register bfd *sub;
- size_t max_contents_size;
- size_t max_external_reloc_size;
- size_t max_internal_reloc_count;
- size_t max_sym_count;
+ bfd_size_type max_contents_size;
+ bfd_size_type max_external_reloc_size;
+ bfd_size_type max_internal_reloc_count;
+ bfd_size_type max_sym_count;
file_ptr off;
Elf_Internal_Sym elfsym;
unsigned int i;
boolean merged;
size_t relativecount = 0;
asection *reldyn = 0;
+ bfd_size_type amt;
if (! is_elf_hash_table (info))
return false;
finfo.symbuf_size = 20;
else
finfo.symbuf_size = max_sym_count;
- finfo.symbuf = ((Elf_External_Sym *)
- bfd_malloc (finfo.symbuf_size * sizeof (Elf_External_Sym)));
+ amt = finfo.symbuf_size;
+ amt *= sizeof (Elf_External_Sym);
+ finfo.symbuf = (Elf_External_Sym *) bfd_malloc (amt);
if (finfo.symbuf == NULL)
goto error_return;
table, do it now. */
if (bed->elf_backend_output_arch_syms)
{
- if (! (*bed->elf_backend_output_arch_syms)
- (abfd, info, (PTR) &finfo,
- (boolean (*) PARAMS ((PTR, const char *,
- Elf_Internal_Sym *, asection *)))
- elf_link_output_sym))
+ typedef boolean (*out_sym_func) PARAMS ((PTR, const char *,
+ Elf_Internal_Sym *,
+ asection *));
+
+ if (! ((*bed->elf_backend_output_arch_syms)
+ (abfd, info, (PTR) &finfo, (out_sym_func) elf_link_output_sym)))
return false;
}
|| strcmp (bfd_get_section_name (abfd, o), ".dynstr") != 0)
{
if (! bfd_set_section_contents (abfd, o->output_section,
- o->contents, o->output_offset,
+ o->contents,
+ (file_ptr) o->output_offset,
o->_raw_size))
goto error_return;
}
else
{
- file_ptr off;
-
/* The contents of the .dynstr section are actually in a
stringtab. */
off = elf_section_data (o->output_section)->this_hdr.sh_offset;
if (finfo->symbuf_count > 0)
{
Elf_Internal_Shdr *symtab;
+ file_ptr pos;
+ bfd_size_type amt;
symtab = &elf_tdata (finfo->output_bfd)->symtab_hdr;
-
- if (bfd_seek (finfo->output_bfd, symtab->sh_offset + symtab->sh_size,
- SEEK_SET) != 0
- || (bfd_write ((PTR) finfo->symbuf, finfo->symbuf_count,
- sizeof (Elf_External_Sym), finfo->output_bfd)
- != finfo->symbuf_count * sizeof (Elf_External_Sym)))
+ pos = symtab->sh_offset + symtab->sh_size;
+ amt = finfo->symbuf_count * sizeof (Elf_External_Sym);
+ if (bfd_seek (finfo->output_bfd, pos, SEEK_SET) != 0
+ || bfd_bwrite ((PTR) finfo->symbuf, amt, finfo->output_bfd) != amt)
return false;
symtab->sh_size += finfo->symbuf_count * sizeof (Elf_External_Sym);
{
if (! ((*finfo->info->callbacks->undefined_symbol)
(finfo->info, h->root.root.string, h->root.u.undef.abfd,
- (asection *) NULL, 0, true)))
+ (asection *) NULL, (bfd_vma) 0, true)))
{
eoinfo->failed = true;
return false;
size_t hash_entry_size;
bfd_byte *bucketpos;
bfd_vma chain;
+ Elf_External_Sym *esym;
sym.st_name = h->dynstr_index;
-
- elf_swap_symbol_out (finfo->output_bfd, &sym,
- (PTR) (((Elf_External_Sym *)
- finfo->dynsym_sec->contents)
- + h->dynindx));
+ esym = (Elf_External_Sym *) finfo->dynsym_sec->contents + h->dynindx;
+ elf_swap_symbol_out (finfo->output_bfd, &sym, (PTR) esym);
bucketcount = elf_hash_table (finfo->info)->bucketcount;
bucket = h->elf_hash_value % bucketcount;
bucketpos = ((bfd_byte *) finfo->hash_sec->contents
+ (bucket + 2) * hash_entry_size);
chain = bfd_get (8 * hash_entry_size, finfo->output_bfd, bucketpos);
- bfd_put (8 * hash_entry_size, finfo->output_bfd, h->dynindx, bucketpos);
+ bfd_put (8 * hash_entry_size, finfo->output_bfd, (bfd_vma) h->dynindx,
+ bucketpos);
bfd_put (8 * hash_entry_size, finfo->output_bfd, chain,
((bfd_byte *) finfo->hash_sec->contents
+ (bucketcount + 2 + h->dynindx) * hash_entry_size));
if (finfo->symver_sec != NULL && finfo->symver_sec->contents != NULL)
{
Elf_Internal_Versym iversym;
+ Elf_External_Versym *eversym;
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
{
if ((h->elf_link_hash_flags & ELF_LINK_HIDDEN) != 0)
iversym.vs_vers |= VERSYM_HIDDEN;
- _bfd_elf_swap_versym_out (finfo->output_bfd, &iversym,
- (((Elf_External_Versym *)
- finfo->symver_sec->contents)
- + h->dynindx));
+ eversym = (Elf_External_Versym *) finfo->symver_sec->contents;
+ eversym += h->dynindx;
+ _bfd_elf_swap_versym_out (finfo->output_bfd, &iversym, eversym);
}
}
asection *output_section;
unsigned int *rel_countp = NULL;
struct elf_backend_data *bed;
+ bfd_size_type amt;
output_section = input_section->output_section;
output_rel_hdr = NULL;
{
Elf_External_Rel *erel;
Elf_Internal_Rel *irel;
-
- irel = (Elf_Internal_Rel *) bfd_zmalloc (bed->s->int_rels_per_ext_rel
- * sizeof (Elf_Internal_Rel));
+
+ amt = bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rel);
+ irel = (Elf_Internal_Rel *) bfd_zmalloc (amt);
if (irel == NULL)
{
(*_bfd_error_handler) (_("Error: out of memory"));
for (; irela < irelaend; irela += bed->s->int_rels_per_ext_rel, erel++)
{
unsigned int i;
-
+
for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
{
irel[i].r_offset = irela[i].r_offset;
external_syms = NULL;
else
{
+ bfd_size_type amt = locsymcount * sizeof (Elf_External_Sym);
external_syms = finfo->external_syms;
if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (external_syms, sizeof (Elf_External_Sym),
- locsymcount, input_bfd)
- != locsymcount * sizeof (Elf_External_Sym)))
+ || bfd_bread (external_syms, amt, input_bfd) != amt)
return false;
}
struct elf_link_hash_entry **rel_hash;
Elf_Internal_Shdr *input_rel_hdr;
unsigned int next_erel;
- void (* reloc_emitter) PARAMS ((bfd *, asection *,
- Elf_Internal_Shdr *,
- Elf_Internal_Rela *));
+ void (*reloc_emitter) PARAMS ((bfd *, asection *,
+ Elf_Internal_Shdr *,
+ Elf_Internal_Rela *));
/* Adjust the reloc addresses and symbol indices. */
irela = internal_relocs;
- irelaend = irela
- + o->reloc_count * bed->s->int_rels_per_ext_rel;
+ irelaend = irela + o->reloc_count * bed->s->int_rels_per_ext_rel;
rel_hash = (elf_section_data (o->output_section)->rel_hashes
+ elf_section_data (o->output_section)->rel_count
+ elf_section_data (o->output_section)->rel_count2);
for (next_erel = 0; irela < irelaend; irela++, next_erel++)
{
unsigned long r_symndx;
- Elf_Internal_Sym *isym;
asection *sec;
if (next_erel == bed->s->int_rels_per_ext_rel)
{
if (finfo->indices[r_symndx] == -1)
{
- unsigned long link;
+ unsigned long shlink;
const char *name;
asection *osec;
/* This symbol was skipped earlier, but
since it is needed by a reloc, we
must output it now. */
- link = symtab_hdr->sh_link;
+ shlink = symtab_hdr->sh_link;
name = (bfd_elf_string_from_elf_section
- (input_bfd, link, isym->st_name));
+ (input_bfd, shlink, isym->st_name));
if (name == NULL)
return false;
input_rel_hdr = elf_section_data (o)->rel_hdr2;
if (input_rel_hdr)
{
- internal_relocs += NUM_SHDR_ENTRIES (input_rel_hdr)
- * bed->s->int_rels_per_ext_rel;
+ internal_relocs += (NUM_SHDR_ENTRIES (input_rel_hdr)
+ * bed->s->int_rels_per_ext_rel);
reloc_emitter (output_bfd, o, input_rel_hdr, internal_relocs);
}
}
else
{
- if (! (o->flags & SEC_EXCLUDE) &&
- ! bfd_set_section_contents (output_bfd, o->output_section,
- contents, o->output_offset,
- (o->_cooked_size != 0
- ? o->_cooked_size
- : o->_raw_size)))
+ bfd_size_type sec_size;
+
+ sec_size = (o->_cooked_size != 0 ? o->_cooked_size : o->_raw_size);
+ if (! (o->flags & SEC_EXCLUDE)
+ && ! bfd_set_section_contents (output_bfd, o->output_section,
+ contents,
+ (file_ptr) o->output_offset,
+ sec_size))
return false;
}
}
bfd_reloc_status_type rstat;
bfd_byte *buf;
boolean ok;
+ const char *sym_name;
size = bfd_get_reloc_size (howto);
buf = (bfd_byte *) bfd_zmalloc (size);
if (buf == (bfd_byte *) NULL)
return false;
- rstat = _bfd_relocate_contents (howto, output_bfd, addend, buf);
+ rstat = _bfd_relocate_contents (howto, output_bfd, (bfd_vma) addend, buf);
switch (rstat)
{
case bfd_reloc_ok:
break;
+
default:
case bfd_reloc_outofrange:
abort ();
+
case bfd_reloc_overflow:
+ if (link_order->type == bfd_section_reloc_link_order)
+ sym_name = bfd_section_name (output_bfd,
+ link_order->u.reloc.p->u.section);
+ else
+ sym_name = link_order->u.reloc.p->u.name;
if (! ((*info->callbacks->reloc_overflow)
- (info,
- (link_order->type == bfd_section_reloc_link_order
- ? bfd_section_name (output_bfd,
- link_order->u.reloc.p->u.section)
- : link_order->u.reloc.p->u.name),
- howto->name, addend, (bfd *) NULL, (asection *) NULL,
- (bfd_vma) 0)))
+ (info, sym_name, howto->name, addend,
+ (bfd *) NULL, (asection *) NULL, (bfd_vma) 0)))
{
free (buf);
return false;
if (rel_hdr->sh_type == SHT_REL)
{
+ bfd_size_type size;
Elf_Internal_Rel *irel;
Elf_External_Rel *erel;
unsigned int i;
-
- irel = (Elf_Internal_Rel *) bfd_zmalloc (bed->s->int_rels_per_ext_rel
- * sizeof (Elf_Internal_Rel));
+
+ size = bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rel);
+ irel = (Elf_Internal_Rel *) bfd_zmalloc (size);
if (irel == NULL)
return false;
-
+
for (i = 0; i < bed->s->int_rels_per_ext_rel; i++)
irel[i].r_offset = offset;
irel[0].r_info = ELF_R_INFO (indx, howto->type);
}
else
{
+ bfd_size_type size;
Elf_Internal_Rela *irela;
Elf_External_Rela *erela;
unsigned int i;
-
- irela = (Elf_Internal_Rela *) bfd_zmalloc (bed->s->int_rels_per_ext_rel
- * sizeof (Elf_Internal_Rela));
+
+ size = bed->s->int_rels_per_ext_rel * sizeof (Elf_Internal_Rela);
+ irela = (Elf_Internal_Rela *) bfd_zmalloc (size);
if (irela == NULL)
return false;
{
elf_linker_section_pointers_t **ptr_linker_section_ptr = NULL;
elf_linker_section_pointers_t *linker_section_ptr;
- unsigned long r_symndx = ELF_R_SYM (rel->r_info);;
+ unsigned long r_symndx = ELF_R_SYM (rel->r_info);
+ bfd_size_type amt;
BFD_ASSERT (lsect != NULL);
unsigned int num_symbols = elf_tdata (abfd)->symtab_hdr.sh_info;
register unsigned int i;
- ptr = (elf_linker_section_pointers_t **)
- bfd_alloc (abfd,
- num_symbols * sizeof (elf_linker_section_pointers_t *));
+ amt = num_symbols;
+ amt *= sizeof (elf_linker_section_pointers_t *);
+ ptr = (elf_linker_section_pointers_t **) bfd_alloc (abfd, amt);
if (!ptr)
return false;
/* Allocate space for a pointer in the linker section, and allocate
a new pointer record from internal memory. */
BFD_ASSERT (ptr_linker_section_ptr != NULL);
- linker_section_ptr = (elf_linker_section_pointers_t *)
- bfd_alloc (abfd, sizeof (elf_linker_section_pointers_t));
+ amt = sizeof (elf_linker_section_pointers_t);
+ linker_section_ptr = (elf_linker_section_pointers_t *) bfd_alloc (abfd, amt);
if (!linker_section_ptr)
return false;
{
asection *srel = lsect->rel_section;
Elf_Internal_Rela *outrel;
+ Elf_External_Rela *erel;
struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
unsigned int i;
+ bfd_size_type amt;
- outrel = (Elf_Internal_Rela *)
- bfd_zmalloc (sizeof (Elf_Internal_Rela)
- * bed->s->int_rels_per_ext_rel);
+ amt = sizeof (Elf_Internal_Rela) * bed->s->int_rels_per_ext_rel;
+ outrel = (Elf_Internal_Rela *) bfd_zmalloc (amt);
if (outrel == NULL)
{
(*_bfd_error_handler) (_("Error: out of memory"));
+ linker_section_ptr->offset);
outrel[0].r_info = ELF_R_INFO (0, relative_reloc);
outrel[0].r_addend = 0;
- elf_swap_reloca_out (output_bfd, outrel,
- (((Elf_External_Rela *)
- lsect->section->contents)
- + (elf_section_data (lsect->section)
- ->rel_count)));
+ erel = (Elf_External_Rela *) lsect->section->contents;
+ erel += elf_section_data (lsect->section)->rel_count;
+ elf_swap_reloca_out (output_bfd, outrel, erel);
++elf_section_data (lsect->section)->rel_count;
-
+
free (outrel);
}
}
locsyms = NULL;
else
{
- locsyms = freesyms =
- bfd_malloc (nlocsyms * sizeof (Elf_External_Sym));
+ bfd_size_type amt = nlocsyms * sizeof (Elf_External_Sym);
+ locsyms = freesyms = bfd_malloc (amt);
if (freesyms == NULL
|| bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (locsyms, sizeof (Elf_External_Sym),
- nlocsyms, input_bfd)
- != nlocsyms * sizeof (Elf_External_Sym)))
+ || bfd_bread (locsyms, amt, input_bfd) != amt)
{
ret = false;
goto out1;
boolean ok = true;
bfd *sub;
asection * (*gc_mark_hook)
- PARAMS ((bfd *abfd, struct bfd_link_info *, Elf_Internal_Rela *,
+ PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
struct elf_link_hash_entry *h, Elf_Internal_Sym *));
if (!get_elf_backend_data (abfd)->can_gc_sections
bfd_set_error (bfd_error_invalid_operation);
return false;
-win:
+ win:
if (!h)
{
/* This *should* only be the absolute section. It could potentially
if (ptr)
{
- ptr = bfd_realloc (ptr - 1, bytes);
+ ptr = bfd_realloc (ptr - 1, (bfd_size_type) bytes);
if (ptr != NULL)
{
}
}
else
- ptr = bfd_zmalloc (bytes);
+ ptr = bfd_zmalloc ((bfd_size_type) bytes);
if (ptr == NULL)
return false;
p = strchr (name, ELF_VER_CHR);
if (p != NULL)
{
- alc = bfd_malloc (p - name + 1);
- memcpy (alc, name, p - name);
+ alc = bfd_malloc ((bfd_size_type) (p - name + 1));
+ memcpy (alc, name, (size_t) (p - name));
alc[p - name] = '\0';
name = alc;
}
PARAMS ((bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Sym *sym,
const char **namep, flagword *flagsp, asection **secp,
bfd_vma *valp));
-static boolean elfNN_ia64_aix_vec
+static boolean elfNN_ia64_aix_vec
PARAMS ((const bfd_target *vec));
static boolean elfNN_ia64_aix_add_symbol_hook
PARAMS ((bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Sym *sym,
const Elf_Internal_Rela *relocs));
static boolean elfNN_ia64_adjust_dynamic_symbol
PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
-static unsigned long global_sym_index
+static long global_sym_index
PARAMS ((struct elf_link_hash_entry *h));
static boolean allocate_fptr
PARAMS ((struct elfNN_ia64_dyn_sym_info *dyn_i, PTR data));
arelent *bfd_reloc;
ElfNN_Internal_Rela *elf_reloc;
{
- bfd_reloc->howto = lookup_howto (ELFNN_R_TYPE (elf_reloc->r_info));
+ bfd_reloc->howto
+ = lookup_howto ((unsigned int) ELFNN_R_TYPE (elf_reloc->r_info));
}
\f
#define PLT_HEADER_SIZE (3 * 16)
goto error_return;
free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
+ || (bfd_bread (extsyms, symtab_hdr->sh_size, abfd)
!= symtab_hdr->sh_size))
goto error_return;
}
Elf_Internal_Sym isym;
asection *tsec;
struct one_fixup *f;
+ bfd_size_type amt;
if (ELFNN_R_TYPE (irel->r_info) != (int) R_IA64_PCREL21B)
continue;
roff = irel->r_offset;
reladdr = (sec->output_section->vma
+ sec->output_offset
- + roff) & -4;
+ + roff) & (bfd_vma) -4;
/* If the branch is in range, no need to do anything. */
if ((bfd_signed_vma) (symaddr - reladdr) >= -0x1000000
make a copy of the FULL_PLT entry. Otherwise, we'll have
to use a `brl' insn to get where we're going. */
- int size;
+ size_t size;
if (tsec == ia64_info->plt_sec)
size = sizeof (plt_full_entry);
}
/* Resize the current section to make room for the new branch. */
- trampoff = (sec->_cooked_size + 15) & -16;
- contents = (bfd_byte *) bfd_realloc (contents, trampoff + size);
+ trampoff = (sec->_cooked_size + 15) & (bfd_vma) -16;
+ amt = trampoff + size;
+ contents = (bfd_byte *) bfd_realloc (contents, amt);
if (contents == NULL)
goto error_return;
- sec->_cooked_size = trampoff + size;
+ sec->_cooked_size = amt;
if (tsec == ia64_info->plt_sec)
{
}
/* Record the fixup so we don't do it again this section. */
- f = (struct one_fixup *) bfd_malloc (sizeof (*f));
+ f = (struct one_fixup *) bfd_malloc ((bfd_size_type) sizeof (*f));
f->next = fixups;
f->tsec = tsec;
f->toff = toff;
/* Fix up the existing branch to hit the trampoline. Hope like
hell this doesn't overflow too. */
if (elfNN_ia64_install_value (abfd, contents + roff,
- f->trampoff - (roff & -4),
+ f->trampoff - (roff & (bfd_vma) -4),
R_IA64_PCREL21B) != bfd_reloc_ok)
goto error_return;
extern const bfd_target bfd_elfNN_ia64_aix_little_vec;
extern const bfd_target bfd_elfNN_ia64_aix_big_vec;
- return (/**/vec == & bfd_elfNN_ia64_aix_little_vec
+ return (/**/vec == & bfd_elfNN_ia64_aix_little_vec
|| vec == & bfd_elfNN_ia64_aix_big_vec);
}
struct elf_link_hash_entry *h;
h = (struct elf_link_hash_entry *) bfd_link_hash_lookup (info->hash, *namep, false, false, false);
- if (h == NULL)
+ if (h == NULL)
{
struct elf_backend_data *bed;
struct elfNN_ia64_link_hash_table *ia64_info;
bed = get_elf_backend_data (abfd);
ia64_info = elfNN_ia64_hash_table (info);
-
+
if (!(_bfd_generic_link_add_one_symbol
- (info, abfd, *namep, BSF_GLOBAL,
+ (info, abfd, *namep, BSF_GLOBAL,
bfd_get_section_by_name (abfd, ".bss"),
bed->got_symbol_offset, (const char *) NULL, false,
bed->collect, (struct bfd_link_hash_entry **) &h)))
return false;
-
+
h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
h->type = STT_OBJECT;
-
+
if (! _bfd_elf_link_record_dynamic_symbol (info, h))
return false;
}
else if (sym->st_shndx == SHN_LOOS)
{
int i;
-
+
/* SHN_AIX_SYSCALL: Treat this as any other symbol. The special symbol
is only relevant when compiling code for extended system calls.
- Replace the "special" section with .text, if possible.
+ Replace the "special" section with .text, if possible.
Note that these symbols are always assumed to be in .text. */
for (i = 1; i < elf_elfheader (abfd)->e_shnum; i++)
{
- asection * sec = bfd_section_from_elf_index (abfd, i);
-
+ asection * sec = bfd_section_from_elf_index (abfd, (unsigned) i);
+
if (sec && strcmp (sec->name, ".text") == 0)
{
*secp = sec;
if (*secp == NULL)
*secp = bfd_abs_section_ptr;
-
+
*valp = sym->st_size;
-
+
return true;
}
- else
+ else
{
- return elfNN_ia64_add_symbol_hook (abfd, info, sym,
+ return elfNN_ia64_add_symbol_hook (abfd, info, sym,
namep, flagsp, secp, valp);
}
}
break;
if (m == NULL)
{
- m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m);
+ m = ((struct elf_segment_map *)
+ bfd_zalloc (abfd, (bfd_size_type) sizeof *m));
if (m == NULL)
return false;
if (m == NULL)
{
- m = (struct elf_segment_map *) bfd_zalloc (abfd, sizeof *m);
+ m = ((struct elf_segment_map *)
+ bfd_zalloc (abfd, (bfd_size_type) sizeof *m));
if (m == NULL)
return false;
{
struct elfNN_ia64_link_hash_table *ret;
- ret = bfd_zalloc (abfd, sizeof (*ret));
+ ret = bfd_zalloc (abfd, (bfd_size_type) sizeof (*ret));
if (!ret)
return 0;
if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
if (dyn_i == NULL && create)
{
- dyn_i = (struct elfNN_ia64_dyn_sym_info *)
- bfd_zalloc (abfd, sizeof *dyn_i);
+ dyn_i = ((struct elfNN_ia64_dyn_sym_info *)
+ bfd_zalloc (abfd, (bfd_size_type) sizeof *dyn_i));
*pp = dyn_i;
dyn_i->addend = addend;
}
if (!rent)
{
- rent = (struct elfNN_ia64_dyn_reloc_entry *)
- bfd_alloc (abfd, sizeof (*rent));
+ rent = ((struct elfNN_ia64_dyn_reloc_entry *)
+ bfd_alloc (abfd, (bfd_size_type) sizeof (*rent)));
if (!rent)
return false;
{
(*info->callbacks->warning)
(info, _("@pltoff reloc against local symbol"), 0,
- abfd, 0, 0);
+ abfd, 0, (bfd_vma) 0);
}
break;
{
(*info->callbacks->warning)
(info, _("non-zero addend in @fptr reloc"), 0,
- abfd, 0, 0);
+ abfd, 0, (bfd_vma) 0);
}
dyn_i = get_dyn_sym_info (ia64_info, h, abfd, rel, true);
|| elfNN_ia64_aix_vec (abfd->xvec)))
{
if (! (_bfd_elfNN_link_record_local_dynamic_symbol
- (info, abfd, r_symndx)))
+ (info, abfd, (long) r_symndx)))
return false;
}
/* Search for the index of a global symbol in it's defining object file. */
-static unsigned long
+static long
global_sym_index (h)
struct elf_link_hash_entry *h;
{
}
/* Align the pointer for the plt2 entries. */
- data.ofs = (data.ofs + 31) & -32;
+ data.ofs = (data.ofs + 31) & (bfd_vma) -32;
elfNN_ia64_dyn_sym_traverse (ia64_info, allocate_plt2_entries, &data);
if (data.ofs != 0)
else
{
/* Allocate memory for the section contents. */
- sec->contents = (bfd_byte *) bfd_zalloc(dynobj, sec->_raw_size);
+ sec->contents = (bfd_byte *) bfd_zalloc (dynobj, sec->_raw_size);
if (sec->contents == NULL && sec->_raw_size != 0)
return false;
}
{
/* The DT_DEBUG entry is filled in by the dynamic linker and used
by the debugger. */
- if (!bfd_elfNN_add_dynamic_entry (info, DT_DEBUG, 0))
+#define add_dynamic_entry(TAG, VAL) \
+ bfd_elfNN_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
+
+ if (!add_dynamic_entry (DT_DEBUG, 0))
return false;
}
- if (! bfd_elfNN_add_dynamic_entry (info, DT_IA_64_PLT_RESERVE, 0))
+ if (!add_dynamic_entry (DT_IA_64_PLT_RESERVE, 0))
return false;
- if (! bfd_elfNN_add_dynamic_entry (info, DT_PLTGOT, 0))
+ if (!add_dynamic_entry (DT_PLTGOT, 0))
return false;
if (relplt)
{
- if (! bfd_elfNN_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elfNN_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elfNN_add_dynamic_entry (info, DT_JMPREL, 0))
+ if (!add_dynamic_entry (DT_PLTRELSZ, 0)
+ || !add_dynamic_entry (DT_PLTREL, DT_RELA)
+ || !add_dynamic_entry (DT_JMPREL, 0))
return false;
}
- if (! bfd_elfNN_add_dynamic_entry (info, DT_RELA, 0)
- || ! bfd_elfNN_add_dynamic_entry (info, DT_RELASZ, 0)
- || ! bfd_elfNN_add_dynamic_entry (info, DT_RELAENT,
- sizeof (ElfNN_External_Rela)))
+ if (!add_dynamic_entry (DT_RELA, 0)
+ || !add_dynamic_entry (DT_RELASZ, 0)
+ || !add_dynamic_entry (DT_RELAENT, sizeof (ElfNN_External_Rela)))
return false;
if (ia64_info->reltext)
{
- if (! bfd_elfNN_add_dynamic_entry (info, DT_TEXTREL, 0))
+ if (!add_dynamic_entry (DT_TEXTREL, 0))
return false;
info->flags |= DF_TEXTREL;
}
if (unwind_output_sec)
{
elfNN_ia64_unwind_entry_compare_bfd = abfd;
- qsort (unwind_output_sec->contents, unwind_output_sec->_raw_size / 24,
- 24, elfNN_ia64_unwind_entry_compare);
+ qsort (unwind_output_sec->contents,
+ (size_t) (unwind_output_sec->_raw_size / 24),
+ 24,
+ elfNN_ia64_unwind_entry_compare);
if (! bfd_set_section_contents (abfd, unwind_output_sec,
- unwind_output_sec->contents, 0,
+ unwind_output_sec->contents, (bfd_vma) 0,
unwind_output_sec->_raw_size))
return false;
}
if ((dynamic_symbol_p || info->shared
|| (elfNN_ia64_aix_vec (info->hash->creator)
/* Don't emit relocs for __GLOB_DATA_PTR on AIX. */
- && (!h || strcmp (h->root.root.string,
+ && (!h || strcmp (h->root.root.string,
"__GLOB_DATA_PTR") != 0)))
&& (input_section->flags & SEC_ALLOC) != 0)
{
else
{
dynindx = (_bfd_elf_link_lookup_local_dynindx
- (info, input_bfd, r_symndx));
+ (info, input_bfd, (long) r_symndx));
}
elfNN_ia64_install_dyn_reloc (output_bfd, info, input_section,
}
else
dynindx = (_bfd_elf_link_lookup_local_dynindx
- (info, input_bfd, r_symndx));
+ (info, input_bfd, (long) r_symndx));
value = 0;
}
name = bfd_section_name (input_bfd, input_section);
}
if (!(*info->callbacks->reloc_overflow) (info, name,
- howto->name, 0,
+ howto->name,
+ (bfd_vma) 0,
input_bfd,
input_section,
rel->r_offset))
#define bfd_elfNN_bfd_debug_info_start bfd_void
#define bfd_elfNN_bfd_debug_info_end bfd_void
-#define bfd_elfNN_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
+#define bfd_elfNN_bfd_debug_info_accumulate \
+ (void (*) PARAMS ((bfd*, struct sec *))) bfd_void
#ifndef bfd_elfNN_bfd_get_relocated_section_contents
#define bfd_elfNN_bfd_get_relocated_section_contents \
extern const struct elf_size_info _bfd_elfNN_size_info;
#ifndef INCLUDED_TARGET_FILE
-static CONST struct elf_backend_data elfNN_bed =
+static const struct elf_backend_data elfNN_bed =
{
ELF_ARCH, /* arch */
ELF_MACHINE_CODE, /* elf_machine_code */
if (matching)
{
+ bfd_size_type amt;
+
*matching = NULL;
- matching_vector =
- (char **) bfd_malloc (sizeof (char *)
- * 2 * _bfd_target_vector_entries);
+ amt = sizeof (char *) * 2 * _bfd_target_vector_entries;
+ matching_vector = (char **) bfd_malloc (amt);
if (!matching_vector)
return false;
}
/* If the target type was explicitly specified, just check that target. */
if (!abfd->target_defaulted)
{
- if (bfd_seek (abfd, (file_ptr)0, SEEK_SET) != 0) /* rewind! */
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) /* rewind! */
return false;
right_targ = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
abfd->xvec = *target; /* Change BFD's target temporarily */
- if (bfd_seek (abfd, (file_ptr)0, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return false;
/* If _bfd_check_format neglects to set bfd_error, assume
_bfd_stringtab_init ()
{
struct bfd_strtab_hash *table;
+ bfd_size_type amt = sizeof (struct bfd_strtab_hash);
- table = ((struct bfd_strtab_hash *)
- bfd_malloc (sizeof (struct bfd_strtab_hash)));
+ table = (struct bfd_strtab_hash *) bfd_malloc (amt);
if (table == NULL)
return NULL;
for (entry = tab->first; entry != NULL; entry = entry->next)
{
- register const char *str;
- register size_t len;
+ const char *str;
+ size_t len;
str = entry->root.string;
len = strlen (str) + 1;
bfd_byte buf[2];
/* The output length includes the null byte. */
- bfd_put_16 (abfd, len, buf);
- if (bfd_write ((PTR) buf, 1, 2, abfd) != 2)
+ bfd_put_16 (abfd, (bfd_vma) len, buf);
+ if (bfd_bwrite ((PTR) buf, (bfd_size_type) 2, abfd) != 2)
return false;
}
- if (bfd_write ((PTR) str, 1, len, abfd) != len)
+ if (bfd_bwrite ((PTR) str, (bfd_size_type) len, abfd) != len)
return false;
}
/* update fields not covered by default swap_exec_header_out */
/* this is really the sym table size but we store it in drelocs */
- bfd_h_put_32 (abfd, bfd_get_symcount (abfd) * 12, exec_bytes.e_drelocs);
+ H_PUT_32 (abfd, (bfd_get_symcount (abfd) * 12), exec_bytes.e_drelocs);
- if (bfd_seek (abfd, 0L, false) != 0
- || (bfd_write ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+ if (bfd_seek (abfd, (file_ptr) 0, false) != 0
+ || (bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, abfd)
!= EXEC_BYTES_SIZE))
return false;
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,
+ if (bfd_seek (abfd, (file_ptr) (N_DRELOFF (*execp) + execp->a_drsize),
SEEK_SET) != 0)
return false;
}
if (bfd_get_symcount (abfd) != 0)
{
- if (bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false) != 0)
+ if (bfd_seek (abfd, (file_ptr) N_TRELOFF (*execp), SEEK_CUR) != 0)
return false;
if (!NAME (aout,squirt_out_relocs) (abfd, obj_textsec (abfd)))
return false;
- if (bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false) != 0)
+ if (bfd_seek (abfd, (file_ptr) N_DRELOFF (*execp), SEEK_CUR) != 0)
return false;
if (!NAME (aout,squirt_out_relocs) (abfd, obj_datasec (abfd)))
return false;
are memcmp'd, and thus the contents do matter. */
memset (execp, 0, sizeof (struct internal_exec));
/* Now fill in fields in the execp, from the bytes in the raw data. */
- execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
+ execp->a_info = H_GET_32 (abfd, bytes->e_info);
execp->a_text = GET_WORD (abfd, bytes->e_text);
execp->a_data = GET_WORD (abfd, bytes->e_data);
execp->a_bss = GET_WORD (abfd, bytes->e_bss);
{
long syms;
struct aout_data_struct *rawptr;
- if (bfd_h_get_32 (abfd, bytes->e_passize) != 0)
+ bfd_size_type amt;
+
+ if (H_GET_32 (abfd, bytes->e_passize) != 0)
break;
- if (bfd_h_get_32 (abfd, bytes->e_syms) != 0)
+ if (H_GET_32 (abfd, bytes->e_syms) != 0)
break;
- if (bfd_h_get_32 (abfd, bytes->e_supsize) != 0)
+ if (H_GET_32 (abfd, bytes->e_supsize) != 0)
break;
- syms = bfd_h_get_32 (abfd, bytes->e_drelocs);
+ syms = H_GET_32 (abfd, bytes->e_drelocs);
if (syms == 0)
break;
execp->a_syms = syms;
/* allocate storage for where we will store this result */
- rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (*rawptr));
+ amt = sizeof (*rawptr);
+ rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, amt);
if (rawptr == NULL)
return;
char *strings;
aout_symbol_type *cached;
unsigned num_syms = 0;
+ bfd_size_type amt;
/* If there's no work to be done, don't do any */
if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
return true;
symbol_bytes = exec_hdr (abfd)->a_syms;
- strings = (char *) bfd_alloc (abfd,
- symbol_bytes + SYM_EXTRA_BYTES);
+ amt = symbol_bytes + SYM_EXTRA_BYTES;
+ strings = (char *) bfd_alloc (abfd, amt);
if (!strings)
return false;
syms = (struct external_nlist *) (strings + SYM_EXTRA_BYTES);
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
- || bfd_read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes)
+ || bfd_bread ((PTR) syms, symbol_bytes, abfd) != symbol_bytes)
{
bfd_release (abfd, syms);
return false;
/* now that we know the symbol count, update the bfd header */
bfd_get_symcount (abfd) = num_syms;
- cached = ((aout_symbol_type *)
- bfd_zalloc (abfd,
- bfd_get_symcount (abfd) * sizeof (aout_symbol_type)));
- if (cached == NULL && bfd_get_symcount (abfd) != 0)
+ amt = num_syms;
+ amt *= sizeof (aout_symbol_type);
+ cached = (aout_symbol_type *) bfd_zalloc (abfd, amt);
+ if (cached == NULL && num_syms != 0)
return false;
/* as we march thru the hp symbol table, convert it into a list of
int r_pcrel = 0;
struct aoutdata *su = &(abfd->tdata.aout_data->a);
- cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
- r_index = bfd_h_get_16 (abfd, bytes->r_index);
+ cache_ptr->address = H_GET_32 (abfd, bytes->r_address);
+ r_index = H_GET_16 (abfd, bytes->r_index);
switch (bytes->r_type[0])
{
sec_ptr asect;
asymbol **symbols;
{
- unsigned int count;
+ bfd_size_type count;
bfd_size_type reloc_size;
PTR relocs;
arelent *reloc_cache;
count = reloc_size / each_size;
- reloc_cache = (arelent *) bfd_zalloc (abfd, (size_t) (count * sizeof
- (arelent)));
+ reloc_cache = (arelent *) bfd_zalloc (abfd, count * sizeof (arelent));
if (!reloc_cache && count != 0)
return false;
return false;
}
- if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
+ if (bfd_bread (relocs, reloc_size, abfd) != reloc_size)
{
bfd_release (abfd, relocs);
bfd_release (abfd, reloc_cache);
for (; counter < count; counter++, rptr++, cache_ptr++)
{
MY (swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols,
- bfd_get_symcount (abfd));
+ (bfd_size_type) bfd_get_symcount (abfd));
}
bfd_release (abfd, relocs);
#include <sys/user.h> /* After a.out.h */
#include <sys/file.h>
-static asection *make_bfd_asection PARAMS ((bfd *, CONST char *,
+static asection *make_bfd_asection PARAMS ((bfd *, const char *,
flagword, bfd_size_type,
file_ptr, unsigned int));
static asymbol *hppabsd_core_make_empty_symbol PARAMS ((bfd *));
static asection *
make_bfd_asection (abfd, name, flags, _raw_size, offset, alignment_power)
bfd *abfd;
- CONST char *name;
+ const char *name;
flagword flags;
bfd_size_type _raw_size;
file_ptr offset;
hppabsd_core_make_empty_symbol (abfd)
bfd *abfd;
{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ asymbol *new;
+
+ new = (asymbol *) bfd_zalloc (abfd, (bfd_size_type) sizeof (asymbol));
if (new)
new->the_bfd = abfd;
return new;
/* Try to read in the u-area. We will need information from this
to know how to grok the rest of the core structures. */
- val = bfd_read ((void *) &u, 1, sizeof u, abfd);
+ val = bfd_bread ((void *) &u, (bfd_size_type) sizeof u, abfd);
if (val != sizeof u)
{
if (bfd_get_error () != bfd_error_system_call)
/* OK, we believe you. You're a core file (sure, sure). */
coredata = (struct hppabsd_core_struct *)
- bfd_zalloc (abfd, sizeof (struct hppabsd_core_struct));
+ bfd_zalloc (abfd, (bfd_size_type) sizeof (struct hppabsd_core_struct));
if (!coredata)
return NULL;
#define core_kernel_thread_id(bfd) (core_hdr(bfd)->lwpid)
#define core_user_thread_id(bfd) (core_hdr(bfd)->user_tid)
+static asection *make_bfd_asection
+ PARAMS ((bfd *, const char *, flagword, bfd_size_type, bfd_vma,
+ unsigned int));
+static asymbol *hpux_core_make_empty_symbol PARAMS ((bfd *));
+static const bfd_target *hpux_core_core_file_p PARAMS ((bfd *));
+static char *hpux_core_core_file_failing_command PARAMS ((bfd *));
+static int hpux_core_core_file_failing_signal PARAMS ((bfd *));
+static boolean hpux_core_core_file_matches_executable_p
+ PARAMS ((bfd *, bfd *));
static void swap_abort PARAMS ((void));
static asection *
make_bfd_asection (abfd, name, flags, _raw_size, vma, alignment_power)
bfd *abfd;
- CONST char *name;
+ const char *name;
flagword flags;
bfd_size_type _raw_size;
bfd_vma vma;
asection *asect;
char *newname;
- newname = bfd_alloc (abfd, strlen (name) + 1);
+ newname = bfd_alloc (abfd, (bfd_size_type) strlen (name) + 1);
if (!newname)
return NULL;
hpux_core_make_empty_symbol (abfd)
bfd *abfd;
{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ asymbol *new;
+
+ new = (asymbol *) bfd_zalloc (abfd, (bfd_size_type) sizeof (asymbol));
if (new)
new->the_bfd = abfd;
return new;
int unknown_sections = 0;
core_hdr (abfd) = (struct hpux_core_struct *)
- bfd_zalloc (abfd, sizeof (struct hpux_core_struct));
+ bfd_zalloc (abfd, (bfd_size_type) sizeof (struct hpux_core_struct));
if (!core_hdr (abfd))
return NULL;
int val;
struct corehead core_header;
- val = bfd_read ((void *) &core_header, 1, sizeof core_header, abfd);
+ val = bfd_bread ((void *) &core_header,
+ (bfd_size_type) sizeof core_header, abfd);
if (val <= 0)
break;
switch (core_header.type)
{
case CORE_KERNEL:
case CORE_FORMAT:
- bfd_seek (abfd, core_header.len, SEEK_CUR); /* Just skip this */
+ /* Just skip this. */
+ bfd_seek (abfd, (file_ptr) core_header.len, SEEK_CUR);
good_sections++;
break;
case CORE_EXEC:
{
struct proc_exec proc_exec;
- if (bfd_read ((void *) &proc_exec, 1, core_header.len, abfd)
- != core_header.len)
+ if (bfd_bread ((void *) &proc_exec, (bfd_size_type) core_header.len,
+ abfd) != core_header.len)
break;
strncpy (core_command (abfd), proc_exec.cmd, MAXCOMLEN + 1);
good_sections++;
/* We need to read this section, 'cause we need to determine
whether the core-dumped app was threaded before we create
any .reg sections. */
- if (bfd_read (&proc_info, 1, core_header.len, abfd)
+ if (bfd_bread (&proc_info, (bfd_size_type) core_header.len, abfd)
!= core_header.len)
break;
/* However, we also want to create those sections with the
file positioned at the start of the record, it seems. */
- if (bfd_seek (abfd, -core_header.len, SEEK_CUR) != 0)
+ if (bfd_seek (abfd, (file_ptr) -core_header.len, SEEK_CUR) != 0)
break;
#if defined(PROC_INFO_HAS_THREAD_ID)
return NULL;
}
core_signal (abfd) = proc_info.sig;
- if (bfd_seek (abfd, core_header.len, SEEK_CUR) != 0)
+ if (bfd_seek (abfd, (file_ptr) core_header.len, SEEK_CUR) != 0)
break;
good_sections++;
}
core_header.len, core_header.addr, 2))
return NULL;
- bfd_seek (abfd, core_header.len, SEEK_CUR);
+ bfd_seek (abfd, (file_ptr) core_header.len, SEEK_CUR);
good_sections++;
break;
/* ARGSUSED */
static boolean
hpux_core_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
+ bfd *core_bfd ATTRIBUTE_UNUSED;
+ bfd *exec_bfd ATTRIBUTE_UNUSED;
{
return true; /* FIXME, We have no way of telling at this point */
}
/* If somebody calls any byte-swapping routines, shoot them. */
static void
-swap_abort()
+swap_abort ()
{
abort(); /* This way doesn't require any declaration for ANSI to fuck up */
}
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-/* The only 386 aout system we have here is GO32 from DJ.
+/* The only 386 aout system we have here is GO32 from DJ.
These numbers make BFD work with that. If your aout 386 system
doesn't work with these, we'll have to split them into different
files. Send me (sac@cygnus.com) the runes to make it work on your
#define MY_write_object_contents i386aout_write_object_contents
#define MY_backend_data &MY(backend_data)
-static CONST struct aout_backend_data MY(backend_data) = {
+static const struct aout_backend_data MY(backend_data) = {
0, /* zmagic contiguous */
1, /* text incl header */
0, /* entry is text address */
/* BFD back-end for i386 a.out binaries under dynix.
- Copyright 1994, 1995 Free Software Foundation, Inc.
+ Copyright 1994, 1995, 2001 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
are memcmp'd, and thus the contents do matter. */
memset ((PTR) execp, 0, sizeof (struct internal_exec));
/* Now fill in fields in the execp, from the bytes in the raw data. */
- execp->a_info = bfd_h_get_32 (abfd, bytes->e_info);
+ execp->a_info = H_GET_32 (abfd, bytes->e_info);
execp->a_text = GET_WORD (abfd, bytes->e_text);
execp->a_data = GET_WORD (abfd, bytes->e_data);
execp->a_bss = GET_WORD (abfd, bytes->e_bss);
/* BFD back-end for linux flavored i386 a.out binaries.
- Copyright 1992, 1993, 1994, 1995, 1996, 1997
+ Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2001
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
bfd *abfd;
{
struct linux_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct linux_link_hash_table);
- ret = ((struct linux_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
+ ret = (struct linux_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct linux_link_hash_table *) NULL)
return (struct bfd_link_hash_table *) NULL;
if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
if (! (_bfd_generic_link_add_one_symbol
(info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
- BSF_GLOBAL | BSF_CONSTRUCTOR, s, 0, NULL, false, false, NULL)))
+ BSF_GLOBAL | BSF_CONSTRUCTOR, s, (bfd_vma) 0, NULL,
+ false, false, NULL)))
return false;
}
name = h->root.root.root.string + sizeof NEEDS_SHRLIB - 1;
p = strrchr (name, '_');
if (p != NULL)
- alloc = (char *) bfd_malloc (strlen (name) + 1);
+ alloc = (char *) bfd_malloc ((bfd_size_type) strlen (name) + 1);
if (p == NULL || alloc == NULL)
(*_bfd_error_handler) (_("Output file requires shared library `%s'\n"),
+ sizeof PLT_REF_PREFIX - 1),
false, false, true);
/* h2 does not follow indirect symbols. */
- h2 = linux_link_hash_lookup (linux_hash_table (info),
+ h2 = linux_link_hash_lookup (linux_hash_table (info),
(h->root.root.root.string
+ sizeof PLT_REF_PREFIX - 1),
false, false, false);
".linux-dynamic");
if (s != NULL)
{
- s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
+ s->_raw_size = linux_hash_table (info)->fixup_count + 1;
+ s->_raw_size *= 8;
s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
if (s->contents == NULL)
return false;
fixups_written = 0;
#ifdef LINUX_LINK_DEBUG
- printf ("Fixup table file offset: %x VMA: %x\n",
+ printf ("Fixup table file offset: %x VMA: %x\n",
os->filepos + s->output_offset,
os->vma + s->output_offset);
#endif
fixup_table = s->contents;
- bfd_put_32 (output_bfd, linux_hash_table (info)->fixup_count, fixup_table);
+ bfd_put_32 (output_bfd,
+ (bfd_vma) linux_hash_table (info)->fixup_count, fixup_table);
fixup_table += 4;
/* Fill in fixup table. */
if (f->jump)
{
/* Relative address */
- new_addr = new_addr - (f->value + 5);
- bfd_put_32 (output_bfd, new_addr, fixup_table);
+ new_addr = new_addr - (f->value + 5);
+ bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
fixup_table += 4;
bfd_put_32 (output_bfd, f->value + 1, fixup_table);
fixup_table += 4;
}
else
{
- bfd_put_32 (output_bfd, new_addr, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
fixup_table += 4;
bfd_put_32 (output_bfd, f->value, fixup_table);
fixup_table += 4;
if (linux_hash_table (info)->local_builtins != 0)
{
/* Special marker so we know to switch to the other type of fixup */
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
fixup_table += 4;
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
fixup_table += 4;
++fixups_written;
for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
new_addr, f->value);
#endif
- bfd_put_32 (output_bfd, new_addr, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
fixup_table += 4;
bfd_put_32 (output_bfd, f->value, fixup_table);
fixup_table += 4;
(*_bfd_error_handler) (_("Warning: fixup count mismatch\n"));
while (linux_hash_table (info)->fixup_count > fixups_written)
{
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
fixup_table += 4;
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
fixup_table += 4;
++fixups_written;
}
}
- h = linux_link_hash_lookup (linux_hash_table (info),
+ h = linux_link_hash_lookup (linux_hash_table (info),
"__BUILTIN_FIXUPS__",
false, false, false);
printf ("Builtin fixup table at %x\n", new_addr);
#endif
- bfd_put_32 (output_bfd, new_addr, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
}
else
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
- if (bfd_seek (output_bfd, os->filepos + s->output_offset, SEEK_SET) != 0)
+ if (bfd_seek (output_bfd, (file_ptr) (os->filepos + s->output_offset),
+ SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) s->contents, 1, s->_raw_size, output_bfd)
- != s->_raw_size)
+ if (bfd_bwrite ((PTR) s->contents, s->_raw_size, output_bfd) != s->_raw_size)
return false;
return true;
obj_reloc_entry_size (abfd)); \
NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
\
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
- if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
- != EXEC_BYTES_SIZE) \
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 \
+ || bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, \
+ abfd) != EXEC_BYTES_SIZE) \
return false; \
/* Now write out reloc info, followed by syms and strings */ \
\
if (bfd_get_symcount (abfd) != 0) \
{ \
- if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) \
+ if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET) \
!= 0) \
return false; \
\
- if (! NAME(aout,write_syms)(abfd)) return false; \
+ if (! NAME(aout,write_syms) (abfd)) return false; \
\
- if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) \
+ if (bfd_seek (abfd, (file_ptr) (N_TRELOFF(*execp)), SEEK_SET) \
!= 0) \
return false; \
\
if (!NAME(lynx,squirt_out_relocs) (abfd, obj_textsec (abfd))) \
return false; \
- if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) \
+ if (bfd_seek (abfd, (file_ptr) (N_DRELOFF(*execp)), SEEK_SET) \
!= 0) \
return 0; \
\
- if (!NAME(lynx,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
+ if (!NAME(lynx,squirt_out_relocs) (abfd, obj_datasec (abfd))) \
return false; \
} \
}
int r_baserel, r_jmptable, r_relative;
struct aoutdata *su = &(abfd->tdata.aout_data->a);
- cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address);
+ cache_ptr->address = H_GET_32 (abfd, bytes->r_address);
r_index = bytes->r_index[1];
r_extern = (0 != (bytes->r_index[0] & RELOC_STD_BITS_EXTERN_BIG));
sec_ptr asect;
asymbol **symbols;
{
- unsigned int count;
+ bfd_size_type count;
bfd_size_type reloc_size;
PTR relocs;
arelent *reloc_cache;
reloc_cache = (arelent *) bfd_malloc (count * sizeof (arelent));
if (!reloc_cache && count != 0)
return false;
- memset (reloc_cache, 0, count * sizeof (arelent));
+ memset (reloc_cache, 0, (size_t) count * sizeof (arelent));
relocs = (PTR) bfd_alloc (abfd, reloc_size);
if (!relocs && reloc_size != 0)
return false;
}
- if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
+ if (bfd_bread (relocs, reloc_size, abfd) != reloc_size)
{
bfd_release (abfd, relocs);
free (reloc_cache);
for (; counter < count; counter++, rptr++, cache_ptr++)
{
NAME(lynx,swap_ext_reloc_in) (abfd, rptr, cache_ptr, symbols,
- bfd_get_symcount (abfd));
+ (bfd_size_type) bfd_get_symcount (abfd));
}
}
else
for (; counter < count; counter++, rptr++, cache_ptr++)
{
NAME(lynx,swap_std_reloc_in) (abfd, rptr, cache_ptr, symbols,
- bfd_get_symcount (abfd));
+ (bfd_size_type) bfd_get_symcount (abfd));
}
}
size_t each_size;
unsigned int count = section->reloc_count;
- size_t natsize;
+ bfd_size_type natsize;
if (count == 0)
return true;
each_size = obj_reloc_entry_size (abfd);
- natsize = each_size * count;
+ natsize = count;
+ natsize *= each_size;
native = (unsigned char *) bfd_zalloc (abfd, natsize);
if (!native)
return false;
NAME(lynx,swap_std_reloc_out) (abfd, *generic, (struct reloc_std_external *) natptr);
}
- if (bfd_write ((PTR) native, 1, natsize, abfd) != natsize)
+ if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize)
{
bfd_release (abfd, native);
return false;
static boolean MY (set_sizes) PARAMS ((bfd *));
#define MY_backend_data &MY(backend_data)
-static CONST struct aout_backend_data MY(backend_data) = {
+static const struct aout_backend_data MY(backend_data) = {
0, /* zmagic contiguous */
1, /* text incl header */
0, /* entry is text address */
}
/* Constants. */
- bfd_h_put_16(abfd, EXE_MAGIC, &hdr[0]);
- bfd_h_put_16(abfd, EXE_PAGE_SIZE / 16, &hdr[8]);
- bfd_h_put_16(abfd, EXE_LOAD_LOW, &hdr[12]);
- bfd_h_put_16(abfd, 0x3e, &hdr[24]);
- bfd_h_put_16(abfd, 0x0001, &hdr[28]); /* XXX??? */
- bfd_h_put_16(abfd, 0x30fb, &hdr[30]); /* XXX??? */
- bfd_h_put_16(abfd, 0x726a, &hdr[32]); /* XXX??? */
+ H_PUT_16 (abfd, EXE_MAGIC, &hdr[0]);
+ H_PUT_16 (abfd, EXE_PAGE_SIZE / 16, &hdr[8]);
+ H_PUT_16 (abfd, EXE_LOAD_LOW, &hdr[12]);
+ H_PUT_16 (abfd, 0x3e, &hdr[24]);
+ H_PUT_16 (abfd, 0x0001, &hdr[28]); /* XXX??? */
+ H_PUT_16 (abfd, 0x30fb, &hdr[30]); /* XXX??? */
+ H_PUT_16 (abfd, 0x726a, &hdr[32]); /* XXX??? */
/* Bytes in last page (0 = full page). */
- bfd_h_put_16(abfd, outfile_size & (EXE_PAGE_SIZE - 1), &hdr[2]);
+ H_PUT_16 (abfd, outfile_size & (EXE_PAGE_SIZE - 1), &hdr[2]);
/* Number of pages. */
- bfd_h_put_16(abfd, (outfile_size + EXE_PAGE_SIZE - 1) / EXE_PAGE_SIZE,
- &hdr[4]);
+ H_PUT_16 (abfd, (outfile_size + EXE_PAGE_SIZE - 1) / EXE_PAGE_SIZE, &hdr[4]);
/* Set the initial stack pointer to the end of the bss.
The program's crt0 code must relocate it to a real stack. */
- bfd_h_put_16(abfd, high_vma, &hdr[16]);
+ H_PUT_16 (abfd, high_vma, &hdr[16]);
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || bfd_write (hdr, 1, sizeof(hdr), abfd) != sizeof(hdr))
+ || bfd_bwrite (hdr, (bfd_size_type) sizeof(hdr), abfd) != sizeof(hdr))
return false;
return true;
if (bfd_get_section_flags (abfd, section) & SEC_LOAD)
{
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
- || bfd_write (location, 1, count, abfd) != count)
+ if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
+ || bfd_bwrite (location, count, abfd) != count)
return false;
}
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
NULL,
-
+
(PTR) 0
};
unsigned int dload, dmemsize, dmemstart;
/* Now fill in fields in the execp, from the bytes in the raw data. */
- execp->a_info = bfd_h_get_16 (abfd, bytes->m_sync);
+ execp->a_info = H_GET_16 (abfd, bytes->m_sync);
execp->a_syms = 0;
- execp->a_entry = bfd_h_get_32 (abfd, bytes->m_exec);
+ execp->a_entry = H_GET_32 (abfd, bytes->m_exec);
execp->a_talign = 2;
execp->a_dalign = 2;
execp->a_balign = 2;
- dload = bfd_h_get_32 (abfd, bytes->m_idata);
+ dload = H_GET_32 (abfd, bytes->m_idata);
execp->a_data = dload + 8;
if (bfd_seek (abfd, (file_ptr) dload, SEEK_SET) != 0
- || (bfd_read (&dmemstart, sizeof (dmemstart), 1, abfd)
+ || (bfd_bread (&dmemstart, (bfd_size_type) sizeof (dmemstart), abfd)
!= sizeof (dmemstart))
- || (bfd_read (&dmemsize, sizeof (dmemsize), 1, abfd)
+ || (bfd_bread (&dmemsize, (bfd_size_type) sizeof (dmemsize), abfd)
!= sizeof (dmemsize)))
return false;
execp->a_tload = 0;
- execp->a_dload = bfd_h_get_32 (abfd, (unsigned char *) &dmemstart);
+ execp->a_dload = H_GET_32 (abfd, (unsigned char *) &dmemstart);
execp->a_text = dload - execp->a_tload;
- execp->a_data = bfd_h_get_32 (abfd, (unsigned char *) &dmemsize);
- execp->a_bss = bfd_h_get_32 (abfd, bytes->m_data) - execp->a_data;
+ execp->a_data = H_GET_32 (abfd, (unsigned char *) &dmemsize);
+ execp->a_bss = H_GET_32 (abfd, bytes->m_data) - execp->a_data;
execp->a_trsize = 0;
execp->a_drsize = 0;
/* Swaps the information in an internal exec header structure into the
supplied buffer ready for writing to disk. */
-PROTO (void, os9k_swap_exec_header_out,
- (bfd * abfd,
- struct internal_exec * execp,
- struct mh_com * raw_bytes));
+void os9k_swap_exec_header_out
+ PARAMS ((bfd *, struct internal_exec *, struct mh_com *));
+
void
os9k_swap_exec_header_out (abfd, execp, raw_bytes)
bfd *abfd;
mh_com *bytes = (mh_com *) raw_bytes;
/* Now fill in fields in the raw data, from the fields in the exec struct. */
- bfd_h_put_32 (abfd, execp->a_info, bytes->e_info);
- bfd_h_put_32 (abfd, execp->a_text, bytes->e_text);
- bfd_h_put_32 (abfd, execp->a_data, bytes->e_data);
- bfd_h_put_32 (abfd, execp->a_bss, bytes->e_bss);
- bfd_h_put_32 (abfd, execp->a_syms, bytes->e_syms);
- bfd_h_put_32 (abfd, execp->a_entry, bytes->e_entry);
- bfd_h_put_32 (abfd, execp->a_trsize, bytes->e_trsize);
- bfd_h_put_32 (abfd, execp->a_drsize, bytes->e_drsize);
- bfd_h_put_32 (abfd, execp->a_tload, bytes->e_tload);
- bfd_h_put_32 (abfd, execp->a_dload, bytes->e_dload);
+ H_PUT_32 (abfd, execp->a_info, bytes->e_info);
+ H_PUT_32 (abfd, execp->a_text, bytes->e_text);
+ H_PUT_32 (abfd, execp->a_data, bytes->e_data);
+ H_PUT_32 (abfd, execp->a_bss, bytes->e_bss);
+ H_PUT_32 (abfd, execp->a_syms, bytes->e_syms);
+ H_PUT_32 (abfd, execp->a_entry, bytes->e_entry);
+ H_PUT_32 (abfd, execp->a_trsize, bytes->e_trsize);
+ H_PUT_32 (abfd, execp->a_drsize, bytes->e_drsize);
+ H_PUT_32 (abfd, execp->a_tload, bytes->e_tload);
+ H_PUT_32 (abfd, execp->a_dload, bytes->e_dload);
bytes->e_talign[0] = execp->a_talign;
bytes->e_dalign[0] = execp->a_dalign;
bytes->e_balign[0] = execp->a_balign;
struct internal_exec anexec;
mh_com exec_bytes;
- if (bfd_read ((PTR) & exec_bytes, MHCOM_BYTES_SIZE, 1, abfd)
+ if (bfd_bread ((PTR) &exec_bytes, (bfd_size_type) MHCOM_BYTES_SIZE, abfd)
!= MHCOM_BYTES_SIZE)
{
if (bfd_get_error () != bfd_error_system_call)
return 0;
}
- anexec.a_info = bfd_h_get_16 (abfd, exec_bytes.m_sync);
+ anexec.a_info = H_GET_16 (abfd, exec_bytes.m_sync);
if (N_BADMAG (anexec))
{
bfd_set_error (bfd_error_wrong_format);
bfd *abfd;
{
struct bout_data_struct *rawptr;
+ bfd_size_type amt = sizeof (struct bout_data_struct);
- rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, sizeof (struct bout_data_struct));
+ rawptr = (struct bout_data_struct *) bfd_zalloc (abfd, amt);
if (rawptr == NULL)
return false;
bout_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || (bfd_write ((PTR) & swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE))
+ || bfd_bwrite ((PTR) & swapped_hdr, (bfd_size_type) EXEC_BYTES_SIZE,
+ abfd) != EXEC_BYTES_SIZE)
return false;
/* Now write out reloc info, followed by syms and strings. */
return false;
if (count != 0)
- return (bfd_write ((PTR) location, 1, count, abfd) == count) ? true : false;
+ return bfd_bwrite ((PTR) location, (bfd_size_type) count, abfd) == count;
return true;
}
BFD_JUMP_TABLE_WRITE (aout_32),
BFD_JUMP_TABLE_LINK (os9k),
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
-
+
NULL,
(PTR) 0,
static file_ptr ieee_part_after PARAMS ((ieee_data_type *, file_ptr));
static ieee_symbol_type *get_symbol
PARAMS ((bfd *, ieee_data_type *, ieee_symbol_type *, unsigned int *,
- ieee_symbol_type ***, unsigned int *, char));
+ ieee_symbol_type ***, unsigned int *, int));
static boolean ieee_slurp_external_symbols PARAMS ((bfd *));
static boolean ieee_slurp_symbol_table PARAMS ((bfd *));
static long ieee_get_symtab_upper_bound PARAMS ((bfd *));
bfd_byte byte;
byte = barg;
- if (bfd_write ((PTR) &byte, 1, 1, abfd) != 1)
+ if (bfd_bwrite ((PTR) &byte, (bfd_size_type) 1, abfd) != 1)
return false;
return true;
}
buffer[0] = bytes >> 8;
buffer[1] = bytes & 0xff;
- if (bfd_write ((PTR) buffer, 1, 2, abfd) != 2)
+ if (bfd_bwrite ((PTR) buffer, (bfd_size_type) 2, abfd) != 2)
return false;
return true;
}
return false;
}
- if (bfd_write ((PTR) id, 1, length, abfd) != length)
+ if (bfd_bwrite ((PTR) id, (bfd_size_type) length, abfd) != length)
return false;
return true;
}
length = (length * 256) + this_byte_and_next (ieee);
}
/* Buy memory and read string */
- string = bfd_alloc (ieee->abfd, length + 1);
+ string = bfd_alloc (ieee->abfd, (bfd_size_type) length + 1);
if (!string)
return NULL;
bfd_get_string (ieee, string, length);
/* Handle the degenerate case of a 0 address. */
if (term_count == 0)
{
- if (! ieee_write_int (abfd, 0))
+ if (! ieee_write_int (abfd, (bfd_vma) 0))
return false;
}
bfd_byte b[5];
ieee_write_int5 (b, value);
- if (bfd_write ((PTR) b, 1, 5, abfd) != 5)
+ if (bfd_bwrite ((PTR) b, (bfd_size_type) 5, abfd) != 5)
return false;
return true;
}
unsigned int *symbol_count;
ieee_symbol_type ***pptr;
unsigned int *max_index;
- char this_type;
+ int this_type;
{
/* Need a new symbol */
unsigned int new_index = must_parse_int (&(ieee->h));
if (new_index != last_index || this_type != last_type)
{
- ieee_symbol_type *new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd,
- sizeof (ieee_symbol_type));
+ ieee_symbol_type *new_symbol;
+ bfd_size_type amt = sizeof (ieee_symbol_type);
+
+ new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd, amt);
if (!new_symbol)
return NULL;
{
unsigned int c, i;
asection **n;
+ bfd_size_type amt;
c = ieee->section_table_size;
if (c == 0)
while (c <= index)
c *= 2;
- n = ((asection **)
- bfd_realloc (ieee->section_table, c * sizeof (asection *)));
+ amt = c;
+ amt *= sizeof (asection *);
+ n = (asection **) bfd_realloc (ieee->section_table, amt);
if (n == NULL)
return NULL;
if (ieee->section_table[index] == (asection *) NULL)
{
- char *tmp = bfd_alloc (abfd, 11);
+ char *tmp = bfd_alloc (abfd, (bfd_size_type) 11);
asection *section;
if (!tmp)
{
ieee_data_type *ieee = IEEE_DATA (abfd);
file_ptr offset = ieee->w.r.section_part;
- asection *section = (asection *) NULL;
char *name;
if (offset != 0)
{
case ieee_section_type_enum:
{
+ asection *section;
unsigned int section_index;
next_byte (&(ieee->h));
section_index = must_parse_int (&(ieee->h));
break;
case ieee_e2_first_byte_enum:
{
- ieee_record_enum_type t = (ieee_record_enum_type) (read_2bytes (&(ieee->h)));
+ asection *section;
+ ieee_record_enum_type t;
+ t = (ieee_record_enum_type) (read_2bytes (&(ieee->h)));
switch (t)
{
case ieee_section_size_enum:
file_ptr buffer_offset = 0;
ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
ieee_ar_data_type *ieee;
- unsigned int alc_elts;
+ bfd_size_type alc_elts;
ieee_ar_obstack_type *elts = NULL;
+ bfd_size_type amt = sizeof (ieee_ar_data_type);
- abfd->tdata.ieee_ar_data =
- (ieee_ar_data_type *) bfd_alloc (abfd, sizeof (ieee_ar_data_type));
+ abfd->tdata.ieee_ar_data = (ieee_ar_data_type *) bfd_alloc (abfd, amt);
if (!abfd->tdata.ieee_ar_data)
goto error_return;
ieee = IEEE_AR_DATA (abfd);
/* Ignore the return value here. It doesn't matter if we don't read
the entire buffer. We might have a very small ieee file. */
- bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
+ bfd_bread ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd);
ieee->h.first_byte = buffer;
ieee->h.input_p = buffer;
if (bfd_seek (abfd, buffer_offset, SEEK_SET) != 0)
goto error_return;
- /* Again ignore return value of bfd_read. */
- bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
+ /* Again ignore return value of bfd_bread. */
+ bfd_bread ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd);
ieee->h.first_byte = buffer;
ieee->h.input_p = buffer;
}
}
- ieee->elements = ((ieee_ar_obstack_type *)
- bfd_alloc (abfd,
- ieee->element_count * sizeof *ieee->elements));
+ amt = ieee->element_count;
+ amt *= sizeof *ieee->elements;
+ ieee->elements = (ieee_ar_obstack_type *) bfd_alloc (abfd, amt);
if (ieee->elements == NULL)
goto error_return;
- memcpy (ieee->elements, elts,
- ieee->element_count * sizeof *ieee->elements);
+ memcpy (ieee->elements, elts, (size_t) amt);
free (elts);
elts = NULL;
if (bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET) != 0)
goto error_return;
- /* Again ignore return value of bfd_read. */
- bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
+ /* Again ignore return value of bfd_bread. */
+ bfd_bread ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd);
ieee->h.first_byte = buffer;
ieee->h.input_p = buffer;
next_byte (&(ieee->h)); /* Drop F8. */
next_byte (&(ieee->h)); /* Drop 14. */
must_parse_int (&(ieee->h)); /* Drop size of block. */
-
+
if (must_parse_int (&(ieee->h)) != 0)
/* This object has been deleted. */
ieee->elements[i].file_offset = 0;
ieee_data_type *ieee;
unsigned char buffer[300];
ieee_data_type *save = IEEE_DATA (abfd);
+ bfd_size_type amt;
abfd->tdata.ieee_data = 0;
ieee_mkobject (abfd);
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
goto fail;
/* Read the first few bytes in to see if it makes sense. Ignore
- bfd_read return value; The file might be very small. */
- bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
+ bfd_bread return value; The file might be very small. */
+ bfd_bread ((PTR) buffer, (bfd_size_type) sizeof (buffer), abfd);
ieee->h.input_p = buffer;
if (this_byte_and_next (&(ieee->h)) != Module_Beginning)
quickly. We can work out how big the file is from the trailer
record */
+ amt = ieee->w.r.me_record + 1;
IEEE_DATA (abfd)->h.first_byte =
- (unsigned char *) bfd_alloc (ieee->h.abfd, ieee->w.r.me_record + 1);
+ (unsigned char *) bfd_alloc (ieee->h.abfd, amt);
if (!IEEE_DATA (abfd)->h.first_byte)
goto fail;
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
goto fail;
/* FIXME: Check return value. I'm not sure whether it needs to read
the entire buffer or not. */
- bfd_read ((PTR) (IEEE_DATA (abfd)->h.first_byte), 1,
- ieee->w.r.me_record + 1, abfd);
+ bfd_bread ((PTR) (IEEE_DATA (abfd)->h.first_byte),
+ (bfd_size_type) ieee->w.r.me_record + 1, abfd);
ieee_slurp_sections (abfd);
if (! ieee_slurp_section_data (abfd))
goto fail;
-
+
return abfd->xvec;
got_wrong_format:
bfd_set_error (bfd_error_wrong_format);
unsigned int extra = 4;
boolean pcrel = false;
asection *section;
- ieee_reloc_type *r =
- (ieee_reloc_type *) bfd_alloc (ieee->h.abfd,
- sizeof (ieee_reloc_type));
+ ieee_reloc_type *r;
+ bfd_size_type amt = sizeof (ieee_reloc_type);
+
+ r = (ieee_reloc_type *) bfd_alloc (ieee->h.abfd, amt);
if (!r)
return false;
if (pcrel == true)
{
#if KEEPMINUSPCININST
- bfd_put_32 (ieee->h.abfd, -current_map->pc, location_ptr +
- current_map->pc);
+ bfd_put_32 (ieee->h.abfd, -current_map->pc,
+ location_ptr + current_map->pc);
r->relent.howto = &rel32_howto;
- r->relent.addend -=
- current_map->pc;
+ r->relent.addend -= current_map->pc;
#else
- bfd_put_32 (ieee->h.abfd, 0, location_ptr +
+ bfd_put_32 (ieee->h.abfd, (bfd_vma) 0, location_ptr +
current_map->pc);
r->relent.howto = &rel32_howto;
#endif
}
else
{
- bfd_put_32 (ieee->h.abfd, 0, location_ptr +
- current_map->pc);
+ bfd_put_32 (ieee->h.abfd, (bfd_vma) 0,
+ location_ptr + current_map->pc);
r->relent.howto = &abs32_howto;
}
current_map->pc += 4;
if (pcrel == true)
{
#if KEEPMINUSPCININST
- bfd_put_16 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc);
+ bfd_put_16 (ieee->h.abfd, (bfd_vma) -current_map->pc,
+ location_ptr + current_map->pc);
r->relent.addend -= current_map->pc;
r->relent.howto = &rel16_howto;
#else
- bfd_put_16 (ieee->h.abfd, 0, location_ptr + current_map->pc);
+ bfd_put_16 (ieee->h.abfd, (bfd_vma) 0,
+ location_ptr + current_map->pc);
r->relent.howto = &rel16_howto;
#endif
}
else
{
- bfd_put_16 (ieee->h.abfd, 0, location_ptr + current_map->pc);
+ bfd_put_16 (ieee->h.abfd, (bfd_vma) 0,
+ location_ptr + current_map->pc);
r->relent.howto = &abs16_howto;
}
current_map->pc += 2;
{
ieee->h.input_p = start;
if (!do_one (ieee, current_map, location_ptr, s,
- iterations))
+ (int) iterations))
return false;
iterations--;
}
asection *newsect;
{
newsect->used_by_bfd = (PTR)
- bfd_alloc (abfd, sizeof (ieee_per_section_type));
+ bfd_alloc (abfd, (bfd_size_type) sizeof (ieee_per_section_type));
if (!newsect->used_by_bfd)
return false;
ieee_per_section (newsect)->data = (bfd_byte *) NULL;
|| ! ieee_write_byte (abfd,
(bfd_byte) (s->index
+ IEEE_SECTION_NUMBER_BASE))
- || ! ieee_write_int (abfd, 1 << s->alignment_power))
+ || ! ieee_write_int (abfd, (bfd_vma) 1 << s->alignment_power))
return false;
/* Size */
}
else
{
- if (! ieee_write_expression (abfd, 0, s->symbol, 0, 0))
+ if (! ieee_write_expression (abfd, (bfd_vma) 0, s->symbol, 0, 0))
return false;
}
/* Output a stream of bytes */
if (! ieee_write_int (abfd, run))
return false;
- if (bfd_write ((PTR) (stream + current_byte_index),
- 1,
- run,
- abfd)
+ if (bfd_bwrite ((PTR) (stream + current_byte_index), run, abfd)
!= run)
return false;
current_byte_index += run;
/* Output a stream of bytes */
if (! ieee_write_int (abfd, run))
return false;
- if (bfd_write ((PTR) (stream + current_byte_index),
- 1,
- run,
- abfd)
+ if (bfd_bwrite ((PTR) (stream + current_byte_index), run, abfd)
!= run)
return false;
current_byte_index += run;
if (! ieee_write_expression (abfd, r->addend + ov,
*(r->sym_ptr_ptr),
r->howto->pc_relative,
- s->index))
+ (unsigned) s->index))
return false;
}
else
if (! ieee_write_expression (abfd, r->addend + ov,
(asymbol *) NULL,
r->howto->pc_relative,
- s->index))
+ (unsigned) s->index))
return false;
}
if (number_of_maus_in_address
!= bfd_get_reloc_size (r->howto))
{
- if (! ieee_write_int (abfd,
- bfd_get_reloc_size (r->howto)))
+ bfd_vma rsize = bfd_get_reloc_size (r->howto);
+ if (! ieee_write_int (abfd, rsize))
return false;
}
if (! ieee_write_byte (abfd,
}
else
{
- if (! ieee_write_expression (abfd, 0, s->symbol, 0, 0))
+ if (! ieee_write_expression (abfd, (bfd_vma) 0, s->symbol, 0, 0))
return false;
}
ieee_mkobject (abfd)
bfd *abfd;
{
+ bfd_size_type amt;
+
output_ptr_start = NULL;
output_ptr = NULL;
output_ptr_end = NULL;
input_bfd = NULL;
output_bfd = NULL;
output_buffer = 0;
- abfd->tdata.ieee_data = (ieee_data_type *) bfd_zalloc (abfd, sizeof (ieee_data_type));
+ amt = sizeof (ieee_data_type);
+ abfd->tdata.ieee_data = (ieee_data_type *) bfd_zalloc (abfd, amt);
return abfd->tdata.ieee_data ? true : false;
}
static void
fill ()
{
+ bfd_size_type amt = input_ptr_end - input_ptr_start;
/* FIXME: Check return value. I'm not sure whether it needs to read
the entire buffer or not. */
- bfd_read ((PTR) input_ptr_start, 1, input_ptr_end - input_ptr_start, input_bfd);
+ bfd_bread ((PTR) input_ptr_start, amt, input_bfd);
input_ptr = input_ptr_start;
}
static void
flush ()
{
- if (bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start,
- output_bfd)
- != (bfd_size_type) (output_ptr - output_ptr_start))
+ bfd_size_type amt = output_ptr - output_ptr_start;
+ if (bfd_bwrite ((PTR) (output_ptr_start), amt, output_bfd) != amt)
abort ();
output_ptr = output_ptr_start;
output_buffer++;
{
int stack[10];
int *tos = stack;
- int value = 0;
+ int value;
while (1)
{
switch (THIS ())
}
*tos++ = THIS ();
NEXT ();
- value = 0;
break;
case 0xa5:
/* PLUS anything */
- {
- int value = *(--tos);
- value += *(--tos);
- *tos++ = value;
- NEXT ();
- }
+ value = *(--tos);
+ value += *(--tos);
+ *tos++ = value;
+ NEXT ();
break;
case VAR ('R'):
{
NEXT ();
ieee = IEEE_DATA (input_bfd);
s = ieee->section_table[section_number];
+ value = 0;
if (s->output_section)
- {
- value = s->output_section->lma;
- }
- else
- {
- value = 0;
- }
+ value = s->output_section->lma;
value += s->output_offset;
*tos++ = value;
- value = 0;
}
break;
case 0x90:
write_int (*(--tos));
OUT (0x90);
return;
-
}
}
}
-
}
/* Drop the int in the buffer, and copy a null into the gap, which we
input_bfd = input;
/* FIXME: Check return value. I'm not sure whether it needs to read
the entire buffer or not. */
- bfd_read ((PTR) input_ptr_start, 1, IBS, input);
+ bfd_bread ((PTR) input_ptr_start, (bfd_size_type) IBS, input);
block ();
}
{
ieee_data_type *ieee = IEEE_DATA (abfd);
bfd_chain_type *chain = ieee->chain_root;
- unsigned char output_buffer[OBS];
+ unsigned char obuff[OBS];
boolean some_debug = false;
file_ptr here = bfd_tell (abfd);
- output_ptr_start = output_ptr = output_buffer;
- output_ptr_end = output_buffer + OBS;
- output_ptr = output_buffer;
+ output_ptr_start = output_ptr = obuff;
+ output_ptr_end = obuff + OBS;
+ output_ptr = obuff;
output_bfd = abfd;
if (chain == (bfd_chain_type *) NULL)
}
ieee->w.r.debug_information_part = here;
- if (bfd_write (s->contents, 1, s->_raw_size, abfd) != s->_raw_size)
+ if (bfd_bwrite (s->contents, s->_raw_size, abfd) != s->_raw_size)
return false;
}
else
if (entry_ieee->w.r.debug_information_part)
{
if (bfd_seek (entry, entry_ieee->w.r.debug_information_part,
- SEEK_SET)
- != 0)
+ SEEK_SET) != 0)
return false;
relocate_debug (abfd, entry);
}
continue;
if (s->_raw_size != 0)
{
- ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, s->_raw_size));
+ bfd_size_type size = s->_raw_size;
+ ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, size));
if (!ieee_per_section (s)->data)
return false;
}
{
if (section->contents == NULL)
{
- section->contents = ((unsigned char *)
- bfd_alloc (abfd, section->_raw_size));
+ bfd_size_type size = section->_raw_size;
+ section->contents = (unsigned char *) bfd_alloc (abfd, size);
if (section->contents == NULL)
return false;
}
/* bfd_set_section_contents has already checked that everything
is within range. */
- memcpy (section->contents + offset, location, count);
+ memcpy (section->contents + offset, location, (size_t) count);
return true;
}
{
/* This must be a symbol reference .. */
if (! ieee_write_byte (abfd, ieee_external_reference_enum)
- || ! ieee_write_int (abfd, reference_index)
+ || ! ieee_write_int (abfd, (bfd_vma) reference_index)
|| ! ieee_write_id (abfd, p->name))
return false;
p->value = reference_index;
{
/* This is a weak reference */
if (! ieee_write_byte (abfd, ieee_external_reference_enum)
- || ! ieee_write_int (abfd, reference_index)
+ || ! ieee_write_int (abfd, (bfd_vma) reference_index)
|| ! ieee_write_id (abfd, p->name)
|| ! ieee_write_byte (abfd,
ieee_weak_external_reference_enum)
- || ! ieee_write_int (abfd, reference_index)
+ || ! ieee_write_int (abfd, (bfd_vma) reference_index)
|| ! ieee_write_int (abfd, p->value))
return false;
p->value = reference_index;
/* This must be a symbol definition */
if (! ieee_write_byte (abfd, ieee_external_symbol_enum)
- || ! ieee_write_int (abfd, public_index)
+ || ! ieee_write_int (abfd, (bfd_vma) public_index)
|| ! ieee_write_id (abfd, p->name)
|| ! ieee_write_2bytes (abfd, ieee_attribute_record_enum)
- || ! ieee_write_int (abfd, public_index)
+ || ! ieee_write_int (abfd, (bfd_vma) public_index)
|| ! ieee_write_byte (abfd, 15) /* instruction address */
|| ! ieee_write_byte (abfd, 19) /* static symbol */
|| ! ieee_write_byte (abfd, 1)) /* one of them */
/* Write out the value */
if (! ieee_write_2bytes (abfd, ieee_value_record_enum)
- || ! ieee_write_int (abfd, public_index))
+ || ! ieee_write_int (abfd, (bfd_vma) public_index))
return false;
if (! bfd_is_abs_section (p->section))
{
return false;
ieee->w.r.extension_record = bfd_tell (abfd);
- if (bfd_write ((char *) exten, 1, sizeof (exten), abfd) != sizeof (exten))
+ if (bfd_bwrite ((char *) exten, (bfd_size_type) sizeof (exten), abfd)
+ != sizeof (exten))
return false;
if (abfd->flags & EXEC_P)
{
}
ieee->w.r.environmental_record = bfd_tell (abfd);
- if (bfd_write ((char *) envi, 1, sizeof (envi), abfd) != sizeof (envi))
+ if (bfd_bwrite ((char *) envi, (bfd_size_type) sizeof (envi), abfd)
+ != sizeof (envi))
return false;
/* The HP emulator database requires a timestamp in the file. */
|| ! ieee_write_byte (abfd, 0x21)
|| ! ieee_write_byte (abfd, 0)
|| ! ieee_write_byte (abfd, 50)
- || ! ieee_write_int (abfd, t->tm_year + 1900)
- || ! ieee_write_int (abfd, t->tm_mon + 1)
- || ! ieee_write_int (abfd, t->tm_mday)
- || ! ieee_write_int (abfd, t->tm_hour)
- || ! ieee_write_int (abfd, t->tm_min)
- || ! ieee_write_int (abfd, t->tm_sec))
+ || ! ieee_write_int (abfd, (bfd_vma) (t->tm_year + 1900))
+ || ! ieee_write_int (abfd, (bfd_vma) (t->tm_mon + 1))
+ || ! ieee_write_int (abfd, (bfd_vma) t->tm_mday)
+ || ! ieee_write_int (abfd, (bfd_vma) t->tm_hour)
+ || ! ieee_write_int (abfd, (bfd_vma) t->tm_min)
+ || ! ieee_write_int (abfd, (bfd_vma) t->tm_sec))
return false;
}
{
if (! ieee_write_2bytes (abfd, ieee_assign_value_to_variable_enum)
|| ! ieee_write_byte (abfd, (bfd_byte) i)
- || ! ieee_write_int5_out (abfd, ieee->w.offset[i]))
+ || ! ieee_write_int5_out (abfd, (bfd_vma) ieee->w.offset[i]))
return false;
}
ieee_make_empty_symbol (abfd)
bfd *abfd;
{
- ieee_symbol_type *new =
- (ieee_symbol_type *) bfd_zalloc (abfd, sizeof (ieee_symbol_type));
+ bfd_size_type amt = sizeof (ieee_symbol_type);
+ ieee_symbol_type *new = (ieee_symbol_type *) bfd_zalloc (abfd, amt);
if (!new)
return NULL;
new->symbol.the_bfd = abfd;
/* Add to chain */
{
- bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, sizeof (bfd_chain_type));
+ bfd_size_type amt = sizeof (bfd_chain_type);
+ bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, amt);
if (!n)
abort (); /* FIXME */
n->this = section->owner;
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
NULL,
-
+
(PTR) 0
};
/* BFD back-end for Intel Hex objects.
- Copyright 1995, 1996, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1995, 1996, 1998, 1999, 2000, 2001
+ Free Software Foundation, Inc.
Written by Ian Lance Taylor of Cygnus Support <ian@cygnus.com>.
This file is part of BFD, the Binary File Descriptor library.
static boolean ihex_set_section_contents
PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
static boolean ihex_write_record
- PARAMS ((bfd *, bfd_size_type, bfd_vma, unsigned int, bfd_byte *));
+ PARAMS ((bfd *, size_t, unsigned int, unsigned int, bfd_byte *));
static boolean ihex_write_object_contents PARAMS ((bfd *));
static asymbol *ihex_make_empty_symbol PARAMS ((bfd *));
static boolean ihex_set_arch_mach
if (abfd->tdata.ihex_data == NULL)
{
struct ihex_data_struct *tdata;
+ bfd_size_type amt = sizeof (struct ihex_data_struct);
- tdata = ((struct ihex_data_struct *)
- bfd_alloc (abfd, sizeof (struct ihex_data_struct)));
+ tdata = (struct ihex_data_struct *) bfd_alloc (abfd, amt);
if (tdata == NULL)
return false;
abfd->tdata.ihex_data = tdata;
{
bfd_byte c;
- if (bfd_read (&c, 1, 1, abfd) != 1)
+ if (bfd_bread (&c, (bfd_size_type) 1, abfd) != 1)
{
if (bfd_get_error () != bfd_error_file_truncated)
*errorptr = true;
bfd_vma segbase;
bfd_vma extbase;
asection *sec;
- int lineno;
+ unsigned int lineno;
boolean error;
bfd_byte *buf = NULL;
size_t bufsize;
/* Read the header bytes. */
- if (bfd_read (hdr, 1, 8, abfd) != 8)
+ if (bfd_bread (hdr, (bfd_size_type) 8, abfd) != 8)
goto error_return;
for (i = 0; i < 8; i++)
chars = len * 2 + 2;
if (chars >= bufsize)
{
- buf = (bfd_byte *) bfd_realloc (buf, chars);
+ buf = (bfd_byte *) bfd_realloc (buf, (bfd_size_type) chars);
if (buf == NULL)
goto error_return;
bufsize = chars;
}
- if (bfd_read (buf, 1, chars, abfd) != chars)
+ if (bfd_bread (buf, (bfd_size_type) chars, abfd) != chars)
goto error_return;
for (i = 0; i < chars; i++)
if (((- chksum) & 0xff) != (unsigned int) HEX2 (buf + 2 * i))
{
(*_bfd_error_handler)
- (_("%s:%d: bad checksum in Intel Hex file (expected %u, found %u)"),
+ (_("%s:%u: bad checksum in Intel Hex file (expected %u, found %u)"),
bfd_get_filename (abfd), lineno,
(- chksum) & 0xff, (unsigned int) HEX2 (buf + 2 * i));
bfd_set_error (bfd_error_bad_value);
{
char secbuf[20];
char *secname;
+ bfd_size_type amt;
sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
- secname = (char *) bfd_alloc (abfd, strlen (secbuf) + 1);
+ amt = strlen (secbuf) + 1;
+ secname = (char *) bfd_alloc (abfd, amt);
if (secname == NULL)
goto error_return;
strcpy (secname, secbuf);
if (len != 2)
{
(*_bfd_error_handler)
- (_("%s:%d: bad extended address record length in Intel Hex file"),
+ (_("%s:%u: bad extended address record length in Intel Hex file"),
bfd_get_filename (abfd), lineno);
bfd_set_error (bfd_error_bad_value);
goto error_return;
if (len != 4)
{
(*_bfd_error_handler)
- (_("%s:%d: bad extended start address length in Intel Hex file"),
+ (_("%s:%u: bad extended start address length in Intel Hex file"),
bfd_get_filename (abfd), lineno);
bfd_set_error (bfd_error_bad_value);
goto error_return;
if (len != 2)
{
(*_bfd_error_handler)
- (_("%s:%d: bad extended linear address record length in Intel Hex file"),
+ (_("%s:%u: bad extended linear address record length in Intel Hex file"),
bfd_get_filename (abfd), lineno);
bfd_set_error (bfd_error_bad_value);
goto error_return;
if (len != 2 && len != 4)
{
(*_bfd_error_handler)
- (_("%s:%d: bad extended linear start address length in Intel Hex file"),
+ (_("%s:%u: bad extended linear start address length in Intel Hex file"),
bfd_get_filename (abfd), lineno);
bfd_set_error (bfd_error_bad_value);
goto error_return;
default:
(*_bfd_error_handler)
- (_("%s:%d: unrecognized ihex type %u in Intel Hex file\n"),
+ (_("%s:%u: unrecognized ihex type %u in Intel Hex file\n"),
bfd_get_filename (abfd), lineno, type);
bfd_set_error (bfd_error_bad_value);
goto error_return;
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return NULL;
- if (bfd_read (b, 1, 9, abfd) != 9)
+ if (bfd_bread (b, (bfd_size_type) 9, abfd) != 9)
{
if (bfd_get_error () == bfd_error_file_truncated)
bfd_set_error (bfd_error_wrong_format);
know the exact format. */
BFD_ASSERT (c == ':');
- if (bfd_read (hdr, 1, 8, abfd) != 8)
+ if (bfd_bread (hdr, (bfd_size_type) 8, abfd) != 8)
goto error_return;
len = HEX2 (hdr);
if (len * 2 > bufsize)
{
- buf = (bfd_byte *) bfd_realloc (buf, len * 2);
+ buf = (bfd_byte *) bfd_realloc (buf, (bfd_size_type) len * 2);
if (buf == NULL)
goto error_return;
bufsize = len * 2;
}
- if (bfd_read (buf, 1, len * 2, abfd) != len * 2)
+ if (bfd_bread (buf, (bfd_size_type) len * 2, abfd) != len * 2)
goto error_return;
for (i = 0; i < len; i++)
}
/* Skip the checksum. */
- if (bfd_read (buf, 1, 2, abfd) != 2)
+ if (bfd_bread (buf, (bfd_size_type) 2, abfd) != 2)
goto error_return;
}
struct ihex_data_list *n;
bfd_byte *data;
struct ihex_data_struct *tdata;
+ bfd_size_type amt;
if (count == 0
|| (section->flags & SEC_ALLOC) == 0
|| (section->flags & SEC_LOAD) == 0)
return true;
- n = ((struct ihex_data_list *)
- bfd_alloc (abfd, sizeof (struct ihex_data_list)));
+ amt = sizeof (struct ihex_data_list);
+ n = (struct ihex_data_list *) bfd_alloc (abfd, amt);
if (n == NULL)
return false;
static boolean
ihex_write_record (abfd, count, addr, type, data)
bfd *abfd;
- bfd_size_type count;
- bfd_vma addr;
+ size_t count;
+ unsigned int addr;
unsigned int type;
bfd_byte *data;
{
char *p;
unsigned int chksum;
unsigned int i;
+ size_t total;
#define TOHEX(buf, v) \
((buf)[0] = digs[((v) >> 4) & 0xf], (buf)[1] = digs[(v) & 0xf])
p[2] = '\r';
p[3] = '\n';
- if (bfd_write (buf, 1, 9 + count * 2 + 4, abfd) != 9 + count * 2 + 4)
+ total = 9 + count * 2 + 4;
+ if (bfd_bwrite (buf, (bfd_size_type) total, abfd) != total)
return false;
return true;
count = l->size;
while (count > 0)
{
- bfd_size_type now;
+ size_t now;
+ unsigned int rec_addr;
now = count;
- if (now > CHUNK)
+ if (count > CHUNK)
now = CHUNK;
if (where > segbase + extbase + 0xffff)
}
}
- if (! ihex_write_record (abfd, now, where - (extbase + segbase),
- 0, p))
+ rec_addr = where - (extbase + segbase);
+ if (! ihex_write_record (abfd, now, rec_addr, 0, p))
return false;
where += now;
{
asymbol *new;
- new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ new = (asymbol *) bfd_zalloc (abfd, (bfd_size_type) sizeof (asymbol));
if (new != NULL)
new->the_bfd = abfd;
return new;
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
NULL,
-
+
(PTR) 0
};
#include <core.out.h>
-struct sgi_core_struct
+struct sgi_core_struct
{
int sig;
char cmd[CORE_NAMESIZE];
#define core_command(bfd) (core_hdr(bfd)->cmd)
static asection *make_bfd_asection
- PARAMS ((bfd *, CONST char *, flagword, bfd_size_type, bfd_vma, file_ptr));
+ PARAMS ((bfd *, const char *, flagword, bfd_size_type, bfd_vma, file_ptr));
static const bfd_target *irix_core_core_file_p PARAMS ((bfd *));
static char *irix_core_core_file_failing_command PARAMS ((bfd *));
static int irix_core_core_file_failing_signal PARAMS ((bfd *));
-static boolean irix_core_core_file_matches_executable_p
+static boolean irix_core_core_file_matches_executable_p
PARAMS ((bfd *, bfd *));
static asymbol *irix_core_make_empty_symbol PARAMS ((bfd *));
static void swap_abort PARAMS ((void));
static asection *
make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
bfd *abfd;
- CONST char *name;
+ const char *name;
flagword flags;
bfd_size_type _raw_size;
bfd_vma vma;
char *secname;
struct coreout coreout;
struct idesc *idg, *idf, *ids;
+ bfd_size_type amt;
- val = bfd_read ((PTR)&coreout, 1, sizeof coreout, abfd);
+ val = bfd_bread ((PTR) &coreout, (bfd_size_type) sizeof coreout, abfd);
if (val != sizeof coreout)
{
if (bfd_get_error () != bfd_error_system_call)
|| coreout.c_version != CORE_VERSION1)
return 0;
- core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, sizeof (struct sgi_core_struct));
+ amt = sizeof (struct sgi_core_struct);
+ core_hdr (abfd) = (struct sgi_core_struct *) bfd_zalloc (abfd, amt);
if (!core_hdr (abfd))
return NULL;
{
struct vmap vmap;
- val = bfd_read ((PTR)&vmap, 1, sizeof vmap, abfd);
+ val = bfd_bread ((PTR) &vmap, (bfd_size_type) sizeof vmap, abfd);
if (val != sizeof vmap)
break;
idg->i_len + idf->i_len + ids->i_len,
0,
idg->i_offset);
-
+
/* OK, we believe you. You're a core file (sure, sure). */
bfd_default_set_arch_mach (abfd, bfd_arch_mips, 0);
irix_core_make_empty_symbol (abfd)
bfd *abfd;
{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ bfd_size_type amt = sizeof (asymbol);
+ asymbol *new = (asymbol *) bfd_zalloc (abfd, amt);
if (new)
new->the_bfd = abfd;
return new;
bfd_false, bfd_false,
bfd_false, bfd_false
},
-
+
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
BFD_JUMP_TABLE_COPY (_bfd_generic),
BFD_JUMP_TABLE_CORE (irix_core),
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
NULL,
-
+
(PTR) 0 /* backend_data */
};
#include "bfdlink.h"
+/* Macros for accessing components in an aout header. Saves cluttering
+ the source with (bfd_vma) and (bfd_byte *) casts. */
+
+#define H_PUT_64(abfd, val, where) \
+ bfd_h_put_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+
+#define H_PUT_32(abfd, val, where) \
+ bfd_h_put_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+
+#define H_PUT_16(abfd, val, where) \
+ bfd_h_put_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+
+#define H_PUT_8 bfd_h_put_8
+
+#define H_PUT_S64(abfd, val, where) \
+ bfd_h_put_signed_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+
+#define H_PUT_S32(abfd, val, where) \
+ bfd_h_put_signed_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+
+#define H_PUT_S16(abfd, val, where) \
+ bfd_h_put_signed_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+
+#define H_PUT_S8 bfd_h_put_signed_8
+
+#define H_GET_64(abfd, where) \
+ bfd_h_get_64 ((abfd), (bfd_byte *) (where))
+
+#define H_GET_32(abfd, where) \
+ bfd_h_get_32 ((abfd), (bfd_byte *) (where))
+
+#define H_GET_16(abfd, where) \
+ bfd_h_get_16 ((abfd), (bfd_byte *) (where))
+
+#define H_GET_8 bfd_h_get_8
+
+#define H_GET_S64(abfd, where) \
+ bfd_h_get_signed_64 ((abfd), (bfd_byte *) (where))
+
+#define H_GET_S32(abfd, where) \
+ bfd_h_get_signed_32 ((abfd), (bfd_byte *) (where))
+
+#define H_GET_S16(abfd, where) \
+ bfd_h_get_signed_16 ((abfd), (bfd_byte *) (where))
+
+#define H_GET_S8 bfd_h_get_signed_8
+
/* Parameterize the a.out code based on whether it is being built
for a 32-bit architecture or a 64-bit architecture. */
#if ARCH_SIZE==64
-#define GET_WORD bfd_h_get_64
-#define GET_SWORD bfd_h_get_signed_64
-#define GET_MAGIC bfd_h_get_32
-#define PUT_WORD bfd_h_put_64
-#define PUT_MAGIC bfd_h_put_32
+#define GET_WORD H_GET_64
+#define GET_SWORD H_GET_S64
+#define GET_MAGIC H_GET_32
+#define PUT_WORD H_PUT_64
+#define PUT_MAGIC H_PUT_32
#ifndef NAME
#define NAME(x,y) CAT3(x,_64_,y)
#endif
#define BYTES_IN_WORD 8
#else
#if ARCH_SIZE==16
-#define GET_WORD bfd_h_get_16
-#define GET_SWORD bfd_h_get_signed_16
-#define GET_MAGIC bfd_h_get_16
-#define PUT_WORD bfd_h_put_16
-#define PUT_MAGIC bfd_h_put_16
+#define GET_WORD H_GET_16
+#define GET_SWORD H_GET_S16
+#define GET_MAGIC H_GET_16
+#define PUT_WORD H_PUT_16
+#define PUT_MAGIC H_PUT_16
#ifndef NAME
#define NAME(x,y) CAT3(x,_16_,y)
#endif
#define JNAME(x) CAT(x,_16)
#define BYTES_IN_WORD 2
#else /* ARCH_SIZE == 32 */
-#define GET_WORD bfd_h_get_32
-#define GET_SWORD bfd_h_get_signed_32
-#define GET_MAGIC bfd_h_get_32
-#define PUT_WORD bfd_h_put_32
-#define PUT_MAGIC bfd_h_put_32
+#define GET_WORD H_GET_32
+#define GET_SWORD H_GET_S32
+#define GET_MAGIC H_GET_32
+#define PUT_WORD H_PUT_32
+#define PUT_MAGIC H_PUT_32
#ifndef NAME
#define NAME(x,y) CAT3(x,_32_,y)
#endif
/* Callback for setting the page and segment sizes, if they can't be
trivially determined from the architecture. */
- boolean (*set_sizes) PARAMS ((bfd *));
+ boolean (*set_sizes)
+ PARAMS ((bfd *));
/* zmagic files only. For go32, the length of the exec header contributes
to the size of the text section in the file for alignment purposes but
/* Callback from the add symbols phase of the linker code to handle
a dynamic object. */
- boolean (*add_dynamic_symbols) PARAMS ((bfd *, struct bfd_link_info *,
- struct external_nlist **,
- bfd_size_type *, char **));
+ boolean (*add_dynamic_symbols)
+ PARAMS ((bfd *, struct bfd_link_info *, struct external_nlist **,
+ bfd_size_type *, char **));
/* Callback from the add symbols phase of the linker code to handle
adding a single symbol to the global linker hash table. */
- boolean (*add_one_symbol) PARAMS ((struct bfd_link_info *, bfd *,
- const char *, flagword, asection *,
- bfd_vma, const char *, boolean,
- boolean,
- struct bfd_link_hash_entry **));
+ boolean (*add_one_symbol)
+ PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword,
+ asection *, bfd_vma, const char *, boolean, boolean,
+ struct bfd_link_hash_entry **));
/* Called to handle linking a dynamic object. */
- boolean (*link_dynamic_object) PARAMS ((struct bfd_link_info *, bfd *));
+ boolean (*link_dynamic_object)
+ PARAMS ((struct bfd_link_info *, bfd *));
/* Called for each global symbol being written out by the linker.
This should write out the dynamic symbol information. */
- boolean (*write_dynamic_symbol) PARAMS ((bfd *, struct bfd_link_info *,
- struct aout_link_hash_entry *));
+ boolean (*write_dynamic_symbol)
+ PARAMS ((bfd *, struct bfd_link_info *, struct aout_link_hash_entry *));
/* If this callback is not NULL, the linker calls it for each reloc.
RELOC is a pointer to the unswapped reloc. If *SKIP is set to
true, the reloc will be skipped. *RELOCATION may be changed to
change the effects of the relocation. */
- boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *info,
- bfd *input_bfd,
- asection *input_section,
- struct aout_link_hash_entry *h,
- PTR reloc, bfd_byte *contents,
- boolean *skip,
- bfd_vma *relocation));
+ boolean (*check_dynamic_reloc)
+ PARAMS ((struct bfd_link_info *info, bfd *input_bfd,
+ asection *input_section, struct aout_link_hash_entry *h,
+ PTR reloc, bfd_byte *contents, boolean *skip,
+ bfd_vma *relocation));
/* Called at the end of a link to finish up any dynamic linking
information. */
- boolean (*finish_dynamic_link) PARAMS ((bfd *, struct bfd_link_info *));
+ boolean (*finish_dynamic_link)
+ PARAMS ((bfd *, struct bfd_link_info *));
};
#define aout_backend_info(abfd) \
- ((CONST struct aout_backend_data *)((abfd)->xvec->backend_data))
+ ((const struct aout_backend_data *)((abfd)->xvec->backend_data))
/* This is the layout in memory of a "struct exec" while we process it.
All 'lengths' are given as a number of bytes.
char a_relaxable; /* Enough info for linker relax */
};
-/* Magic number is written
+/* Magic number is written
< MSB >
3130292827262524232221201918171615141312111009080706050403020100
< FLAGS >< MACHINE TYPE >< MAGIC NUMBER >
struct aoutdata {
struct internal_exec *hdr; /* exec file header */
aout_symbol_type *symbols; /* symtab for input bfd */
-
+
/* For ease, we do this */
asection *textsec;
asection *datasec;
/* Prototype declarations for functions defined in aoutx.h */
-boolean
-NAME(aout,squirt_out_relocs) PARAMS ((bfd *abfd, asection *section));
+extern boolean NAME(aout,squirt_out_relocs)
+ PARAMS ((bfd *, asection *));
-boolean
-NAME(aout,make_sections) PARAMS ((bfd *));
+extern boolean NAME(aout,make_sections)
+ PARAMS ((bfd *));
-const bfd_target *
-NAME(aout,some_aout_object_p) PARAMS ((bfd *abfd,
- struct internal_exec *execp,
- const bfd_target *(*callback)(bfd *)));
+extern const bfd_target * NAME(aout,some_aout_object_p)
+ PARAMS ((bfd *, struct internal_exec *, const bfd_target *(*) (bfd *)));
-boolean
-NAME(aout,mkobject) PARAMS ((bfd *abfd));
+extern boolean NAME(aout,mkobject)
+ PARAMS ((bfd *));
-enum machine_type
-NAME(aout,machine_type) PARAMS ((enum bfd_architecture arch,
- unsigned long machine,
- boolean *unknown));
+extern enum machine_type NAME(aout,machine_type)
+ PARAMS ((enum bfd_architecture, unsigned long, boolean *));
-boolean
-NAME(aout,set_arch_mach) PARAMS ((bfd *abfd, enum bfd_architecture arch,
- unsigned long machine));
+extern boolean NAME(aout,set_arch_mach)
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
-boolean
-NAME(aout,new_section_hook) PARAMS ((bfd *abfd, asection *newsect));
+extern boolean NAME(aout,new_section_hook)
+ PARAMS ((bfd *, asection *));
-boolean
-NAME(aout,set_section_contents) PARAMS ((bfd *abfd, sec_ptr section,
- PTR location, file_ptr offset, bfd_size_type count));
+extern boolean NAME(aout,set_section_contents)
+ PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
-asymbol *
-NAME(aout,make_empty_symbol) PARAMS ((bfd *abfd));
+extern asymbol * NAME(aout,make_empty_symbol)
+ PARAMS ((bfd *));
-boolean
-NAME(aout,translate_symbol_table) PARAMS ((bfd *, aout_symbol_type *,
- struct external_nlist *,
- bfd_size_type, char *,
- bfd_size_type,
- boolean dynamic));
+extern boolean NAME(aout,translate_symbol_table)
+ PARAMS ((bfd *, aout_symbol_type *, struct external_nlist *, bfd_size_type,
+ char *, bfd_size_type, boolean));
-boolean
-NAME(aout,slurp_symbol_table) PARAMS ((bfd *abfd));
+extern boolean NAME(aout,slurp_symbol_table)
+ PARAMS ((bfd *));
-boolean
-NAME(aout,write_syms) PARAMS ((bfd *abfd));
+extern boolean NAME(aout,write_syms)
+ PARAMS ((bfd *));
-void
-NAME(aout,reclaim_symbol_table) PARAMS ((bfd *abfd));
+extern void NAME(aout,reclaim_symbol_table)
+ PARAMS ((bfd *));
-long
-NAME(aout,get_symtab_upper_bound) PARAMS ((bfd *abfd));
+extern long NAME(aout,get_symtab_upper_bound)
+ PARAMS ((bfd *));
-long
-NAME(aout,get_symtab) PARAMS ((bfd *abfd, asymbol **location));
+extern long NAME(aout,get_symtab)
+ PARAMS ((bfd *, asymbol **));
-void
-NAME(aout,swap_ext_reloc_in) PARAMS ((bfd *, struct reloc_ext_external *,
- arelent *, asymbol **, bfd_size_type));
-void
-NAME(aout,swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *,
- arelent *, asymbol **, bfd_size_type));
+extern void NAME(aout,swap_ext_reloc_in)
+ PARAMS ((bfd *, struct reloc_ext_external *, arelent *, asymbol **,
+ bfd_size_type));
+extern void NAME(aout,swap_std_reloc_in)
+ PARAMS ((bfd *, struct reloc_std_external *, arelent *, asymbol **,
+ bfd_size_type));
-reloc_howto_type *
-NAME(aout,reloc_type_lookup) PARAMS ((bfd *abfd,
- bfd_reloc_code_real_type code));
+extern reloc_howto_type * NAME(aout,reloc_type_lookup)
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
-boolean
-NAME(aout,slurp_reloc_table) PARAMS ((bfd *abfd, sec_ptr asect,
- asymbol **symbols));
+extern boolean NAME(aout,slurp_reloc_table)
+ PARAMS ((bfd *, sec_ptr, asymbol **));
-long
-NAME(aout,canonicalize_reloc) PARAMS ((bfd *abfd, sec_ptr section,
- arelent **relptr, asymbol **symbols));
+extern long NAME(aout,canonicalize_reloc)
+ PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
-long
-NAME(aout,get_reloc_upper_bound) PARAMS ((bfd *abfd, sec_ptr asect));
+extern long NAME(aout,get_reloc_upper_bound)
+ PARAMS ((bfd *, sec_ptr));
-void
-NAME(aout,reclaim_reloc) PARAMS ((bfd *ignore_abfd, sec_ptr ignore));
+extern void NAME(aout,reclaim_reloc)
+ PARAMS ((bfd *, sec_ptr));
-alent *
-NAME(aout,get_lineno) PARAMS ((bfd *ignore_abfd, asymbol *ignore_symbol));
+extern alent * NAME(aout,get_lineno)
+ PARAMS ((bfd *, asymbol *));
-void
-NAME(aout,print_symbol) PARAMS ((bfd *ignore_abfd, PTR file,
- asymbol *symbol, bfd_print_symbol_type how));
+extern void NAME(aout,print_symbol)
+ PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
-void
-NAME(aout,get_symbol_info) PARAMS ((bfd *ignore_abfd,
- asymbol *symbol, symbol_info *ret));
+extern void NAME(aout,get_symbol_info)
+ PARAMS ((bfd *, asymbol *, symbol_info *));
-boolean
-NAME(aout,find_nearest_line) PARAMS ((bfd *abfd, asection *section,
- asymbol **symbols, bfd_vma offset, CONST char **filename_ptr,
- CONST char **functionname_ptr, unsigned int *line_ptr));
+extern boolean NAME(aout,find_nearest_line)
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
+ const char **, unsigned int *));
-long
-NAME(aout,read_minisymbols) PARAMS ((bfd *, boolean, PTR *, unsigned int *));
+extern long NAME(aout,read_minisymbols)
+ PARAMS ((bfd *, boolean, PTR *, unsigned int *));
-asymbol *
-NAME(aout,minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
- asymbol *));
+extern asymbol * NAME(aout,minisymbol_to_symbol)
+ PARAMS ((bfd *, boolean, const PTR, asymbol *));
-int
-NAME(aout,sizeof_headers) PARAMS ((bfd *abfd, boolean exec));
+extern int NAME(aout,sizeof_headers)
+ PARAMS ((bfd *, boolean));
-boolean
-NAME(aout,adjust_sizes_and_vmas) PARAMS ((bfd *abfd,
- bfd_size_type *text_size, file_ptr *text_end));
+extern boolean NAME(aout,adjust_sizes_and_vmas)
+ PARAMS ((bfd *, bfd_size_type *, file_ptr *));
-void
-NAME(aout,swap_exec_header_in) PARAMS ((bfd *abfd,
- struct external_exec *raw_bytes, struct internal_exec *execp));
+extern void NAME(aout,swap_exec_header_in)
+ PARAMS ((bfd *, struct external_exec *, struct internal_exec *));
-void
-NAME(aout,swap_exec_header_out) PARAMS ((bfd *abfd,
- struct internal_exec *execp, struct external_exec *raw_bytes));
+extern void NAME(aout,swap_exec_header_out)
+ PARAMS ((bfd *, struct internal_exec *, struct external_exec *));
-struct bfd_hash_entry *
-NAME(aout,link_hash_newfunc)
+extern struct bfd_hash_entry * NAME(aout,link_hash_newfunc)
PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-boolean
-NAME(aout,link_hash_table_init)
- PARAMS ((struct aout_link_hash_table *, bfd *,
- struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *)));
+extern boolean NAME(aout,link_hash_table_init)
+ PARAMS ((struct aout_link_hash_table *, bfd *,
+ struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
+ struct bfd_hash_table *,
+ const char *)));
-struct bfd_link_hash_table *
-NAME(aout,link_hash_table_create) PARAMS ((bfd *));
+extern struct bfd_link_hash_table * NAME(aout,link_hash_table_create)
+ PARAMS ((bfd *));
-boolean
-NAME(aout,link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
+extern boolean NAME(aout,link_add_symbols)
+ PARAMS ((bfd *, struct bfd_link_info *));
-boolean
-NAME(aout,final_link) PARAMS ((bfd *, struct bfd_link_info *,
- void (*) (bfd *, file_ptr *, file_ptr *,
- file_ptr *)));
+extern boolean NAME(aout,final_link)
+ PARAMS ((bfd *, struct bfd_link_info *,
+ void (*) (bfd *, file_ptr *, file_ptr *, file_ptr *)));
-boolean
-NAME(aout,bfd_free_cached_info) PARAMS ((bfd *));
+extern boolean NAME(aout,bfd_free_cached_info)
+ PARAMS ((bfd *));
/* A.out uses the generic versions of these routines... */
obj_reloc_entry_size (abfd)); \
NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
\
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
- if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
- != EXEC_BYTES_SIZE) \
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 \
+ || bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, \
+ abfd) != EXEC_BYTES_SIZE) \
return false; \
/* Now write out reloc info, followed by syms and strings */ \
\
if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \
&& bfd_get_symcount (abfd) != 0) \
{ \
- if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) != 0) \
+ if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET) != 0)\
return false; \
\
- if (! NAME(aout,write_syms)(abfd)) return false; \
+ if (! NAME(aout,write_syms) (abfd)) \
+ return false; \
} \
\
- if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) != 0) \
+ if (bfd_seek (abfd, (file_ptr) (N_TRELOFF(*execp)), SEEK_SET) != 0) \
return false; \
if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) \
return false; \
\
- if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) != 0) \
+ if (bfd_seek (abfd, (file_ptr) (N_DRELOFF(*execp)), SEEK_SET) != 0) \
return false; \
- if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
+ if (!NAME(aout,squirt_out_relocs) (abfd, obj_datasec (abfd))) \
return false; \
- }
+ }
#endif
#endif /* ! defined (LIBAOUT_H) */
E.g. align to an 8-byte boundary with argument of 8. Take care never
to wrap around if the address is within boundary-1 of the end of the
address space. */
-#define BFD_ALIGN(this, boundary) \
- ((((bfd_vma) (this) + (boundary) - 1) >= (bfd_vma) (this)) \
- ? (((bfd_vma) (this) + ((boundary) - 1)) & (~((boundary)-1))) \
+#define BFD_ALIGN(this, boundary) \
+ ((((bfd_vma) (this) + (boundary) - 1) >= (bfd_vma) (this)) \
+ ? (((bfd_vma) (this) + ((boundary) - 1)) & ~ (bfd_vma) ((boundary)-1)) \
: ~ (bfd_vma) 0)
/* If you want to read and write large blocks, you might want to do it
#define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
-extern PTR bfd_malloc PARAMS ((size_t));
-extern PTR bfd_realloc PARAMS ((PTR, size_t));
-extern PTR bfd_zmalloc PARAMS ((size_t));
+extern PTR bfd_malloc PARAMS ((bfd_size_type));
+extern PTR bfd_realloc PARAMS ((PTR, bfd_size_type));
+extern PTR bfd_zmalloc PARAMS ((bfd_size_type));
extern bfd_error_handler_type _bfd_error_handler;
/* These routines allocate and free things on the BFD's objalloc. */
-extern PTR bfd_alloc PARAMS ((bfd *, size_t));
-extern PTR bfd_zalloc PARAMS ((bfd *, size_t));
+extern PTR bfd_alloc PARAMS ((bfd *, bfd_size_type));
+extern PTR bfd_zalloc PARAMS ((bfd *, bfd_size_type));
extern void bfd_release PARAMS ((bfd *, PTR));
bfd * _bfd_create_empty_archive_element_shell PARAMS ((bfd *obfd));
-bfd * _bfd_look_for_bfd_in_cache PARAMS ((bfd *arch_bfd, file_ptr index));
+bfd * _bfd_look_for_bfd_in_cache PARAMS ((bfd *, file_ptr));
boolean _bfd_add_bfd_to_archive_cache PARAMS ((bfd *, file_ptr, bfd *));
boolean _bfd_generic_mkarchive PARAMS ((bfd *abfd));
const bfd_target *bfd_generic_archive_p PARAMS ((bfd *abfd));
#define _bfd_generic_new_section_hook \
((boolean (*) PARAMS ((bfd *, asection *))) bfd_true)
extern boolean _bfd_generic_get_section_contents
- PARAMS ((bfd *, asection *, PTR location, file_ptr offset,
- bfd_size_type count));
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
extern boolean _bfd_generic_get_section_contents_in_window
PARAMS ((bfd *, asection *, bfd_window *, file_ptr, bfd_size_type));
/* Final link relocation routine. */
extern bfd_reloc_status_type _bfd_final_link_relocate
PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
- bfd_vma address, bfd_vma value, bfd_vma addend));
+ bfd_vma, bfd_vma, bfd_vma));
/* Relocate a particular location by a howto and a value. */
extern bfd_reloc_status_type _bfd_relocate_contents
#define getpagesize() 2048
#endif
-static int real_read PARAMS ((PTR, size_t, size_t, FILE *));
+static size_t real_read PARAMS ((PTR, size_t, size_t, FILE *));
/*
SECTION
PTR
bfd_malloc (size)
- size_t size;
+ bfd_size_type size;
{
PTR ptr;
- ptr = (PTR) malloc (size);
- if (ptr == NULL && size != 0)
+ if (size != (size_t) size)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return NULL;
+ }
+
+ ptr = (PTR) malloc ((size_t) size);
+ if (ptr == NULL && (size_t) size != 0)
bfd_set_error (bfd_error_no_memory);
+
return ptr;
}
PTR
bfd_realloc (ptr, size)
PTR ptr;
- size_t size;
+ bfd_size_type size;
{
PTR ret;
+ if (size != (size_t) size)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return NULL;
+ }
+
if (ptr == NULL)
- ret = malloc (size);
+ ret = malloc ((size_t) size);
else
- ret = realloc (ptr, size);
+ ret = realloc (ptr, (size_t) size);
- if (ret == NULL)
+ if (ret == NULL && (size_t) size != 0)
bfd_set_error (bfd_error_no_memory);
return ret;
PTR
bfd_zmalloc (size)
- size_t size;
+ bfd_size_type size;
{
PTR ptr;
- ptr = (PTR) malloc (size);
+ if (size != (size_t) size)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return NULL;
+ }
- if (size != 0)
+ ptr = (PTR) malloc ((size_t) size);
+
+ if ((size_t) size != 0)
{
if (ptr == NULL)
bfd_set_error (bfd_error_no_memory);
else
- memset (ptr, 0, size);
+ memset (ptr, 0, (size_t) size);
}
return ptr;
contents (0 for non-archive elements). For archive entries this is the
first octet in the file, NOT the beginning of the archive header. */
-static int
-real_read (where, a,b, file)
+static size_t
+real_read (where, a, b, file)
PTR where;
size_t a;
size_t b;
#endif
}
-/* Return value is amount read (FIXME: how are errors and end of file dealt
- with? We never call bfd_set_error, which is probably a mistake). */
+/* Return value is amount read. */
bfd_size_type
-bfd_read (ptr, size, nitems, abfd)
+bfd_bread (ptr, size, abfd)
PTR ptr;
bfd_size_type size;
- bfd_size_type nitems;
bfd *abfd;
{
- int nread;
+ size_t nread;
if ((abfd->flags & BFD_IN_MEMORY) != 0)
{
bfd_size_type get;
bim = (struct bfd_in_memory *) abfd->iostream;
- get = size * nitems;
+ get = size;
if (abfd->where + get > bim->size)
{
if (bim->size < (bfd_size_type) abfd->where)
get = bim->size - abfd->where;
bfd_set_error (bfd_error_file_truncated);
}
- memcpy (ptr, bim->buffer + abfd->where, get);
+ memcpy (ptr, bim->buffer + abfd->where, (size_t) get);
abfd->where += get;
return get;
}
- nread = real_read (ptr, 1, (size_t) (size*nitems), bfd_cache_lookup(abfd));
- if (nread > 0)
+ nread = real_read (ptr, 1, (size_t) size, bfd_cache_lookup (abfd));
+ if (nread != (size_t) -1)
abfd->where += nread;
/* Set bfd_error if we did not read as much data as we expected.
A BFD backend may wish to override bfd_error_file_truncated to
provide something more useful (eg. no_symbols or wrong_format). */
- if (nread != (int) (size * nitems))
+ if (nread != size)
{
if (ferror (bfd_cache_lookup (abfd)))
bfd_set_error (bfd_error_system_call);
{
static size_t pagesize;
bfd_window_internal *i = windowp->i;
- size_t size_to_alloc = size;
+ bfd_size_type size_to_alloc = size;
if (debug_windows)
fprintf (stderr, "bfd_get_file_window (%p, %6ld, %6ld, %p<%p,%lx,%p>, %d)",
if (i == 0)
{
- windowp->i = i = (bfd_window_internal *) bfd_zmalloc (sizeof (bfd_window_internal));
+ i = ((bfd_window_internal *)
+ bfd_zmalloc ((bfd_size_type) sizeof (bfd_window_internal)));
+ windowp->i = i;
if (i == 0)
return false;
i->data = 0;
{
if (size_to_alloc == 0)
return true;
- bfd_set_error (bfd_error_no_memory);
return false;
}
if (bfd_seek (abfd, offset, SEEK_SET) != 0)
return false;
- i->size = bfd_read (i->data, size, 1, abfd);
+ i->size = bfd_bread (i->data, size, abfd);
if (i->size != size)
return false;
i->mapped = 0;
#endif /* USE_MMAP */
\f
bfd_size_type
-bfd_write (ptr, size, nitems, abfd)
- CONST PTR ptr;
+bfd_bwrite (ptr, size, abfd)
+ const PTR ptr;
bfd_size_type size;
- bfd_size_type nitems;
bfd *abfd;
{
- long nwrote;
+ size_t nwrote;
if ((abfd->flags & BFD_IN_MEMORY) != 0)
{
struct bfd_in_memory *bim = (struct bfd_in_memory *) (abfd->iostream);
- size *= nitems;
+ size = (size_t) size;
if (abfd->where + size > bim->size)
{
- long newsize, oldsize = (bim->size + 127) & ~127;
+ bfd_size_type newsize, oldsize;
+
+ oldsize = (bim->size + 127) & ~(bfd_size_type) 127;
bim->size = abfd->where + size;
/* Round up to cut down on memory fragmentation */
- newsize = (bim->size + 127) & ~127;
+ newsize = (bim->size + 127) & ~(bfd_size_type) 127;
if (newsize > oldsize)
{
bim->buffer = bfd_realloc (bim->buffer, newsize);
}
}
}
- memcpy (bim->buffer + abfd->where, ptr, size);
+ memcpy (bim->buffer + abfd->where, ptr, (size_t) size);
abfd->where += size;
return size;
}
- nwrote = fwrite (ptr, 1, (size_t) (size * nitems),
- bfd_cache_lookup (abfd));
- if (nwrote > 0)
+ nwrote = fwrite (ptr, 1, (size_t) size, bfd_cache_lookup (abfd));
+ if (nwrote != (size_t) -1)
abfd->where += nwrote;
- if ((bfd_size_type) nwrote != size * nitems)
+ if (nwrote != size)
{
#ifdef ENOSPC
if (nwrote >= 0)
bfd_write_bigendian_4byte_int
SYNOPSIS
- void bfd_write_bigendian_4byte_int(bfd *abfd, int i);
+ void bfd_write_bigendian_4byte_int (bfd *, unsigned int);
DESCRIPTION
Write a 4 byte integer @var{i} to the output BFD @var{abfd}, in big
void
bfd_write_bigendian_4byte_int (abfd, i)
bfd *abfd;
- int i;
+ unsigned int i;
{
bfd_byte buffer[4];
- bfd_putb32(i, buffer);
- if (bfd_write((PTR)buffer, 4, 1, abfd) != 4)
+ bfd_putb32 ((bfd_vma) i, buffer);
+ if (bfd_bwrite ((PTR) buffer, (bfd_size_type) 4, abfd) != 4)
abort ();
}
-long
+bfd_vma
bfd_tell (abfd)
bfd *abfd;
{
if ((abfd->flags & BFD_IN_MEMORY) != 0)
return abfd->where;
- ptr = ftell (bfd_cache_lookup(abfd));
+ ptr = ftell (bfd_cache_lookup (abfd));
if (abfd->my_archive)
ptr -= abfd->origin;
{
int result;
FILE *f;
- file_ptr file_position;
+ long file_position;
/* For the time being, a BFD may not seek to it's end. The problem
is that we don't easily have a way to recognize the end of an
element in an archive. */
else
abfd->where += position;
- if ((bfd_size_type) abfd->where > bim->size)
+ if (abfd->where > bim->size)
{
if ((abfd->direction == write_direction) ||
(abfd->direction == both_direction))
{
- long newsize, oldsize = (bim->size + 127) & ~127;
+ bfd_size_type newsize, oldsize;
+ oldsize = (bim->size + 127) & ~(bfd_size_type) 127;
bim->size = abfd->where;
/* Round up to cut down on memory fragmentation */
- newsize = (bim->size + 127) & ~127;
+ newsize = (bim->size + 127) & ~(bfd_size_type) 127;
if (newsize > oldsize)
{
bim->buffer = bfd_realloc (bim->buffer, newsize);
if (bim->buffer == 0)
{
bim->size = 0;
- bfd_set_error (bfd_error_no_memory);
return -1;
}
}
if (where_am_i_now != abfd->where)
abort ();
#endif
- if (direction == SEEK_SET && position == abfd->where)
+ if (direction == SEEK_SET && (bfd_vma) position == abfd->where)
return 0;
}
else
.#define bfd_put_signed_8 \
. bfd_put_8
.#define bfd_get_8(abfd, ptr) \
-. (*(unsigned char *) (ptr))
+. (*(unsigned char *) (ptr) & 0xff)
.#define bfd_get_signed_8(abfd, ptr) \
-. ((*(unsigned char *) (ptr) ^ 0x80) - 0x80)
+. (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80)
.
.#define bfd_put_16(abfd, val, ptr) \
. BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
DESCRIPTION
These macros have the same function as their <<bfd_get_x>>
- bretheren, except that they are used for removing information
+ brethren, except that they are used for removing information
for the header records of object files. Believe it or not,
some object files keep their header records in big endian
order and their data in little endian order.
.{* Byte swapping macros for file header data. *}
.
.#define bfd_h_put_8(abfd, val, ptr) \
-. bfd_put_8 (abfd, val, ptr)
+. bfd_put_8 (abfd, val, ptr)
.#define bfd_h_put_signed_8(abfd, val, ptr) \
-. bfd_put_8 (abfd, val, ptr)
+. bfd_put_8 (abfd, val, ptr)
.#define bfd_h_get_8(abfd, ptr) \
-. bfd_get_8 (abfd, ptr)
+. bfd_get_8 (abfd, ptr)
.#define bfd_h_get_signed_8(abfd, ptr) \
-. bfd_get_signed_8 (abfd, ptr)
+. bfd_get_signed_8 (abfd, ptr)
.
.#define bfd_h_put_16(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
+. BFD_SEND (abfd, bfd_h_putx16, (val, ptr))
.#define bfd_h_put_signed_16 \
-. bfd_h_put_16
+. bfd_h_put_16
.#define bfd_h_get_16(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx16,(ptr))
+. BFD_SEND (abfd, bfd_h_getx16, (ptr))
.#define bfd_h_get_signed_16(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx_signed_16, (ptr))
+. BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr))
.
.#define bfd_h_put_32(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
+. BFD_SEND (abfd, bfd_h_putx32, (val, ptr))
.#define bfd_h_put_signed_32 \
-. bfd_h_put_32
+. bfd_h_put_32
.#define bfd_h_get_32(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx32,(ptr))
+. BFD_SEND (abfd, bfd_h_getx32, (ptr))
.#define bfd_h_get_signed_32(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx_signed_32, (ptr))
+. BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr))
.
.#define bfd_h_put_64(abfd, val, ptr) \
-. BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
+. BFD_SEND (abfd, bfd_h_putx64, (val, ptr))
.#define bfd_h_put_signed_64 \
-. bfd_h_put_64
+. bfd_h_put_64
.#define bfd_h_get_64(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx64,(ptr))
+. BFD_SEND (abfd, bfd_h_getx64, (ptr))
.#define bfd_h_get_signed_64(abfd, ptr) \
-. BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr))
+. BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr))
.
-*/
+.{* Refinements on the above, which should eventually go away. Save
+. cluttering the source with (bfd_vma) and (bfd_byte *) casts. *}
+.
+.#define H_PUT_64(abfd, val, where) \
+. bfd_h_put_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+.
+.#define H_PUT_32(abfd, val, where) \
+. bfd_h_put_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+.
+.#define H_PUT_16(abfd, val, where) \
+. bfd_h_put_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+.
+.#define H_PUT_8 bfd_h_put_8
+.
+.#define H_PUT_S64(abfd, val, where) \
+. bfd_h_put_signed_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+.
+.#define H_PUT_S32(abfd, val, where) \
+. bfd_h_put_signed_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+.
+.#define H_PUT_S16(abfd, val, where) \
+. bfd_h_put_signed_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
+.
+.#define H_PUT_S8 bfd_h_put_signed_8
+.
+.#define H_GET_64(abfd, where) \
+. bfd_h_get_64 ((abfd), (bfd_byte *) (where))
+.
+.#define H_GET_32(abfd, where) \
+. bfd_h_get_32 ((abfd), (bfd_byte *) (where))
+.
+.#define H_GET_16(abfd, where) \
+. bfd_h_get_16 ((abfd), (bfd_byte *) (where))
+.
+.#define H_GET_8 bfd_h_get_8
+.
+.#define H_GET_S64(abfd, where) \
+. bfd_h_get_signed_64 ((abfd), (bfd_byte *) (where))
+.
+.#define H_GET_S32(abfd, where) \
+. bfd_h_get_signed_32 ((abfd), (bfd_byte *) (where))
+.
+.#define H_GET_S16(abfd, where) \
+. bfd_h_get_signed_16 ((abfd), (bfd_byte *) (where))
+.
+.#define H_GET_S8 bfd_h_get_signed_8
+.
+.*/
/* Sign extension to bfd_signed_vma. */
#define COERCE16(x) (((bfd_signed_vma) (x) ^ 0x8000) - 0x8000)
if (count == 0)
return true;
- if ((bfd_size_type) (offset + count) > section->_raw_size)
+ if (offset + count > section->_raw_size)
{
bfd_set_error (bfd_error_invalid_operation);
return false;
}
if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
- || bfd_read (location, (bfd_size_type) 1, count, abfd) != count)
+ || bfd_bread (location, count, abfd) != count)
return false;
return true;
/* @@ FIXME : If the internal window has a refcount of 1 and was
allocated with malloc instead of mmap, just reuse it. */
bfd_free_window (w);
- w->i = (bfd_window_internal *) bfd_zmalloc (sizeof (bfd_window_internal));
+ w->i = ((bfd_window_internal *)
+ bfd_zmalloc ((bfd_size_type) sizeof (bfd_window_internal)));
if (w->i == NULL)
return false;
- w->i->data = (PTR) bfd_malloc ((size_t) count);
+ w->i->data = (PTR) bfd_malloc (count);
if (w->i->data == NULL)
{
free (w->i);
w->data = w->i->data;
return bfd_get_section_contents (abfd, section, w->data, offset, count);
}
- if ((bfd_size_type) (offset+count) > section->_raw_size
+ if (offset + count > section->_raw_size
|| (bfd_get_file_window (abfd, section->filepos + offset, count, w, true)
== false))
return false;
if (count == 0)
return true;
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) == -1
- || bfd_write (location, (bfd_size_type) 1, count, abfd) != count)
+ if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
+ || bfd_bwrite (location, count, abfd) != count)
return false;
return true;
bfd_log2
SYNOPSIS
- unsigned int bfd_log2(bfd_vma x);
+ unsigned int bfd_log2 (bfd_vma x);
DESCRIPTION
Return the log base 2 of the value supplied, rounded up. E.g., an
- @var{x} of 1025 returns 11.
+ @var{x} of 1025 returns 11. A @var{x} of 0 returns 0.
*/
unsigned int
return true;
}
+
+/* Give a warning at runtime if someone compiles code which calls
+ old routines. */
+void
+warn_deprecated (what, file, line, func)
+ const char *what;
+ const char *file;
+ int line;
+ const char *func;
+{
+ /* Poor man's tracking of functions we've already warned about. */
+ static size_t mask = 0;
+
+ if (~(size_t) func & ~mask)
+ {
+ fprintf (stderr, _("Deprecated %s called"), what);
+ if (func)
+ fprintf (stderr, _(" at %s line %d in %s\n"), file, line, func);
+ else
+ fprintf (stderr, "\n");
+ mask |= ~(size_t) func;
+ }
+}
E.g. align to an 8-byte boundary with argument of 8. Take care never
to wrap around if the address is within boundary-1 of the end of the
address space. */
-#define BFD_ALIGN(this, boundary) \
- ((((bfd_vma) (this) + (boundary) - 1) >= (bfd_vma) (this)) \
- ? (((bfd_vma) (this) + ((boundary) - 1)) & (~((boundary)-1))) \
+#define BFD_ALIGN(this, boundary) \
+ ((((bfd_vma) (this) + (boundary) - 1) >= (bfd_vma) (this)) \
+ ? (((bfd_vma) (this) + ((boundary) - 1)) & ~ (bfd_vma) ((boundary)-1)) \
: ~ (bfd_vma) 0)
/* If you want to read and write large blocks, you might want to do it
#define arelt_size(bfd) (((struct areltdata *)((bfd)->arelt_data))->parsed_size)
-extern PTR bfd_malloc PARAMS ((size_t));
-extern PTR bfd_realloc PARAMS ((PTR, size_t));
-extern PTR bfd_zmalloc PARAMS ((size_t));
+extern PTR bfd_malloc PARAMS ((bfd_size_type));
+extern PTR bfd_realloc PARAMS ((PTR, bfd_size_type));
+extern PTR bfd_zmalloc PARAMS ((bfd_size_type));
extern bfd_error_handler_type _bfd_error_handler;
/* These routines allocate and free things on the BFD's objalloc. */
-extern PTR bfd_alloc PARAMS ((bfd *, size_t));
-extern PTR bfd_zalloc PARAMS ((bfd *, size_t));
+extern PTR bfd_alloc PARAMS ((bfd *, bfd_size_type));
+extern PTR bfd_zalloc PARAMS ((bfd *, bfd_size_type));
extern void bfd_release PARAMS ((bfd *, PTR));
bfd * _bfd_create_empty_archive_element_shell PARAMS ((bfd *obfd));
-bfd * _bfd_look_for_bfd_in_cache PARAMS ((bfd *arch_bfd, file_ptr index));
+bfd * _bfd_look_for_bfd_in_cache PARAMS ((bfd *, file_ptr));
boolean _bfd_add_bfd_to_archive_cache PARAMS ((bfd *, file_ptr, bfd *));
boolean _bfd_generic_mkarchive PARAMS ((bfd *abfd));
const bfd_target *bfd_generic_archive_p PARAMS ((bfd *abfd));
#define _bfd_generic_new_section_hook \
((boolean (*) PARAMS ((bfd *, asection *))) bfd_true)
extern boolean _bfd_generic_get_section_contents
- PARAMS ((bfd *, asection *, PTR location, file_ptr offset,
- bfd_size_type count));
+ PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
extern boolean _bfd_generic_get_section_contents_in_window
PARAMS ((bfd *, asection *, bfd_window *, file_ptr, bfd_size_type));
/* Final link relocation routine. */
extern bfd_reloc_status_type _bfd_final_link_relocate
PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *,
- bfd_vma address, bfd_vma value, bfd_vma addend));
+ bfd_vma, bfd_vma, bfd_vma));
/* Relocate a particular location by a howto and a value. */
extern bfd_reloc_status_type _bfd_relocate_contents
/* And more follows */
void
-bfd_write_bigendian_4byte_int PARAMS ((bfd *abfd, int i));
+bfd_write_bigendian_4byte_int PARAMS ((bfd *, unsigned int));
unsigned int
bfd_log2 PARAMS ((bfd_vma x));
"BFD_RELOC_PPC64_TOC16_HI",
"BFD_RELOC_PPC64_TOC16_HA",
"BFD_RELOC_PPC64_TOC",
- "BFD_RELOC_PPC64_PLTGOT16 ",
+ "BFD_RELOC_PPC64_PLTGOT16",
"BFD_RELOC_PPC64_PLTGOT16_LO",
"BFD_RELOC_PPC64_PLTGOT16_HI",
"BFD_RELOC_PPC64_PLTGOT16_HA",
#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
/* Functions in coffgen.c. */
-extern const bfd_target *coff_object_p PARAMS ((bfd *));
-extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
-extern long coff_get_symtab_upper_bound PARAMS ((bfd *));
-extern long coff_get_symtab PARAMS ((bfd *, asymbol **));
-extern int coff_count_linenumbers PARAMS ((bfd *));
-extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
-extern boolean coff_renumber_symbols PARAMS ((bfd *, int *));
-extern void coff_mangle_symbols PARAMS ((bfd *));
-extern boolean coff_write_symbols PARAMS ((bfd *));
-extern boolean coff_write_linenumbers PARAMS ((bfd *));
-extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *));
-extern asymbol *coff_section_symbol PARAMS ((bfd *, char *));
-extern boolean _bfd_coff_get_external_symbols PARAMS ((bfd *));
-extern const char *_bfd_coff_read_string_table PARAMS ((bfd *));
-extern boolean _bfd_coff_free_symbols PARAMS ((bfd *));
-extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *));
-extern long coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
-extern asymbol *coff_make_empty_symbol PARAMS ((bfd *));
-extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *,
- bfd_print_symbol_type how));
-extern void coff_get_symbol_info PARAMS ((bfd *, asymbol *,
- symbol_info *ret));
-extern boolean _bfd_coff_is_local_label_name PARAMS ((bfd *, const char *));
-extern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR,
- unsigned long));
-extern boolean coff_find_nearest_line PARAMS ((bfd *,
- asection *,
- asymbol **,
- bfd_vma offset,
- CONST char **filename_ptr,
- CONST char **functionname_ptr,
- unsigned int *line_ptr));
-extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc));
+extern const bfd_target *coff_object_p
+ PARAMS ((bfd *));
+extern struct sec *coff_section_from_bfd_index
+ PARAMS ((bfd *, int));
+extern long coff_get_symtab_upper_bound
+ PARAMS ((bfd *));
+extern long coff_get_symtab
+ PARAMS ((bfd *, asymbol **));
+extern int coff_count_linenumbers
+ PARAMS ((bfd *));
+extern struct coff_symbol_struct *coff_symbol_from
+ PARAMS ((bfd *, asymbol *));
+extern boolean coff_renumber_symbols
+ PARAMS ((bfd *, int *));
+extern void coff_mangle_symbols
+ PARAMS ((bfd *));
+extern boolean coff_write_symbols
+ PARAMS ((bfd *));
+extern boolean coff_write_linenumbers
+ PARAMS ((bfd *));
+extern alent *coff_get_lineno
+ PARAMS ((bfd *, asymbol *));
+extern asymbol *coff_section_symbol
+ PARAMS ((bfd *, char *));
+extern boolean _bfd_coff_get_external_symbols
+ PARAMS ((bfd *));
+extern const char *_bfd_coff_read_string_table
+ PARAMS ((bfd *));
+extern boolean _bfd_coff_free_symbols
+ PARAMS ((bfd *));
+extern struct coff_ptr_struct *coff_get_normalized_symtab
+ PARAMS ((bfd *));
+extern long coff_get_reloc_upper_bound
+ PARAMS ((bfd *, sec_ptr));
+extern asymbol *coff_make_empty_symbol
+ PARAMS ((bfd *));
+extern void coff_print_symbol
+ PARAMS ((bfd *, PTR filep, asymbol *, bfd_print_symbol_type));
+extern void coff_get_symbol_info
+ PARAMS ((bfd *, asymbol *, symbol_info *ret));
+extern boolean _bfd_coff_is_local_label_name
+ PARAMS ((bfd *, const char *));
+extern asymbol *coff_bfd_make_debug_symbol
+ PARAMS ((bfd *, PTR, unsigned long));
+extern boolean coff_find_nearest_line
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
+ const char **, unsigned int *));
+extern int coff_sizeof_headers
+ PARAMS ((bfd *, boolean));
extern boolean bfd_coff_reloc16_relax_section
PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
- bfd_byte *, boolean relocateable, asymbol **));
-extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *,
- struct bfd_link_info *,
- asection *));
-extern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip,
- asection *input_section,
- bfd_vma val));
+ bfd_byte *, boolean, asymbol **));
+extern bfd_vma bfd_coff_reloc16_get_value
+ PARAMS ((arelent *, struct bfd_link_info *, asection *));
+extern void bfd_perform_slip
+ PARAMS ((bfd *, unsigned int, asection *, bfd_vma));
/* Functions and types in cofflink.c. */
/* Functions in xcofflink.c. */
-extern long _bfd_xcoff_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
+extern long _bfd_xcoff_get_dynamic_symtab_upper_bound
+ PARAMS ((bfd *));
extern long _bfd_xcoff_canonicalize_dynamic_symtab
PARAMS ((bfd *, asymbol **));
-extern long _bfd_xcoff_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
+extern long _bfd_xcoff_get_dynamic_reloc_upper_bound
+ PARAMS ((bfd *));
extern long _bfd_xcoff_canonicalize_dynamic_reloc
PARAMS ((bfd *, arelent **, asymbol **));
extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
/* Functions in coff-ppc.c. FIXME: These are called be pe.em in the
linker, and so should start with bfd and be declared in bfd.h. */
-extern boolean ppc_allocate_toc_section PARAMS ((struct bfd_link_info *));
+extern boolean ppc_allocate_toc_section
+ PARAMS ((struct bfd_link_info *));
extern boolean ppc_process_before_allocation
PARAMS ((bfd *, struct bfd_link_info *));
#define coff_hash_table(p) ((struct coff_link_hash_table *) ((p)->hash))
/* Functions in coffgen.c. */
-extern const bfd_target *coff_object_p PARAMS ((bfd *));
-extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
-extern long coff_get_symtab_upper_bound PARAMS ((bfd *));
-extern long coff_get_symtab PARAMS ((bfd *, asymbol **));
-extern int coff_count_linenumbers PARAMS ((bfd *));
-extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
-extern boolean coff_renumber_symbols PARAMS ((bfd *, int *));
-extern void coff_mangle_symbols PARAMS ((bfd *));
-extern boolean coff_write_symbols PARAMS ((bfd *));
-extern boolean coff_write_linenumbers PARAMS ((bfd *));
-extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *));
-extern asymbol *coff_section_symbol PARAMS ((bfd *, char *));
-extern boolean _bfd_coff_get_external_symbols PARAMS ((bfd *));
-extern const char *_bfd_coff_read_string_table PARAMS ((bfd *));
-extern boolean _bfd_coff_free_symbols PARAMS ((bfd *));
-extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *));
-extern long coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
-extern asymbol *coff_make_empty_symbol PARAMS ((bfd *));
-extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *,
- bfd_print_symbol_type how));
-extern void coff_get_symbol_info PARAMS ((bfd *, asymbol *,
- symbol_info *ret));
-extern boolean _bfd_coff_is_local_label_name PARAMS ((bfd *, const char *));
-extern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR,
- unsigned long));
-extern boolean coff_find_nearest_line PARAMS ((bfd *,
- asection *,
- asymbol **,
- bfd_vma offset,
- CONST char **filename_ptr,
- CONST char **functionname_ptr,
- unsigned int *line_ptr));
-extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc));
+extern const bfd_target *coff_object_p
+ PARAMS ((bfd *));
+extern struct sec *coff_section_from_bfd_index
+ PARAMS ((bfd *, int));
+extern long coff_get_symtab_upper_bound
+ PARAMS ((bfd *));
+extern long coff_get_symtab
+ PARAMS ((bfd *, asymbol **));
+extern int coff_count_linenumbers
+ PARAMS ((bfd *));
+extern struct coff_symbol_struct *coff_symbol_from
+ PARAMS ((bfd *, asymbol *));
+extern boolean coff_renumber_symbols
+ PARAMS ((bfd *, int *));
+extern void coff_mangle_symbols
+ PARAMS ((bfd *));
+extern boolean coff_write_symbols
+ PARAMS ((bfd *));
+extern boolean coff_write_linenumbers
+ PARAMS ((bfd *));
+extern alent *coff_get_lineno
+ PARAMS ((bfd *, asymbol *));
+extern asymbol *coff_section_symbol
+ PARAMS ((bfd *, char *));
+extern boolean _bfd_coff_get_external_symbols
+ PARAMS ((bfd *));
+extern const char *_bfd_coff_read_string_table
+ PARAMS ((bfd *));
+extern boolean _bfd_coff_free_symbols
+ PARAMS ((bfd *));
+extern struct coff_ptr_struct *coff_get_normalized_symtab
+ PARAMS ((bfd *));
+extern long coff_get_reloc_upper_bound
+ PARAMS ((bfd *, sec_ptr));
+extern asymbol *coff_make_empty_symbol
+ PARAMS ((bfd *));
+extern void coff_print_symbol
+ PARAMS ((bfd *, PTR filep, asymbol *, bfd_print_symbol_type));
+extern void coff_get_symbol_info
+ PARAMS ((bfd *, asymbol *, symbol_info *ret));
+extern boolean _bfd_coff_is_local_label_name
+ PARAMS ((bfd *, const char *));
+extern asymbol *coff_bfd_make_debug_symbol
+ PARAMS ((bfd *, PTR, unsigned long));
+extern boolean coff_find_nearest_line
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
+ const char **, unsigned int *));
+extern int coff_sizeof_headers
+ PARAMS ((bfd *, boolean));
extern boolean bfd_coff_reloc16_relax_section
PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
- bfd_byte *, boolean relocateable, asymbol **));
-extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *,
- struct bfd_link_info *,
- asection *));
-extern void bfd_perform_slip PARAMS ((bfd *abfd, unsigned int slip,
- asection *input_section,
- bfd_vma val));
+ bfd_byte *, boolean, asymbol **));
+extern bfd_vma bfd_coff_reloc16_get_value
+ PARAMS ((arelent *, struct bfd_link_info *, asection *));
+extern void bfd_perform_slip
+ PARAMS ((bfd *, unsigned int, asection *, bfd_vma));
/* Functions and types in cofflink.c. */
/* Functions in xcofflink.c. */
-extern long _bfd_xcoff_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
+extern long _bfd_xcoff_get_dynamic_symtab_upper_bound
+ PARAMS ((bfd *));
extern long _bfd_xcoff_canonicalize_dynamic_symtab
PARAMS ((bfd *, asymbol **));
-extern long _bfd_xcoff_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
+extern long _bfd_xcoff_get_dynamic_reloc_upper_bound
+ PARAMS ((bfd *));
extern long _bfd_xcoff_canonicalize_dynamic_reloc
PARAMS ((bfd *, arelent **, asymbol **));
extern struct bfd_link_hash_table *_bfd_xcoff_bfd_link_hash_table_create
/* Functions in coff-ppc.c. FIXME: These are called be pe.em in the
linker, and so should start with bfd and be declared in bfd.h. */
-extern boolean ppc_allocate_toc_section PARAMS ((struct bfd_link_info *));
+extern boolean ppc_allocate_toc_section
+ PARAMS ((struct bfd_link_info *));
extern boolean ppc_process_before_allocation
PARAMS ((bfd *, struct bfd_link_info *));
typedef struct coff_ptr_struct
{
-
- /* Remembers the offset from the first symbol in the file for
- this symbol. Generated by coff_renumber_symbols. */
-unsigned int offset;
-
- /* Should the value of this symbol be renumbered. Used for
- XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */
-unsigned int fix_value : 1;
-
- /* Should the tag field of this symbol be renumbered.
- Created by coff_pointerize_aux. */
-unsigned int fix_tag : 1;
-
- /* Should the endidx field of this symbol be renumbered.
- Created by coff_pointerize_aux. */
-unsigned int fix_end : 1;
-
- /* Should the x_csect.x_scnlen field be renumbered.
- Created by coff_pointerize_aux. */
-unsigned int fix_scnlen : 1;
-
- /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the
- index into the line number entries. Set by
- coff_slurp_symbol_table. */
-unsigned int fix_line : 1;
-
- /* The container for the symbol structure as read and translated
- from the file. */
-
-union {
- union internal_auxent auxent;
- struct internal_syment syment;
- } u;
+ /* Remembers the offset from the first symbol in the file for
+ this symbol. Generated by coff_renumber_symbols. */
+ unsigned int offset;
+
+ /* Should the value of this symbol be renumbered. Used for
+ XCOFF C_BSTAT symbols. Set by coff_slurp_symbol_table. */
+ unsigned int fix_value : 1;
+
+ /* Should the tag field of this symbol be renumbered.
+ Created by coff_pointerize_aux. */
+ unsigned int fix_tag : 1;
+
+ /* Should the endidx field of this symbol be renumbered.
+ Created by coff_pointerize_aux. */
+ unsigned int fix_end : 1;
+
+ /* Should the x_csect.x_scnlen field be renumbered.
+ Created by coff_pointerize_aux. */
+ unsigned int fix_scnlen : 1;
+
+ /* Fix up an XCOFF C_BINCL/C_EINCL symbol. The value is the
+ index into the line number entries. Set by coff_slurp_symbol_table. */
+ unsigned int fix_line : 1;
+
+ /* The container for the symbol structure as read and translated
+ from the file. */
+ union
+ {
+ union internal_auxent auxent;
+ struct internal_syment syment;
+ } u;
} combined_entry_type;
typedef struct coff_symbol_struct
{
- /* The actual symbol which the rest of BFD works with */
-asymbol symbol;
+ /* The actual symbol which the rest of BFD works with */
+ asymbol symbol;
- /* A pointer to the hidden information for this symbol */
-combined_entry_type *native;
+ /* A pointer to the hidden information for this symbol */
+ combined_entry_type *native;
- /* A pointer to the linenumber information for this symbol */
-struct lineno_cache_entry *lineno;
+ /* A pointer to the linenumber information for this symbol */
+ struct lineno_cache_entry *lineno;
- /* Have the line numbers been relocated yet ? */
-boolean done_lineno;
+ /* Have the line numbers been relocated yet ? */
+ boolean done_lineno;
} coff_symbol_type;
/* COFF symbol classifications. */
typedef struct
{
- void (*_bfd_coff_swap_aux_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- int type,
- int class,
- int indaux,
- int numaux,
- PTR in));
-
- void (*_bfd_coff_swap_sym_in) PARAMS ((
- bfd *abfd ,
- PTR ext,
- PTR in));
-
- void (*_bfd_coff_swap_lineno_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
-
- unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
- bfd *abfd,
- PTR in,
- int type,
- int class,
- int indaux,
- int numaux,
- PTR ext));
-
- unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR ext));
-
- unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR ext));
-
- unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
- bfd *abfd,
- PTR src,
- PTR dst));
-
- unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR out));
-
- unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR out));
-
- unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
- bfd *abfd,
- PTR in,
- PTR out));
-
- unsigned int _bfd_filhsz;
- unsigned int _bfd_aoutsz;
- unsigned int _bfd_scnhsz;
- unsigned int _bfd_symesz;
- unsigned int _bfd_auxesz;
- unsigned int _bfd_relsz;
- unsigned int _bfd_linesz;
- unsigned int _bfd_filnmlen;
- boolean _bfd_coff_long_filenames;
- boolean _bfd_coff_long_section_names;
- unsigned int _bfd_coff_default_section_alignment_power;
- boolean _bfd_coff_force_symnames_in_strings;
- unsigned int _bfd_coff_debug_string_prefix_length;
- void (*_bfd_coff_swap_filehdr_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
- void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
- void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
- void (*_bfd_coff_swap_reloc_in) PARAMS ((
- bfd *abfd,
- PTR ext,
- PTR in));
- boolean (*_bfd_coff_bad_format_hook) PARAMS ((
- bfd *abfd,
- PTR internal_filehdr));
- boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
- bfd *abfd,
- PTR internal_filehdr));
- PTR (*_bfd_coff_mkobject_hook) PARAMS ((
- bfd *abfd,
- PTR internal_filehdr,
- PTR internal_aouthdr));
- boolean (*_bfd_styp_to_sec_flags_hook) PARAMS ((
- bfd *abfd,
- PTR internal_scnhdr,
- const char *name,
- asection *section,
- flagword *flags_ptr));
- void (*_bfd_set_alignment_hook) PARAMS ((
- bfd *abfd,
- asection *sec,
- PTR internal_scnhdr));
- boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
- bfd *abfd));
- boolean (*_bfd_coff_symname_in_debug) PARAMS ((
- bfd *abfd,
- struct internal_syment *sym));
- boolean (*_bfd_coff_pointerize_aux_hook) PARAMS ((
- bfd *abfd,
- combined_entry_type *table_base,
- combined_entry_type *symbol,
- unsigned int indaux,
- combined_entry_type *aux));
- boolean (*_bfd_coff_print_aux) PARAMS ((
- bfd *abfd,
- FILE *file,
- combined_entry_type *table_base,
- combined_entry_type *symbol,
- combined_entry_type *aux,
- unsigned int indaux));
- void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
- bfd *abfd,
- struct bfd_link_info *link_info,
- struct bfd_link_order *link_order,
- arelent *reloc,
- bfd_byte *data,
- unsigned int *src_ptr,
- unsigned int *dst_ptr));
- int (*_bfd_coff_reloc16_estimate) PARAMS ((
- bfd *abfd,
- asection *input_section,
- arelent *r,
- unsigned int shrink,
- struct bfd_link_info *link_info));
- enum coff_symbol_classification (*_bfd_coff_classify_symbol) PARAMS ((
- bfd *abfd,
- struct internal_syment *));
- boolean (*_bfd_coff_compute_section_file_positions) PARAMS ((
- bfd *abfd));
- boolean (*_bfd_coff_start_final_link) PARAMS ((
- bfd *output_bfd,
- struct bfd_link_info *info));
- boolean (*_bfd_coff_relocate_section) PARAMS ((
- bfd *output_bfd,
- struct bfd_link_info *info,
- bfd *input_bfd,
- asection *input_section,
- bfd_byte *contents,
- struct internal_reloc *relocs,
- struct internal_syment *syms,
- asection **sections));
- reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS ((
- bfd *abfd,
- asection *sec,
- struct internal_reloc *rel,
- struct coff_link_hash_entry *h,
- struct internal_syment *sym,
- bfd_vma *addendp));
- boolean (*_bfd_coff_adjust_symndx) PARAMS ((
- bfd *obfd,
- struct bfd_link_info *info,
- bfd *ibfd,
- asection *sec,
- struct internal_reloc *reloc,
- boolean *adjustedp));
- boolean (*_bfd_coff_link_add_one_symbol) PARAMS ((
- struct bfd_link_info *info,
- bfd *abfd,
- const char *name,
- flagword flags,
- asection *section,
- bfd_vma value,
- const char *string,
- boolean copy,
- boolean collect,
- struct bfd_link_hash_entry **hashp));
-
- boolean (*_bfd_coff_link_output_has_begun) PARAMS ((
- bfd * abfd,
- struct coff_final_link_info * pfinfo));
- boolean (*_bfd_coff_final_link_postscript) PARAMS ((
- bfd * abfd,
- struct coff_final_link_info * pfinfo));
+ void (*_bfd_coff_swap_aux_in)
+ PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+
+ void (*_bfd_coff_swap_sym_in)
+ PARAMS ((bfd *, PTR, PTR));
+
+ void (*_bfd_coff_swap_lineno_in)
+ PARAMS ((bfd *, PTR, PTR));
+
+ unsigned int (*_bfd_coff_swap_aux_out)
+ PARAMS ((bfd *, PTR, int, int, int, int, PTR));
+
+ unsigned int (*_bfd_coff_swap_sym_out)
+ PARAMS ((bfd *, PTR, PTR));
+
+ unsigned int (*_bfd_coff_swap_lineno_out)
+ PARAMS ((bfd *, PTR, PTR));
+
+ unsigned int (*_bfd_coff_swap_reloc_out)
+ PARAMS ((bfd *, PTR, PTR));
+
+ unsigned int (*_bfd_coff_swap_filehdr_out)
+ PARAMS ((bfd *, PTR, PTR));
+
+ unsigned int (*_bfd_coff_swap_aouthdr_out)
+ PARAMS ((bfd *, PTR, PTR));
+
+ unsigned int (*_bfd_coff_swap_scnhdr_out)
+ PARAMS ((bfd *, PTR, PTR));
+
+ unsigned int _bfd_filhsz;
+ unsigned int _bfd_aoutsz;
+ unsigned int _bfd_scnhsz;
+ unsigned int _bfd_symesz;
+ unsigned int _bfd_auxesz;
+ unsigned int _bfd_relsz;
+ unsigned int _bfd_linesz;
+ unsigned int _bfd_filnmlen;
+ boolean _bfd_coff_long_filenames;
+ boolean _bfd_coff_long_section_names;
+ unsigned int _bfd_coff_default_section_alignment_power;
+ boolean _bfd_coff_force_symnames_in_strings;
+ unsigned int _bfd_coff_debug_string_prefix_length;
+
+ void (*_bfd_coff_swap_filehdr_in)
+ PARAMS ((bfd *, PTR, PTR));
+
+ void (*_bfd_coff_swap_aouthdr_in)
+ PARAMS ((bfd *, PTR, PTR));
+
+ void (*_bfd_coff_swap_scnhdr_in)
+ PARAMS ((bfd *, PTR, PTR));
+
+ void (*_bfd_coff_swap_reloc_in)
+ PARAMS ((bfd *abfd, PTR, PTR));
+
+ boolean (*_bfd_coff_bad_format_hook)
+ PARAMS ((bfd *, PTR));
+
+ boolean (*_bfd_coff_set_arch_mach_hook)
+ PARAMS ((bfd *, PTR));
+
+ PTR (*_bfd_coff_mkobject_hook)
+ PARAMS ((bfd *, PTR, PTR));
+
+ boolean (*_bfd_styp_to_sec_flags_hook)
+ PARAMS ((bfd *, PTR, const char *, asection *, flagword *));
+
+ void (*_bfd_set_alignment_hook)
+ PARAMS ((bfd *, asection *, PTR));
+
+ boolean (*_bfd_coff_slurp_symbol_table)
+ PARAMS ((bfd *));
+
+ boolean (*_bfd_coff_symname_in_debug)
+ PARAMS ((bfd *, struct internal_syment *));
+
+ boolean (*_bfd_coff_pointerize_aux_hook)
+ PARAMS ((bfd *, combined_entry_type *, combined_entry_type *,
+ unsigned int, combined_entry_type *));
+
+ boolean (*_bfd_coff_print_aux)
+ PARAMS ((bfd *, FILE *, combined_entry_type *, combined_entry_type *,
+ combined_entry_type *, unsigned int));
+
+ void (*_bfd_coff_reloc16_extra_cases)
+ PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *, arelent *,
+ bfd_byte *, unsigned int *, unsigned int *));
+
+ int (*_bfd_coff_reloc16_estimate)
+ PARAMS ((bfd *, asection *, arelent *, unsigned int,
+ struct bfd_link_info *));
+
+ enum coff_symbol_classification (*_bfd_coff_classify_symbol)
+ PARAMS ((bfd *, struct internal_syment *));
+
+ boolean (*_bfd_coff_compute_section_file_positions)
+ PARAMS ((bfd *));
+
+ boolean (*_bfd_coff_start_final_link)
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+ boolean (*_bfd_coff_relocate_section)
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+ struct internal_reloc *, struct internal_syment *, asection **));
+
+ reloc_howto_type *(*_bfd_coff_rtype_to_howto)
+ PARAMS ((bfd *, asection *, struct internal_reloc *,
+ struct coff_link_hash_entry *, struct internal_syment *,
+ bfd_vma *));
+
+ boolean (*_bfd_coff_adjust_symndx)\
+ PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
+ struct internal_reloc *, boolean *));
+
+ boolean (*_bfd_coff_link_add_one_symbol)
+ PARAMS ((struct bfd_link_info *, bfd *, const char *, flagword,
+ asection *, bfd_vma, const char *, boolean, boolean,
+ struct bfd_link_hash_entry **));
+
+ boolean (*_bfd_coff_link_output_has_begun)
+ PARAMS ((bfd *, struct coff_final_link_info *));
+
+ boolean (*_bfd_coff_final_link_postscript)
+ PARAMS ((bfd *, struct coff_final_link_info *));
} bfd_coff_backend_data;
-#define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
+#define coff_backend_info(abfd) \
+ ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
#define bfd_coff_swap_aux_in(a,e,t,c,ind,num,i) \
- ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
+ ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,ind,num,i))
#define bfd_coff_swap_sym_in(a,e,i) \
- ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
+ ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
#define bfd_coff_swap_lineno_in(a,e,i) \
- ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
+ ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
#define bfd_coff_swap_reloc_out(abfd, i, o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
+ ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
#define bfd_coff_swap_lineno_out(abfd, i, o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
+ ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
#define bfd_coff_swap_aux_out(a,i,t,c,ind,num,o) \
- ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
+ ((coff_backend_info (a)->_bfd_coff_swap_aux_out) (a,i,t,c,ind,num,o))
#define bfd_coff_swap_sym_out(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
+ ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
#define bfd_coff_swap_scnhdr_out(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
+ ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
#define bfd_coff_swap_filehdr_out(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
+ ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
#define bfd_coff_swap_aouthdr_out(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
+ ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
#define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
#define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
#define bfd_coff_relsz(abfd) (coff_backend_info (abfd)->_bfd_relsz)
#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
#define bfd_coff_filnmlen(abfd) (coff_backend_info (abfd)->_bfd_filnmlen)
-#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
+#define bfd_coff_long_filenames(abfd) \
+ (coff_backend_info (abfd)->_bfd_coff_long_filenames)
#define bfd_coff_long_section_names(abfd) \
- (coff_backend_info (abfd)->_bfd_coff_long_section_names)
+ (coff_backend_info (abfd)->_bfd_coff_long_section_names)
#define bfd_coff_default_section_alignment_power(abfd) \
- (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
+ (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power)
#define bfd_coff_swap_filehdr_in(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
+ ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
#define bfd_coff_swap_aouthdr_in(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
+ ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
+ ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
#define bfd_coff_swap_reloc_in(abfd, i, o) \
- ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
+ ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
#define bfd_coff_bad_format_hook(abfd, filehdr) \
- ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
+ ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
- ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
+ ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
- ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
+ ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name, section, flags_ptr)\
- ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
- (abfd, scnhdr, name, section, flags_ptr))
+ ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook)\
+ (abfd, scnhdr, name, section, flags_ptr))
#define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
- ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
+ ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
#define bfd_coff_slurp_symbol_table(abfd)\
- ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
+ ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
#define bfd_coff_symname_in_debug(abfd, sym)\
- ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
+ ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
#define bfd_coff_force_symnames_in_strings(abfd)\
- (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings)
+ (coff_backend_info (abfd)->_bfd_coff_force_symnames_in_strings)
#define bfd_coff_debug_string_prefix_length(abfd)\
- (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length)
+ (coff_backend_info (abfd)->_bfd_coff_debug_string_prefix_length)
#define bfd_coff_print_aux(abfd, file, base, symbol, aux, indaux)\
- ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
- (abfd, file, base, symbol, aux, indaux))
+ ((coff_backend_info (abfd)->_bfd_coff_print_aux)\
+ (abfd, file, base, symbol, aux, indaux))
#define bfd_coff_reloc16_extra_cases(abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr)\
- ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
- (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
+ ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
+ (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
- ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
- (abfd, section, reloc, shrink, link_info))
+ ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
+ (abfd, section, reloc, shrink, link_info))
#define bfd_coff_classify_symbol(abfd, sym)\
- ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
- (abfd, sym))
+ ((coff_backend_info (abfd)->_bfd_coff_classify_symbol)\
+ (abfd, sym))
#define bfd_coff_compute_section_file_positions(abfd)\
- ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
- (abfd))
+ ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
+ (abfd))
#define bfd_coff_start_final_link(obfd, info)\
- ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
- (obfd, info))
+ ((coff_backend_info (obfd)->_bfd_coff_start_final_link)\
+ (obfd, info))
#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
- ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
- (obfd, info, ibfd, o, con, rel, isyms, secs))
+ ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
+ (obfd, info, ibfd, o, con, rel, isyms, secs))
#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
- ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
- (abfd, sec, rel, h, sym, addendp))
+ ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
+ (abfd, sec, rel, h, sym, addendp))
#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
- ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
- (obfd, info, ibfd, sec, rel, adjustedp))
+ ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
+ (obfd, info, ibfd, sec, rel, adjustedp))
#define bfd_coff_link_add_one_symbol(info,abfd,name,flags,section,value,string,cp,coll,hashp)\
- ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
- (info, abfd, name, flags, section, value, string, cp, coll, hashp))
+ ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\
+ (info, abfd, name, flags, section, value, string, cp, coll, hashp))
#define bfd_coff_link_output_has_begun(a,p) \
- ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a,p))
+ ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a,p))
#define bfd_coff_final_link_postscript(a,p) \
- ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a,p))
+ ((coff_backend_info (a)->_bfd_coff_final_link_postscript) (a,p))
/* BFD ECOFF object file private structure.
- Copyright 1993, 1994, 1995, 1996, 1999 Free Software Foundation, Inc.
+ Copyright 1993, 1994, 1995, 1996, 1999, 2001
+ Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
/* ecoff_bfd_reloc_type_lookup defined by backend. */
extern boolean _bfd_ecoff_set_arch_mach
- PARAMS ((bfd *, enum bfd_architecture, unsigned long machine));
+ PARAMS ((bfd *, enum bfd_architecture, unsigned long));
extern boolean _bfd_ecoff_set_section_contents
PARAMS ((bfd *, asection *, PTR location, file_ptr, bfd_size_type));
struct ct *next;
} bfd_chain_type;
-typedef struct ieee_symbol
+typedef struct ieee_symbol
{
asymbol symbol;
struct ieee_symbol *next;
} ieee_per_section_type;
#define ieee_per_section(x) ((ieee_per_section_type *)((x)->used_by_bfd))
-
+
typedef struct {
unsigned char *input_p;
unsigned char *first_byte;
{
common_header_type h;
boolean read_symbols;
- boolean read_data;
+ boolean read_data;
file_ptr output_cursor;
/* Map of section indexes to section ptrs */
asection **section_table;
ieee_address_descriptor_type ad;
ieee_module_begin_type mb;
ieee_w_variable_type w;
-
+
unsigned int section_count;
-
+
unsigned int map_idx;
/* List of GLOBAL EXPORT symbols */
ieee_symbol_type *external_symbols;
/* List of UNDEFINED symbols */
ieee_symbol_type *external_reference;
-
+
/* When the symbols have been canonicalized, they are in a
* special order, we remember various bases here.. */
unsigned int external_symbol_max_index;
unsigned int external_symbol_min_index;
unsigned int external_symbol_count;
int external_symbol_base_offset;
-
+
unsigned int external_reference_max_index;
unsigned int external_reference_min_index;
unsigned int external_reference_count;
int external_reference_base_offset;
-
+
boolean symbol_table_full;
-
+
boolean done_debug;
bfd *abfd;
} ieee_ar_obstack_type;
-typedef struct ieee_ar_data_struct
+typedef struct ieee_ar_data_struct
{
common_header_type h;
ieee_ar_obstack_type *elements;
-
+
unsigned int element_index ;
unsigned int element_count;
/* BFD back-end data structures for NLM (NetWare Loadable Modules) files.
- Copyright 1993, 1994 Free Software Foundation, Inc.
+ Copyright 1993, 1994, 2001 Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
/* Architecture. */
enum bfd_architecture arch;
/* Machine. */
- long mach;
+ unsigned int mach;
/* Some NLM formats do not use the uninitialized data section, so
all uninitialized data must be put into the regular data section
instead. */
/* Some NLM formats have a prefix on the file. If this function is
not NULL, it will be called by nlm_object_p. It should return
true if this file could match this format, and it should leave
- the BFD such that a bfd_read will pick up the fixed header. */
+ the BFD such that a bfd_bread will pick up the fixed header. */
boolean (*nlm_backend_object_p) PARAMS ((bfd *));
/* Write out the prefix. This function may be NULL. This must
write out the same number of bytes as is in the field
#ifndef GET_FCN_LNNOPTR
#define GET_FCN_LNNOPTR(abfd, ext) \
- bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
+ H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
#endif
#ifndef GET_FCN_ENDNDX
-#define GET_FCN_ENDNDX(abfd, ext) \
- bfd_h_get_32(abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
+#define GET_FCN_ENDNDX(abfd, ext) \
+ H_GET_32 (abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx)
#endif
#ifndef PUT_FCN_LNNOPTR
-#define PUT_FCN_LNNOPTR(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
+#define PUT_FCN_LNNOPTR(abfd, in, ext) \
+ H_PUT_32(abfd, in, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr)
#endif
#ifndef PUT_FCN_ENDNDX
-#define PUT_FCN_ENDNDX(abfd, in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_sym.x_fcnary.x_fcn.x_endndx)
+#define PUT_FCN_ENDNDX(abfd, in, ext) \
+ H_PUT_32(abfd, in, ext->x_sym.x_fcnary.x_fcn.x_endndx)
#endif
#ifndef GET_LNSZ_LNNO
-#define GET_LNSZ_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_lnno)
+#define GET_LNSZ_LNNO(abfd, ext) \
+ H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_lnno)
#endif
#ifndef GET_LNSZ_SIZE
-#define GET_LNSZ_SIZE(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) ext->x_sym.x_misc.x_lnsz.x_size)
+#define GET_LNSZ_SIZE(abfd, ext) \
+ H_GET_16 (abfd, ext->x_sym.x_misc.x_lnsz.x_size)
#endif
#ifndef PUT_LNSZ_LNNO
-#define PUT_LNSZ_LNNO(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_sym.x_misc.x_lnsz.x_lnno)
+#define PUT_LNSZ_LNNO(abfd, in, ext) \
+ H_PUT_16(abfd, in, ext->x_sym.x_misc.x_lnsz.x_lnno)
#endif
#ifndef PUT_LNSZ_SIZE
-#define PUT_LNSZ_SIZE(abfd, in, ext) bfd_h_put_16(abfd, in, (bfd_byte*) ext->x_sym.x_misc.x_lnsz.x_size)
+#define PUT_LNSZ_SIZE(abfd, in, ext) \
+ H_PUT_16(abfd, in, ext->x_sym.x_misc.x_lnsz.x_size)
#endif
#ifndef GET_SCN_SCNLEN
-#define GET_SCN_SCNLEN(abfd, ext) bfd_h_get_32(abfd, (bfd_byte *) ext->x_scn.x_scnlen)
+#define GET_SCN_SCNLEN(abfd, ext) \
+ H_GET_32 (abfd, ext->x_scn.x_scnlen)
#endif
#ifndef GET_SCN_NRELOC
-#define GET_SCN_NRELOC(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nreloc)
+#define GET_SCN_NRELOC(abfd, ext) \
+ H_GET_16 (abfd, ext->x_scn.x_nreloc)
#endif
#ifndef GET_SCN_NLINNO
-#define GET_SCN_NLINNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *)ext->x_scn.x_nlinno)
+#define GET_SCN_NLINNO(abfd, ext) \
+ H_GET_16 (abfd, ext->x_scn.x_nlinno)
#endif
#ifndef PUT_SCN_SCNLEN
-#define PUT_SCN_SCNLEN(abfd,in, ext) bfd_h_put_32(abfd, in, (bfd_byte *) ext->x_scn.x_scnlen)
+#define PUT_SCN_SCNLEN(abfd, in, ext) \
+ H_PUT_32(abfd, in, ext->x_scn.x_scnlen)
#endif
#ifndef PUT_SCN_NRELOC
-#define PUT_SCN_NRELOC(abfd,in, ext) bfd_h_put_16(abfd, in, (bfd_byte *)ext->x_scn.x_nreloc)
+#define PUT_SCN_NRELOC(abfd, in, ext) \
+ H_PUT_16(abfd, in, ext->x_scn.x_nreloc)
#endif
#ifndef PUT_SCN_NLINNO
-#define PUT_SCN_NLINNO(abfd,in, ext) bfd_h_put_16(abfd,in, (bfd_byte *) ext->x_scn.x_nlinno)
+#define PUT_SCN_NLINNO(abfd, in, ext) \
+ H_PUT_16(abfd,in, ext->x_scn.x_nlinno)
#endif
#ifndef GET_LINENO_LNNO
-#define GET_LINENO_LNNO(abfd, ext) bfd_h_get_16(abfd, (bfd_byte *) (ext->l_lnno));
+#define GET_LINENO_LNNO(abfd, ext) \
+ H_GET_16 (abfd, ext->l_lnno);
#endif
#ifndef PUT_LINENO_LNNO
-#define PUT_LINENO_LNNO(abfd,val, ext) bfd_h_put_16(abfd,val, (bfd_byte *) (ext->l_lnno));
+#define PUT_LINENO_LNNO(abfd, val, ext) \
+ H_PUT_16(abfd,val, ext->l_lnno);
#endif
/* The f_symptr field in the filehdr is sometimes 64 bits. */
#ifndef GET_FILEHDR_SYMPTR
-#define GET_FILEHDR_SYMPTR bfd_h_get_32
+#define GET_FILEHDR_SYMPTR H_GET_32
#endif
#ifndef PUT_FILEHDR_SYMPTR
-#define PUT_FILEHDR_SYMPTR bfd_h_put_32
+#define PUT_FILEHDR_SYMPTR H_PUT_32
#endif
/* Some fields in the aouthdr are sometimes 64 bits. */
#ifndef GET_AOUTHDR_TSIZE
-#define GET_AOUTHDR_TSIZE bfd_h_get_32
+#define GET_AOUTHDR_TSIZE H_GET_32
#endif
#ifndef PUT_AOUTHDR_TSIZE
-#define PUT_AOUTHDR_TSIZE bfd_h_put_32
+#define PUT_AOUTHDR_TSIZE H_PUT_32
#endif
#ifndef GET_AOUTHDR_DSIZE
-#define GET_AOUTHDR_DSIZE bfd_h_get_32
+#define GET_AOUTHDR_DSIZE H_GET_32
#endif
#ifndef PUT_AOUTHDR_DSIZE
-#define PUT_AOUTHDR_DSIZE bfd_h_put_32
+#define PUT_AOUTHDR_DSIZE H_PUT_32
#endif
#ifndef GET_AOUTHDR_BSIZE
-#define GET_AOUTHDR_BSIZE bfd_h_get_32
+#define GET_AOUTHDR_BSIZE H_GET_32
#endif
#ifndef PUT_AOUTHDR_BSIZE
-#define PUT_AOUTHDR_BSIZE bfd_h_put_32
+#define PUT_AOUTHDR_BSIZE H_PUT_32
#endif
#ifndef GET_AOUTHDR_ENTRY
-#define GET_AOUTHDR_ENTRY bfd_h_get_32
+#define GET_AOUTHDR_ENTRY H_GET_32
#endif
#ifndef PUT_AOUTHDR_ENTRY
-#define PUT_AOUTHDR_ENTRY bfd_h_put_32
+#define PUT_AOUTHDR_ENTRY H_PUT_32
#endif
#ifndef GET_AOUTHDR_TEXT_START
-#define GET_AOUTHDR_TEXT_START bfd_h_get_32
+#define GET_AOUTHDR_TEXT_START H_GET_32
#endif
#ifndef PUT_AOUTHDR_TEXT_START
-#define PUT_AOUTHDR_TEXT_START bfd_h_put_32
+#define PUT_AOUTHDR_TEXT_START H_PUT_32
#endif
#ifndef GET_AOUTHDR_DATA_START
-#define GET_AOUTHDR_DATA_START bfd_h_get_32
+#define GET_AOUTHDR_DATA_START H_GET_32
#endif
#ifndef PUT_AOUTHDR_DATA_START
-#define PUT_AOUTHDR_DATA_START bfd_h_put_32
+#define PUT_AOUTHDR_DATA_START H_PUT_32
#endif
/* Some fields in the scnhdr are sometimes 64 bits. */
#ifndef GET_SCNHDR_PADDR
-#define GET_SCNHDR_PADDR bfd_h_get_32
+#define GET_SCNHDR_PADDR H_GET_32
#endif
#ifndef PUT_SCNHDR_PADDR
-#define PUT_SCNHDR_PADDR bfd_h_put_32
+#define PUT_SCNHDR_PADDR H_PUT_32
#endif
#ifndef GET_SCNHDR_VADDR
-#define GET_SCNHDR_VADDR bfd_h_get_32
+#define GET_SCNHDR_VADDR H_GET_32
#endif
#ifndef PUT_SCNHDR_VADDR
-#define PUT_SCNHDR_VADDR bfd_h_put_32
+#define PUT_SCNHDR_VADDR H_PUT_32
#endif
#ifndef GET_SCNHDR_SIZE
-#define GET_SCNHDR_SIZE bfd_h_get_32
+#define GET_SCNHDR_SIZE H_GET_32
#endif
#ifndef PUT_SCNHDR_SIZE
-#define PUT_SCNHDR_SIZE bfd_h_put_32
+#define PUT_SCNHDR_SIZE H_PUT_32
#endif
#ifndef GET_SCNHDR_SCNPTR
-#define GET_SCNHDR_SCNPTR bfd_h_get_32
+#define GET_SCNHDR_SCNPTR H_GET_32
#endif
#ifndef PUT_SCNHDR_SCNPTR
-#define PUT_SCNHDR_SCNPTR bfd_h_put_32
+#define PUT_SCNHDR_SCNPTR H_PUT_32
#endif
#ifndef GET_SCNHDR_RELPTR
-#define GET_SCNHDR_RELPTR bfd_h_get_32
+#define GET_SCNHDR_RELPTR H_GET_32
#endif
#ifndef PUT_SCNHDR_RELPTR
-#define PUT_SCNHDR_RELPTR bfd_h_put_32
+#define PUT_SCNHDR_RELPTR H_PUT_32
#endif
#ifndef GET_SCNHDR_LNNOPTR
-#define GET_SCNHDR_LNNOPTR bfd_h_get_32
+#define GET_SCNHDR_LNNOPTR H_GET_32
#endif
#ifndef PUT_SCNHDR_LNNOPTR
-#define PUT_SCNHDR_LNNOPTR bfd_h_put_32
+#define PUT_SCNHDR_LNNOPTR H_PUT_32
#endif
#ifdef COFF_WITH_pep
-#define GET_OPTHDR_IMAGE_BASE bfd_h_get_64
-#define PUT_OPTHDR_IMAGE_BASE bfd_h_put_64
-#define GET_OPTHDR_SIZE_OF_STACK_RESERVE bfd_h_get_64
-#define PUT_OPTHDR_SIZE_OF_STACK_RESERVE bfd_h_put_64
-#define GET_OPTHDR_SIZE_OF_STACK_COMMIT bfd_h_get_64
-#define PUT_OPTHDR_SIZE_OF_STACK_COMMIT bfd_h_put_64
-#define GET_OPTHDR_SIZE_OF_HEAP_RESERVE bfd_h_get_64
-#define PUT_OPTHDR_SIZE_OF_HEAP_RESERVE bfd_h_put_64
-#define GET_OPTHDR_SIZE_OF_HEAP_COMMIT bfd_h_get_64
-#define PUT_OPTHDR_SIZE_OF_HEAP_COMMIT bfd_h_put_64
+#define GET_OPTHDR_IMAGE_BASE H_GET_64
+#define PUT_OPTHDR_IMAGE_BASE H_PUT_64
+#define GET_OPTHDR_SIZE_OF_STACK_RESERVE H_GET_64
+#define PUT_OPTHDR_SIZE_OF_STACK_RESERVE H_PUT_64
+#define GET_OPTHDR_SIZE_OF_STACK_COMMIT H_GET_64
+#define PUT_OPTHDR_SIZE_OF_STACK_COMMIT H_PUT_64
+#define GET_OPTHDR_SIZE_OF_HEAP_RESERVE H_GET_64
+#define PUT_OPTHDR_SIZE_OF_HEAP_RESERVE H_PUT_64
+#define GET_OPTHDR_SIZE_OF_HEAP_COMMIT H_GET_64
+#define PUT_OPTHDR_SIZE_OF_HEAP_COMMIT H_PUT_64
#define GET_PDATA_ENTRY bfd_get_64
#define _bfd_XX_bfd_copy_private_bfd_data_common _bfd_pep_bfd_copy_private_bfd_data_common
#else /* !COFF_WITH_pep */
-#define GET_OPTHDR_IMAGE_BASE bfd_h_get_32
-#define PUT_OPTHDR_IMAGE_BASE bfd_h_put_32
-#define GET_OPTHDR_SIZE_OF_STACK_RESERVE bfd_h_get_32
-#define PUT_OPTHDR_SIZE_OF_STACK_RESERVE bfd_h_put_32
-#define GET_OPTHDR_SIZE_OF_STACK_COMMIT bfd_h_get_32
-#define PUT_OPTHDR_SIZE_OF_STACK_COMMIT bfd_h_put_32
-#define GET_OPTHDR_SIZE_OF_HEAP_RESERVE bfd_h_get_32
-#define PUT_OPTHDR_SIZE_OF_HEAP_RESERVE bfd_h_put_32
-#define GET_OPTHDR_SIZE_OF_HEAP_COMMIT bfd_h_get_32
-#define PUT_OPTHDR_SIZE_OF_HEAP_COMMIT bfd_h_put_32
+#define GET_OPTHDR_IMAGE_BASE H_GET_32
+#define PUT_OPTHDR_IMAGE_BASE H_PUT_32
+#define GET_OPTHDR_SIZE_OF_STACK_RESERVE H_GET_32
+#define PUT_OPTHDR_SIZE_OF_STACK_RESERVE H_PUT_32
+#define GET_OPTHDR_SIZE_OF_STACK_COMMIT H_GET_32
+#define PUT_OPTHDR_SIZE_OF_STACK_COMMIT H_PUT_32
+#define GET_OPTHDR_SIZE_OF_HEAP_RESERVE H_GET_32
+#define PUT_OPTHDR_SIZE_OF_HEAP_RESERVE H_PUT_32
+#define GET_OPTHDR_SIZE_OF_HEAP_COMMIT H_GET_32
+#define PUT_OPTHDR_SIZE_OF_HEAP_COMMIT H_PUT_32
#define GET_PDATA_ENTRY bfd_get_32
#define _bfd_XX_bfd_copy_private_bfd_data_common _bfd_pe_bfd_copy_private_bfd_data_common
struct xcoff_backend_data_rec
{
- /*
- * COFF backend information. Must be the first field.
+ /*
+ * COFF backend information. Must be the first field.
* This is where the std coff swap table goes
*/
bfd_coff_backend_data coff;
/* Magic number */
- unsigned short _xcoff_magic_number;
+ unsigned short _xcoff_magic_number;
/* Architecture and machine for coff_set_arch_mach_hook */
enum bfd_architecture _xcoff_architecture;
void (* _xcoff_swap_ldrel_out)(bfd *, const struct internal_ldrel *, PTR);
/* size of the the external struct */
- unsigned int _xcoff_ldhdrsz;
+ unsigned int _xcoff_ldhdrsz;
unsigned int _xcoff_ldsymsz;
unsigned int _xcoff_ldrelsz;
/* size of the small aout file header */
unsigned int _xcoff_small_aout_header_size;
- /*
- * version
- * loader version
+ /*
+ * version
+ * loader version
* 1 : xcoff32
* 2 : xcoff64
*/
struct internal_syment *,
const char *);
- boolean (* _xcoff_put_ldsymbol_name)(bfd *, struct xcoff_loader_info *,
+ boolean (* _xcoff_put_ldsymbol_name)(bfd *, struct xcoff_loader_info *,
struct internal_ldsym *,
const char *);
asection * (* _xcoff_create_csect_from_smclas) (bfd *, union internal_auxent *, const char *);
- /*
- * line_no and reloc overflow
+ /*
+ * line_no and reloc overflow
* 32 overflows to another section when the line_no or reloc count go
- * over 0xffff. 64 does not overflow.
+ * over 0xffff. 64 does not overflow.
*/
boolean (*_xcoff_is_lineno_count_overflow)(bfd *, bfd_vma);
boolean (*_xcoff_is_reloc_count_overflow)(bfd *, bfd_vma);
- /*
+ /*
* .loader symbol table offset
* 32 is after the .loader header
* 64 is offset in .loader header
- *
+ *
* Similar for the reloc table
*/
bfd_vma (*_xcoff_loader_symbol_offset)(bfd *, struct internal_ldhdr *);
bfd_vma (*_xcoff_loader_reloc_offset)(bfd *, struct internal_ldhdr *);
- /*
- * Global linkage
- *
+ /*
+ * Global linkage
+ *
* The first word of global linkage code must be be modified by
- * filling in the correct TOC offset.
+ * filling in the correct TOC offset.
*/
unsigned long *_xcoff_glink_code;
- /*
+ /*
* Size of the global link code in bytes of the xcoff_glink_code table
*/
unsigned long _xcoff_glink_size;
PARAMS ((bfd *, struct bfd_link_info *));
extern boolean _bfd_xcoff_bfd_final_link
PARAMS ((bfd *, struct bfd_link_info *));
-extern boolean _bfd_xcoff_slurp_symbol_table
+extern boolean _bfd_xcoff_slurp_symbol_table
PARAMS ((bfd *));
-extern long _bfd_xcoff_get_symbol_table
+extern long _bfd_xcoff_get_symbol_table
PARAMS ((bfd *, asymbol **));
-extern asymbol *_bfd_xcoff_make_empty_symbol
+extern asymbol *_bfd_xcoff_make_empty_symbol
PARAMS ((bfd *));
-extern long _bfd_xcoff_get_symbol_table_upper_bound
+extern long _bfd_xcoff_get_symbol_table_upper_bound
PARAMS ((bfd *));
-extern void _bfd_xcoff_print_symbol
+extern void _bfd_xcoff_print_symbol
PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
-extern void _bfd_xcoff_get_symbol_info
+extern void _bfd_xcoff_get_symbol_info
PARAMS ((bfd *, asymbol *, symbol_info *));
-extern long _bfd_xcoff_canonicalize_reloc
+extern long _bfd_xcoff_canonicalize_reloc
PARAMS((bfd *, sec_ptr, arelent **, asymbol **));
extern reloc_howto_type *_bfd_xcoff_rtype_to_howto
PARAMS ((bfd *, asection *, struct internal_reloc *,
PARAMS ((bfd *, struct bfd_link_info *, const char *, const char *,
unsigned long, unsigned long, unsigned long, boolean,
int, boolean, boolean, struct sec **));
-extern boolean xcoff_slurp_reloc_table
+extern boolean xcoff_slurp_reloc_table
PARAMS ((bfd *, asection *, asymbol **));
#endif /* LIBXCOFF_H */
boolean copy;
boolean follow;
{
+ bfd_size_type amt;
+
if (info->wrap_hash != NULL)
{
const char *l;
/* This symbol is being wrapped. We want to replace all
references to SYM with references to __wrap_SYM. */
- n = (char *) bfd_malloc (strlen (l) + sizeof WRAP + 1);
+ amt = strlen (l) + sizeof WRAP + 1;
+ n = (char *) bfd_malloc (amt);
if (n == NULL)
return NULL;
wrapped. We want to replace all references to __real_SYM
with references to SYM. */
- n = (char *) bfd_malloc (strlen (l + sizeof REAL - 1) + 2);
+ amt = strlen (l + sizeof REAL - 1) + 2;
+ n = (char *) bfd_malloc (amt);
if (n == NULL)
return NULL;
bfd *abfd;
{
struct generic_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct generic_link_hash_table);
- ret = ((struct generic_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct generic_link_hash_table)));
+ ret = (struct generic_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == NULL)
return (struct bfd_link_hash_table *) NULL;
if (! _bfd_link_hash_table_init (&ret->root, abfd,
symsize = bfd_get_symtab_upper_bound (abfd);
if (symsize < 0)
return false;
- bfd_get_outsymbols (abfd) = (asymbol **) bfd_alloc (abfd, symsize);
+ bfd_get_outsymbols (abfd) =
+ (asymbol **) bfd_alloc (abfd, (bfd_size_type) symsize);
if (bfd_get_outsymbols (abfd) == NULL && symsize != 0)
return false;
symcount = bfd_canonicalize_symtab (abfd, bfd_get_outsymbols (abfd));
struct bfd_link_info *info;
boolean collect;
{
+ bfd_size_type symcount;
+ struct symbol_cache_entry **outsyms;
+
if (! generic_link_read_symbols (abfd))
return false;
- return generic_link_add_symbol_list (abfd, info,
- _bfd_generic_link_get_symcount (abfd),
- _bfd_generic_link_get_symbols (abfd),
- collect);
+ symcount = _bfd_generic_link_get_symcount (abfd);
+ outsyms = _bfd_generic_link_get_symbols (abfd);
+ return generic_link_add_symbol_list (abfd, info, symcount, outsyms, collect);
}
\f
/* We build a hash table of all symbols defined in an archive. */
struct archive_list
{
struct archive_list *next;
- int indx;
+ unsigned int indx;
};
/* An entry in an archive hash table. */
register carsym *arsym;
int pass;
struct archive_hash_table arsym_hash;
- int indx;
+ unsigned int indx;
struct bfd_link_hash_entry **pundef;
if (! bfd_has_map (abfd))
arh = archive_hash_lookup (&arsym_hash, h->root.string, false, false);
if (arh == (struct archive_hash_entry *) NULL)
{
- /* If we haven't found the exact symbol we're looking for,
+ /* If we haven't found the exact symbol we're looking for,
let's look for its import thunk */
if (info->pei386_auto_import)
{
- char *buf = (char *) bfd_malloc (strlen (h->root.string) + 10);
+ bfd_size_type amt = strlen (h->root.string) + 10;
+ char *buf = (char *) bfd_malloc (amt);
if (buf == NULL)
return false;
&& inh->u.i.link == h)
{
(*_bfd_error_handler)
- (_("%s: indirect symbol `%s' to `%s' is a loop"),
+ (_("%s: indirect symbol `%s' to `%s' is a loop"),
bfd_get_filename (abfd), name, string);
bfd_set_error (bfd_error_invalid_operation);
return false;
input_section);
if (relsize < 0)
return false;
- relocs = (arelent **) bfd_malloc ((size_t) relsize);
+ relocs = (arelent **) bfd_malloc ((bfd_size_type) relsize);
if (!relocs && relsize != 0)
return false;
symbols = _bfd_generic_link_get_symbols (input_bfd);
}
if (o->reloc_count > 0)
{
- o->orelocation = ((arelent **)
- bfd_alloc (abfd,
- (o->reloc_count
- * sizeof (arelent *))));
+ bfd_size_type amt;
+
+ amt = o->reloc_count;
+ amt *= sizeof (arelent *);
+ o->orelocation = (arelent **) bfd_alloc (abfd, amt);
if (!o->orelocation)
return false;
o->flags |= SEC_RELOC;
if (bfd_get_symcount (output_bfd) >= *psymalloc)
{
asymbol **newsyms;
+ bfd_size_type amt;
if (*psymalloc == 0)
*psymalloc = 124;
else
*psymalloc *= 2;
- newsyms = (asymbol **) bfd_realloc (bfd_get_outsymbols (output_bfd),
- *psymalloc * sizeof (asymbol *));
+ amt = *psymalloc;
+ amt *= sizeof (asymbol *);
+ newsyms = (asymbol **) bfd_realloc (bfd_get_outsymbols (output_bfd), amt);
if (newsyms == (asymbol **) NULL)
return false;
bfd_get_outsymbols (output_bfd) = newsyms;
if (sec->orelocation == (arelent **) NULL)
abort ();
- r = (arelent *) bfd_alloc (abfd, sizeof (arelent));
+ r = (arelent *) bfd_alloc (abfd, (bfd_size_type) sizeof (arelent));
if (r == (arelent *) NULL)
return false;
bfd_reloc_status_type rstat;
bfd_byte *buf;
boolean ok;
+ file_ptr loc;
size = bfd_get_reloc_size (r->howto);
buf = (bfd_byte *) bfd_zmalloc (size);
if (buf == (bfd_byte *) NULL)
return false;
rstat = _bfd_relocate_contents (r->howto, abfd,
- link_order->u.reloc.p->addend, buf);
+ (bfd_vma) link_order->u.reloc.p->addend,
+ buf);
switch (rstat)
{
case bfd_reloc_ok:
}
break;
}
- ok = bfd_set_section_contents (abfd, sec, (PTR) buf,
- (file_ptr)
- (link_order->offset *
- bfd_octets_per_byte (abfd)), size);
+ loc = link_order->offset * bfd_octets_per_byte (abfd);
+ ok = bfd_set_section_contents (abfd, sec, (PTR) buf, loc,
+ (bfd_size_type) size);
free (buf);
if (! ok)
return false;
bfd *abfd;
asection *section;
{
- struct bfd_link_order *new;
-
- new = ((struct bfd_link_order *)
- bfd_alloc (abfd, sizeof (struct bfd_link_order)));
+ bfd_size_type amt = sizeof (struct bfd_link_order);
+ struct bfd_link_order *new = (struct bfd_link_order *) bfd_alloc (abfd, amt);
if (!new)
return NULL;
asection *sec;
struct bfd_link_order *link_order;
{
+ file_ptr loc;
+
switch (link_order->type)
{
case bfd_undefined_link_order:
case bfd_fill_link_order:
return default_fill_link_order (abfd, info, sec, link_order);
case bfd_data_link_order:
+ loc = link_order->offset * bfd_octets_per_byte (abfd);
return bfd_set_section_contents (abfd, sec,
(PTR) link_order->u.data.contents,
- (file_ptr)
- (link_order->offset *
- bfd_octets_per_byte (abfd)),
- link_order->size);
+ loc, link_order->size);
}
}
asection *sec;
struct bfd_link_order *link_order;
{
- size_t size;
+ bfd_size_type size;
unsigned char *space;
size_t i;
unsigned int fill;
BFD_ASSERT ((sec->flags & SEC_HAS_CONTENTS) != 0);
- size = (size_t) link_order->size;
+ size = link_order->size;
if (size == 0)
return true;
for (i = 3; i < size; i += 4)
space[i] = fill;
- loc = (file_ptr) (link_order->offset * bfd_octets_per_byte (abfd));
- result = bfd_set_section_contents (abfd, sec, space, loc, link_order->size);
+ loc = link_order->offset * bfd_octets_per_byte (abfd);
+ result = bfd_set_section_contents (abfd, sec, space, loc, size);
free (space);
return result;
bfd *input_bfd;
bfd_byte *contents = NULL;
bfd_byte *new_contents;
+ bfd_size_type sec_size;
+ file_ptr loc;
BFD_ASSERT ((output_section->flags & SEC_HAS_CONTENTS) != 0);
}
/* Get and relocate the section contents. */
- contents = ((bfd_byte *)
- bfd_malloc (bfd_section_size (input_bfd, input_section)));
- if (contents == NULL && bfd_section_size (input_bfd, input_section) != 0)
+ sec_size = bfd_section_size (input_bfd, input_section);
+ contents = ((bfd_byte *) bfd_malloc (sec_size));
+ if (contents == NULL && sec_size != 0)
goto error_return;
new_contents = (bfd_get_relocated_section_contents
(output_bfd, info, link_order, contents, info->relocateable,
goto error_return;
/* Output the section contents. */
+ loc = link_order->offset * bfd_octets_per_byte (output_bfd);
if (! bfd_set_section_contents (output_bfd, output_section,
- (PTR) new_contents,
- (file_ptr)
- (link_order->offset *
- bfd_octets_per_byte (output_bfd)),
- link_order->size))
+ (PTR) new_contents, loc, link_order->size))
goto error_return;
if (contents != NULL)
static asection *
make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
bfd *abfd;
- CONST char *name;
+ const char *name;
flagword flags;
bfd_size_type _raw_size;
bfd_vma vma;
asection *asect;
char *newname;
- newname = bfd_alloc (abfd, strlen (name) + 1);
+ newname = bfd_alloc (abfd, (bfd_size_type) strlen (name) + 1);
if (!newname)
return NULL;
lynx_core_file_p (abfd)
bfd *abfd;
{
- int val;
int secnum;
struct pssentry pss;
- size_t tcontext_size;
+ bfd_size_type tcontext_size;
core_st_t *threadp;
int pagesize;
asection *newsect;
+ bfd_size_type amt;
pagesize = getpagesize (); /* Serious cross-target issue here... This
really needs to come from a system-specific
/* Get the pss entry from the core file */
- if (bfd_seek (abfd, 0, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return NULL;
- val = bfd_read ((void *)&pss, 1, sizeof pss, abfd);
- if (val != sizeof pss)
+ amt = sizeof pss;
+ if (bfd_bread ((void *) &pss, amt, abfd) != amt)
{
/* Too small to be a core file */
if (bfd_get_error () != bfd_error_system_call)
return NULL;
}
- core_hdr (abfd) = (struct lynx_core_struct *)
- bfd_zalloc (abfd, sizeof (struct lynx_core_struct));
+ amt = sizeof (struct lynx_core_struct);
+ core_hdr (abfd) = (struct lynx_core_struct *) bfd_zalloc (abfd, amt);
if (!core_hdr (abfd))
return NULL;
/* Allocate space for the thread contexts */
- threadp = (core_st_t *)bfd_alloc (abfd, tcontext_size);
+ threadp = (core_st_t *) bfd_alloc (abfd, tcontext_size);
if (!threadp)
return NULL;
/* Save thread contexts */
- if (bfd_seek (abfd, pagesize, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) pagesize, SEEK_SET) != 0)
return NULL;
- val = bfd_read ((void *)threadp, pss.threadcnt, sizeof (core_st_t), abfd);
-
- if (val != tcontext_size)
+ if (bfd_bread ((void *) threadp, tcontext_size, abfd) != tcontext_size)
{
/* Probably too small to be a core file */
if (bfd_get_error () != bfd_error_system_call)
/* BFD back-end for linux flavored m68k a.out binaries.
- Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000
+ Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
bfd *abfd;
{
struct linux_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct linux_link_hash_table);
- ret = ((struct linux_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
+ ret = (struct linux_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct linux_link_hash_table *) NULL)
{
bfd_set_error (bfd_error_no_memory);
if (! (_bfd_generic_link_add_one_symbol
(info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
- BSF_GLOBAL | BSF_CONSTRUCTOR, s, 0, NULL, false, false, NULL)))
+ BSF_GLOBAL | BSF_CONSTRUCTOR, s, (bfd_vma) 0, NULL,
+ false, false, NULL)))
return false;
}
name = h->root.root.root.string + sizeof NEEDS_SHRLIB - 1;
p = strrchr (name, '_');
if (p != NULL)
- alloc = (char *) bfd_malloc (strlen (name) + 1);
+ alloc = (char *) bfd_malloc ((bfd_size_type) strlen (name) + 1);
if (p == NULL || alloc == NULL)
(*_bfd_error_handler) (_("Output file requires shared library `%s'\n"),
".linux-dynamic");
if (s != NULL)
{
- s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
+ s->_raw_size = linux_hash_table (info)->fixup_count + 1;
+ s->_raw_size *= 8;
s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
if (s->contents == NULL)
{
#endif
fixup_table = s->contents;
- bfd_put_32 (output_bfd, linux_hash_table (info)->fixup_count, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) linux_hash_table (info)->fixup_count,
+ fixup_table);
fixup_table += 4;
/* Fill in fixup table. */
if (f->jump)
{
- bfd_put_32 (output_bfd, new_addr, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
fixup_table += 4;
bfd_put_32 (output_bfd, f->value + 2, fixup_table);
fixup_table += 4;
}
else
{
- bfd_put_32 (output_bfd, new_addr, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
fixup_table += 4;
bfd_put_32 (output_bfd, f->value, fixup_table);
fixup_table += 4;
if (linux_hash_table (info)->local_builtins != 0)
{
/* Special marker so we know to switch to the other type of fixup */
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
fixup_table += 4;
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
fixup_table += 4;
++fixups_written;
for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
new_addr, f->value);
#endif
- bfd_put_32 (output_bfd, new_addr, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
fixup_table += 4;
bfd_put_32 (output_bfd, f->value, fixup_table);
fixup_table += 4;
(*_bfd_error_handler) (_("Warning: fixup count mismatch\n"));
while (linux_hash_table (info)->fixup_count > fixups_written)
{
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
fixup_table += 4;
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
fixup_table += 4;
++fixups_written;
}
printf ("Builtin fixup table at %x\n", new_addr);
#endif
- bfd_put_32 (output_bfd, new_addr, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
}
else
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
- if (bfd_seek (output_bfd, os->filepos + s->output_offset, SEEK_SET) != 0)
+ if (bfd_seek (output_bfd, (file_ptr) (os->filepos + s->output_offset),
+ SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) s->contents, 1, s->_raw_size, output_bfd)
- != s->_raw_size)
+ if (bfd_bwrite ((PTR) s->contents, s->_raw_size, output_bfd) != s->_raw_size)
return false;
return true;
}
hash ^= hash >> 2;
len += table->entsize;
- }
+ }
else
{
for (i = 0; i < table->entsize; ++i)
boolean strings;
{
struct sec_merge_hash *table;
+ bfd_size_type amt = sizeof (struct sec_merge_hash);
- table = ((struct sec_merge_hash *)
- bfd_malloc (sizeof (struct sec_merge_hash)));
+ table = (struct sec_merge_hash *) bfd_malloc (amt);
if (table == NULL)
return NULL;
int alignment_power = bfd_get_section_alignment (abfd, sec->output_section);
if (alignment_power)
- pad = bfd_zmalloc (1 << alignment_power);
+ pad = bfd_zmalloc ((bfd_size_type) 1 << alignment_power);
for (; entry != NULL && entry->secinfo == secinfo; entry = entry->next)
{
if (len)
{
len = entry->alignment - len;
- if (bfd_write ((PTR) pad, 1, len, abfd) != len)
+ if (bfd_bwrite ((PTR) pad, (bfd_size_type) len, abfd) != len)
break;
off += len;
}
str = entry->root.string;
len = entry->len;
- if (bfd_write ((PTR) str, 1, len, abfd) != len)
+ if (bfd_bwrite ((PTR) str, (bfd_size_type) len, abfd) != len)
break;
off += len;
struct sec_merge_info *sinfo;
struct sec_merge_sec_info *secinfo;
unsigned int align;
+ bfd_size_type amt;
if (sec->_raw_size == 0
|| (sec->flags & SEC_EXCLUDE)
{
/* Initialize the information we need to keep track of. */
sinfo = (struct sec_merge_info *)
- bfd_alloc (abfd, sizeof (struct sec_merge_info));
+ bfd_alloc (abfd, (bfd_size_type) sizeof (struct sec_merge_info));
if (sinfo == NULL)
goto error_return;
sinfo->next = (struct sec_merge_info *) *psinfo;
/* Read the section from abfd. */
- *psecinfo = bfd_alloc (abfd, sizeof (struct sec_merge_sec_info)
- + sec->_raw_size - 1);
+ amt = sizeof (struct sec_merge_sec_info) + sec->_raw_size - 1;
+ *psecinfo = bfd_alloc (abfd, amt);
if (*psecinfo == NULL)
goto error_return;
secinfo->htab = sinfo->htab;
secinfo->first = NULL;
- if (! bfd_get_section_contents (sec->owner, sec, secinfo->contents, 0,
- sec->_raw_size))
+ if (! bfd_get_section_contents (sec->owner, sec, secinfo->contents,
+ (bfd_vma) 0, sec->_raw_size))
goto error_return;
return true;
{
struct sec_merge_hash_entry * A = *(struct sec_merge_hash_entry **) a;
struct sec_merge_hash_entry * B = *(struct sec_merge_hash_entry **) b;
-
+
if (A->len < B->len)
return 1;
else if (A->len > B->len)
align = bfd_get_section_alignment (sec->owner, sec);
end = secinfo->contents + sec->_raw_size;
nul = false;
- mask = ((bfd_vma)1 << align) - 1;
+ mask = ((bfd_vma) 1 << align) - 1;
if (sec->flags & SEC_STRINGS)
{
- for (p = secinfo->contents; p < end;)
+ for (p = secinfo->contents; p < end; )
{
eltalign = p - secinfo->contents;
eltalign = ((eltalign ^ (eltalign - 1)) + 1) >> 1;
if (!eltalign || eltalign > mask)
eltalign = mask + 1;
- entry = sec_merge_add (sinfo->htab, p, eltalign, secinfo);
+ entry = sec_merge_add (sinfo->htab, p, (unsigned) eltalign, secinfo);
if (! entry)
goto error_return;
p += entry->len;
if (!nul && !((p - secinfo->contents) & mask))
{
nul = true;
- entry = sec_merge_add (sinfo->htab, "", mask + 1,
- secinfo);
+ entry = sec_merge_add (sinfo->htab, "",
+ (unsigned) mask + 1, secinfo);
if (! entry)
goto error_return;
}
if (!nul && !((p - secinfo->contents) & mask))
{
nul = true;
- entry = sec_merge_add (sinfo->htab, p, mask + 1,
- secinfo);
+ entry = sec_merge_add (sinfo->htab, p,
+ (unsigned) mask + 1, secinfo);
if (! entry)
goto error_return;
}
struct sec_merge_hash_entry **array, **a, **end, *e;
struct sec_merge_sec_info *secinfo;
htab_t lasttab = NULL, last4tab = NULL;
- bfd_size_type size;
+ bfd_size_type size, amt;
/* Now sort the strings by length, longest first. */
- array = (struct sec_merge_hash_entry **)
- malloc (sinfo->htab->size
- * sizeof (struct sec_merge_hash_entry *));
+ array = NULL;
+ amt = sinfo->htab->size * sizeof (struct sec_merge_hash_entry *);
+ array = (struct sec_merge_hash_entry **) bfd_malloc (amt);
if (array == NULL)
goto alloc_failure;
sinfo->htab->size = a - array;
- qsort (array, sinfo->htab->size, sizeof (struct sec_merge_hash_entry *),
- cmplengthentry);
+ qsort (array, (size_t) sinfo->htab->size,
+ sizeof (struct sec_merge_hash_entry *), cmplengthentry);
- last4tab = htab_create (sinfo->htab->size * 4, NULL, last4_eq, NULL);
- lasttab = htab_create (sinfo->htab->size * 4, NULL, last_eq, NULL);
+ last4tab = htab_create ((size_t) sinfo->htab->size * 4, NULL, last4_eq, NULL);
+ lasttab = htab_create ((size_t) sinfo->htab->size * 4, NULL, last_eq, NULL);
if (lasttab == NULL || last4tab == NULL)
goto alloc_failure;
PTR psecinfo;
{
struct sec_merge_sec_info *secinfo;
+ file_ptr pos;
secinfo = (struct sec_merge_sec_info *) psecinfo;
if (!secinfo->first)
return true;
- if (bfd_seek (output_bfd,
- (sec->output_section->filepos + sec->output_offset),
- SEEK_SET) != 0)
+ pos = sec->output_section->filepos + sec->output_offset;
+ if (bfd_seek (output_bfd, pos, SEEK_SET) != 0)
return false;
if (! sec_merge_emit (output_bfd, secinfo->first))
#define SET_ARCH_MACH(ABFD, EXEC) \
MY(set_arch_mach) (ABFD, N_MACHTYPE (EXEC)); \
MY(choose_reloc_size) (ABFD);
-static void MY(set_arch_mach) PARAMS ((bfd *abfd, int machtype));
+static void MY(set_arch_mach) PARAMS ((bfd *abfd, unsigned long machtype));
static void MY(choose_reloc_size) PARAMS ((bfd *abfd));
#define MY_write_object_contents MY(write_object_contents)
#include "aout-target.h"
-static bfd_reloc_status_type mips_fix_jmp_addr PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR, asection *, bfd *));
-static reloc_howto_type * MY(reloc_howto_type_lookup) PARAMS ((bfd *, bfd_reloc_code_real_type));
+static bfd_reloc_status_type mips_fix_jmp_addr
+ PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR, asection *,
+ bfd *, char **));
+static reloc_howto_type *MY(reloc_howto_type_lookup)
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
long MY(canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
static void
MY(set_arch_mach) (abfd, machtype)
bfd *abfd;
- int machtype;
+ unsigned long machtype;
{
enum bfd_architecture arch;
- long machine;
+ unsigned int machine;
/* Determine the architecture and machine type of the object file. */
switch (machtype)
program counter, then we need to signal an error. */
static bfd_reloc_status_type
-mips_fix_jmp_addr (abfd,reloc_entry,symbol,data,input_section,output_bfd)
+mips_fix_jmp_addr (abfd, reloc_entry, symbol, data, input_section, output_bfd,
+ error_message)
bfd *abfd ATTRIBUTE_UNUSED;
arelent *reloc_entry;
struct symbol_cache_entry *symbol;
PTR data ATTRIBUTE_UNUSED;
asection *input_section;
bfd *output_bfd;
+ char **error_message ATTRIBUTE_UNUSED;
{
bfd_vma relocation, pc;
return section->reloc_count;
}
-static CONST struct aout_backend_data MY(backend_data) = {
+static const struct aout_backend_data MY(backend_data) = {
0, /* zmagic contiguous */
1, /* text incl header */
0, /* entry is text address */
/* BFD back end for NetBSD style core files
- Copyright 1988, 1989, 1991, 1992, 1993, 1996, 1998, 1999, 2000
+ Copyright 1988, 1989, 1991, 1992, 1993, 1996, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
Written by Paul Kranenburg, EUR
/* forward declarations */
-static const bfd_target * netbsd_core_file_p PARAMS ((bfd *abfd));
-static char * netbsd_core_file_failing_command PARAMS ((bfd *abfd));
-static int netbsd_core_file_failing_signal PARAMS ((bfd *abfd));
-static boolean netbsd_core_file_matches_executable_p
- PARAMS ((bfd *core_bfd, bfd *exec_bfd));
-static void swap_abort PARAMS ((void));
+static const bfd_target *netbsd_core_file_p PARAMS ((bfd *abfd));
+static char *netbsd_core_file_failing_command PARAMS ((bfd *abfd));
+static int netbsd_core_file_failing_signal PARAMS ((bfd *abfd));
+static boolean netbsd_core_file_matches_executable_p
+ PARAMS ((bfd *core_bfd, bfd *exec_bfd));
+static void swap_abort PARAMS ((void));
/* Handle NetBSD-style core dump file. */
bfd *abfd;
{
- int i, val, offset;
- asection *asect, *asect2;
- struct core core;
- struct coreseg coreseg;
-
- val = bfd_read ((void *)&core, 1, sizeof core, abfd);
- if (val != sizeof core) {
- /* Too small to be a core file */
- bfd_set_error(bfd_error_wrong_format);
- return 0;
+ int i, val;
+ file_ptr offset;
+ asection *asect, *asect2;
+ struct core core;
+ struct coreseg coreseg;
+ bfd_size_type amt = sizeof core;
+
+ val = bfd_bread ((void *) &core, amt, abfd);
+ if (val != sizeof core)
+ {
+ /* Too small to be a core file */
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ if (CORE_GETMAGIC (core) != COREMAGIC)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
+
+ amt = sizeof (struct netbsd_core_struct);
+ rawptr = (struct netbsd_core_struct *) bfd_zalloc (abfd, amt);
+ if (rawptr == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return 0;
+ }
+
+ rawptr->core = core;
+ abfd->tdata.netbsd_core_data = rawptr;
+
+ offset = core.c_hdrsize;
+ for (i = 0; i < core.c_nseg; i++)
+ {
+
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0)
+ goto punt;
+
+ val = bfd_bread ((void *) &coreseg, (bfd_size_type) sizeof coreseg, abfd);
+ if (val != sizeof coreseg)
+ {
+ bfd_set_error (bfd_error_file_truncated);
+ goto punt;
}
-
- if (CORE_GETMAGIC(core) != COREMAGIC) {
- bfd_set_error(bfd_error_wrong_format);
- return 0;
+ if (CORE_GETMAGIC (coreseg) != CORESEGMAGIC)
+ {
+ bfd_set_error (bfd_error_wrong_format);
+ goto punt;
}
- rawptr = (struct netbsd_core_struct *)
- bfd_zalloc (abfd, sizeof (struct netbsd_core_struct));
- if (rawptr == NULL) {
- bfd_set_error(bfd_error_no_memory);
- return 0;
+ offset += core.c_seghdrsize;
+
+ amt = sizeof (asection);
+ asect = (asection *) bfd_zalloc (abfd, amt);
+ if (asect == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ goto punt;
}
- rawptr->core = core;
- abfd->tdata.netbsd_core_data = rawptr;
-
- offset = core.c_hdrsize;
- for (i = 0; i < core.c_nseg; i++) {
-
- if (bfd_seek (abfd, offset, SEEK_SET) != 0)
- goto punt;
-
- val = bfd_read ((void *)&coreseg, 1, sizeof coreseg, abfd);
- if (val != sizeof coreseg) {
- bfd_set_error(bfd_error_file_truncated);
- goto punt;
- }
- if (CORE_GETMAGIC(coreseg) != CORESEGMAGIC) {
- bfd_set_error(bfd_error_wrong_format);
- goto punt;
- }
-
- offset += core.c_seghdrsize;
-
- asect = (asection *) bfd_zalloc (abfd, sizeof (asection));
- if (asect == NULL) {
- bfd_set_error(bfd_error_no_memory);
- goto punt;
- }
-
- asect->_raw_size = coreseg.c_size;
- asect->vma = coreseg.c_addr;
- asect->filepos = offset;
- asect->alignment_power = 2;
- asect->next = abfd->sections;
- abfd->sections = asect;
- abfd->section_count++;
- offset += coreseg.c_size;
-
- switch (CORE_GETFLAG(coreseg)) {
- case CORE_CPU:
- asect->name = ".reg";
- asect->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
+ asect->_raw_size = coreseg.c_size;
+ asect->vma = coreseg.c_addr;
+ asect->filepos = offset;
+ asect->alignment_power = 2;
+ asect->next = abfd->sections;
+ abfd->sections = asect;
+ abfd->section_count++;
+ offset += coreseg.c_size;
+
+ switch (CORE_GETFLAG(coreseg))
+ {
+ case CORE_CPU:
+ asect->name = ".reg";
+ asect->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
#ifdef CORE_FPU_OFFSET
- /* Hackish... */
- asect->_raw_size = CORE_FPU_OFFSET;
- asect2 = (asection *)bfd_zalloc (abfd,
- sizeof (asection));
- if (asect2 == NULL) {
- bfd_set_error(bfd_error_no_memory);
- goto punt;
- }
- asect2->_raw_size = coreseg.c_size - CORE_FPU_OFFSET;
- asect2->vma = 0;
- asect2->filepos = asect->filepos + CORE_FPU_OFFSET;
- asect2->alignment_power = 2;
- asect2->next = abfd->sections;
- asect2->name = ".reg2";
- asect2->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
- abfd->sections = asect2;
- abfd->section_count++;
+ /* Hackish... */
+ asect->_raw_size = CORE_FPU_OFFSET;
+ amt = sizeof (asection);
+ asect2 = (asection *) bfd_zalloc (abfd, amt);
+ if (asect2 == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ goto punt;
+ }
+ asect2->_raw_size = coreseg.c_size - CORE_FPU_OFFSET;
+ asect2->vma = 0;
+ asect2->filepos = asect->filepos + CORE_FPU_OFFSET;
+ asect2->alignment_power = 2;
+ asect2->next = abfd->sections;
+ asect2->name = ".reg2";
+ asect2->flags = SEC_ALLOC + SEC_HAS_CONTENTS;
+ abfd->sections = asect2;
+ abfd->section_count++;
#endif
- break;
- case CORE_DATA:
- asect->name = ".data";
- asect->flags = SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS;
- break;
- case CORE_STACK:
- asect->name = ".stack";
- asect->flags = SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS;
- break;
- }
+ break;
+ case CORE_DATA:
+ asect->name = ".data";
+ asect->flags = SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS;
+ break;
+ case CORE_STACK:
+ asect->name = ".stack";
+ asect->flags = SEC_ALLOC+SEC_LOAD+SEC_HAS_CONTENTS;
+ break;
}
+ }
- /* OK, we believe you. You're a core file (sure, sure). */
- return abfd->xvec;
+ /* OK, we believe you. You're a core file (sure, sure). */
+ return abfd->xvec;
-punt: {
- asection *anext;
- for (asect = abfd->sections; asect; asect = anext) {
- anext = asect->next;
- free((void *)asect);
- }
- }
- free ((void *)rawptr);
- abfd->tdata.netbsd_core_data = NULL;
- abfd->sections = NULL;
- abfd->section_count = 0;
- return 0;
+ punt:
+ {
+ asection *anext;
+ for (asect = abfd->sections; asect; asect = anext)
+ {
+ anext = asect->next;
+ free ((void *) asect);
+ }
+ }
+
+ free ((void *) rawptr);
+ abfd->tdata.netbsd_core_data = NULL;
+ abfd->sections = NULL;
+ abfd->section_count = 0;
+ return 0;
}
static char*
/* ARGSUSED */
static boolean
netbsd_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
+ bfd *core_bfd ATTRIBUTE_UNUSED;
+ bfd *exec_bfd ATTRIBUTE_UNUSED;
{
return true; /* FIXME, We have no way of telling at this point */
}
/* NLM (NetWare Loadable Module) executable support for BFD.
- Copyright 1993, 1994 Free Software Foundation, Inc.
+ Copyright 1993, 1994, 2001 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
nlm_mkobject (abfd)
bfd * abfd;
{
- nlm_tdata (abfd) =
- (struct nlm_obj_tdata *) bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata));
+ bfd_size_type amt = sizeof (struct nlm_obj_tdata);
+ nlm_tdata (abfd) = (struct nlm_obj_tdata *) bfd_zalloc (abfd, amt);
if (nlm_tdata (abfd) == NULL)
return (false);
bfd *abfd;
{
struct nlm32_alpha_external_prefix_header s;
- bfd_size_type size;
+ file_ptr size;
- if (bfd_read ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
+ if (bfd_bread ((PTR) &s, (bfd_size_type) sizeof s, abfd) != sizeof s)
return false;
- if (bfd_h_get_32 (abfd, s.magic) != NLM32_ALPHA_MAGIC)
+ if (H_GET_32 (abfd, s.magic) != NLM32_ALPHA_MAGIC)
return false;
/* FIXME: Should we check the format number? */
/* Skip to the end of the header. */
- size = bfd_h_get_32 (abfd, s.size);
+ size = H_GET_32 (abfd, s.size);
if (bfd_seek (abfd, size, SEEK_SET) != 0)
return false;
struct nlm32_alpha_external_prefix_header s;
memset (&s, 0, sizeof s);
- bfd_h_put_32 (abfd, (bfd_vma) NLM32_ALPHA_MAGIC, s.magic);
- bfd_h_put_32 (abfd, (bfd_vma) 2, s.format);
- bfd_h_put_32 (abfd, (bfd_vma) sizeof s, s.size);
- if (bfd_write ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
+ H_PUT_32 (abfd, NLM32_ALPHA_MAGIC, s.magic);
+ H_PUT_32 (abfd, 2, s.format);
+ H_PUT_32 (abfd, sizeof s, s.size);
+ if (bfd_bwrite ((PTR) &s, (bfd_size_type) sizeof s, abfd) != sizeof s)
return false;
return true;
}
asection *code_sec, *data_sec;
/* Read the reloc from the file. */
- if (bfd_read (&ext, sizeof ext, 1, abfd) != sizeof ext)
+ if (bfd_bread (&ext, (bfd_size_type) sizeof ext, abfd) != sizeof ext)
return false;
/* Swap in the reloc information. */
- r_vaddr = bfd_h_get_64 (abfd, (bfd_byte *) ext.r_vaddr);
- r_symndx = bfd_h_get_32 (abfd, (bfd_byte *) ext.r_symndx);
+ r_vaddr = H_GET_64 (abfd, ext.r_vaddr);
+ r_symndx = H_GET_32 (abfd, ext.r_symndx);
BFD_ASSERT (bfd_little_endian (abfd));
bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* temporary 32-bit value */
unsigned char symlength; /* length of symbol name */
char *name;
+ bfd_size_type amt;
- if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
+ if (bfd_bread ((PTR) &symlength, (bfd_size_type) sizeof (symlength), abfd)
!= sizeof (symlength))
return false;
sym -> symbol.the_bfd = abfd;
- name = bfd_alloc (abfd, symlength + 1);
+ name = bfd_alloc (abfd, (bfd_size_type) symlength + 1);
if (name == NULL)
return false;
- if (bfd_read (name, symlength, 1, abfd) != symlength)
+ if (bfd_bread (name, (bfd_size_type) symlength, abfd) != symlength)
return false;
name[symlength] = '\0';
sym -> symbol.name = name;
sym -> symbol.flags = 0;
sym -> symbol.value = 0;
sym -> symbol.section = bfd_und_section_ptr;
- if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bread ((PTR) temp, (bfd_size_type) sizeof (temp), abfd)
+ != sizeof (temp))
return false;
- rcount = bfd_h_get_32 (abfd, temp);
- nlm_relocs = ((struct nlm_relent *)
- bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
+ rcount = H_GET_32 (abfd, temp);
+ amt = rcount * sizeof (struct nlm_relent);
+ nlm_relocs = (struct nlm_relent *) bfd_alloc (abfd, amt);
if (!nlm_relocs)
return false;
sym -> relocs = nlm_relocs;
}
/* Swap out the relocation fields. */
- bfd_h_put_64 (abfd, r_vaddr, (bfd_byte *) ext.r_vaddr);
- bfd_h_put_32 (abfd, r_symndx, (bfd_byte *) ext.r_symndx);
+ H_PUT_64 (abfd, r_vaddr, ext.r_vaddr);
+ H_PUT_32 (abfd, r_symndx, ext.r_symndx);
BFD_ASSERT (bfd_little_endian (abfd));
& RELOC_BITS3_SIZE_LITTLE);
/* Write out the relocation. */
- if (bfd_write (&ext, sizeof ext, 1, abfd) != sizeof ext)
+ if (bfd_bwrite (&ext, (bfd_size_type) sizeof ext, abfd) != sizeof ext)
return false;
return true;
arelent r;
len = strlen (sym->name);
- if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof (bfd_byte))
- || bfd_write (sym->name, len, 1, abfd) != len)
+ if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
+ != sizeof (bfd_byte))
+ || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
return false;
bfd_put_32 (abfd, count + 2, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
return false;
/* The first two relocs for each external symbol are the .lita
/* Support for 32-bit i386 NLM (NetWare Loadable Module)
- Copyright 1993, 1994, 2000 Free Software Foundation, Inc.
+ Copyright 1993, 1994, 2000, 2001 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
bfd_vma val;
const char *name;
- if (bfd_read (temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bread (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
return false;
val = bfd_get_32 (abfd, temp);
}
bfd_put_32 (abfd, val, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
return false;
return true;
unsigned char symlength; /* length of symbol name */
char *name;
- if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
+ if (bfd_bread ((PTR) &symlength, (bfd_size_type) sizeof (symlength), abfd)
!= sizeof (symlength))
return false;
sym -> symbol.the_bfd = abfd;
- name = bfd_alloc (abfd, symlength + 1);
+ name = bfd_alloc (abfd, (bfd_size_type) symlength + 1);
if (name == NULL)
return false;
- if (bfd_read (name, symlength, 1, abfd) != symlength)
+ if (bfd_bread (name, (bfd_size_type) symlength, abfd) != symlength)
return false;
name[symlength] = '\0';
sym -> symbol.name = name;
sym -> symbol.flags = 0;
sym -> symbol.value = 0;
sym -> symbol.section = bfd_und_section_ptr;
- if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bread ((PTR) temp, (bfd_size_type) sizeof (temp), abfd)
+ != sizeof (temp))
return false;
- rcount = bfd_h_get_32 (abfd, temp);
+ rcount = H_GET_32 (abfd, temp);
nlm_relocs = ((struct nlm_relent *)
bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
if (!nlm_relocs)
unsigned char temp[NLM_TARGET_LONG_SIZE];
len = strlen (sym->name);
- if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof (bfd_byte))
- || bfd_write (sym->name, len, 1, abfd) != len)
+ if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
+ != sizeof (bfd_byte))
+ || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
return false;
bfd_put_32 (abfd, count, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
return false;
for (i = 0; i < count; i++)
/* Support for 32-bit PowerPC NLM (NetWare Loadable Module)
- Copyright 1994, 1995, 2000 Free Software Foundation, Inc.
+ Copyright 1994, 1995, 2000, 2001 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
{
struct nlm32_powerpc_external_prefix_header s;
- if (bfd_read ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
+ if (bfd_bread ((PTR) &s, (bfd_size_type) sizeof s, abfd) != sizeof s)
return false;
if (memcmp (s.signature, NLM32_POWERPC_SIGNATURE, sizeof s.signature) != 0
- || bfd_h_get_32 (abfd, s.headerVersion) != NLM32_POWERPC_HEADER_VERSION)
+ || H_GET_32 (abfd, s.headerVersion) != NLM32_POWERPC_HEADER_VERSION)
return false;
return true;
memset (&s, 0, sizeof s);
memcpy (s.signature, NLM32_POWERPC_SIGNATURE, sizeof s.signature);
- bfd_h_put_32 (abfd, (bfd_vma) NLM32_POWERPC_HEADER_VERSION, s.headerVersion);
- bfd_h_put_32 (abfd, (bfd_vma) 0, s.origins);
+ H_PUT_32 (abfd, NLM32_POWERPC_HEADER_VERSION, s.headerVersion);
+ H_PUT_32 (abfd, 0, s.origins);
/* FIXME: What should we do about the date? */
- if (bfd_write ((PTR) &s, sizeof s, 1, abfd) != sizeof s)
+ if (bfd_bwrite ((PTR) &s, (bfd_size_type) sizeof s, abfd) != sizeof s)
return false;
return true;
bfd_vma val;
const char *name;
- if (bfd_read (temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bread (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
return false;
val = bfd_get_32 (abfd, temp);
asection *code_sec, *data_sec, *bss_sec;
/* Read the reloc from the file. */
- if (bfd_read (&ext, sizeof ext, 1, abfd) != sizeof ext)
+ if (bfd_bread (&ext, (bfd_size_type) sizeof ext, abfd) != sizeof ext)
return false;
/* Swap in the fields. */
- l_vaddr = bfd_h_get_32 (abfd, ext.l_vaddr);
- l_symndx = bfd_h_get_32 (abfd, ext.l_symndx);
- l_rtype = bfd_h_get_16 (abfd, ext.l_rtype);
- l_rsecnm = bfd_h_get_16 (abfd, ext.l_rsecnm);
+ l_vaddr = H_GET_32 (abfd, ext.l_vaddr);
+ l_symndx = H_GET_32 (abfd, ext.l_symndx);
+ l_rtype = H_GET_16 (abfd, ext.l_rtype);
+ l_rsecnm = H_GET_16 (abfd, ext.l_rsecnm);
/* Get the sections now, for convenience. */
code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
unsigned char symlength; /* length of symbol name */
char *name;
- if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
+ if (bfd_bread ((PTR) &symlength, (bfd_size_type) sizeof (symlength), abfd)
!= sizeof (symlength))
return (false);
sym -> symbol.the_bfd = abfd;
- name = bfd_alloc (abfd, symlength + 1);
+ name = bfd_alloc (abfd, (bfd_size_type) symlength + 1);
if (name == NULL)
return false;
- if (bfd_read (name, symlength, 1, abfd) != symlength)
+ if (bfd_bread (name, (bfd_size_type) symlength, abfd) != symlength)
return (false);
name[symlength] = '\0';
sym -> symbol.name = name;
sym -> symbol.flags = 0;
sym -> symbol.value = 0;
sym -> symbol.section = bfd_und_section_ptr;
- if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bread ((PTR) temp, (bfd_size_type) sizeof (temp), abfd)
+ != sizeof (temp))
return (false);
- rcount = bfd_h_get_32 (abfd, temp);
+ rcount = H_GET_32 (abfd, temp);
nlm_relocs = ((struct nlm_relent *)
bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
if (nlm_relocs == (struct nlm_relent *) NULL)
}
bfd_put_32 (abfd, val, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
return false;
return true;
}
}
- bfd_h_put_32 (abfd, (bfd_vma) l_symndx, ext.l_symndx);
+ H_PUT_32 (abfd, l_symndx, ext.l_symndx);
for (howto = nlm_powerpc_howto_table;
howto < nlm_powerpc_howto_table + HOWTO_COUNT;
if (howto->complain_on_overflow == complain_overflow_signed)
l_rtype |= 0x8000;
l_rtype |= (howto->bitsize - 1) << 8;
- bfd_h_put_16 (abfd, (bfd_vma) l_rtype, ext.l_rtype);
+ H_PUT_16 (abfd, l_rtype, ext.l_rtype);
address = rel->address;
return false;
}
- bfd_h_put_16 (abfd, (bfd_vma) l_rsecnm, ext.l_rsecnm);
- bfd_h_put_32 (abfd, (bfd_vma) address, ext.l_vaddr);
+ H_PUT_16 (abfd, l_rsecnm, ext.l_rsecnm);
+ H_PUT_32 (abfd, address, ext.l_vaddr);
- if (bfd_write (&ext, sizeof ext, 1, abfd) != sizeof ext)
+ if (bfd_bwrite (&ext, (bfd_size_type) sizeof ext, abfd) != sizeof ext)
return false;
return true;
#endif
len = strlen (sym->name);
- if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof (bfd_byte))
- || bfd_write (sym->name, len, 1, abfd) != len)
+ if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
+ != sizeof (bfd_byte))
+ || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
return false;
bfd_put_32 (abfd, count, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
return false;
for (i = 0; i < count; i++)
};
#if 0
-static CONST char *CONST reloc_type_names[] =
+static const char *const reloc_type_names[] =
{
"R_SPARC_NONE",
"R_SPARC_8", "R_SPARC_16", "R_SPARC_32",
struct nlm32_sparc_reloc_ext tmp_reloc;
asection *code_sec, *data_sec;
- if (bfd_read (&tmp_reloc, 12, 1, abfd) != 12)
+ if (bfd_bread (&tmp_reloc, (bfd_size_type) 12, abfd) != 12)
return false;
code_sec = bfd_get_section_by_name (abfd, NLM_CODE_NAME);
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)
+ if (bfd_bwrite (&tmp_reloc, (bfd_size_type) 12, abfd) != 12)
return false;
return true;
/* First, read in the number of relocation
entries for this symbol. */
- if (bfd_read ((PTR) temp, 4, 1, abfd) != 4)
+ if (bfd_bread ((PTR) temp, (bfd_size_type) 4, abfd) != 4)
return false;
rcount = bfd_get_32 (abfd, temp);
/* Next, read in the length of the symbol. */
- if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
+ if (bfd_bread ((PTR) &symlength, (bfd_size_type) sizeof (symlength), abfd)
!= sizeof (symlength))
return false;
sym -> symbol.the_bfd = abfd;
- name = bfd_alloc (abfd, symlength + 1);
+ name = bfd_alloc (abfd, (bfd_size_type) symlength + 1);
if (name == NULL)
return false;
/* Then read in the symbol. */
- if (bfd_read (name, symlength, 1, abfd) != symlength)
+ if (bfd_bread (name, (bfd_size_type) symlength, abfd) != symlength)
return false;
name[symlength] = '\0';
sym -> symbol.name = name;
__FUNCTION__, base + (*rel->sym_ptr_ptr)->value);
#endif
bfd_put_32 (abfd, base + (*rel->sym_ptr_ptr)->value, temp);
- if (bfd_write ((PTR)temp, 4, 1, abfd) != 4)
+ if (bfd_bwrite ((PTR) temp, (bfd_size_type) 4, abfd) != 4)
return false;
- bfd_put_32 (abfd, 1, temp);
- if (bfd_write ((PTR)temp, 4, 1, abfd) != 4)
+ bfd_put_32 (abfd, (bfd_vma) 1, temp);
+ if (bfd_bwrite ((PTR) temp, (bfd_size_type) 4, abfd) != 4)
return false;
if (nlm_sparc_write_reloc (abfd, sec, rel) == false)
return false;
unsigned char temp[NLM_TARGET_LONG_SIZE];
bfd_put_32 (abfd, count, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd) != sizeof (temp))
return false;
len = strlen (sym->name);
- if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof (bfd_byte))
- || bfd_write (sym->name, len, 1, abfd) != len)
+ if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
+ != sizeof (bfd_byte))
+ || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
return false;
for (i = 0; i < count; i++)
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)
+ if (bfd_bwrite (temp, (bfd_size_type) 4, abfd) != 4
+ || bfd_bwrite (&len, (bfd_size_type) 1, abfd) != 1
+ || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
return false;
return true;
/* NLM (NetWare Loadable Module) executable support for BFD.
- Copyright 1993, 1994, 1995, 1998, 2000 Free Software Foundation, Inc.
+ Copyright 1993, 1994, 1995, 1998, 2000, 2001
+ Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support, using ELF support as the
template.
/* Should perhaps use put_offset, put_word, etc. For now, the two versions
can be handled by explicitly specifying 32 bits or "the long type". */
#if ARCH_SIZE == 64
-#define put_word bfd_h_put_64
-#define get_word bfd_h_get_64
+#define put_word H_PUT_64
+#define get_word H_GET_64
#endif
#if ARCH_SIZE == 32
-#define put_word bfd_h_put_32
-#define get_word bfd_h_get_32
+#define put_word H_PUT_32
+#define get_word H_GET_32
#endif
const bfd_target *
struct nlm_obj_tdata *new_tdata = NULL;
const char *signature;
enum bfd_architecture arch;
+ bfd_size_type amt;
/* Some NLM formats have a prefix before the standard NLM fixed
header. */
/* Read in the fixed length portion of the NLM header in external format. */
- x_fxdhdr = (PTR) bfd_malloc ((size_t) nlm_fixed_header_size (abfd));
+ amt = nlm_fixed_header_size (abfd);
+ x_fxdhdr = (PTR) bfd_malloc (amt);
if (x_fxdhdr == NULL)
goto got_no_match;
- if (bfd_read ((PTR) x_fxdhdr, nlm_fixed_header_size (abfd), 1, abfd) !=
- nlm_fixed_header_size (abfd))
+ if (bfd_bread ((PTR) x_fxdhdr, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
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. */
- new_tdata = ((struct nlm_obj_tdata *)
- bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata)));
+ amt = sizeof (struct nlm_obj_tdata);
+ new_tdata = (struct nlm_obj_tdata *) bfd_zalloc (abfd, amt);
if (new_tdata == NULL)
goto got_no_match;
newsect = bfd_make_section (abfd, name);
if (newsect == NULL)
{
- return (false);
+ return false;
}
newsect->vma = 0; /* NLM's are relocatable. */
newsect->_raw_size = size;
newsect->filepos = offset;
newsect->flags = flags;
- newsect->alignment_power = bfd_log2 (0); /* FIXME */
- return (true);
+ newsect->alignment_power = bfd_log2 ((bfd_vma) 0); /* FIXME */
+ return true;
}
/* Read and swap in the variable length header. All the fields must
bfd *abfd;
{
unsigned char temp[NLM_TARGET_LONG_SIZE];
+ bfd_size_type amt;
/* Read the description length and text members. */
- if (bfd_read ((PTR) & nlm_variable_header (abfd)->descriptionLength,
- sizeof (nlm_variable_header (abfd)->descriptionLength),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->descriptionLength))
- return (false);
- if (bfd_read ((PTR) nlm_variable_header (abfd)->descriptionText,
- nlm_variable_header (abfd)->descriptionLength + 1,
- 1, abfd) !=
- (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1)
- return (false);
+ amt = sizeof (nlm_variable_header (abfd)->descriptionLength);
+ if (bfd_bread ((PTR) &nlm_variable_header (abfd)->descriptionLength,
+ amt, abfd) != amt)
+ return false;
+ amt = nlm_variable_header (abfd)->descriptionLength + 1;
+ if (bfd_bread ((PTR) nlm_variable_header (abfd)->descriptionText,
+ amt, abfd) != amt)
+ return false;
/* Read and convert the stackSize field. */
- if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return (false);
+ amt = sizeof (temp);
+ if (bfd_bread ((PTR) temp, amt, abfd) != amt)
+ return false;
nlm_variable_header (abfd)->stackSize = get_word (abfd, (bfd_byte *) temp);
/* Read and convert the reserved field. */
- if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return (false);
+ amt = sizeof (temp);
+ if (bfd_bread ((PTR) temp, amt, abfd) != amt)
+ return false;
nlm_variable_header (abfd)->reserved = get_word (abfd, (bfd_byte *) temp);
/* Read the oldThreadName field. This field is a fixed length string. */
- if (bfd_read ((PTR) nlm_variable_header (abfd)->oldThreadName,
- sizeof (nlm_variable_header (abfd)->oldThreadName),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->oldThreadName))
- return (false);
+ amt = sizeof (nlm_variable_header (abfd)->oldThreadName);
+ if (bfd_bread ((PTR) nlm_variable_header (abfd)->oldThreadName,
+ amt, abfd) != amt)
+ return false;
/* Read the screen name length and text members. */
- if (bfd_read ((PTR) & nlm_variable_header (abfd)->screenNameLength,
- sizeof (nlm_variable_header (abfd)->screenNameLength),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->screenNameLength))
- return (false);
- if (bfd_read ((PTR) nlm_variable_header (abfd)->screenName,
- nlm_variable_header (abfd)->screenNameLength + 1,
- 1, abfd) !=
- (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1)
- return (false);
+ amt = sizeof (nlm_variable_header (abfd)->screenNameLength);
+ if (bfd_bread ((PTR) & nlm_variable_header (abfd)->screenNameLength,
+ amt, abfd) != amt)
+ return false;
+ amt = nlm_variable_header (abfd)->screenNameLength + 1;
+ if (bfd_bread ((PTR) nlm_variable_header (abfd)->screenName,
+ amt, abfd) != amt)
+ return false;
/* Read the thread name length and text members. */
- if (bfd_read ((PTR) & nlm_variable_header (abfd)->threadNameLength,
- sizeof (nlm_variable_header (abfd)->threadNameLength),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->threadNameLength))
- return (false);
- if (bfd_read ((PTR) nlm_variable_header (abfd)->threadName,
- nlm_variable_header (abfd)->threadNameLength + 1,
- 1, abfd) !=
- (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1)
- return (false);
- return (true);
+ amt = sizeof (nlm_variable_header (abfd)->threadNameLength);
+ if (bfd_bread ((PTR) & nlm_variable_header (abfd)->threadNameLength,
+ amt, abfd) != amt)
+ return false;
+ amt = nlm_variable_header (abfd)->threadNameLength + 1;
+ if (bfd_bread ((PTR) nlm_variable_header (abfd)->threadName,
+ amt, abfd) != amt)
+ return false;
+ return true;
}
/* Swap and write out the variable length header. All the fields must
bfd *abfd;
{
unsigned char temp[NLM_TARGET_LONG_SIZE];
+ bfd_size_type amt;
/* Write the description length and text members. */
- if (bfd_write ((PTR) & nlm_variable_header (abfd)->descriptionLength,
- sizeof (nlm_variable_header (abfd)->descriptionLength),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->descriptionLength))
- return (false);
- if (bfd_write ((PTR) nlm_variable_header (abfd)->descriptionText,
- nlm_variable_header (abfd)->descriptionLength + 1,
- 1, abfd) !=
- (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1)
- return (false);
+ amt = sizeof (nlm_variable_header (abfd)->descriptionLength);
+ if (bfd_bwrite ((PTR) & nlm_variable_header (abfd)->descriptionLength, amt,
+ abfd) != amt)
+ return false;
+ amt = nlm_variable_header (abfd)->descriptionLength + 1;
+ if (bfd_bwrite ((PTR) nlm_variable_header (abfd)->descriptionText, amt,
+ abfd) != amt)
+ return false;
/* Convert and write the stackSize field. */
put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->stackSize,
(bfd_byte *) temp);
- if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return (false);
+ amt = sizeof (temp);
+ if (bfd_bwrite ((PTR) temp, amt, abfd) != amt)
+ return false;
/* Convert and write the reserved field. */
put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->reserved,
(bfd_byte *) temp);
- if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return (false);
+ amt = sizeof (temp);
+ if (bfd_bwrite ((PTR) temp, amt, abfd) != amt)
+ return false;
/* Write the oldThreadName field. This field is a fixed length string. */
- if (bfd_write ((PTR) nlm_variable_header (abfd)->oldThreadName,
- sizeof (nlm_variable_header (abfd)->oldThreadName),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->oldThreadName))
- return (false);
+ amt = sizeof (nlm_variable_header (abfd)->oldThreadName);
+ if (bfd_bwrite ((PTR) nlm_variable_header (abfd)->oldThreadName, amt,
+ abfd) != amt)
+ return false;
/* Write the screen name length and text members. */
- if (bfd_write ((PTR) & nlm_variable_header (abfd)->screenNameLength,
- sizeof (nlm_variable_header (abfd)->screenNameLength),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->screenNameLength))
- return (false);
- if (bfd_write ((PTR) nlm_variable_header (abfd)->screenName,
- nlm_variable_header (abfd)->screenNameLength + 1,
- 1, abfd) !=
- (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1)
- return (false);
+ amt = sizeof (nlm_variable_header (abfd)->screenNameLength);
+ if (bfd_bwrite ((PTR) & nlm_variable_header (abfd)->screenNameLength, amt,
+ abfd) != amt)
+ return false;
+ amt = nlm_variable_header (abfd)->screenNameLength + 1;
+ if (bfd_bwrite ((PTR) nlm_variable_header (abfd)->screenName, amt,
+ abfd) != amt)
+ return false;
/* Write the thread name length and text members. */
- if (bfd_write ((PTR) & nlm_variable_header (abfd)->threadNameLength,
- sizeof (nlm_variable_header (abfd)->threadNameLength),
- 1, abfd) !=
- sizeof (nlm_variable_header (abfd)->threadNameLength))
- return (false);
- if (bfd_write ((PTR) nlm_variable_header (abfd)->threadName,
- nlm_variable_header (abfd)->threadNameLength + 1,
- 1, abfd) !=
- (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1)
- return (false);
- return (true);
+ amt = sizeof (nlm_variable_header (abfd)->threadNameLength);
+ if (bfd_bwrite ((PTR) & nlm_variable_header (abfd)->threadNameLength, amt,
+ abfd) != amt)
+ return false;
+ amt = nlm_variable_header (abfd)->threadNameLength + 1;
+ if (bfd_bwrite ((PTR) nlm_variable_header (abfd)->threadName, amt,
+ abfd) != amt)
+ return false;
+ return true;
}
/* Read and swap in the contents of all the auxiliary headers. Because of
bfd *abfd;
{
char tempstr[16];
- long position;
+ file_ptr position;
+ bfd_size_type amt;
for (;;)
{
position = bfd_tell (abfd);
- if (bfd_read ((PTR) tempstr, sizeof (tempstr), 1, abfd) !=
- sizeof (tempstr))
- return (false);
- if (bfd_seek (abfd, position, SEEK_SET) == -1)
- return (false);
+ amt = sizeof (tempstr);
+ if (bfd_bread ((PTR) tempstr, amt, abfd) != amt)
+ return false;
+ if (bfd_seek (abfd, position, SEEK_SET) != 0)
+ return false;
if (strncmp (tempstr, "VeRsIoN#", 8) == 0)
{
Nlm_External_Version_Header thdr;
- if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- return (false);
+
+ amt = sizeof (thdr);
+ if (bfd_bread ((PTR) &thdr, amt, abfd) != amt)
+ return false;
memcpy (nlm_version_header (abfd)->stamp, thdr.stamp,
sizeof (thdr.stamp));
nlm_version_header (abfd)->majorVersion =
else if (strncmp (tempstr, "MeSsAgEs", 8) == 0)
{
Nlm_External_Extended_Header thdr;
- if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- return (false);
+
+ amt = sizeof (thdr);
+ if (bfd_bread ((PTR) &thdr, amt, abfd) != amt)
+ return false;
memcpy (nlm_extended_header (abfd)->stamp, thdr.stamp,
sizeof (thdr.stamp));
nlm_extended_header (abfd)->languageID =
}
else if (strncmp (tempstr, "CoPyRiGhT=", 10) == 0)
{
- if (bfd_read ((PTR) nlm_copyright_header (abfd)->stamp,
- sizeof (nlm_copyright_header (abfd)->stamp),
- 1, abfd)
- != sizeof (nlm_copyright_header (abfd)->stamp))
- return (false);
- if (bfd_read ((PTR) & (nlm_copyright_header (abfd)
- ->copyrightMessageLength),
- 1, 1, abfd) != 1)
- return (false);
+ amt = sizeof (nlm_copyright_header (abfd)->stamp);
+ if (bfd_bread ((PTR) nlm_copyright_header (abfd)->stamp,
+ amt, abfd) != amt)
+ return false;
+ if (bfd_bread ((PTR) &(nlm_copyright_header (abfd)
+ ->copyrightMessageLength),
+ (bfd_size_type) 1, abfd) != 1)
+ return false;
/* The copyright message is a variable length string. */
- if (bfd_read ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
- nlm_copyright_header (abfd)->copyrightMessageLength + 1,
- 1, abfd) !=
- ((bfd_size_type)
- nlm_copyright_header (abfd)->copyrightMessageLength + 1))
- return (false);
+ amt = nlm_copyright_header (abfd)->copyrightMessageLength + 1;
+ if (bfd_bread ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
+ amt, abfd) != amt)
+ return false;
}
else if (strncmp (tempstr, "CuStHeAd", 8) == 0)
{
PTR hdr;
/* Read the stamp ("CuStHeAd"). */
- if (bfd_read ((PTR) thdr.stamp, 1, sizeof (thdr.stamp), abfd)
- != sizeof (thdr.stamp))
+ amt = sizeof (thdr.stamp);
+ if (bfd_bread ((PTR) thdr.stamp, amt, abfd) != amt)
return false;
/* Read the length of this custom header. */
- if (bfd_read ((PTR) thdr.length, 1, sizeof (thdr.length), abfd)
- != sizeof (thdr.length))
+ amt = sizeof (thdr.length);
+ if (bfd_bread ((PTR) thdr.length, amt, abfd) != amt)
return false;
hdrLength = get_word (abfd, (bfd_byte *) thdr.length);
/* Read further fields if we have them. */
dataOffset = 0;
else
{
- if (bfd_read ((PTR) thdr.dataOffset, 1,
- sizeof (thdr.dataOffset), abfd)
- != sizeof (thdr.dataOffset))
+ amt = sizeof (thdr.dataOffset);
+ if (bfd_bread ((PTR) thdr.dataOffset, amt, abfd) != amt)
return false;
dataOffset = get_word (abfd, (bfd_byte *) thdr.dataOffset);
}
dataLength = 0;
else
{
- if (bfd_read ((PTR) thdr.dataLength, 1,
- sizeof (thdr.dataLength), abfd)
- != sizeof (thdr.dataLength))
+ amt = sizeof (thdr.dataLength);
+ if (bfd_bread ((PTR) thdr.dataLength, amt, abfd) != amt)
return false;
dataLength = get_word (abfd, (bfd_byte *) thdr.dataLength);
}
memset (dataStamp, 0, sizeof (dataStamp));
else
{
- if (bfd_read ((PTR) dataStamp, 1, sizeof (dataStamp), abfd)
- != sizeof (dataStamp))
+ amt = sizeof (dataStamp);
+ if (bfd_bread ((PTR) dataStamp, amt, abfd) != amt)
return false;
}
hdr = bfd_alloc (abfd, hdrLength);
if (hdr == NULL)
return false;
- if (bfd_read (hdr, 1, hdrLength, abfd) != hdrLength)
+ if (bfd_bread (hdr, hdrLength, abfd) != hdrLength)
return false;
}
contents = (bfd_byte *) bfd_alloc (abfd, dataLength);
if (contents == NULL)
return false;
- if (bfd_read (contents, 1, dataLength, abfd) != dataLength)
+ if (bfd_bread (contents, dataLength, abfd) != dataLength)
return false;
if (bfd_seek (abfd, pos, SEEK_SET) != 0)
return false;
name = (char *) p;
l = strlen (name) + 1;
- l = (l + 3) &~ 3;
+ l = (l + 3) &~ (size_t) 3;
p += l;
- filepos = bfd_h_get_32 (abfd, p);
+ filepos = H_GET_32 (abfd, p);
p += 4;
- size = bfd_h_get_32 (abfd, p);
+ size = H_GET_32 (abfd, p);
p += 4;
newsec = bfd_make_section_anyway (abfd, name);
break;
}
}
- return (true);
+ return true;
}
/* Return whether there is a non-zero byte in a memory block. */
nlm_swap_auxiliary_headers_out (abfd)
bfd *abfd;
{
+ bfd_size_type amt;
+
/* Write out the version header if there is one. */
if (find_nonzero ((PTR) nlm_version_header (abfd),
sizeof (Nlm_Internal_Version_Header)))
(bfd_byte *) thdr.month);
put_word (abfd, (bfd_vma) nlm_version_header (abfd)->day,
(bfd_byte *) thdr.day);
- if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ if (bfd_bwrite ((PTR) &thdr, (bfd_size_type) sizeof (thdr), abfd)
+ != sizeof (thdr))
return false;
}
put_word (abfd,
(bfd_vma) nlm_extended_header (abfd)->reserved5,
(bfd_byte *) thdr.reserved5);
- if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ if (bfd_bwrite ((PTR) &thdr, (bfd_size_type) sizeof (thdr), abfd)
+ != sizeof (thdr))
return false;
}
Nlm_External_Copyright_Header thdr;
memcpy (thdr.stamp, "CoPyRiGhT=", 10);
- if (bfd_write ((PTR) thdr.stamp, sizeof (thdr.stamp), 1, abfd)
- != sizeof (thdr.stamp))
+ amt = sizeof (thdr.stamp);
+ if (bfd_bwrite ((PTR) thdr.stamp, amt, abfd) != amt)
return false;
thdr.copyrightMessageLength[0] =
nlm_copyright_header (abfd)->copyrightMessageLength;
- if (bfd_write ((PTR) thdr.copyrightMessageLength, 1, 1, abfd) != 1)
+ amt = 1;
+ if (bfd_bwrite ((PTR) thdr.copyrightMessageLength, amt, abfd) != amt)
return false;
/* The copyright message is a variable length string. */
- if (bfd_write ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
- nlm_copyright_header (abfd)->copyrightMessageLength + 1,
- 1, abfd) !=
- ((bfd_size_type)
- nlm_copyright_header (abfd)->copyrightMessageLength + 1))
+ amt = nlm_copyright_header (abfd)->copyrightMessageLength + 1;
+ if (bfd_bwrite ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
+ amt, abfd) != amt)
return false;
}
if (! ds)
{
BFD_ASSERT (nlm_custom_header (abfd)->hdrLength == 0);
- if (bfd_write ((PTR) &thdr, 1,
- sizeof (thdr) - sizeof (thdr.dataStamp), abfd)
- != sizeof (thdr) - sizeof (thdr.dataStamp))
+ amt = sizeof (thdr) - sizeof (thdr.dataStamp);
+ if (bfd_bwrite ((PTR) &thdr, amt, abfd) != amt)
return false;
}
else
{
memcpy (thdr.dataStamp, nlm_custom_header (abfd)->dataStamp,
sizeof (thdr.dataStamp));
- if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ amt = sizeof (thdr);
+ if (bfd_bwrite ((PTR) &thdr, amt, abfd) != amt)
return false;
- if (bfd_write (nlm_custom_header (abfd)->hdr, 1,
- nlm_custom_header (abfd)->hdrLength, abfd)
- != nlm_custom_header (abfd)->hdrLength)
+ amt = nlm_custom_header (abfd)->hdrLength;
+ if (bfd_bwrite (nlm_custom_header (abfd)->hdr, amt, abfd) != amt)
return false;
}
}
put_word (abfd, (bfd_vma) nlm_cygnus_ext_header (abfd)->length,
(bfd_byte *) thdr.dataLength);
memcpy (thdr.dataStamp, "CyGnUsEx", 8);
- if (bfd_write ((PTR) &thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
+ amt = sizeof (thdr);
+ if (bfd_bwrite ((PTR) &thdr, amt, abfd) != amt)
return false;
}
nlm_make_empty_symbol (abfd)
bfd *abfd;
{
- nlm_symbol_type *new;
+ bfd_size_type amt = sizeof (nlm_symbol_type);
+ nlm_symbol_type *new = (nlm_symbol_type *) bfd_zalloc (abfd, amt);
- new = (nlm_symbol_type *) bfd_zalloc (abfd, sizeof (nlm_symbol_type));
if (new)
new->symbol.the_bfd = abfd;
return &new->symbol;
bfd_byte temp[NLM_TARGET_LONG_SIZE]; /* Symbol offsets read into here */
boolean (*read_import_func) PARAMS ((bfd *, nlm_symbol_type *));
boolean (*set_public_section_func) PARAMS ((bfd *, nlm_symbol_type *));
+ bfd_size_type amt;
if (nlm_get_symbols (abfd) != NULL)
- return (true);
+ return true;
/* Read each raw NLM symbol, using the information to create a canonical bfd
symbol table entry.
+ i_fxdhdrp->numberOfExternalReferences);
if (totsymcount == 0)
{
- return (true);
+ return true;
}
- if (bfd_seek (abfd, i_fxdhdrp->publicsOffset, SEEK_SET) == -1)
- return (false);
+ if (bfd_seek (abfd, i_fxdhdrp->publicsOffset, SEEK_SET) != 0)
+ return false;
- sym = ((nlm_symbol_type *)
- bfd_zalloc (abfd, totsymcount * sizeof (nlm_symbol_type)));
+ amt = totsymcount * sizeof (nlm_symbol_type);
+ sym = ((nlm_symbol_type *) bfd_zalloc (abfd, amt));
if (!sym)
return false;
nlm_set_symbols (abfd, sym);
symcount = i_fxdhdrp->numberOfPublics;
while (abfd->symcount < symcount)
{
- if (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd)
- != sizeof (symlength))
- return (false);
+ amt = sizeof (symlength);
+ if (bfd_bread ((PTR) &symlength, amt, abfd) != amt)
+ return false;
+ amt = symlength;
sym->symbol.the_bfd = abfd;
- sym->symbol.name = bfd_alloc (abfd, symlength + 1);
+ sym->symbol.name = bfd_alloc (abfd, amt + 1);
if (!sym->symbol.name)
return false;
- if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
- != symlength)
- return (false);
+ if (bfd_bread ((PTR) sym->symbol.name, amt, abfd) != amt)
+ return false;
/* Cast away const. */
((char *) (sym->symbol.name))[symlength] = '\0';
- if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- return (false);
+ amt = sizeof (temp);
+ if (bfd_bread ((PTR) temp, amt, abfd) != amt)
+ return false;
sym->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
sym->symbol.value = get_word (abfd, temp);
if (set_public_section_func)
if (i_fxdhdrp->numberOfDebugRecords > 0)
{
- if (bfd_seek (abfd, i_fxdhdrp->debugInfoOffset, SEEK_SET) == -1)
- return (false);
+ if (bfd_seek (abfd, i_fxdhdrp->debugInfoOffset, SEEK_SET) != 0)
+ return false;
symcount += i_fxdhdrp->numberOfDebugRecords;
while (abfd->symcount < symcount)
{
- if ((bfd_read ((PTR) & symtype, sizeof (symtype), 1, abfd)
- != sizeof (symtype))
- || bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)
- || (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd)
- != sizeof (symlength)))
+ amt = sizeof (symtype);
+ if (bfd_bread ((PTR) &symtype, amt, abfd) != amt)
+ return false;
+ amt = sizeof (temp);
+ if (bfd_bread ((PTR) temp, amt, abfd) != amt)
+ return false;
+ amt = sizeof (symlength);
+ if (bfd_bread ((PTR) &symlength, amt, abfd) != amt)
return false;
+ amt = symlength;
sym->symbol.the_bfd = abfd;
- sym->symbol.name = bfd_alloc (abfd, symlength + 1);
+ sym->symbol.name = bfd_alloc (abfd, amt + 1);
if (!sym->symbol.name)
return false;
- if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
- != symlength)
- return (false);
+ if (bfd_bread ((PTR) sym->symbol.name, amt, abfd) != amt)
+ return false;
/* Cast away const. */
((char *) (sym->symbol.name))[symlength] = '\0';
sym->symbol.flags = BSF_LOCAL;
read_import_func = nlm_read_import_func (abfd);
if (read_import_func != NULL)
{
- if (bfd_seek (abfd, i_fxdhdrp->externalReferencesOffset, SEEK_SET)
- == -1)
- return (false);
+ if (bfd_seek (abfd, i_fxdhdrp->externalReferencesOffset, SEEK_SET) != 0)
+ return false;
symcount += i_fxdhdrp->numberOfExternalReferences;
while (abfd->symcount < symcount)
}
}
- return (true);
+ return true;
}
\f
/* Get the relocs for an NLM file. There are two types of relocs.
{
boolean (*read_func) PARAMS ((bfd *, nlm_symbol_type *, asection **,
arelent *));
- bfd_size_type count;
+ bfd_size_type count, amt;
arelent *rels;
asection **secs;
return false;
count = nlm_fixed_header (abfd)->numberOfRelocationFixups;
- rels = (arelent *) bfd_alloc (abfd, count * sizeof (arelent));
- secs = (asection **) bfd_alloc (abfd, count * sizeof (asection *));
+ amt = count * sizeof (arelent);
+ rels = (arelent *) bfd_alloc (abfd, amt);
+ amt = count * sizeof (asection *);
+ secs = (asection **) bfd_alloc (abfd, amt);
if ((rels == NULL || secs == NULL) && count != 0)
return false;
nlm_relocation_fixups (abfd) = rels;
}
}
- if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
- || bfd_write (location, 1, count, abfd) != count)
+ if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
+ || bfd_bwrite (location, count, abfd) != count)
return false;
return true;
file_ptr last;
boolean (*write_prefix_func) PARAMS ((bfd *));
unsigned char *fixed_header = NULL;
+ file_ptr pos;
+ bfd_size_type amt;
fixed_header = ((unsigned char *)
- bfd_malloc ((size_t) nlm_fixed_header_size (abfd)));
+ bfd_malloc (nlm_fixed_header_size (abfd)));
if (fixed_header == NULL)
goto error_return;
goto error_return;
/* Write out the variable length headers. */
- if (bfd_seek (abfd,
- nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd),
- SEEK_SET) != 0)
+ pos = nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd);
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0)
goto error_return;
if (nlm_swap_variable_header_out (abfd) == false
|| nlm_swap_auxiliary_headers_out (abfd) == false)
/* A weak check on whether the section file positions were
reasonable. */
- if (bfd_tell (abfd) > nlm_fixed_header (abfd)->codeImageOffset)
+ if (bfd_tell (abfd) > (ufile_ptr) nlm_fixed_header (abfd)->codeImageOffset)
{
bfd_set_error (bfd_error_invalid_operation);
goto error_return;
are output as a symbol name followed by all the relocs for that
symbol, so we must first gather together all the relocs against
external symbols and sort them. */
- external_relocs =
- (struct reloc_and_sec *) bfd_alloc (abfd,
- (external_reloc_count
- * sizeof (struct reloc_and_sec)));
+ amt = external_reloc_count * sizeof (struct reloc_and_sec);
+ external_relocs = (struct reloc_and_sec *) bfd_alloc (abfd, amt);
if (external_relocs == (struct reloc_and_sec *) NULL)
goto error_return;
i = 0;
else
{
len = strlen (sym->name);
- if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd)
+ if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
!= sizeof (bfd_byte))
- || bfd_write (sym->name, len, 1, abfd) != len)
+ || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
goto error_return;
put_word (abfd, offset, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd)
+ != sizeof (temp))
goto error_return;
}
}
type = 2;
/* The type is 0 for data, 1 for code, 2 for absolute. */
- if (bfd_write (&type, sizeof (bfd_byte), 1, abfd)
+ if (bfd_bwrite (&type, (bfd_size_type) sizeof (bfd_byte), abfd)
!= sizeof (bfd_byte))
goto error_return;
put_word (abfd, offset, temp);
- if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
+ if (bfd_bwrite (temp, (bfd_size_type) sizeof (temp), abfd)
+ != sizeof (temp))
goto error_return;
len = strlen (sym->name);
- if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd)
+ if ((bfd_bwrite (&len, (bfd_size_type) sizeof (bfd_byte), abfd)
!= sizeof (bfd_byte))
- || bfd_write (sym->name, len, 1, abfd) != len)
+ || bfd_bwrite (sym->name, (bfd_size_type) len, abfd) != len)
goto error_return;
}
nlm_fixed_header (abfd)->numberOfDebugRecords = c;
nlm_fixed_header (abfd)->checkUnloadProcedureOffset -=
nlm_get_text_low (abfd);
- if (bfd_seek (abfd, 0, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
goto error_return;
write_prefix_func = nlm_write_prefix_func (abfd);
== nlm_optional_prefix_size (abfd));
nlm_swap_fixed_header_out (abfd, nlm_fixed_header (abfd), fixed_header);
- if (bfd_write (fixed_header, nlm_fixed_header_size (abfd), 1, abfd)
+ if (bfd_bwrite (fixed_header, nlm_fixed_header_size (abfd), abfd)
!= nlm_fixed_header_size (abfd))
goto error_return;
/* NLM (NetWare Loadable Module) swapping routines for BFD.
- Copyright 1993, 2000 Free Software Foundation, Inc.
+ Copyright 1993, 2000, 2001 Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support, using ELF support as the
template.
memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
dst->version =
- bfd_h_get_32 (abfd, (bfd_byte *) src->version);
+ H_GET_32 (abfd, src->version);
dst->codeImageOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->codeImageOffset);
+ H_GET_32 (abfd, src->codeImageOffset);
dst->codeImageSize =
- bfd_h_get_32 (abfd, (bfd_byte *) src->codeImageSize);
+ H_GET_32 (abfd, src->codeImageSize);
dst->dataImageOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->dataImageOffset);
+ H_GET_32 (abfd, src->dataImageOffset);
dst->dataImageSize =
- bfd_h_get_32 (abfd, (bfd_byte *) src->dataImageSize);
+ H_GET_32 (abfd, src->dataImageSize);
dst->uninitializedDataSize =
- bfd_h_get_32 (abfd, (bfd_byte *) src->uninitializedDataSize);
+ H_GET_32 (abfd, src->uninitializedDataSize);
dst->customDataOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->customDataOffset);
+ H_GET_32 (abfd, src->customDataOffset);
dst->customDataSize =
- bfd_h_get_32 (abfd, (bfd_byte *) src->customDataSize);
+ H_GET_32 (abfd, src->customDataSize);
dst->moduleDependencyOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->moduleDependencyOffset);
+ H_GET_32 (abfd, src->moduleDependencyOffset);
dst->numberOfModuleDependencies =
- bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfModuleDependencies);
+ H_GET_32 (abfd, src->numberOfModuleDependencies);
dst->relocationFixupOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->relocationFixupOffset);
+ H_GET_32 (abfd, src->relocationFixupOffset);
dst->numberOfRelocationFixups =
- bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfRelocationFixups);
+ H_GET_32 (abfd, src->numberOfRelocationFixups);
dst->externalReferencesOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->externalReferencesOffset);
+ H_GET_32 (abfd, src->externalReferencesOffset);
dst->numberOfExternalReferences =
- bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfExternalReferences);
+ H_GET_32 (abfd, src->numberOfExternalReferences);
dst->publicsOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->publicsOffset);
+ H_GET_32 (abfd, src->publicsOffset);
dst->numberOfPublics =
- bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfPublics);
+ H_GET_32 (abfd, src->numberOfPublics);
dst->debugInfoOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->debugInfoOffset);
+ H_GET_32 (abfd, src->debugInfoOffset);
dst->numberOfDebugRecords =
- bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfDebugRecords);
+ H_GET_32 (abfd, src->numberOfDebugRecords);
dst->codeStartOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->codeStartOffset);
+ H_GET_32 (abfd, src->codeStartOffset);
dst->exitProcedureOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->exitProcedureOffset);
+ H_GET_32 (abfd, src->exitProcedureOffset);
dst->checkUnloadProcedureOffset =
- bfd_h_get_32 (abfd, (bfd_byte *) src->checkUnloadProcedureOffset);
+ H_GET_32 (abfd, src->checkUnloadProcedureOffset);
dst->moduleType =
- bfd_h_get_32 (abfd, (bfd_byte *) src->moduleType);
+ H_GET_32 (abfd, src->moduleType);
dst->flags =
- bfd_h_get_32 (abfd, (bfd_byte *) src->flags);
+ H_GET_32 (abfd, src->flags);
}
/* Translate an NLM fixed length file header in internal format into
memset (dst, 0, sizeof *dst);
memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
- bfd_h_put_32 (abfd, (bfd_vma) src->version,
- (bfd_byte *) dst->version);
- bfd_h_put_32 (abfd, (bfd_vma) src->codeImageOffset,
- (bfd_byte *) dst->codeImageOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->codeImageSize,
- (bfd_byte *) dst->codeImageSize);
- bfd_h_put_32 (abfd, (bfd_vma) src->dataImageOffset,
- (bfd_byte *) dst->dataImageOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->dataImageSize,
- (bfd_byte *) dst->dataImageSize);
- bfd_h_put_32 (abfd, (bfd_vma) src->uninitializedDataSize,
- (bfd_byte *) dst->uninitializedDataSize);
- bfd_h_put_32 (abfd, (bfd_vma) src->customDataOffset,
- (bfd_byte *) dst->customDataOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->customDataSize,
- (bfd_byte *) dst->customDataSize);
- bfd_h_put_32 (abfd, (bfd_vma) src->moduleDependencyOffset,
- (bfd_byte *) dst->moduleDependencyOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->numberOfModuleDependencies,
- (bfd_byte *) dst->numberOfModuleDependencies);
- bfd_h_put_32 (abfd, (bfd_vma) src->relocationFixupOffset,
- (bfd_byte *) dst->relocationFixupOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->numberOfRelocationFixups,
- (bfd_byte *) dst->numberOfRelocationFixups);
- bfd_h_put_32 (abfd, (bfd_vma) src->externalReferencesOffset,
- (bfd_byte *) dst->externalReferencesOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->numberOfExternalReferences,
- (bfd_byte *) dst->numberOfExternalReferences);
- bfd_h_put_32 (abfd, (bfd_vma) src->publicsOffset,
- (bfd_byte *) dst->publicsOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->numberOfPublics,
- (bfd_byte *) dst->numberOfPublics);
- bfd_h_put_32 (abfd, (bfd_vma) src->debugInfoOffset,
- (bfd_byte *) dst->debugInfoOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->numberOfDebugRecords,
- (bfd_byte *) dst->numberOfDebugRecords);
- bfd_h_put_32 (abfd, (bfd_vma) src->codeStartOffset,
- (bfd_byte *) dst->codeStartOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->exitProcedureOffset,
- (bfd_byte *) dst->exitProcedureOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->checkUnloadProcedureOffset,
- (bfd_byte *) dst->checkUnloadProcedureOffset);
- bfd_h_put_32 (abfd, (bfd_vma) src->moduleType,
- (bfd_byte *) dst->moduleType);
- bfd_h_put_32 (abfd, (bfd_vma) src->flags,
- (bfd_byte *) dst->flags);
+ H_PUT_32 (abfd, src->version,
+ dst->version);
+ H_PUT_32 (abfd, src->codeImageOffset,
+ dst->codeImageOffset);
+ H_PUT_32 (abfd, src->codeImageSize,
+ dst->codeImageSize);
+ H_PUT_32 (abfd, src->dataImageOffset,
+ dst->dataImageOffset);
+ H_PUT_32 (abfd, src->dataImageSize,
+ dst->dataImageSize);
+ H_PUT_32 (abfd, src->uninitializedDataSize,
+ dst->uninitializedDataSize);
+ H_PUT_32 (abfd, src->customDataOffset,
+ dst->customDataOffset);
+ H_PUT_32 (abfd, src->customDataSize,
+ dst->customDataSize);
+ H_PUT_32 (abfd, src->moduleDependencyOffset,
+ dst->moduleDependencyOffset);
+ H_PUT_32 (abfd, src->numberOfModuleDependencies,
+ dst->numberOfModuleDependencies);
+ H_PUT_32 (abfd, src->relocationFixupOffset,
+ dst->relocationFixupOffset);
+ H_PUT_32 (abfd, src->numberOfRelocationFixups,
+ dst->numberOfRelocationFixups);
+ H_PUT_32 (abfd, src->externalReferencesOffset,
+ dst->externalReferencesOffset);
+ H_PUT_32 (abfd, src->numberOfExternalReferences,
+ dst->numberOfExternalReferences);
+ H_PUT_32 (abfd, src->publicsOffset,
+ dst->publicsOffset);
+ H_PUT_32 (abfd, src->numberOfPublics,
+ dst->numberOfPublics);
+ H_PUT_32 (abfd, src->debugInfoOffset,
+ dst->debugInfoOffset);
+ H_PUT_32 (abfd, src->numberOfDebugRecords,
+ dst->numberOfDebugRecords);
+ H_PUT_32 (abfd, src->codeStartOffset,
+ dst->codeStartOffset);
+ H_PUT_32 (abfd, src->exitProcedureOffset,
+ dst->exitProcedureOffset);
+ H_PUT_32 (abfd, src->checkUnloadProcedureOffset,
+ dst->checkUnloadProcedureOffset);
+ H_PUT_32 (abfd, src->moduleType,
+ dst->moduleType);
+ H_PUT_32 (abfd, src->flags,
+ dst->flags);
}
/* Header file for ns32k routines.
- Copyright 1996 Free Software Foundation, Inc.
+ Copyright 1996, 2001 Free Software Foundation, Inc.
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
extern bfd_reloc_status_type _bfd_do_ns32k_reloc_contents
PARAMS ((reloc_howto_type *, bfd *, bfd_vma, bfd_byte *,
- long (*) PARAMS ((bfd_byte *, long, long)),
- int (*) PARAMS ((long, bfd_byte *, long, long))));
+ bfd_vma (*) (bfd_byte *, int),
+ int (*) (bfd_vma, bfd_byte *, int)));
extern bfd_reloc_status_type _bfd_ns32k_final_link_relocate
PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, bfd_vma,
bfd_vma, bfd_vma));
-extern long _bfd_ns32k_get_displacement PARAMS ((bfd_byte *, long, long));
-extern long _bfd_ns32k_get_immediate PARAMS ((bfd_byte *, long, long));
-extern int _bfd_ns32k_put_displacement PARAMS ((long, bfd_byte *, long, long));
-extern int _bfd_ns32k_put_immediate PARAMS ((long, bfd_byte *, long, long));
+extern bfd_vma _bfd_ns32k_get_displacement PARAMS ((bfd_byte *, int));
+extern bfd_vma _bfd_ns32k_get_immediate PARAMS ((bfd_byte *, int));
+extern int _bfd_ns32k_put_displacement PARAMS ((bfd_vma, bfd_byte *, int));
+extern int _bfd_ns32k_put_immediate PARAMS ((bfd_vma, bfd_byte *, int));
extern bfd_reloc_status_type _bfd_ns32k_reloc_disp
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
#include "oasys.h"
#include "liboasys.h"
-static boolean oasys_read_record PARAMS ((bfd *,
- oasys_record_union_type *));
+static boolean oasys_slurp_section_data PARAMS ((bfd * const));
+static boolean oasys_read_record PARAMS ((bfd *, oasys_record_union_type *));
static boolean oasys_write_sections PARAMS ((bfd *));
-static boolean oasys_write_record PARAMS ((bfd *,
- oasys_record_enum_type,
- oasys_record_union_type *,
- size_t));
+static boolean oasys_write_record
+ PARAMS ((bfd *, oasys_record_enum_type, oasys_record_union_type *, size_t));
static boolean oasys_write_syms PARAMS ((bfd *));
static boolean oasys_write_header PARAMS ((bfd *));
static boolean oasys_write_end PARAMS ((bfd *));
static boolean oasys_mkobject PARAMS ((bfd *));
static const bfd_target *oasys_object_p PARAMS ((bfd *));
static void oasys_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
-static void oasys_print_symbol PARAMS ((bfd *, void *, asymbol *, bfd_print_symbol_type));
+static void oasys_print_symbol
+ PARAMS ((bfd *, void *, asymbol *, bfd_print_symbol_type));
static boolean oasys_new_section_hook PARAMS ((bfd *, asection *));
static long int oasys_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
static boolean oasys_get_section_contents
static asymbol *oasys_make_empty_symbol PARAMS ((bfd *));
static bfd *oasys_openr_next_archived_file PARAMS ((bfd *, bfd *));
static boolean oasys_find_nearest_line
- PARAMS ((bfd *, asection *, asymbol **, bfd_vma, char **, char **, unsigned int *));
+ PARAMS ((bfd *, asection *, asymbol **, bfd_vma,
+ const char **, const char **, unsigned int *));
static int oasys_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
static int oasys_sizeof_headers PARAMS ((bfd *, boolean));
long oasys_get_symtab PARAMS ((bfd *, asymbol **));
-long oasys_canonicalize_reloc PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
+long oasys_canonicalize_reloc
+ PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
/* Read in all the section data and relocation stuff too. */
-PROTO (static boolean, oasys_slurp_section_data, (bfd * CONST abfd));
static boolean
oasys_read_record (abfd, record)
bfd *abfd;
oasys_record_union_type *record;
{
- if (bfd_read ((PTR) record, 1, sizeof (record->header), abfd)
- != sizeof (record->header))
+ bfd_size_type amt = sizeof (record->header);
+ if (bfd_bread ((PTR) record, amt, abfd) != amt)
return false;
- if ((size_t) record->header.length <= (size_t) sizeof (record->header))
+ amt = record->header.length - sizeof (record->header);
+ if ((long) amt <= 0)
return true;
- if (bfd_read ((PTR) (((char *) record) + sizeof (record->header)),
- 1, record->header.length - sizeof (record->header),
- abfd)
- != record->header.length - sizeof (record->header))
+ if (bfd_bread ((PTR) ((char *) record + sizeof (record->header)), amt, abfd)
+ != amt)
return false;
return true;
}
+
static size_t
oasys_string_length (record)
oasys_record_union_type *record;
static boolean
oasys_slurp_symbol_table (abfd)
- bfd *CONST abfd;
+ bfd *const abfd;
{
oasys_record_union_type record;
oasys_data_type *data = OASYS_DATA (abfd);
asymbol *dest_defined;
asymbol *dest;
char *string_ptr;
-
+ bfd_size_type amt;
if (data->symbols != (asymbol *) NULL)
{
return true;
}
/* Buy enough memory for all the symbols and all the names */
- data->symbols =
- (asymbol *) bfd_alloc (abfd, sizeof (asymbol) * abfd->symcount);
+ amt = abfd->symcount;
+ amt *= sizeof (asymbol);
+ data->symbols = (asymbol *) bfd_alloc (abfd, amt);
+
+ amt = data->symbol_string_length;
#ifdef UNDERSCORE_HACK
/* buy 1 more char for each symbol to keep the underscore in*/
- data->strings = bfd_alloc (abfd, data->symbol_string_length +
- abfd->symcount);
-#else
- data->strings = bfd_alloc (abfd, data->symbol_string_length);
+ amt += abfd->symcount;
#endif
+ data->strings = bfd_alloc (abfd, amt);
+
if (!data->symbols || !data->strings)
return false;
}
break;
case RELOCATION_TYPE_UND:
- dest = data->symbols + bfd_h_get_16 (abfd, record.symbol.refno);
+ dest = data->symbols + H_GET_16 (abfd, record.symbol.refno);
dest->section = bfd_und_section_ptr;
break;
case RELOCATION_TYPE_COM:
dest->name = string_ptr;
dest->the_bfd = abfd;
dest->udata.p = (PTR) NULL;
- dest->value = bfd_h_get_32 (abfd, record.symbol.value);
+ dest->value = H_GET_32 (abfd, record.symbol.value);
#ifdef UNDERSCORE_HACK
if (record.symbol.name[0] != '_')
static long
oasys_get_symtab_upper_bound (abfd)
- bfd *CONST abfd;
+ bfd *const abfd;
{
if (! oasys_slurp_symbol_table (abfd))
return -1;
oasys_extarchive_header_type header_ext;
unsigned int i;
file_ptr filepos;
+ bfd_size_type amt;
- if (bfd_seek (abfd, (file_ptr) 0, false) != 0
- || (bfd_read ((PTR) & header_ext, 1, sizeof (header_ext), abfd)
- != sizeof (header_ext)))
+ amt = sizeof (header_ext);
+ if (bfd_seek (abfd, (file_ptr) 0, 0) != 0
+ || bfd_bread ((PTR) &header_ext, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
- header.version = bfd_h_get_32 (abfd, header_ext.version);
- header.mod_count = bfd_h_get_32 (abfd, header_ext.mod_count);
- header.mod_tbl_offset = bfd_h_get_32 (abfd, header_ext.mod_tbl_offset);
- header.sym_tbl_size = bfd_h_get_32 (abfd, header_ext.sym_tbl_size);
- header.sym_count = bfd_h_get_32 (abfd, header_ext.sym_count);
- header.sym_tbl_offset = bfd_h_get_32 (abfd, header_ext.sym_tbl_offset);
- header.xref_count = bfd_h_get_32 (abfd, header_ext.xref_count);
- header.xref_lst_offset = bfd_h_get_32 (abfd, header_ext.xref_lst_offset);
+ header.version = H_GET_32 (abfd, header_ext.version);
+ header.mod_count = H_GET_32 (abfd, header_ext.mod_count);
+ header.mod_tbl_offset = H_GET_32 (abfd, header_ext.mod_tbl_offset);
+ header.sym_tbl_size = H_GET_32 (abfd, header_ext.sym_tbl_size);
+ header.sym_count = H_GET_32 (abfd, header_ext.sym_count);
+ header.sym_tbl_offset = H_GET_32 (abfd, header_ext.sym_tbl_offset);
+ header.xref_count = H_GET_32 (abfd, header_ext.xref_count);
+ header.xref_lst_offset = H_GET_32 (abfd, header_ext.xref_lst_offset);
/*
There isn't a magic number in an Oasys archive, so the best we
the headers.
*/
{
- oasys_ar_data_type *ar =
- (oasys_ar_data_type *) bfd_alloc (abfd, sizeof (oasys_ar_data_type));
-
- oasys_module_info_type *module =
- (oasys_module_info_type *)
- bfd_alloc (abfd, sizeof (oasys_module_info_type) * header.mod_count);
+ oasys_ar_data_type *ar;
+ oasys_module_info_type *module;
oasys_module_table_type record;
+ amt = sizeof (oasys_ar_data_type);
+ ar = (oasys_ar_data_type *) bfd_alloc (abfd, amt);
+
+ amt = header.mod_count;
+ amt *= sizeof (oasys_module_info_type);
+ module = (oasys_module_info_type *) bfd_alloc (abfd, amt);
+
if (!ar || !module)
return NULL;
if (0)
{
oasys_extmodule_table_type_a_type record_ext;
- if (bfd_read ((PTR) & record_ext, 1, sizeof (record_ext), abfd)
- != sizeof (record_ext))
+
+ amt = sizeof (record_ext);
+ if (bfd_bread ((PTR) &record_ext, amt, abfd) != amt)
return NULL;
- record.mod_size = bfd_h_get_32 (abfd, record_ext.mod_size);
- record.file_offset = bfd_h_get_32 (abfd, record_ext.file_offset);
+ record.mod_size = H_GET_32 (abfd, record_ext.mod_size);
+ record.file_offset = H_GET_32 (abfd, record_ext.file_offset);
- record.dep_count = bfd_h_get_32 (abfd, record_ext.dep_count);
- record.depee_count = bfd_h_get_32 (abfd, record_ext.depee_count);
- record.sect_count = bfd_h_get_32 (abfd, record_ext.sect_count);
+ record.dep_count = H_GET_32 (abfd, record_ext.dep_count);
+ record.depee_count = H_GET_32 (abfd, record_ext.depee_count);
+ record.sect_count = H_GET_32 (abfd, record_ext.sect_count);
- module[i].name = bfd_alloc (abfd, 33);
+ module[i].name = bfd_alloc (abfd, (bfd_size_type) 33);
if (!module[i].name)
return NULL;
else
{
oasys_extmodule_table_type_b_type record_ext;
- if (bfd_read ((PTR) & record_ext, 1, sizeof (record_ext), abfd)
- != sizeof (record_ext))
+
+ amt = sizeof (record_ext);
+ if (bfd_bread ((PTR) &record_ext, amt, abfd) != amt)
return NULL;
- record.mod_size = bfd_h_get_32 (abfd, record_ext.mod_size);
- record.file_offset = bfd_h_get_32 (abfd, record_ext.file_offset);
+ record.mod_size = H_GET_32 (abfd, record_ext.mod_size);
+ record.file_offset = H_GET_32 (abfd, record_ext.file_offset);
- record.dep_count = bfd_h_get_32 (abfd, record_ext.dep_count);
- record.depee_count = bfd_h_get_32 (abfd, record_ext.depee_count);
- record.sect_count = bfd_h_get_32 (abfd, record_ext.sect_count);
- record.module_name_size = bfd_h_get_32 (abfd, record_ext.mod_name_length);
+ record.dep_count = H_GET_32 (abfd, record_ext.dep_count);
+ record.depee_count = H_GET_32 (abfd, record_ext.depee_count);
+ record.sect_count = H_GET_32 (abfd, record_ext.sect_count);
+ record.module_name_size = H_GET_32 (abfd,
+ record_ext.mod_name_length);
- module[i].name = bfd_alloc (abfd, record.module_name_size + 1);
+ amt = record.module_name_size;
+ module[i].name = bfd_alloc (abfd, amt + 1);
if (!module[i].name)
return NULL;
- if (bfd_read ((PTR) module[i].name, 1, record.module_name_size,
- abfd)
- != record.module_name_size)
+ if (bfd_bread ((PTR) module[i].name, amt, abfd) != amt)
return NULL;
module[i].name[record.module_name_size] = 0;
- filepos +=
- sizeof (record_ext) +
- record.dep_count * 4 +
- record.module_name_size + 1;
-
+ filepos += (sizeof (record_ext)
+ + record.dep_count * 4
+ + record.module_name_size + 1);
}
-
module[i].size = record.mod_size;
module[i].pos = record.file_offset;
module[i].abfd = 0;
}
-
}
return abfd->xvec;
}
oasys_mkobject (abfd)
bfd *abfd;
{
-
- abfd->tdata.oasys_obj_data = (oasys_data_type *) bfd_alloc (abfd, sizeof (oasys_data_type));
+ bfd_size_type amt = sizeof (oasys_data_type);
+ abfd->tdata.oasys_obj_data = (oasys_data_type *) bfd_alloc (abfd, amt);
return abfd->tdata.oasys_obj_data ? true : false;
}
{
goto fail;
}
- buffer = bfd_alloc (abfd, 3);
+ buffer = bfd_alloc (abfd, (bfd_size_type) 3);
if (!buffer)
goto fail;
section_number = record.section.relb & RELOCATION_SECT_BITS;
BFD_FAIL ();
}
- s->_raw_size = bfd_h_get_32 (abfd, record.section.value);
- s->vma = bfd_h_get_32 (abfd, record.section.vma);
+ s->_raw_size = H_GET_32 (abfd, record.section.value);
+ s->vma = H_GET_32 (abfd, record.section.vma);
s->flags = 0;
had_usefull = true;
}
break;
case bfd_print_symbol_all:
{
- CONST char *section_name = symbol->section == (asection *) NULL ?
- (CONST char *) "*abs" : symbol->section->name;
+ const char *section_name = symbol->section == (asection *) NULL ?
+ (const char *) "*abs" : symbol->section->name;
bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
/* Read in all the section data and relocation stuff too */
static boolean
oasys_slurp_section_data (abfd)
- bfd *CONST abfd;
+ bfd *const abfd;
{
oasys_record_union_type record;
oasys_data_type *data = OASYS_DATA (abfd);
boolean loop = true;
-
oasys_per_section_type *per;
-
asection *s;
+ bfd_size_type amt;
/* See if the data has been slurped already .. */
for (s = abfd->sections; s != (asection *) NULL; s = s->next)
per->data = (bfd_byte *) bfd_zalloc (abfd, section->_raw_size);
if (!per->data)
return false;
- per->reloc_tail_ptr = (oasys_reloc_type **) & (section->relocation);
+ per->reloc_tail_ptr
+ = (oasys_reloc_type **) §ion->relocation;
per->had_vma = false;
per->initialized = true;
section->reloc_count = 0;
section->flags = SEC_ALLOC;
}
- dst_offset = bfd_h_get_32 (abfd, record.data.addr);
+ dst_offset = H_GET_32 (abfd, record.data.addr);
if (per->had_vma == false)
{
/* Take the first vma we see as the base */
case RELOCATION_TYPE_REL:
{
/* Relocate the item relative to the section */
- oasys_reloc_type *r =
- (oasys_reloc_type *)
- bfd_alloc (abfd,
- sizeof (oasys_reloc_type));
+ oasys_reloc_type *r;
+
+ amt = sizeof (oasys_reloc_type);
+ r = (oasys_reloc_type *) bfd_alloc (abfd,
+ amt);
if (!r)
return false;
*(per->reloc_tail_ptr) = r;
case RELOCATION_TYPE_UND:
{
- oasys_reloc_type *r =
- (oasys_reloc_type *)
- bfd_alloc (abfd,
- sizeof (oasys_reloc_type));
+ oasys_reloc_type *r;
+
+ amt = sizeof (oasys_reloc_type);
+ r = (oasys_reloc_type *) bfd_alloc (abfd,
+ amt);
if (!r)
return false;
*(per->reloc_tail_ptr) = r;
asection *newsect;
{
newsect->used_by_bfd = (PTR)
- bfd_alloc (abfd, sizeof (oasys_per_section_type));
+ bfd_alloc (abfd, (bfd_size_type) sizeof (oasys_per_section_type));
if (!newsect->used_by_bfd)
return false;
oasys_per_section (newsect)->data = (bfd_byte *) NULL;
oasys_slurp_section_data (abfd);
if (p->initialized == false)
{
- (void) memset (location, 0, (int) count);
+ (void) memset (location, 0, (size_t) count);
}
else
{
- (void) memcpy (location, (PTR) (p->data + offset), (int) count);
+ (void) memcpy (location, (PTR) (p->data + offset), (size_t) count);
}
return true;
}
checksum += *ptr++;
}
record->header.check_sum = 0xff & (-checksum);
- if (bfd_write ((PTR) record, 1, size, abfd) != size)
+ if (bfd_bwrite ((PTR) record, (bfd_size_type) size, abfd) != size)
return false;
return true;
}
{
oasys_symbol_record_type symbol;
- asymbol *CONST g = generic[count];
+ asymbol *const g = generic[count];
- CONST char *src = g->name;
+ const char *src = g->name;
char *dst = symbol.name;
unsigned int l = 0;
if (bfd_is_com_section (g->section))
{
symbol.relb = RELOCATION_TYPE_COM;
- bfd_h_put_16 (abfd, index, symbol.refno);
+ H_PUT_16 (abfd, index, symbol.refno);
index++;
}
else if (bfd_is_abs_section (g->section))
{
symbol.relb = RELOCATION_TYPE_ABS;
- bfd_h_put_16 (abfd, 0, symbol.refno);
+ H_PUT_16 (abfd, 0, symbol.refno);
}
else if (bfd_is_und_section (g->section))
{
symbol.relb = RELOCATION_TYPE_UND;
- bfd_h_put_16 (abfd, index, symbol.refno);
+ H_PUT_16 (abfd, index, symbol.refno);
/* Overload the value field with the output index number */
index++;
}
{
symbol.relb = RELOCATION_TYPE_REL | g->section->output_section->target_index;
}
- bfd_h_put_16 (abfd, 0, symbol.refno);
+ H_PUT_16 (abfd, 0, symbol.refno);
}
#ifdef UNDERSCORE_HACK
if (src[l] == '_')
l++;
}
- bfd_h_put_32 (abfd, g->value, symbol.value);
+ H_PUT_32 (abfd, g->value, symbol.value);
if (g->flags & BSF_LOCAL)
return false;
}
out.relb = RELOCATION_TYPE_REL | s->target_index;
- bfd_h_put_32 (abfd, s->_cooked_size, out.value);
- bfd_h_put_32 (abfd, s->vma, out.vma);
+ H_PUT_32 (abfd, s->_cooked_size, out.value);
+ H_PUT_32 (abfd, s->vma, out.vma);
if (! oasys_write_record (abfd,
oasys_record_is_section_enum,
oasys_end_record_type end;
unsigned char null = 0;
end.relb = RELOCATION_TYPE_ABS;
- bfd_h_put_32 (abfd, abfd->start_address, end.entry);
- bfd_h_put_16 (abfd, 0, end.fill);
+ H_PUT_32 (abfd, abfd->start_address, end.entry);
+ H_PUT_16 (abfd, 0, end.fill);
end.zero = 0;
if (! oasys_write_record (abfd,
oasys_record_is_end_enum,
(oasys_record_union_type *) & end,
sizeof (end)))
return false;
- if (bfd_write ((PTR) & null, 1, 1, abfd) != 1)
+ if (bfd_bwrite ((PTR) &null, (bfd_size_type) 1, abfd) != 1)
return false;
return true;
}
static int
comp (ap, bp)
- CONST PTR ap;
- CONST PTR bp;
+ const PTR ap;
+ const PTR bp;
{
arelent *a = *((arelent **) ap);
arelent *b = *((arelent **) bp);
*mod = 0;
- bfd_h_put_32 (abfd, s->vma + current_byte_index,
- processed_data.addr);
+ H_PUT_32 (abfd, s->vma + current_byte_index,
+ processed_data.addr);
/* Don't start a relocation unless you're sure you can finish it
within the same data record. The worst case relocation is a
else
#endif
{
- asymbol *p = *(r->sym_ptr_ptr);
+ asymbol *sym = *(r->sym_ptr_ptr);
/* If this symbol has a section attached, then it
has already been resolved. Change from a symbol
ref to a section ref */
- if (p->section != (asection *) NULL)
+ if (sym->section != (asection *) NULL)
{
rel_byte |= RELOCATION_TYPE_REL;
rel_byte |=
- p->section->output_section->target_index;
+ sym->section->output_section->target_index;
*dst++ = rel_byte;
}
else
into the symbol index in the table when the
symbol table was written
*/
- *dst++ = p->value >> 8;
- *dst++ = p->value;
+ *dst++ = sym->value >> 8;
+ *dst++ = sym->value;
}
}
#define ADVANCE { if (++i >= 8) { i = 0; mod = dst++; *mod = 0; } current_byte_index++; }
--dst;
}
- if (! oasys_write_record (abfd,
- oasys_record_is_data_enum,
- ((oasys_record_union_type *)
- & processed_data),
- dst - (bfd_byte *) & processed_data))
+ if (! (oasys_write_record
+ (abfd, oasys_record_is_data_enum,
+ ((oasys_record_union_type *) &processed_data),
+ (size_t) (dst - (bfd_byte *) &processed_data))))
return false;
}
}
oasys_make_empty_symbol (abfd)
bfd *abfd;
{
-
- oasys_symbol_type *new =
- (oasys_symbol_type *) bfd_zalloc (abfd, sizeof (oasys_symbol_type));
+ bfd_size_type amt = sizeof (oasys_symbol_type);
+ oasys_symbol_type *new = (oasys_symbol_type *) bfd_zalloc (abfd, amt);
if (!new)
return NULL;
new->symbol.the_bfd = abfd;
}
static boolean
-oasys_find_nearest_line (abfd,
- section,
- symbols,
- offset,
- filename_ptr,
- functionname_ptr,
- line_ptr)
+oasys_find_nearest_line (abfd, section, symbols, offset,
+ filename_ptr, functionname_ptr, line_ptr)
bfd *abfd ATTRIBUTE_UNUSED;
asection *section ATTRIBUTE_UNUSED;
asymbol **symbols ATTRIBUTE_UNUSED;
bfd_vma offset ATTRIBUTE_UNUSED;
- char **filename_ptr ATTRIBUTE_UNUSED;
- char **functionname_ptr ATTRIBUTE_UNUSED;
+ const char **filename_ptr ATTRIBUTE_UNUSED;
+ const char **functionname_ptr ATTRIBUTE_UNUSED;
unsigned int *line_ptr ATTRIBUTE_UNUSED;
{
return false;
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
NULL,
-
+
(PTR) 0
};
{
bfd *nbfd;
- nbfd = (bfd *) bfd_zmalloc (sizeof (bfd));
+ nbfd = (bfd *) bfd_zmalloc ((bfd_size_type) sizeof (bfd));
if (nbfd == NULL)
return NULL;
nbfd->sections = (asection *) NULL;
nbfd->format = bfd_unknown;
nbfd->my_archive = (bfd *) NULL;
- nbfd->origin = 0;
+ nbfd->origin = 0;
nbfd->opened_once = false;
nbfd->output_has_begun = false;
nbfd->section_count = 0;
bfd_openr
SYNOPSIS
- bfd *bfd_openr(CONST char *filename, CONST char *target);
+ bfd *bfd_openr(const char *filename, const char *target);
DESCRIPTION
Open the file @var{filename} (using <<fopen>>) with the target
bfd *
bfd_openr (filename, target)
- CONST char *filename;
- CONST char *target;
+ const char *filename;
+ const char *target;
{
bfd *nbfd;
const bfd_target *target_vec;
bfd_fdopenr
SYNOPSIS
- bfd *bfd_fdopenr(CONST char *filename, CONST char *target, int fd);
+ bfd *bfd_fdopenr(const char *filename, const char *target, int fd);
DESCRIPTION
<<bfd_fdopenr>> is to <<bfd_fopenr>> much like <<fdopen>> is to <<fopen>>.
bfd *
bfd_fdopenr (filename, target, fd)
- CONST char *filename;
- CONST char *target;
+ const char *filename;
+ const char *target;
int fd;
{
bfd *nbfd;
nbfd->iostream = (PTR) stream;
nbfd->filename = filename;
nbfd->direction = read_direction;
-
+
if (! bfd_cache_init (nbfd))
{
objalloc_free ((struct objalloc *) nbfd->memory);
bfd_openw
SYNOPSIS
- bfd *bfd_openw(CONST char *filename, CONST char *target);
+ bfd *bfd_openw(const char *filename, const char *target);
DESCRIPTION
Create a BFD, associated with file @var{filename}, using the
bfd *
bfd_openw (filename, target)
- CONST char *filename;
- CONST char *target;
+ const char *filename;
+ const char *target;
{
bfd *nbfd;
const bfd_target *target_vec;
if (stat (abfd->filename, &buf) == 0)
{
- int mask = umask (0);
+ unsigned int mask = umask (0);
umask (mask);
chmod (abfd->filename,
(0777
if (stat (abfd->filename, &buf) == 0)
{
- int mask = umask (0);
+ unsigned int mask = umask (0);
umask (mask);
chmod (abfd->filename,
(0777
bfd_create
SYNOPSIS
- bfd *bfd_create(CONST char *filename, bfd *templ);
+ bfd *bfd_create(const char *filename, bfd *templ);
DESCRIPTION
Create a new BFD in the manner of
bfd *
bfd_create (filename, templ)
- CONST char *filename;
+ const char *filename;
bfd *templ;
{
bfd *nbfd;
return false;
}
- bim = (struct bfd_in_memory *) bfd_malloc (sizeof (struct bfd_in_memory));
+ bim = ((struct bfd_in_memory *)
+ bfd_malloc ((bfd_size_type) sizeof (struct bfd_in_memory)));
abfd->iostream = (PTR) bim;
- /* bfd_write will grow these as needed */
+ /* bfd_bwrite will grow these as needed */
bim->size = 0;
bim->buffer = 0;
abfd->sections = (asection *) NULL;
abfd->format = bfd_unknown;
abfd->my_archive = (bfd *) NULL;
- abfd->origin = 0;
+ abfd->origin = 0;
abfd->opened_once = false;
abfd->output_has_begun = false;
abfd->section_count = 0;
PTR
bfd_alloc (abfd, size)
bfd *abfd;
- size_t size;
+ bfd_size_type size;
{
PTR ret;
+ if (size != (unsigned long) size)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return NULL;
+ }
+
ret = objalloc_alloc (abfd->memory, (unsigned long) size);
if (ret == NULL)
bfd_set_error (bfd_error_no_memory);
PTR
bfd_zalloc (abfd, size)
bfd *abfd;
- size_t size;
+ bfd_size_type size;
{
PTR res;
res = bfd_alloc (abfd, size);
if (res)
- memset (res, 0, size);
+ memset (res, 0, (size_t) size);
return res;
}
/* BFD back-end for OSF/1 core files.
- Copyright 1993, 1994, 1995, 1998, 1999 Free Software Foundation, Inc.
+ Copyright 1993, 1994, 1995, 1998, 1999, 2001
+ Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
/* forward declarations */
static asection *
-make_bfd_asection PARAMS ((bfd *, CONST char *, flagword, bfd_size_type,
+make_bfd_asection PARAMS ((bfd *, const char *, flagword, bfd_size_type,
bfd_vma, file_ptr));
static asymbol *
osf_core_make_empty_symbol PARAMS ((bfd *));
/* These are stored in the bfd's tdata */
-struct osf_core_struct
+struct osf_core_struct
{
int sig;
char cmd[MAXCOMLEN + 1];
static asection *
make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
bfd *abfd;
- CONST char *name;
+ const char *name;
flagword flags;
bfd_size_type _raw_size;
bfd_vma vma;
osf_core_make_empty_symbol (abfd)
bfd *abfd;
{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ asymbol *new;
+
+ new = (asymbol *) bfd_zalloc (abfd, (bfd_size_type) sizeof (asymbol));
if (new)
new->the_bfd = abfd;
return new;
int i;
char *secname;
struct core_filehdr core_header;
+ bfd_size_type amt;
- val = bfd_read ((PTR)&core_header, 1, sizeof core_header, abfd);
+ amt = sizeof core_header;
+ val = bfd_bread ((PTR) &core_header, amt, abfd);
if (val != sizeof core_header)
return NULL;
return NULL;
core_hdr (abfd) = (struct osf_core_struct *)
- bfd_zalloc (abfd, sizeof (struct osf_core_struct));
+ bfd_zalloc (abfd, (bfd_size_type) sizeof (struct osf_core_struct));
if (!core_hdr (abfd))
return NULL;
struct core_scnhdr core_scnhdr;
flagword flags;
- val = bfd_read ((PTR)&core_scnhdr, 1, sizeof core_scnhdr, abfd);
+ amt = sizeof core_scnhdr;
+ val = bfd_bread ((PTR) &core_scnhdr, amt, abfd);
if (val != sizeof core_scnhdr)
break;
/* ARGSUSED */
static boolean
osf_core_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
+ bfd *core_bfd ATTRIBUTE_UNUSED;
+ bfd *exec_bfd ATTRIBUTE_UNUSED;
{
return true; /* FIXME, We have no way of telling at this point */
}
bfd_false, bfd_false,
bfd_false, bfd_false
},
-
+
BFD_JUMP_TABLE_GENERIC (_bfd_generic),
BFD_JUMP_TABLE_COPY (_bfd_generic),
BFD_JUMP_TABLE_CORE (osf_core),
BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
NULL,
-
+
(PTR) 0 /* backend_data */
};
#include "libbfd.h"
#include "aout/aout64.h"
-/* We can`t use the MYNS macro here for cpp reasons too subtle for me -- IWD */
-
#define MY_bfd_reloc_type_lookup ns32kaout_bfd_reloc_type_lookup
/* libaout doesn't use NAME for these ... */
#define MY_exec_header_not_counted 1
-#define MYNSX(OP) CAT(ns32kaout_,OP)
-reloc_howto_type *
-MYNSX(bfd_reloc_type_lookup)
- PARAMS((bfd *abfd AND
- bfd_reloc_code_real_type code));
+reloc_howto_type *ns32kaout_bfd_reloc_type_lookup
+ PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
-boolean
-MYNSX(write_object_contents)
- PARAMS((bfd *abfd));
+static boolean MY(write_object_contents)
+ PARAMS ((bfd *abfd));
static boolean
MY(write_object_contents) (abfd)
-bfd *abfd;
+ bfd *abfd;
{
struct external_exec exec_bytes;
struct internal_exec *execp = exec_hdr (abfd);
* support for overlay object files (see 2.11 a.out(5))
* support for old and very old archives
(see 2.11 ar(5), historical section)
-
+
Search for TODO to find other areas needing more work. */
#define BYTES_IN_WORD 2
/* Alternative_target */
NULL,
-
+
(PTR) MY_backend_data,
};
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+ if (bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, abfd)
!= EXEC_BYTES_SIZE)
return false;
if (bfd_get_outsymbols (abfd) != (asymbol **) NULL
&& bfd_get_symcount (abfd) != 0)
{
- if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET) != 0)
return false;
- if (! NAME(aout,write_syms)(abfd)) return false;
+ if (! NAME(aout,write_syms) (abfd))
+ return false;
}
if (obj_textsec (abfd)->reloc_count > 0 ||
obj_datasec (abfd)->reloc_count > 0)
{
- if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) (N_TRELOFF(*execp)), SEEK_SET) != 0)
return false;
if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd)))
return false;
- if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) (N_DRELOFF(*execp)), SEEK_SET) != 0)
return false;
- if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd)))
+ if (!NAME(aout,squirt_out_relocs) (abfd, obj_datasec (abfd)))
return false;
}
return true;
-}
+}
/* Write an object file.
Section contents have already been written. We write the
{
struct aout_data_struct *rawptr, *oldrawptr;
const bfd_target *result;
+ bfd_size_type amt = sizeof (struct aout_data_struct);
- rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
+ rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, amt);
if (rawptr == NULL)
return 0;
bfd *abfd;
{
struct aout_data_struct *rawptr;
+ bfd_size_type amt = sizeof (struct aout_data_struct);
bfd_set_error (bfd_error_system_call);
/* Use an intermediate variable for clarity */
- rawptr = (struct aout_data_struct *)bfd_zalloc (abfd, sizeof (struct aout_data_struct ));
+ rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, amt);
if (rawptr == NULL)
return false;
case bfd_arch_vax:
*unknown = false;
break;
-
+
default:
arch_flags = M_UNKNOWN;
}
{
bfd_size_type data_pad, text_pad;
file_ptr text_end;
- CONST struct aout_backend_data *abdp;
+ const struct aout_backend_data *abdp;
int ztih; /* Nonzero if text includes exec header. */
-
+
abdp = aout_backend_info (abfd);
/* Text. */
}
obj_datasec (abfd)->filepos = (obj_textsec (abfd)->filepos
+ obj_textsec (abfd)->_raw_size);
-
+
/* Fix up exec header while we're at it. */
execp->a_text = obj_textsec(abfd)->_raw_size;
if (ztih && (!abdp || (abdp && !abdp->exec_header_not_counted)))
file_ptr pos = adata(abfd).exec_bytes_size;
bfd_vma vma = 0;
int pad;
-
+
/* Text. */
obj_textsec(abfd)->filepos = pos;
if (!obj_textsec(abfd)->user_set_vma)
if (!obj_datasec(abfd)->user_set_vma)
obj_datasec(abfd)->vma = BFD_ALIGN (vma, adata(abfd).segment_size);
vma = obj_datasec(abfd)->vma;
-
+
/* Since BSS follows data immediately, see if it needs alignment. */
vma += obj_datasec(abfd)->_raw_size;
pad = align_power (vma, obj_bsssec(abfd)->alignment_power) - vma;
if (count != 0)
{
if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
- || bfd_write (location, 1, count, abfd) != count)
+ || bfd_bwrite (location, count, abfd) != count)
return false;
}
/* We allocate using malloc to make the values easy to free
later on. If we put them on the objalloc it might not be
possible to free them. */
- syms = ((struct external_nlist *)
- bfd_malloc ((size_t) count * EXTERNAL_NLIST_SIZE));
+ syms = (struct external_nlist *) bfd_malloc (count * EXTERNAL_NLIST_SIZE);
if (syms == (struct external_nlist *) NULL && count != 0)
return false;
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
- || (bfd_read (syms, 1, exec_hdr (abfd)->a_syms, abfd)
+ || (bfd_bread (syms, exec_hdr (abfd)->a_syms, abfd)
!= exec_hdr (abfd)->a_syms))
{
free (syms);
obj_aout_external_syms (abfd) = syms;
obj_aout_external_sym_count (abfd) = count;
}
-
+
if (obj_aout_external_strings (abfd) == NULL
&& exec_hdr (abfd)->a_syms != 0)
{
/* Get the size of the strings. */
if (bfd_seek (abfd, obj_str_filepos (abfd), SEEK_SET) != 0
- || (bfd_read ((PTR) string_chars, BYTES_IN_LONG, 1, abfd) !=
- BYTES_IN_LONG))
+ || (bfd_bread ((PTR) string_chars, (bfd_size_type) BYTES_IN_LONG,
+ abfd) != BYTES_IN_LONG))
return false;
- stringsize = bfd_h_get_32 (abfd, string_chars);
+ stringsize = H_GET_32 (abfd, string_chars);
#ifdef USE_MMAP
if (bfd_get_file_window (abfd, obj_str_filepos (abfd), stringsize,
return false;
strings = (char *) obj_aout_string_window (abfd).data;
#else
- strings = (char *) bfd_malloc ((size_t) stringsize + 1);
+ strings = (char *) bfd_malloc (stringsize + 1);
if (strings == NULL)
return false;
/* Skip space for the string count in the buffer for convenience
when using indexes. */
- if (bfd_read (strings + 4, 1, stringsize - 4, abfd) != stringsize - 4)
+ if (bfd_bread (strings + 4, stringsize - 4, abfd) != stringsize - 4)
{
free (strings);
return false;
file. */
(*_bfd_error_handler)
("%s: can not represent section for symbol `%s' in a.out object file format",
- bfd_get_filename (abfd),
+ bfd_get_filename (abfd),
cache_ptr->name != NULL ? cache_ptr->name : "*unknown*");
bfd_set_error (bfd_error_nonrepresentable_section);
return false;
NAME(aout,make_empty_symbol) (abfd)
bfd *abfd;
{
- aout_symbol_type *new =
- (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
+ bfd_size_type amt = sizeof (aout_symbol_type);
+ aout_symbol_type *new = (aout_symbol_type *) bfd_zalloc (abfd, amt);
if (!new)
return NULL;
new->symbol.the_bfd = abfd;
/* TODO: is 0 a safe value here? */
in->desc = 0;
in->other = 0;
- in->type = bfd_h_get_8 (abfd, ext->e_type);
+ in->type = H_GET_8 (abfd, ext->e_type);
in->symbol.udata.p = NULL;
if (! translate_from_native_sym_flags (abfd, in))
{
struct external_nlist *old_external_syms;
aout_symbol_type *cached;
- size_t cached_size;
+ bfd_size_type cached_size;
/* If there's no work to be done, don't do any */
if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL)
if (! aout_get_external_symbols (abfd))
return false;
- cached_size = (obj_aout_external_sym_count (abfd)
- * sizeof (aout_symbol_type));
+ cached_size = obj_aout_external_sym_count (abfd);
+ cached_size *= sizeof (aout_symbol_type);
cached = (aout_symbol_type *) bfd_malloc (cached_size);
if (cached == NULL && cached_size != 0)
return false;
if (cached_size != 0)
- memset (cached, 0, cached_size);
+ memset (cached, 0, (size_t) cached_size);
/* Convert from external symbol information to internal. */
if (! (NAME(aout,translate_symbol_table)
bfd_byte buffer[BYTES_IN_LONG];
/* The string table starts with the size. */
- bfd_h_put_32 (abfd, _bfd_stringtab_size (tab) + BYTES_IN_LONG, buffer);
- if (bfd_write ((PTR) buffer, 1, BYTES_IN_LONG, abfd) != BYTES_IN_LONG)
+ H_PUT_32 (abfd, _bfd_stringtab_size (tab) + BYTES_IN_LONG, buffer);
+ if (bfd_bwrite ((PTR) buffer, (bfd_size_type) BYTES_IN_LONG, abfd)
+ != BYTES_IN_LONG)
return false;
return _bfd_stringtab_emit (abfd, tab);
bfd_size_type indx;
struct external_nlist nsp;
- PUT_WORD (abfd, 0, (bfd_byte *)nsp.e_unused);
+ PUT_WORD (abfd, 0, nsp.e_unused);
indx = add_to_stringtab (abfd, strtab, g->name, false);
if (indx == (bfd_size_type) -1)
goto error_return;
- PUT_WORD (abfd, indx, (bfd_byte *) nsp.e_strx);
+ PUT_WORD (abfd, indx, nsp.e_strx);
if (bfd_asymbol_flavour(g) == abfd->xvec->flavour)
- bfd_h_put_8 (abfd, aout_symbol(g)->type, nsp.e_type);
+ H_PUT_8 (abfd, aout_symbol(g)->type, nsp.e_type);
else
- bfd_h_put_8 (abfd, 0, nsp.e_type);
+ H_PUT_8 (abfd, 0, nsp.e_type);
if (! translate_to_native_sym_flags (abfd, g, &nsp))
goto error_return;
- bfd_h_put_8 (abfd, 0, nsp.e_ovly);
+ H_PUT_8 (abfd, 0, nsp.e_ovly);
- if (bfd_write((PTR)&nsp,1,EXTERNAL_NLIST_SIZE, abfd)
+ if (bfd_bwrite ((PTR)&nsp, (bfd_size_type) EXTERNAL_NLIST_SIZE, abfd)
!= EXTERNAL_NLIST_SIZE)
goto error_return;
cache_ptr->addend = ad; \
break; \
} \
- }
+ }
void
pdp11_aout_swap_reloc_in (abfd, bytes, cache_ptr, offset,
asymbol **symbols;
{
struct pdp11_aout_reloc_external *rptr;
- unsigned int count;
+ bfd_size_type count;
bfd_size_type reloc_size;
PTR relocs;
arelent *reloc_cache;
each_size = obj_reloc_entry_size (abfd);
- relocs = bfd_malloc ((size_t) reloc_size);
+ relocs = bfd_malloc (reloc_size);
if (relocs == NULL && reloc_size != 0)
return false;
- if (bfd_read (relocs, 1, reloc_size, abfd) != reloc_size)
+ if (bfd_bread (relocs, reloc_size, abfd) != reloc_size)
{
free (relocs);
return false;
count = real_count;
}
- reloc_cache = (arelent *) bfd_malloc ((size_t) (count * sizeof (arelent)));
+ reloc_cache = (arelent *) bfd_malloc (count * sizeof (arelent));
if (reloc_cache == NULL && count != 0)
return false;
- memset (reloc_cache, 0, count * sizeof (arelent));
+ memset (reloc_cache, 0, (size_t) count * sizeof (arelent));
cache_ptr = reloc_cache;
{
rptr =
(struct pdp11_aout_reloc_external *)
- ((char *)rptr + RELOC_SIZE);
- if ((char *)rptr >= (char *)relocs + reloc_size)
+ ((char *) rptr + RELOC_SIZE);
+ if ((char *) rptr >= (char *) relocs + reloc_size)
goto done;
}
pdp11_aout_swap_reloc_in (abfd, rptr, cache_ptr,
- (char *)rptr - (char *)relocs,
- symbols, bfd_get_symcount (abfd));
+ (bfd_size_type) ((char *) rptr - (char *) relocs),
+ symbols,
+ (bfd_size_type) bfd_get_symcount (abfd));
}
done:
/* Just in case, if rptr >= relocs + reloc_size should happen
arelent **generic;
unsigned char *native;
unsigned int count = section->reloc_count;
- size_t natsize;
+ bfd_size_type natsize;
#if 0
/* If we're writing an .o file, we must write
if (!native)
return false;
- memset ((PTR)native, 0, natsize);
+ memset ((PTR)native, 0, (size_t) natsize);
generic = section->orelocation;
if (generic != NULL)
}
}
- if (bfd_write ((PTR) native, 1, natsize, abfd) != natsize)
+ if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize)
{
- bfd_release(abfd, native);
+ bfd_release (abfd, native);
return false;
}
bfd_release (abfd, native);
-
return true;
}
return -1;
}
- if (asect->flags & SEC_CONSTRUCTOR)
+ if (asect->flags & SEC_CONSTRUCTOR)
return (sizeof (arelent *) * (asect->reloc_count+1));
if (asect == obj_datasec (abfd))
break;
case bfd_print_symbol_all:
{
- CONST char *section_name = symbol->section->name;
+ const char *section_name = symbol->section->name;
bfd_print_symbol_vandf (abfd, (PTR)file, symbol);
asection *section;
asymbol **symbols;
bfd_vma offset;
- CONST char **filename_ptr;
- CONST char **functionname_ptr;
+ const char **filename_ptr;
+ const char **functionname_ptr;
unsigned int *line_ptr;
{
/* Run down the file looking for the filename, function and linenumber */
asymbol **p;
- CONST char *directory_name = NULL;
- CONST char *main_file_name = NULL;
- CONST char *current_file_name = NULL;
- CONST char *line_file_name = NULL; /* Value of current_file_name at line number. */
+ const char *directory_name = NULL;
+ const char *main_file_name = NULL;
+ const char *current_file_name = NULL;
+ const char *line_file_name = NULL; /* Value of current_file_name at line number. */
bfd_vma low_line_vma = 0;
bfd_vma low_func_vma = 0;
asymbol *func = 0;
adata (abfd).line_buf = buf = NULL;
else
{
- buf = (char *) bfd_malloc (filelen + funclen + 3);
+ buf = (char *) bfd_malloc ((bfd_size_type) filelen + funclen + 3);
adata (abfd).line_buf = buf;
if (buf == NULL)
return false;
if (func)
{
const char *function = func->name;
- char *p;
+ char *colon;
/* The caller expects a symbol name. We actually have a
function name, without the leading underscore. Put the
}
/* Have to remove : stuff. */
- p = strchr (buf, ':');
- if (p != NULL)
- *p = '\0';
+ colon = strchr (buf, ':');
+ if (colon != NULL)
+ *colon = '\0';
*functionname_ptr = buf;
}
bfd *abfd;
{
struct aout_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct aout_link_hash_table);
- ret = ((struct aout_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct aout_link_hash_table)));
+ ret = ((struct aout_link_hash_table *) bfd_alloc (abfd, amt));
if (ret == NULL)
return (struct bfd_link_hash_table *) NULL;
if (! NAME(aout,link_hash_table_init) (ret, abfd,
strings = obj_aout_external_strings (abfd);
for (; p < pend; p++)
{
- int type = bfd_h_get_8 (abfd, p->e_type);
+ int type = H_GET_8 (abfd, p->e_type);
const char *name;
struct bfd_link_hash_entry *h;
should be conditional on info->keep_memory. */
sym_hash = ((struct aout_link_hash_entry **)
bfd_alloc (abfd,
- ((size_t) sym_count
- * sizeof (struct aout_link_hash_entry *))));
+ sym_count * sizeof (struct aout_link_hash_entry *)));
if (sym_hash == NULL && sym_count != 0)
return false;
obj_aout_sym_hashes (abfd) = sym_hash;
*sym_hash = NULL;
- type = bfd_h_get_8 (abfd, p->e_type);
+ type = H_GET_8 (abfd, p->e_type);
#if 0 /* not supported in PDP-11 a.out */
/* Ignore debugging symbols. */
boolean includes_hash_initialized = false;
register bfd *sub;
bfd_size_type trsize, drsize;
- size_t max_contents_size;
- size_t max_relocs_size;
- size_t max_sym_count;
+ bfd_size_type max_contents_size;
+ bfd_size_type max_relocs_size;
+ bfd_size_type max_sym_count;
bfd_size_type text_size;
file_ptr text_end;
register struct bfd_link_order *p;
b = 0;
if (bfd_seek (abfd,
- (obj_datasec (abfd)->filepos
- + exec_hdr (abfd)->a_data
- - 1),
+ (file_ptr) (obj_datasec (abfd)->filepos
+ + exec_hdr (abfd)->a_data
+ - 1),
SEEK_SET) != 0
- || bfd_write (&b, 1, 1, abfd) != 1)
+ || bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1)
goto error_return;
}
false, false) != NULL)
&& discard != discard_all)
{
- bfd_h_put_8 (output_bfd, N_TEXT, outsym->e_type);
+ H_PUT_8 (output_bfd, N_TEXT, outsym->e_type);
strtab_index = add_to_stringtab (output_bfd, finfo->strtab,
input_bfd->filename, false);
if (strtab_index == (bfd_size_type) -1)
sym_end = sym + sym_count;
sym_hash = obj_aout_sym_hashes (input_bfd);
symbol_map = finfo->symbol_map;
- memset (symbol_map, 0, sym_count * sizeof *symbol_map);
+ memset (symbol_map, 0, (size_t) sym_count * sizeof *symbol_map);
for (; sym < sym_end; sym++, sym_hash++, symbol_map++)
{
const char *name;
we do copy the symbol over. */
*symbol_map = -1;
- type = bfd_h_get_8 (input_bfd, sym->e_type);
+ type = H_GET_8 (input_bfd, sym->e_type);
name = strings + GET_WORD (input_bfd, sym->e_strx);
h = NULL;
{
int incl_type;
- incl_type = bfd_h_get_8 (input_bfd, incl_sym->e_type);
+ incl_type = H_GET_8 (input_bfd, incl_sym->e_type);
if (incl_type == N_EINCL)
{
if (nest == 0)
{
int incl_type;
- incl_type = bfd_h_get_8 (input_bfd, incl_sym->e_type);
+ incl_type = H_GET_8 (input_bfd, incl_sym->e_type);
if (incl_type == N_EINCL)
{
if (nest == 0)
/* Copy this symbol into the list of symbols we are going to
write out. */
- bfd_h_put_8 (output_bfd, type, outsym->e_type);
+ H_PUT_8 (output_bfd, type, outsym->e_type);
copy = false;
if (! finfo->info->keep_memory)
{
/* Write out the output symbols we have just constructed. */
if (outsym > finfo->output_syms)
{
- bfd_size_type outsym_count;
+ bfd_size_type size;
if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0)
return false;
- outsym_count = outsym - finfo->output_syms;
- if (bfd_write ((PTR) finfo->output_syms,
- (bfd_size_type) EXTERNAL_NLIST_SIZE,
- (bfd_size_type) outsym_count, output_bfd)
- != outsym_count * EXTERNAL_NLIST_SIZE)
+ size = outsym - finfo->output_syms;
+ size *= EXTERNAL_NLIST_SIZE;
+ if (bfd_bwrite ((PTR) finfo->output_syms, size, output_bfd) != size)
return false;
- finfo->symoff += outsym_count * EXTERNAL_NLIST_SIZE;
+ finfo->symoff += size;
}
return true;
bfd_vma val;
struct external_nlist outsym;
bfd_size_type indx;
+ bfd_size_type amt;
output_bfd = finfo->output_bfd;
return true;
}
- bfd_h_put_8 (output_bfd, type, outsym.e_type);
+ H_PUT_8 (output_bfd, type, outsym.e_type);
indx = add_to_stringtab (output_bfd, finfo->strtab, h->root.root.string,
false);
if (indx == (bfd_size_type) -1)
PUT_WORD (output_bfd, indx, outsym.e_strx);
PUT_WORD (output_bfd, val, outsym.e_value);
+ amt = EXTERNAL_NLIST_SIZE;
if (bfd_seek (output_bfd, finfo->symoff, SEEK_SET) != 0
- || bfd_write ((PTR) &outsym, (bfd_size_type) EXTERNAL_NLIST_SIZE,
- (bfd_size_type) 1, output_bfd) != EXTERNAL_NLIST_SIZE)
+ || bfd_bwrite ((PTR) &outsym, amt, output_bfd) != amt)
{
/* FIXME: No way to handle errors. */
abort ();
}
- finfo->symoff += EXTERNAL_NLIST_SIZE;
+ finfo->symoff += amt;
h->indx = obj_aout_external_sym_count (output_bfd);
++obj_aout_external_sym_count (output_bfd);
if (rel_size > 0)
{
if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
- || bfd_read (relocs, 1, rel_size, input_bfd) != rel_size)
+ || bfd_bread (relocs, rel_size, input_bfd) != rel_size)
return false;
}
}
if (! bfd_set_section_contents (finfo->output_bfd,
input_section->output_section,
(PTR) finfo->contents,
- input_section->output_offset,
+ (file_ptr) input_section->output_offset,
input_size))
return false;
{
if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0)
return false;
- if (bfd_write (relocs, (bfd_size_type) 1, rel_size, finfo->output_bfd)
- != rel_size)
+ if (bfd_bwrite (relocs, rel_size, finfo->output_bfd) != rel_size)
return false;
*reloff_ptr += rel_size;
file_ptr *reloff_ptr;
struct reloc_std_external srel;
PTR rel_ptr;
+ bfd_size_type rel_size;
pr = p->u.reloc.p;
return false;
}
+ rel_size = obj_reloc_entry_size (finfo->output_bfd);
if (bfd_seek (finfo->output_bfd, *reloff_ptr, SEEK_SET) != 0
- || (bfd_write (rel_ptr, (bfd_size_type) 1,
- obj_reloc_entry_size (finfo->output_bfd),
- finfo->output_bfd)
- != obj_reloc_entry_size (finfo->output_bfd)))
+ || bfd_bwrite (rel_ptr, rel_size, finfo->output_bfd) != rel_size)
return false;
- *reloff_ptr += obj_reloc_entry_size (finfo->output_bfd);
+ *reloff_ptr += rel_size;
/* Assert that the relocs have not run into the symbols, and that n
the text relocs have not run into the data relocs. */
{
short x = bfd_get_16 (abfd, addr);
DOIT (x);
- bfd_put_16 (abfd, x, addr);
+ bfd_put_16 (abfd, (bfd_vma) x, addr);
}
break;
{
long x = bfd_get_32 (abfd, addr);
DOIT (x);
- bfd_put_32 (abfd, x, addr);
+ bfd_put_32 (abfd, (bfd_vma) x, addr);
}
break;
RELOC *reloc_src = (RELOC *) src;
struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
- reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
- reloc_dst->r_symndx =
- bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx);
- reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
+ reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr);
+ reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx);
+ reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type);
reloc_dst->r_size = 0;
reloc_dst->r_extern = 0;
reloc_dst->r_offset = 0;
the same address as a REFHI, we assume this is the matching
PAIR reloc and output it accordingly. The symndx is really
the low 16 bits of the addend */
- bfd_h_put_32 (abfd, reloc_src->r_vaddr,
- (bfd_byte *) reloc_dst->r_vaddr);
- bfd_h_put_32 (abfd, reloc_src->r_symndx,
- (bfd_byte *) reloc_dst->r_symndx);
-
- bfd_h_put_16(abfd, MIPS_R_PAIR, (bfd_byte *)
- reloc_dst->r_type);
+ H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
+ H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
+ H_PUT_16 (abfd, MIPS_R_PAIR, reloc_dst->r_type);
return RELSZ;
}
break;
}
- bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
- bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
+ H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
+ H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
- bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
- reloc_dst->r_type);
+ H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type);
return RELSZ;
}
if (ext->e.e_name[0] == 0)
{
in->_n._n_n._n_zeroes = 0;
- in->_n._n_n._n_offset =
- bfd_h_get_32 (abfd, (bfd_byte *) ext->e.e.e_offset);
+ in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset);
}
else
memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN);
- in->n_value = bfd_h_get_32 (abfd, (bfd_byte *) ext->e_value);
- in->n_scnum = bfd_h_get_16 (abfd, (bfd_byte *) ext->e_scnum);
+ in->n_value = H_GET_32 (abfd, ext->e_value);
+ in->n_scnum = H_GET_16 (abfd, ext->e_scnum);
if (sizeof (ext->e_type) == 2)
- in->n_type = bfd_h_get_16 (abfd, (bfd_byte *) ext->e_type);
+ in->n_type = H_GET_16 (abfd, ext->e_type);
else
- in->n_type = bfd_h_get_32 (abfd, (bfd_byte *) ext->e_type);
+ in->n_type = H_GET_32 (abfd, ext->e_type);
- in->n_sclass = bfd_h_get_8 (abfd, ext->e_sclass);
- in->n_numaux = bfd_h_get_8 (abfd, ext->e_numaux);
+ in->n_sclass = H_GET_8 (abfd, ext->e_sclass);
+ in->n_numaux = H_GET_8 (abfd, ext->e_numaux);
#ifndef STRICT_PE_FORMAT
/* This is for Gnu-created DLLs. */
if (unused_section_number <= sec->target_index)
unused_section_number = sec->target_index + 1;
- name = bfd_alloc (abfd, strlen (in->n_name) + 10);
+ name = bfd_alloc (abfd, (bfd_size_type) strlen (in->n_name) + 10);
if (name == NULL)
return;
strcpy (name, in->n_name);
if (in->_n._n_name[0] == 0)
{
- bfd_h_put_32 (abfd, 0, (bfd_byte *) ext->e.e.e_zeroes);
- bfd_h_put_32 (abfd, in->_n._n_n._n_offset, (bfd_byte *) ext->e.e.e_offset);
+ H_PUT_32 (abfd, 0, ext->e.e.e_zeroes);
+ H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e.e.e_offset);
}
else
memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN);
- bfd_h_put_32 (abfd, in->n_value, (bfd_byte *) ext->e_value);
- bfd_h_put_16 (abfd, in->n_scnum, (bfd_byte *) ext->e_scnum);
+ H_PUT_32 (abfd, in->n_value, ext->e_value);
+ H_PUT_16 (abfd, in->n_scnum, ext->e_scnum);
if (sizeof (ext->e_type) == 2)
- bfd_h_put_16 (abfd, in->n_type, (bfd_byte *) ext->e_type);
+ H_PUT_16 (abfd, in->n_type, ext->e_type);
else
- bfd_h_put_32 (abfd, in->n_type, (bfd_byte *) ext->e_type);
+ H_PUT_32 (abfd, in->n_type, ext->e_type);
- bfd_h_put_8 (abfd, in->n_sclass, ext->e_sclass);
- bfd_h_put_8 (abfd, in->n_numaux, ext->e_numaux);
+ H_PUT_8 (abfd, in->n_sclass, ext->e_sclass);
+ H_PUT_8 (abfd, in->n_numaux, ext->e_numaux);
return SYMESZ;
}
if (ext->x_file.x_fname[0] == 0)
{
in->x_file.x_n.x_zeroes = 0;
- in->x_file.x_n.x_offset =
- bfd_h_get_32 (abfd, (bfd_byte *) ext->x_file.x_n.x_offset);
+ in->x_file.x_n.x_offset = H_GET_32 (abfd, ext->x_file.x_n.x_offset);
}
else
memcpy (in->x_file.x_fname, ext->x_file.x_fname, FILNMLEN);
in->x_scn.x_scnlen = GET_SCN_SCNLEN (abfd, ext);
in->x_scn.x_nreloc = GET_SCN_NRELOC (abfd, ext);
in->x_scn.x_nlinno = GET_SCN_NLINNO (abfd, ext);
- in->x_scn.x_checksum =
- bfd_h_get_32 (abfd, (bfd_byte *) ext->x_scn.x_checksum);
- in->x_scn.x_associated =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_scn.x_associated);
- in->x_scn.x_comdat =
- bfd_h_get_8 (abfd, (bfd_byte *) ext->x_scn.x_comdat);
+ in->x_scn.x_checksum = H_GET_32 (abfd, ext->x_scn.x_checksum);
+ in->x_scn.x_associated = H_GET_16 (abfd, ext->x_scn.x_associated);
+ in->x_scn.x_comdat = H_GET_8 (abfd, ext->x_scn.x_comdat);
return;
}
break;
}
- in->x_sym.x_tagndx.l = bfd_h_get_32 (abfd, (bfd_byte *) ext->x_sym.x_tagndx);
- in->x_sym.x_tvndx = bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_tvndx);
+ in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->x_sym.x_tagndx);
+ in->x_sym.x_tvndx = H_GET_16 (abfd, ext->x_sym.x_tvndx);
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
{
else
{
in->x_sym.x_fcnary.x_ary.x_dimen[0] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+ H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
in->x_sym.x_fcnary.x_ary.x_dimen[1] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+ H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
in->x_sym.x_fcnary.x_ary.x_dimen[2] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+ H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
in->x_sym.x_fcnary.x_ary.x_dimen[3] =
- bfd_h_get_16 (abfd, (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+ H_GET_16 (abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
}
if (ISFCN (type))
{
- in->x_sym.x_misc.x_fsize =
- bfd_h_get_32 (abfd, (bfd_byte *) ext->x_sym.x_misc.x_fsize);
+ in->x_sym.x_misc.x_fsize = H_GET_32 (abfd, ext->x_sym.x_misc.x_fsize);
}
else
{
case C_FILE:
if (in->x_file.x_fname[0] == 0)
{
- bfd_h_put_32 (abfd, 0, (bfd_byte *) ext->x_file.x_n.x_zeroes);
- bfd_h_put_32 (abfd,
- in->x_file.x_n.x_offset,
- (bfd_byte *) ext->x_file.x_n.x_offset);
+ H_PUT_32 (abfd, 0, ext->x_file.x_n.x_zeroes);
+ H_PUT_32 (abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
}
else
memcpy (ext->x_file.x_fname, in->x_file.x_fname, FILNMLEN);
PUT_SCN_SCNLEN (abfd, in->x_scn.x_scnlen, ext);
PUT_SCN_NRELOC (abfd, in->x_scn.x_nreloc, ext);
PUT_SCN_NLINNO (abfd, in->x_scn.x_nlinno, ext);
- bfd_h_put_32 (abfd, in->x_scn.x_checksum,
- (bfd_byte *) ext->x_scn.x_checksum);
- bfd_h_put_16 (abfd, in->x_scn.x_associated,
- (bfd_byte *) ext->x_scn.x_associated);
- bfd_h_put_8 (abfd, in->x_scn.x_comdat,
- (bfd_byte *) ext->x_scn.x_comdat);
+ H_PUT_32 (abfd, in->x_scn.x_checksum, ext->x_scn.x_checksum);
+ H_PUT_16 (abfd, in->x_scn.x_associated, ext->x_scn.x_associated);
+ H_PUT_8 (abfd, in->x_scn.x_comdat, ext->x_scn.x_comdat);
return AUXESZ;
}
break;
}
- bfd_h_put_32 (abfd, in->x_sym.x_tagndx.l, (bfd_byte *) ext->x_sym.x_tagndx);
- bfd_h_put_16 (abfd, in->x_sym.x_tvndx, (bfd_byte *) ext->x_sym.x_tvndx);
+ H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->x_sym.x_tagndx);
+ H_PUT_16 (abfd, in->x_sym.x_tvndx, ext->x_sym.x_tvndx);
if (class == C_BLOCK || class == C_FCN || ISFCN (type) || ISTAG (class))
{
}
else
{
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
- bfd_h_put_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
- (bfd_byte *) ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
+ H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],
+ ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
+ H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],
+ ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
+ H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],
+ ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
+ H_PUT_16 (abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],
+ ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
}
if (ISFCN (type))
- bfd_h_put_32 (abfd, in->x_sym.x_misc.x_fsize,
- (bfd_byte *) ext->x_sym.x_misc.x_fsize);
+ H_PUT_32 (abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize);
else
{
PUT_LNSZ_LNNO (abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext);
LINENO *ext = (LINENO *) ext1;
struct internal_lineno *in = (struct internal_lineno *) in1;
- in->l_addr.l_symndx = bfd_h_get_32 (abfd, (bfd_byte *) ext->l_addr.l_symndx);
+ in->l_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx);
in->l_lnno = GET_LINENO_LNNO (abfd, ext);
}
{
struct internal_lineno *in = (struct internal_lineno *) inp;
struct external_lineno *ext = (struct external_lineno *) outp;
- bfd_h_put_32 (abfd, in->l_addr.l_symndx, (bfd_byte *)
- ext->l_addr.l_symndx);
+ H_PUT_32 (abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
PUT_LINENO_LNNO (abfd, in->l_lnno, ext);
return LINESZ;
AOUTHDR *aouthdr_ext = (AOUTHDR *) aouthdr_ext1;
struct internal_aouthdr *aouthdr_int = (struct internal_aouthdr *)aouthdr_int1;
- aouthdr_int->magic = bfd_h_get_16 (abfd, (bfd_byte *) aouthdr_ext->magic);
- aouthdr_int->vstamp = bfd_h_get_16 (abfd, (bfd_byte *) aouthdr_ext->vstamp);
- aouthdr_int->tsize =
- GET_AOUTHDR_TSIZE (abfd, (bfd_byte *) aouthdr_ext->tsize);
- aouthdr_int->dsize =
- GET_AOUTHDR_DSIZE (abfd, (bfd_byte *) aouthdr_ext->dsize);
- aouthdr_int->bsize =
- GET_AOUTHDR_BSIZE (abfd, (bfd_byte *) aouthdr_ext->bsize);
- aouthdr_int->entry =
- GET_AOUTHDR_ENTRY (abfd, (bfd_byte *) aouthdr_ext->entry);
+ aouthdr_int->magic = H_GET_16 (abfd, aouthdr_ext->magic);
+ aouthdr_int->vstamp = H_GET_16 (abfd, aouthdr_ext->vstamp);
+ aouthdr_int->tsize = GET_AOUTHDR_TSIZE (abfd, aouthdr_ext->tsize);
+ aouthdr_int->dsize = GET_AOUTHDR_DSIZE (abfd, aouthdr_ext->dsize);
+ aouthdr_int->bsize = GET_AOUTHDR_BSIZE (abfd, aouthdr_ext->bsize);
+ aouthdr_int->entry = GET_AOUTHDR_ENTRY (abfd, aouthdr_ext->entry);
aouthdr_int->text_start =
- GET_AOUTHDR_TEXT_START (abfd, (bfd_byte *) aouthdr_ext->text_start);
+ GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start);
#ifndef COFF_WITH_pep
/* PE32+ does not have data_start member! */
aouthdr_int->data_start =
- GET_AOUTHDR_DATA_START (abfd, (bfd_byte *) aouthdr_ext->data_start);
+ GET_AOUTHDR_DATA_START (abfd, aouthdr_ext->data_start);
#endif
a = &aouthdr_int->pe;
- a->ImageBase = GET_OPTHDR_IMAGE_BASE (abfd, (bfd_byte *) src->ImageBase);
- a->SectionAlignment = bfd_h_get_32 (abfd, (bfd_byte *) src->SectionAlignment);
- a->FileAlignment = bfd_h_get_32 (abfd, (bfd_byte *) src->FileAlignment);
+ a->ImageBase = GET_OPTHDR_IMAGE_BASE (abfd, src->ImageBase);
+ a->SectionAlignment = H_GET_32 (abfd, src->SectionAlignment);
+ a->FileAlignment = H_GET_32 (abfd, src->FileAlignment);
a->MajorOperatingSystemVersion =
- bfd_h_get_16 (abfd, (bfd_byte *) src->MajorOperatingSystemVersion);
+ H_GET_16 (abfd, src->MajorOperatingSystemVersion);
a->MinorOperatingSystemVersion =
- bfd_h_get_16 (abfd, (bfd_byte *) src->MinorOperatingSystemVersion);
- a->MajorImageVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MajorImageVersion);
- a->MinorImageVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MinorImageVersion);
- a->MajorSubsystemVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MajorSubsystemVersion);
- a->MinorSubsystemVersion = bfd_h_get_16 (abfd, (bfd_byte *) src->MinorSubsystemVersion);
- a->Reserved1 = bfd_h_get_32 (abfd, (bfd_byte *) src->Reserved1);
- a->SizeOfImage = bfd_h_get_32 (abfd, (bfd_byte *) src->SizeOfImage);
- a->SizeOfHeaders = bfd_h_get_32 (abfd, (bfd_byte *) src->SizeOfHeaders);
- a->CheckSum = bfd_h_get_32 (abfd, (bfd_byte *) src->CheckSum);
- a->Subsystem = bfd_h_get_16 (abfd, (bfd_byte *) src->Subsystem);
- a->DllCharacteristics = bfd_h_get_16 (abfd, (bfd_byte *) src->DllCharacteristics);
- a->SizeOfStackReserve = GET_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, (bfd_byte *) src->SizeOfStackReserve);
- a->SizeOfStackCommit = GET_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, (bfd_byte *) src->SizeOfStackCommit);
- a->SizeOfHeapReserve = GET_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, (bfd_byte *) src->SizeOfHeapReserve);
- a->SizeOfHeapCommit = GET_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, (bfd_byte *) src->SizeOfHeapCommit);
- a->LoaderFlags = bfd_h_get_32 (abfd, (bfd_byte *) src->LoaderFlags);
- a->NumberOfRvaAndSizes = bfd_h_get_32 (abfd, (bfd_byte *) src->NumberOfRvaAndSizes);
+ H_GET_16 (abfd, src->MinorOperatingSystemVersion);
+ a->MajorImageVersion = H_GET_16 (abfd, src->MajorImageVersion);
+ a->MinorImageVersion = H_GET_16 (abfd, src->MinorImageVersion);
+ a->MajorSubsystemVersion = H_GET_16 (abfd, src->MajorSubsystemVersion);
+ a->MinorSubsystemVersion = H_GET_16 (abfd, src->MinorSubsystemVersion);
+ a->Reserved1 = H_GET_32 (abfd, src->Reserved1);
+ a->SizeOfImage = H_GET_32 (abfd, src->SizeOfImage);
+ a->SizeOfHeaders = H_GET_32 (abfd, src->SizeOfHeaders);
+ a->CheckSum = H_GET_32 (abfd, src->CheckSum);
+ a->Subsystem = H_GET_16 (abfd, src->Subsystem);
+ a->DllCharacteristics = H_GET_16 (abfd, src->DllCharacteristics);
+ a->SizeOfStackReserve =
+ GET_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, src->SizeOfStackReserve);
+ a->SizeOfStackCommit =
+ GET_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, src->SizeOfStackCommit);
+ a->SizeOfHeapReserve =
+ GET_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, src->SizeOfHeapReserve);
+ a->SizeOfHeapCommit =
+ GET_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, src->SizeOfHeapCommit);
+ a->LoaderFlags = H_GET_32 (abfd, src->LoaderFlags);
+ a->NumberOfRvaAndSizes = H_GET_32 (abfd, src->NumberOfRvaAndSizes);
{
int idx;
{
/* If data directory is empty, rva also should be 0. */
int size =
- bfd_h_get_32 (abfd, (bfd_byte *) src->DataDirectory[idx][1]);
+ H_GET_32 (abfd, src->DataDirectory[idx][1]);
a->DataDirectory[idx].Size = size;
if (size)
a->DataDirectory[idx].VirtualAddress =
- bfd_h_get_32 (abfd, (bfd_byte *) src->DataDirectory[idx][0]);
+ H_GET_32 (abfd, src->DataDirectory[idx][0]);
else
a->DataDirectory[idx].VirtualAddress = 0;
}
}
extra->SizeOfHeaders = abfd->sections->filepos;
- bfd_h_put_16 (abfd, aouthdr_in->magic, (bfd_byte *) aouthdr_out->standard.magic);
+ H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->standard.magic);
#define LINKER_VERSION 256 /* That is, 2.56 */
/* This piece of magic sets the "linker version" field to
LINKER_VERSION. */
- bfd_h_put_16 (abfd,
- LINKER_VERSION / 100 + (LINKER_VERSION % 100) * 256,
- (bfd_byte *) aouthdr_out->standard.vstamp);
-
- PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, (bfd_byte *) aouthdr_out->standard.tsize);
- PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, (bfd_byte *) aouthdr_out->standard.dsize);
- PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, (bfd_byte *) aouthdr_out->standard.bsize);
- PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, (bfd_byte *) aouthdr_out->standard.entry);
+ H_PUT_16 (abfd, (LINKER_VERSION / 100 + (LINKER_VERSION % 100) * 256),
+ aouthdr_out->standard.vstamp);
+
+ PUT_AOUTHDR_TSIZE (abfd, aouthdr_in->tsize, aouthdr_out->standard.tsize);
+ PUT_AOUTHDR_DSIZE (abfd, aouthdr_in->dsize, aouthdr_out->standard.dsize);
+ PUT_AOUTHDR_BSIZE (abfd, aouthdr_in->bsize, aouthdr_out->standard.bsize);
+ PUT_AOUTHDR_ENTRY (abfd, aouthdr_in->entry, aouthdr_out->standard.entry);
PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start,
- (bfd_byte *) aouthdr_out->standard.text_start);
+ aouthdr_out->standard.text_start);
#ifndef COFF_WITH_pep
/* PE32+ does not have data_start member! */
PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start,
- (bfd_byte *) aouthdr_out->standard.data_start);
+ aouthdr_out->standard.data_start);
#endif
- PUT_OPTHDR_IMAGE_BASE (abfd, extra->ImageBase,
- (bfd_byte *) aouthdr_out->ImageBase);
- bfd_h_put_32 (abfd, extra->SectionAlignment,
- (bfd_byte *) aouthdr_out->SectionAlignment);
- bfd_h_put_32 (abfd, extra->FileAlignment,
- (bfd_byte *) aouthdr_out->FileAlignment);
- bfd_h_put_16 (abfd, extra->MajorOperatingSystemVersion,
- (bfd_byte *) aouthdr_out->MajorOperatingSystemVersion);
- bfd_h_put_16 (abfd, extra->MinorOperatingSystemVersion,
- (bfd_byte *) aouthdr_out->MinorOperatingSystemVersion);
- bfd_h_put_16 (abfd, extra->MajorImageVersion,
- (bfd_byte *) aouthdr_out->MajorImageVersion);
- bfd_h_put_16 (abfd, extra->MinorImageVersion,
- (bfd_byte *) aouthdr_out->MinorImageVersion);
- bfd_h_put_16 (abfd, extra->MajorSubsystemVersion,
- (bfd_byte *) aouthdr_out->MajorSubsystemVersion);
- bfd_h_put_16 (abfd, extra->MinorSubsystemVersion,
- (bfd_byte *) aouthdr_out->MinorSubsystemVersion);
- bfd_h_put_32 (abfd, extra->Reserved1,
- (bfd_byte *) aouthdr_out->Reserved1);
- bfd_h_put_32 (abfd, extra->SizeOfImage,
- (bfd_byte *) aouthdr_out->SizeOfImage);
- bfd_h_put_32 (abfd, extra->SizeOfHeaders,
- (bfd_byte *) aouthdr_out->SizeOfHeaders);
- bfd_h_put_32 (abfd, extra->CheckSum,
- (bfd_byte *) aouthdr_out->CheckSum);
- bfd_h_put_16 (abfd, extra->Subsystem,
- (bfd_byte *) aouthdr_out->Subsystem);
- bfd_h_put_16 (abfd, extra->DllCharacteristics,
- (bfd_byte *) aouthdr_out->DllCharacteristics);
+ PUT_OPTHDR_IMAGE_BASE (abfd, extra->ImageBase, aouthdr_out->ImageBase);
+ H_PUT_32 (abfd, extra->SectionAlignment, aouthdr_out->SectionAlignment);
+ H_PUT_32 (abfd, extra->FileAlignment, aouthdr_out->FileAlignment);
+ H_PUT_16 (abfd, extra->MajorOperatingSystemVersion,
+ aouthdr_out->MajorOperatingSystemVersion);
+ H_PUT_16 (abfd, extra->MinorOperatingSystemVersion,
+ aouthdr_out->MinorOperatingSystemVersion);
+ H_PUT_16 (abfd, extra->MajorImageVersion, aouthdr_out->MajorImageVersion);
+ H_PUT_16 (abfd, extra->MinorImageVersion, aouthdr_out->MinorImageVersion);
+ H_PUT_16 (abfd, extra->MajorSubsystemVersion,
+ aouthdr_out->MajorSubsystemVersion);
+ H_PUT_16 (abfd, extra->MinorSubsystemVersion,
+ aouthdr_out->MinorSubsystemVersion);
+ H_PUT_32 (abfd, extra->Reserved1, aouthdr_out->Reserved1);
+ H_PUT_32 (abfd, extra->SizeOfImage, aouthdr_out->SizeOfImage);
+ H_PUT_32 (abfd, extra->SizeOfHeaders, aouthdr_out->SizeOfHeaders);
+ H_PUT_32 (abfd, extra->CheckSum, aouthdr_out->CheckSum);
+ H_PUT_16 (abfd, extra->Subsystem, aouthdr_out->Subsystem);
+ H_PUT_16 (abfd, extra->DllCharacteristics, aouthdr_out->DllCharacteristics);
PUT_OPTHDR_SIZE_OF_STACK_RESERVE (abfd, extra->SizeOfStackReserve,
- (bfd_byte *) aouthdr_out->SizeOfStackReserve);
+ aouthdr_out->SizeOfStackReserve);
PUT_OPTHDR_SIZE_OF_STACK_COMMIT (abfd, extra->SizeOfStackCommit,
- (bfd_byte *) aouthdr_out->SizeOfStackCommit);
+ aouthdr_out->SizeOfStackCommit);
PUT_OPTHDR_SIZE_OF_HEAP_RESERVE (abfd, extra->SizeOfHeapReserve,
- (bfd_byte *) aouthdr_out->SizeOfHeapReserve);
+ aouthdr_out->SizeOfHeapReserve);
PUT_OPTHDR_SIZE_OF_HEAP_COMMIT (abfd, extra->SizeOfHeapCommit,
- (bfd_byte *) aouthdr_out->SizeOfHeapCommit);
- bfd_h_put_32 (abfd, extra->LoaderFlags,
- (bfd_byte *) aouthdr_out->LoaderFlags);
- bfd_h_put_32 (abfd, extra->NumberOfRvaAndSizes,
- (bfd_byte *) aouthdr_out->NumberOfRvaAndSizes);
+ aouthdr_out->SizeOfHeapCommit);
+ H_PUT_32 (abfd, extra->LoaderFlags, aouthdr_out->LoaderFlags);
+ H_PUT_32 (abfd, extra->NumberOfRvaAndSizes,
+ aouthdr_out->NumberOfRvaAndSizes);
{
int idx;
for (idx = 0; idx < 16; idx++)
{
- bfd_h_put_32 (abfd, extra->DataDirectory[idx].VirtualAddress,
- (bfd_byte *) aouthdr_out->DataDirectory[idx][0]);
- bfd_h_put_32 (abfd, extra->DataDirectory[idx].Size,
- (bfd_byte *) aouthdr_out->DataDirectory[idx][1]);
+ H_PUT_32 (abfd, extra->DataDirectory[idx].VirtualAddress,
+ aouthdr_out->DataDirectory[idx][0]);
+ H_PUT_32 (abfd, extra->DataDirectory[idx].Size,
+ aouthdr_out->DataDirectory[idx][1]);
}
}
filehdr_in->pe.dos_message[15] = 0x0;
filehdr_in->pe.nt_signature = NT_SIGNATURE;
- bfd_h_put_16 (abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
- bfd_h_put_16 (abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
+ H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic);
+ H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
- bfd_h_put_32 (abfd, time (0), (bfd_byte *) filehdr_out->f_timdat);
- PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
- (bfd_byte *) filehdr_out->f_symptr);
- bfd_h_put_32 (abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
- bfd_h_put_16 (abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
- bfd_h_put_16 (abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
+ H_PUT_32 (abfd, time (0), filehdr_out->f_timdat);
+ PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr,
+ filehdr_out->f_symptr);
+ H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
+ H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
+ H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags);
/* Put in extra dos header stuff. This data remains essentially
constant, it just has to be tacked on to the beginning of all exes
for NT. */
- bfd_h_put_16 (abfd, filehdr_in->pe.e_magic, (bfd_byte *) filehdr_out->e_magic);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_cblp, (bfd_byte *) filehdr_out->e_cblp);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_cp, (bfd_byte *) filehdr_out->e_cp);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_crlc, (bfd_byte *) filehdr_out->e_crlc);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_cparhdr,
- (bfd_byte *) filehdr_out->e_cparhdr);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_minalloc,
- (bfd_byte *) filehdr_out->e_minalloc);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_maxalloc,
- (bfd_byte *) filehdr_out->e_maxalloc);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_ss, (bfd_byte *) filehdr_out->e_ss);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_sp, (bfd_byte *) filehdr_out->e_sp);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_csum, (bfd_byte *) filehdr_out->e_csum);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_ip, (bfd_byte *) filehdr_out->e_ip);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_cs, (bfd_byte *) filehdr_out->e_cs);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_lfarlc, (bfd_byte *) filehdr_out->e_lfarlc);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_ovno, (bfd_byte *) filehdr_out->e_ovno);
+ H_PUT_16 (abfd, filehdr_in->pe.e_magic, filehdr_out->e_magic);
+ H_PUT_16 (abfd, filehdr_in->pe.e_cblp, filehdr_out->e_cblp);
+ H_PUT_16 (abfd, filehdr_in->pe.e_cp, filehdr_out->e_cp);
+ H_PUT_16 (abfd, filehdr_in->pe.e_crlc, filehdr_out->e_crlc);
+ H_PUT_16 (abfd, filehdr_in->pe.e_cparhdr, filehdr_out->e_cparhdr);
+ H_PUT_16 (abfd, filehdr_in->pe.e_minalloc, filehdr_out->e_minalloc);
+ H_PUT_16 (abfd, filehdr_in->pe.e_maxalloc, filehdr_out->e_maxalloc);
+ H_PUT_16 (abfd, filehdr_in->pe.e_ss, filehdr_out->e_ss);
+ H_PUT_16 (abfd, filehdr_in->pe.e_sp, filehdr_out->e_sp);
+ H_PUT_16 (abfd, filehdr_in->pe.e_csum, filehdr_out->e_csum);
+ H_PUT_16 (abfd, filehdr_in->pe.e_ip, filehdr_out->e_ip);
+ H_PUT_16 (abfd, filehdr_in->pe.e_cs, filehdr_out->e_cs);
+ H_PUT_16 (abfd, filehdr_in->pe.e_lfarlc, filehdr_out->e_lfarlc);
+ H_PUT_16 (abfd, filehdr_in->pe.e_ovno, filehdr_out->e_ovno);
for (idx = 0; idx < 4; idx++)
- bfd_h_put_16 (abfd, filehdr_in->pe.e_res[idx],
- (bfd_byte *) filehdr_out->e_res[idx]);
+ H_PUT_16 (abfd, filehdr_in->pe.e_res[idx], filehdr_out->e_res[idx]);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_oemid, (bfd_byte *) filehdr_out->e_oemid);
- bfd_h_put_16 (abfd, filehdr_in->pe.e_oeminfo,
- (bfd_byte *) filehdr_out->e_oeminfo);
+ H_PUT_16 (abfd, filehdr_in->pe.e_oemid, filehdr_out->e_oemid);
+ H_PUT_16 (abfd, filehdr_in->pe.e_oeminfo, filehdr_out->e_oeminfo);
for (idx = 0; idx < 10; idx++)
- bfd_h_put_16 (abfd, filehdr_in->pe.e_res2[idx],
- (bfd_byte *) filehdr_out->e_res2[idx]);
+ H_PUT_16 (abfd, filehdr_in->pe.e_res2[idx], filehdr_out->e_res2[idx]);
- bfd_h_put_32 (abfd, filehdr_in->pe.e_lfanew, (bfd_byte *) filehdr_out->e_lfanew);
+ H_PUT_32 (abfd, filehdr_in->pe.e_lfanew, filehdr_out->e_lfanew);
for (idx = 0; idx < 16; idx++)
- bfd_h_put_32 (abfd, filehdr_in->pe.dos_message[idx],
- (bfd_byte *) filehdr_out->dos_message[idx]);
+ H_PUT_32 (abfd, filehdr_in->pe.dos_message[idx],
+ filehdr_out->dos_message[idx]);
/* Also put in the NT signature. */
- bfd_h_put_32 (abfd, filehdr_in->pe.nt_signature,
- (bfd_byte *) filehdr_out->nt_signature);
+ H_PUT_32 (abfd, filehdr_in->pe.nt_signature, filehdr_out->nt_signature);
return FILHSZ;
}
struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in;
FILHDR *filehdr_out = (FILHDR *) out;
- bfd_h_put_16 (abfd, filehdr_in->f_magic, (bfd_byte *) filehdr_out->f_magic);
- bfd_h_put_16 (abfd, filehdr_in->f_nscns, (bfd_byte *) filehdr_out->f_nscns);
- bfd_h_put_32 (abfd, filehdr_in->f_timdat, (bfd_byte *) filehdr_out->f_timdat);
- PUT_FILEHDR_SYMPTR (abfd, (bfd_vma) filehdr_in->f_symptr,
- (bfd_byte *) filehdr_out->f_symptr);
- bfd_h_put_32 (abfd, filehdr_in->f_nsyms, (bfd_byte *) filehdr_out->f_nsyms);
- bfd_h_put_16 (abfd, filehdr_in->f_opthdr, (bfd_byte *) filehdr_out->f_opthdr);
- bfd_h_put_16 (abfd, filehdr_in->f_flags, (bfd_byte *) filehdr_out->f_flags);
+ H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->f_magic);
+ H_PUT_16 (abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
+ H_PUT_32 (abfd, filehdr_in->f_timdat, filehdr_out->f_timdat);
+ PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, filehdr_out->f_symptr);
+ H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
+ H_PUT_16 (abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
+ H_PUT_16 (abfd, filehdr_in->f_flags, filehdr_out->f_flags);
return FILHSZ;
}
((scnhdr_int->s_vaddr
- pe_data (abfd)->pe_opthdr.ImageBase)
& 0xffffffff),
- (bfd_byte *) scnhdr_ext->s_vaddr);
+ scnhdr_ext->s_vaddr);
/* NT wants the size data to be rounded up to the next
NT_FILE_ALIGNMENT, but zero if it has no content (as in .bss,
}
PUT_SCNHDR_SIZE (abfd, ss,
- (bfd_byte *) scnhdr_ext->s_size);
+ scnhdr_ext->s_size);
/* s_paddr in PE is really the virtual size. */
- PUT_SCNHDR_PADDR (abfd, ps, (bfd_byte *) scnhdr_ext->s_paddr);
+ PUT_SCNHDR_PADDR (abfd, ps, scnhdr_ext->s_paddr);
PUT_SCNHDR_SCNPTR (abfd, scnhdr_int->s_scnptr,
- (bfd_byte *) scnhdr_ext->s_scnptr);
+ scnhdr_ext->s_scnptr);
PUT_SCNHDR_RELPTR (abfd, scnhdr_int->s_relptr,
- (bfd_byte *) scnhdr_ext->s_relptr);
+ scnhdr_ext->s_relptr);
PUT_SCNHDR_LNNOPTR (abfd, scnhdr_int->s_lnnoptr,
- (bfd_byte *) scnhdr_ext->s_lnnoptr);
+ scnhdr_ext->s_lnnoptr);
/* Extra flags must be set when dealing with NT. All sections should also
have the IMAGE_SCN_MEM_READ (0x40000000) flag set. In addition, the
{
int flags = scnhdr_int->s_flags;
- bfd_h_put_32 (abfd, flags, (bfd_byte *) scnhdr_ext->s_flags);
+ H_PUT_32 (abfd, flags, scnhdr_ext->s_flags);
}
if (coff_data (abfd)->link_info
executables, but the 17-th bit has been observed to be there.
Overflow is not an issue: a 4G-line program will overflow a
bunch of other fields long before this! */
- bfd_h_put_16 (abfd, scnhdr_int->s_nlnno & 0xffff,
- (bfd_byte *) scnhdr_ext->s_nlnno);
- bfd_h_put_16 (abfd, scnhdr_int->s_nlnno >> 16,
- (bfd_byte *) scnhdr_ext->s_nreloc);
+ H_PUT_16 (abfd, (scnhdr_int->s_nlnno & 0xffff), scnhdr_ext->s_nlnno);
+ H_PUT_16 (abfd, (scnhdr_int->s_nlnno >> 16), scnhdr_ext->s_nreloc);
}
else
{
if (scnhdr_int->s_nlnno <= 0xffff)
- bfd_h_put_16 (abfd, scnhdr_int->s_nlnno,
- (bfd_byte *) scnhdr_ext->s_nlnno);
+ H_PUT_16 (abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
else
{
(*_bfd_error_handler) (_("%s: line number overflow: 0x%lx > 0xffff"),
bfd_get_filename (abfd),
scnhdr_int->s_nlnno);
bfd_set_error (bfd_error_file_truncated);
- bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nlnno);
+ H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nlnno);
ret = 0;
}
if (scnhdr_int->s_nreloc <= 0xffff)
- bfd_h_put_16 (abfd, scnhdr_int->s_nreloc,
- (bfd_byte *) scnhdr_ext->s_nreloc);
+ H_PUT_16 (abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
else
{
/* PE can deal with large #s of relocs, but not here. */
- bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
+ H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nreloc);
scnhdr_int->s_flags |= IMAGE_SCN_LNK_NRELOC_OVFL;
- bfd_h_put_32 (abfd, scnhdr_int->s_flags,
- (bfd_byte *) scnhdr_ext->s_flags);
+ H_PUT_32 (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
#if 0
(*_bfd_error_handler) (_("%s: reloc overflow 1: 0x%lx > 0xffff"),
bfd_get_filename (abfd),
scnhdr_int->s_nreloc);
bfd_set_error (bfd_error_file_truncated);
- bfd_h_put_16 (abfd, 0xffff, (bfd_byte *) scnhdr_ext->s_nreloc);
+ H_PUT_16 (abfd, 0xffff, scnhdr_ext->s_nreloc);
ret = 0;
#endif
}
bfd_size_type datasize = 0;
bfd_size_type dataoff;
bfd_size_type i;
+ bfd_size_type amt;
int onaline = 20;
pe_data_type *pe = pe_data (abfd);
bfd_byte *data = 0;
int offset;
- data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd,
- rel_section));
- if (data == NULL && bfd_section_size (abfd, rel_section) != 0)
+ amt = bfd_section_size (abfd, rel_section);
+ data = (bfd_byte *) bfd_malloc (amt);
+ if (data == NULL && amt != 0)
return false;
- bfd_get_section_contents (abfd,
- rel_section,
- (PTR) data, 0,
- bfd_section_size (abfd, rel_section));
+ bfd_get_section_contents (abfd, rel_section, (PTR) data, (bfd_vma) 0,
+ amt);
offset = abfd->start_address - rel_section->vma;
fprintf (file,
_(" Table Stamp Chain Name Thunk\n"));
- data = (bfd_byte *) bfd_malloc (dataoff + datasize);
+ amt = dataoff + datasize;
+ data = (bfd_byte *) bfd_malloc (amt);
if (data == NULL)
return false;
/* Read the whole section. Some of the fields might be before dataoff. */
- if (! bfd_get_section_contents (abfd, section, (PTR) data,
- 0, dataoff + datasize))
+ if (! bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0, amt))
return false;
adj = section->vma - extra->ImageBase;
if (data == NULL)
return false;
- if (! bfd_get_section_contents (abfd, section, (PTR) data, dataoff,
- datasize))
+ if (! bfd_get_section_contents (abfd, section, (PTR) data,
+ (file_ptr) dataoff, datasize))
return false;
/* Go get Export Directory Table. */
_(" \t\tAddress Address Handler Data Address Mask\n"));
#endif
- if (bfd_section_size (abfd, section) == 0)
+ datasize = bfd_section_size (abfd, section);
+ if (datasize == 0)
return true;
- data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
- datasize = bfd_section_size (abfd, section);
+ data = (bfd_byte *) bfd_malloc (datasize);
if (data == NULL && datasize != 0)
return false;
- bfd_get_section_contents (abfd,
- section,
- (PTR) data, 0,
- bfd_section_size (abfd, section));
+ bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0,
+ datasize);
start = 0;
FILE *file = (FILE *) vfile;
bfd_byte *data = 0;
asection *section = bfd_get_section_by_name (abfd, ".reloc");
- bfd_size_type datasize = 0;
+ bfd_size_type datasize;
bfd_size_type i;
bfd_size_type start, stop;
fprintf (file,
_("\n\nPE File Base Relocations (interpreted .reloc section contents)\n"));
- data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
datasize = bfd_section_size (abfd, section);
+ data = (bfd_byte *) bfd_malloc (datasize);
if (data == NULL && datasize != 0)
return false;
- bfd_get_section_contents (abfd,
- section,
- (PTR) data, 0,
- bfd_section_size (abfd, section));
+ bfd_get_section_contents (abfd, section, (PTR) data, (bfd_vma) 0,
+ datasize);
start = 0;
{
if (coff_section_data (obfd, osec) == NULL)
{
- osec->used_by_bfd =
- (PTR) bfd_zalloc (obfd, sizeof (struct coff_section_tdata));
+ bfd_size_type amt = sizeof (struct coff_section_tdata);
+ osec->used_by_bfd = (PTR) bfd_zalloc (obfd, amt);
if (osec->used_by_bfd == NULL)
return false;
}
if (pei_section_data (obfd, osec) == NULL)
{
- coff_section_data (obfd, osec)->tdata =
- (PTR) bfd_zalloc (obfd, sizeof (struct pei_section_tdata));
+ bfd_size_type amt = sizeof (struct pei_section_tdata);
+ coff_section_data (obfd, osec)->tdata = (PTR) bfd_zalloc (obfd, amt);
if (coff_section_data (obfd, osec)->tdata == NULL)
return false;
}
static void pe_ILF_make_a_symbol PARAMS ((pe_ILF_vars *, const char *, const char *, asection_ptr, flagword));
static void pe_ILF_save_relocs PARAMS ((pe_ILF_vars *, asection_ptr));
static void pe_ILF_make_a_symbol_reloc PARAMS ((pe_ILF_vars *, bfd_vma, bfd_reloc_code_real_type, struct symbol_cache_entry **, unsigned int));
-static boolean pe_ILF_build_a_bfd PARAMS ((bfd *, unsigned short, bfd_byte *, bfd_byte *, unsigned int, unsigned int));
+static boolean pe_ILF_build_a_bfd PARAMS ((bfd *, unsigned int, bfd_byte *, bfd_byte *, unsigned int, unsigned int));
static const bfd_target * pe_ILF_object_p PARAMS ((bfd *));
static const bfd_target * pe_bfd_object_p PARAMS ((bfd *));
#endif /* COFF_IMAGE_WITH_PE */
RELOC *reloc_src = (RELOC *) src;
struct internal_reloc *reloc_dst = (struct internal_reloc *) dst;
- reloc_dst->r_vaddr = bfd_h_get_32(abfd, (bfd_byte *)reloc_src->r_vaddr);
- reloc_dst->r_symndx = bfd_h_get_signed_32(abfd, (bfd_byte *) reloc_src->r_symndx);
+ reloc_dst->r_vaddr = H_GET_32 (abfd, reloc_src->r_vaddr);
+ reloc_dst->r_symndx = H_GET_S32 (abfd, reloc_src->r_symndx);
- reloc_dst->r_type = bfd_h_get_16(abfd, (bfd_byte *) reloc_src->r_type);
+ reloc_dst->r_type = H_GET_16 (abfd, reloc_src->r_type);
#ifdef SWAP_IN_RELOC_OFFSET
- reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET(abfd,
- (bfd_byte *) reloc_src->r_offset);
+ reloc_dst->r_offset = SWAP_IN_RELOC_OFFSET (abfd, reloc_src->r_offset);
#endif
}
{
struct internal_reloc *reloc_src = (struct internal_reloc *)src;
struct external_reloc *reloc_dst = (struct external_reloc *)dst;
- bfd_h_put_32(abfd, reloc_src->r_vaddr, (bfd_byte *) reloc_dst->r_vaddr);
- bfd_h_put_32(abfd, reloc_src->r_symndx, (bfd_byte *) reloc_dst->r_symndx);
+ H_PUT_32 (abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
+ H_PUT_32 (abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
- bfd_h_put_16(abfd, reloc_src->r_type, (bfd_byte *)
- reloc_dst->r_type);
+ H_PUT_16 (abfd, reloc_src->r_type, reloc_dst->r_type);
#ifdef SWAP_OUT_RELOC_OFFSET
- SWAP_OUT_RELOC_OFFSET(abfd,
- reloc_src->r_offset,
- (bfd_byte *) reloc_dst->r_offset);
+ SWAP_OUT_RELOC_OFFSET (abfd, reloc_src->r_offset, reloc_dst->r_offset);
#endif
#ifdef SWAP_OUT_RELOC_EXTRA
- SWAP_OUT_RELOC_EXTRA(abfd,reloc_src, reloc_dst);
+ SWAP_OUT_RELOC_EXTRA(abfd, reloc_src, reloc_dst);
#endif
return RELSZ;
}
{
FILHDR *filehdr_src = (FILHDR *) src;
struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst;
- filehdr_dst->f_magic = bfd_h_get_16(abfd, (bfd_byte *) filehdr_src->f_magic);
- filehdr_dst->f_nscns = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_nscns);
- filehdr_dst->f_timdat = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_timdat);
+ filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->f_magic);
+ filehdr_dst->f_nscns = H_GET_16 (abfd, filehdr_src-> f_nscns);
+ filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src-> f_timdat);
- filehdr_dst->f_nsyms = bfd_h_get_32(abfd, (bfd_byte *)filehdr_src-> f_nsyms);
- filehdr_dst->f_flags = bfd_h_get_16(abfd, (bfd_byte *)filehdr_src-> f_flags);
- filehdr_dst->f_symptr = bfd_h_get_32 (abfd, (bfd_byte *) filehdr_src->f_symptr);
+ filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src-> f_nsyms);
+ filehdr_dst->f_flags = H_GET_16 (abfd, filehdr_src-> f_flags);
+ filehdr_dst->f_symptr = H_GET_32 (abfd, filehdr_src->f_symptr);
/* Other people's tools sometimes generate headers with an nsyms but
a zero symptr. */
filehdr_dst->f_flags |= F_LSYMS;
}
- filehdr_dst->f_opthdr = bfd_h_get_16(abfd,
- (bfd_byte *)filehdr_src-> f_opthdr);
+ filehdr_dst->f_opthdr = H_GET_16 (abfd, filehdr_src-> f_opthdr);
}
#ifdef COFF_IMAGE_WITH_PE
struct internal_scnhdr *scnhdr_int = (struct internal_scnhdr *) in;
memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof (scnhdr_int->s_name));
- scnhdr_int->s_vaddr =
- GET_SCNHDR_VADDR (abfd, (bfd_byte *) scnhdr_ext->s_vaddr);
- scnhdr_int->s_paddr =
- GET_SCNHDR_PADDR (abfd, (bfd_byte *) scnhdr_ext->s_paddr);
- scnhdr_int->s_size =
- GET_SCNHDR_SIZE (abfd, (bfd_byte *) scnhdr_ext->s_size);
- scnhdr_int->s_scnptr =
- GET_SCNHDR_SCNPTR (abfd, (bfd_byte *) scnhdr_ext->s_scnptr);
- scnhdr_int->s_relptr =
- GET_SCNHDR_RELPTR (abfd, (bfd_byte *) scnhdr_ext->s_relptr);
- scnhdr_int->s_lnnoptr =
- GET_SCNHDR_LNNOPTR (abfd, (bfd_byte *) scnhdr_ext->s_lnnoptr);
- scnhdr_int->s_flags = bfd_h_get_32(abfd, (bfd_byte *) scnhdr_ext->s_flags);
+ scnhdr_int->s_vaddr = GET_SCNHDR_VADDR (abfd, scnhdr_ext->s_vaddr);
+ scnhdr_int->s_paddr = GET_SCNHDR_PADDR (abfd, scnhdr_ext->s_paddr);
+ scnhdr_int->s_size = GET_SCNHDR_SIZE (abfd, scnhdr_ext->s_size);
+ scnhdr_int->s_scnptr = GET_SCNHDR_SCNPTR (abfd, scnhdr_ext->s_scnptr);
+ scnhdr_int->s_relptr = GET_SCNHDR_RELPTR (abfd, scnhdr_ext->s_relptr);
+ scnhdr_int->s_lnnoptr = GET_SCNHDR_LNNOPTR (abfd, scnhdr_ext->s_lnnoptr);
+ scnhdr_int->s_flags = H_GET_32 (abfd, scnhdr_ext->s_flags);
/* MS handles overflow of line numbers by carrying into the reloc
field (it appears). Since it's supposed to be zero for PE
*IMAGE* format, that's safe. This is still a bit iffy. */
#ifdef COFF_IMAGE_WITH_PE
- scnhdr_int->s_nlnno =
- (bfd_h_get_16 (abfd, (bfd_byte *) scnhdr_ext->s_nlnno)
- + (bfd_h_get_16 (abfd, (bfd_byte *) scnhdr_ext->s_nreloc) << 16));
+ scnhdr_int->s_nlnno = (H_GET_16 (abfd, scnhdr_ext->s_nlnno)
+ + (H_GET_16 (abfd, scnhdr_ext->s_nreloc) << 16));
scnhdr_int->s_nreloc = 0;
#else
- scnhdr_int->s_nreloc = bfd_h_get_16 (abfd,
- (bfd_byte *) scnhdr_ext->s_nreloc);
- scnhdr_int->s_nlnno = bfd_h_get_16 (abfd,
- (bfd_byte *) scnhdr_ext->s_nlnno);
+ scnhdr_int->s_nreloc = H_GET_16 (abfd, scnhdr_ext->s_nreloc);
+ scnhdr_int->s_nlnno = H_GET_16 (abfd, scnhdr_ext->s_nlnno);
#endif
if (scnhdr_int->s_vaddr != 0)
bfd * abfd;
{
pe_data_type *pe;
- abfd->tdata.pe_obj_data =
- (struct pe_tdata *) bfd_zalloc (abfd, sizeof (pe_data_type));
+ bfd_size_type amt = sizeof (pe_data_type);
+
+ abfd->tdata.pe_obj_data = (struct pe_tdata *) bfd_zalloc (abfd, amt);
if (abfd->tdata.pe_obj_data == 0)
return false;
vars->int_reltab += vars->relcount;
vars->relcount = 0;
- BFD_ASSERT ((bfd_byte *)vars->int_reltab < (bfd_byte *)vars->string_table);
+ BFD_ASSERT ((bfd_byte *) vars->int_reltab < (bfd_byte *) vars->string_table);
}
/* Create a global symbol and add it to the relevant tables. */
section = (asection_ptr) & bfd_und_section;
/* Initialise the external symbol. */
- bfd_h_put_32 (vars->abfd, vars->string_ptr - vars->string_table, (bfd_byte *) esym->e.e.e_offset);
- bfd_h_put_16 (vars->abfd, section->target_index, (bfd_byte *) esym->e_scnum);
+ H_PUT_32 (vars->abfd, vars->string_ptr - vars->string_table,
+ esym->e.e.e_offset);
+ H_PUT_16 (vars->abfd, section->target_index, esym->e_scnum);
esym->e_sclass[0] = sclass;
/* The following initialisations are unnecessary - the memory is
/* Set the section size and contents. The actual
contents are filled in by our parent. */
- bfd_set_section_size (vars->abfd, sec, size);
+ bfd_set_section_size (vars->abfd, sec, (bfd_size_type) size);
sec->contents = vars->data;
sec->target_index = vars->sec_index ++;
/* Build a full BFD from the information supplied in a ILF object. */
static boolean
pe_ILF_build_a_bfd (bfd * abfd,
- unsigned short magic,
+ unsigned int magic,
bfd_byte * symbol_name,
bfd_byte * source_dll,
unsigned int ordinal,
We are going to construct the contents of the BFD in memory,
so allocate all the space that we will need right now. */
- ptr = bfd_zalloc (abfd, ILF_DATA_SIZE);
+ ptr = bfd_zalloc (abfd, (bfd_size_type) ILF_DATA_SIZE);
if (ptr == NULL)
return false;
if (import_name_type != IMPORT_ORDINAL)
{
- pe_ILF_make_a_reloc (& vars, 0, BFD_RELOC_RVA, id6);
- pe_ILF_save_relocs (& vars, id4);
+ pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6);
+ pe_ILF_save_relocs (&vars, id4);
- pe_ILF_make_a_reloc (& vars, 0, BFD_RELOC_RVA, id6);
- pe_ILF_save_relocs (& vars, id5);
+ pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_RVA, id6);
+ pe_ILF_save_relocs (&vars, id5);
}
/* Create extra sections depending upon the type of import we are dealing with. */
#ifdef MIPS_ARCH_MAGIC_WINCE
if (magic == MIPS_ARCH_MAGIC_WINCE)
{
- pe_ILF_make_a_symbol_reloc (& vars, 0, BFD_RELOC_HI16_S,
- (struct symbol_cache_entry **) imp_sym, imp_index);
- pe_ILF_make_a_reloc (& vars, 0, BFD_RELOC_LO16, text);
- pe_ILF_make_a_symbol_reloc (& vars, 4, BFD_RELOC_LO16,
- (struct symbol_cache_entry **) imp_sym, imp_index);
+ pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 0, BFD_RELOC_HI16_S,
+ (struct symbol_cache_entry **) imp_sym,
+ imp_index);
+ pe_ILF_make_a_reloc (&vars, (bfd_vma) 0, BFD_RELOC_LO16, text);
+ pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) 4, BFD_RELOC_LO16,
+ (struct symbol_cache_entry **) imp_sym,
+ imp_index);
}
else
#endif
- pe_ILF_make_a_symbol_reloc (& vars, jtab[i].offset, BFD_RELOC_32,
- (asymbol **) imp_sym, imp_index);
+ pe_ILF_make_a_symbol_reloc (&vars, (bfd_vma) jtab[i].offset,
+ BFD_RELOC_32, (asymbol **) imp_sym,
+ imp_index);
pe_ILF_save_relocs (& vars, text);
break;
internal_f.f_nsyms = 0;
internal_f.f_flags = F_AR32WR | F_LNNO; /* XXX is this correct ? */
- if ( ! bfd_set_start_address (abfd, 0)
+ if ( ! bfd_set_start_address (abfd, (bfd_vma) 0)
|| ! bfd_coff_set_arch_mach_hook (abfd, & internal_f))
return false;
/* Now create a symbol describing the imported value. */
switch (import_type)
{
- bfd_byte * ptr;
-
case IMPORT_CODE:
pe_ILF_make_a_symbol (& vars, "", symbol_name, text,
BSF_NOT_AT_END | BSF_FUNCTION);
bfd_byte * symbol_name;
bfd_byte * source_dll;
unsigned int machine;
- unsigned long size;
+ bfd_size_type size;
unsigned int ordinal;
unsigned int types;
- unsigned short magic;
+ unsigned int magic;
/* Upon entry the first four buyes of the ILF header have
already been read. Now read the rest of the header. */
- if (bfd_read (buffer, 1, 16, abfd) != 16)
+ if (bfd_bread (buffer, (bfd_size_type) 16, abfd) != 16)
return NULL;
ptr = buffer;
/* We do not bother to check the version number.
- version = bfd_h_get_16 (abfd, ptr); */
+ version = H_GET_16 (abfd, ptr); */
ptr += 2;
- machine = bfd_h_get_16 (abfd, ptr);
+ machine = H_GET_16 (abfd, ptr);
ptr += 2;
/* Check that the machine type is recognised. */
}
/* We do not bother to check the date.
- date = bfd_h_get_32 (abfd, ptr); */
+ date = H_GET_32 (abfd, ptr); */
ptr += 4;
- size = bfd_h_get_32 (abfd, ptr);
+ size = H_GET_32 (abfd, ptr);
ptr += 4;
if (size == 0)
return NULL;
}
- ordinal = bfd_h_get_16 (abfd, ptr);
+ ordinal = H_GET_16 (abfd, ptr);
ptr += 2;
- types = bfd_h_get_16 (abfd, ptr);
+ types = H_GET_16 (abfd, ptr);
/* ptr += 2; */
/* Now read in the two strings that follow. */
if (ptr == NULL)
return NULL;
- if (bfd_read (ptr, 1, size, abfd) != size)
+ if (bfd_bread (ptr, size, abfd) != size)
return NULL;
symbol_name = ptr;
file_ptr offset;
/* Detect if this a Microsoft Import Library Format element. */
- if (bfd_seek (abfd, 0x00, SEEK_SET) != 0
- || bfd_read (buffer, 1, 4, abfd) != 4)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || bfd_bread (buffer, (bfd_size_type) 4, abfd) != 4)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
- if (bfd_h_get_32 (abfd, buffer) == 0xffff0000)
+ if (H_GET_32 (abfd, buffer) == 0xffff0000)
return pe_ILF_object_p (abfd);
- if (bfd_seek (abfd, 0x00, SEEK_SET) != 0
- || bfd_read (&dos_hdr, 1, sizeof (dos_hdr), abfd)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || bfd_bread (&dos_hdr, (bfd_size_type) sizeof (dos_hdr), abfd)
!= sizeof (dos_hdr))
{
if (bfd_get_error () != bfd_error_system_call)
correctly for a PEI file, check the e_magic number here, and, if
it doesn't match, clobber the f_magic number so that we don't get
a false match. */
- if (bfd_h_get_16 (abfd, (bfd_byte *) dos_hdr.e_magic) != DOSMAGIC)
+ if (H_GET_16 (abfd, dos_hdr.e_magic) != DOSMAGIC)
{
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
- offset = bfd_h_get_32 (abfd, (bfd_byte *) dos_hdr.e_lfanew);
- if (bfd_seek (abfd, (file_ptr) offset, SEEK_SET) != 0
- || bfd_read (&image_hdr, 1, sizeof (image_hdr), abfd)
- != sizeof (image_hdr))
+ offset = H_GET_32 (abfd, dos_hdr.e_lfanew);
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0
+ || (bfd_bread (&image_hdr, (bfd_size_type) sizeof (image_hdr), abfd)
+ != sizeof (image_hdr)))
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
- if (bfd_h_get_32 (abfd, (bfd_byte *) image_hdr.nt_signature)
- != 0x4550)
+ if (H_GET_32 (abfd, image_hdr.nt_signature) != 0x4550)
{
bfd_set_error (bfd_error_wrong_format);
return NULL;
/* Here is the hack. coff_object_p wants to read filhsz bytes to
pick up the COFF header for PE, see "struct external_PEI_filehdr"
in include/coff/pe.h. We adjust so that that will work. */
- if (bfd_seek (abfd,
- (file_ptr) (offset - sizeof (dos_hdr)),
- SEEK_SET)
- != 0)
+ if (bfd_seek (abfd, (file_ptr) (offset - sizeof (dos_hdr)), SEEK_SET) != 0)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
bfd *abfd;
{
if (!ppcboot_get_tdata (abfd))
- ppcboot_set_tdata (abfd, bfd_zalloc (abfd, sizeof (ppcboot_data_t)));
+ {
+ bfd_size_type amt = sizeof (ppcboot_data_t);
+ ppcboot_set_tdata (abfd, bfd_zalloc (abfd, amt));
+ }
return true;
}
return NULL;
}
- if (bfd_read ((PTR) &hdr, sizeof (hdr), 1, abfd) != sizeof (hdr))
+ if (bfd_bread ((PTR) &hdr, (bfd_size_type) sizeof (hdr), abfd)
+ != sizeof (hdr))
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
tdata->sec = sec;
memcpy ((PTR) &tdata->header, (PTR) &hdr, sizeof (ppcboot_hdr_t));
- ppcboot_set_arch_mach (abfd, bfd_arch_powerpc, 0);
+ ppcboot_set_arch_mach (abfd, bfd_arch_powerpc, 0L);
return abfd->xvec;
}
file_ptr offset;
bfd_size_type count;
{
- if (bfd_seek (abfd, offset + sizeof (ppcboot_hdr_t), SEEK_SET) != 0
- || bfd_read (location, 1, count, abfd) != count)
+ if (bfd_seek (abfd, offset + (file_ptr) sizeof (ppcboot_hdr_t), SEEK_SET) != 0
+ || bfd_bread (location, count, abfd) != count)
return false;
return true;
}
bfd *abfd;
char *suffix;
{
- int size;
+ bfd_size_type size;
char *buf;
char *p;
asection *sec = ppcboot_get_tdata (abfd)->sec;
asymbol *syms;
unsigned int i;
+ bfd_size_type amt = PPCBOOT_SYMS * sizeof (asymbol);
- syms = (asymbol *) bfd_alloc (abfd, PPCBOOT_SYMS * sizeof (asymbol));
+ syms = (asymbol *) bfd_alloc (abfd, amt);
if (syms == NULL)
return false;
ppcboot_make_empty_symbol (abfd)
bfd *abfd;
{
- return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
+ return (asymbol *) bfd_alloc (abfd, (bfd_size_type) sizeof (asymbol));
}
\f
int val;
struct ptrace_user u;
struct trad_core_struct *rawptr;
+ bfd_size_type amt;
- val = bfd_read ((void *)&u, 1, sizeof u, abfd);
+ val = bfd_bread ((void *)&u, (bfd_size_type) sizeof u, abfd);
if (val != sizeof u || u.pt_magic != _BCS_PTRACE_MAGIC
|| u.pt_rev != _BCS_PTRACE_REV)
{
/* Allocate both the upage and the struct core_data at once, so
a single free() will free them both. */
- rawptr = (struct trad_core_struct *)
- bfd_zalloc (abfd, sizeof (struct trad_core_struct));
+ amt = sizeof (struct trad_core_struct);
+ rawptr = (struct trad_core_struct *) bfd_zalloc (abfd, amt);
if (rawptr == NULL)
return 0;
/* Create the sections. This is raunchy, but bfd_close wants to free
them separately. */
- core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ amt = sizeof (asection);
+ core_stacksec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_stacksec (abfd) == NULL)
return NULL;
- core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ core_datasec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_datasec (abfd) == NULL)
return NULL;
- core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_regsec (abfd) == NULL)
return NULL;
.
.typedef enum bfd_reloc_status
.{
-. {* No errors detected *}
+. {* No errors detected *}
. bfd_reloc_ok,
.
-. {* The relocation was performed, but there was an overflow. *}
+. {* The relocation was performed, but there was an overflow. *}
. bfd_reloc_overflow,
.
-. {* The address to relocate was not within the section supplied. *}
+. {* The address to relocate was not within the section supplied. *}
. bfd_reloc_outofrange,
.
-. {* Used by special functions *}
+. {* Used by special functions *}
. bfd_reloc_continue,
.
-. {* Unsupported relocation size requested. *}
+. {* Unsupported relocation size requested. *}
. bfd_reloc_notsupported,
.
-. {* Unused *}
+. {* Unused *}
. bfd_reloc_other,
.
-. {* The symbol to relocate against was undefined. *}
+. {* The symbol to relocate against was undefined. *}
. bfd_reloc_undefined,
.
-. {* The relocation was performed, but may not be ok - presently
-. generated only when linking i960 coff files with i960 b.out
-. symbols. If this type is returned, the error_message argument
-. to bfd_perform_relocation will be set. *}
+. {* The relocation was performed, but may not be ok - presently
+. generated only when linking i960 coff files with i960 b.out
+. symbols. If this type is returned, the error_message argument
+. to bfd_perform_relocation will be set. *}
. bfd_reloc_dangerous
. }
. bfd_reloc_status_type;
.
.typedef struct reloc_cache_entry
.{
-. {* A pointer into the canonical table of pointers *}
+. {* A pointer into the canonical table of pointers *}
. struct symbol_cache_entry **sym_ptr_ptr;
.
-. {* offset in section *}
+. {* offset in section *}
. bfd_size_type address;
.
-. {* addend for relocation value *}
+. {* addend for relocation value *}
. bfd_vma addend;
.
-. {* Pointer to how to perform the required relocation *}
+. {* Pointer to how to perform the required relocation *}
. reloc_howto_type *howto;
.
.} arelent;
.
.enum complain_overflow
.{
-. {* Do not complain on overflow. *}
+. {* Do not complain on overflow. *}
. complain_overflow_dont,
.
-. {* Complain if the bitfield overflows, whether it is considered
-. as signed or unsigned. *}
+. {* Complain if the bitfield overflows, whether it is considered
+. as signed or unsigned. *}
. complain_overflow_bitfield,
.
-. {* Complain if the value overflows when considered as signed
-. number. *}
+. {* Complain if the value overflows when considered as signed
+. number. *}
. complain_overflow_signed,
.
-. {* Complain if the value overflows when considered as an
-. unsigned number. *}
+. {* Complain if the value overflows when considered as an
+. unsigned number. *}
. complain_overflow_unsigned
.};
.
.struct reloc_howto_struct
.{
-. {* The type field has mainly a documentary use - the back end can
-. do what it wants with it, though normally the back end's
-. external idea of what a reloc number is stored
-. in this field. For example, a PC relative word relocation
-. in a coff environment has the type 023 - because that's
-. what the outside world calls a R_PCRWORD reloc. *}
+. {* The type field has mainly a documentary use - the back end can
+. do what it wants with it, though normally the back end's
+. external idea of what a reloc number is stored
+. in this field. For example, a PC relative word relocation
+. in a coff environment has the type 023 - because that's
+. what the outside world calls a R_PCRWORD reloc. *}
. unsigned int type;
.
-. {* The value the final relocation is shifted right by. This drops
-. unwanted data from the relocation. *}
+. {* The value the final relocation is shifted right by. This drops
+. unwanted data from the relocation. *}
. unsigned int rightshift;
.
-. {* The size of the item to be relocated. This is *not* a
-. power-of-two measure. To get the number of bytes operated
-. on by a type of relocation, use bfd_get_reloc_size. *}
+. {* The size of the item to be relocated. This is *not* a
+. power-of-two measure. To get the number of bytes operated
+. on by a type of relocation, use bfd_get_reloc_size. *}
. int size;
.
-. {* The number of bits in the item to be relocated. This is used
-. when doing overflow checking. *}
+. {* The number of bits in the item to be relocated. This is used
+. when doing overflow checking. *}
. unsigned int bitsize;
.
-. {* Notes that the relocation is relative to the location in the
-. data section of the addend. The relocation function will
-. subtract from the relocation value the address of the location
-. being relocated. *}
+. {* Notes that the relocation is relative to the location in the
+. data section of the addend. The relocation function will
+. subtract from the relocation value the address of the location
+. being relocated. *}
. boolean pc_relative;
.
-. {* The bit position of the reloc value in the destination.
-. The relocated value is left shifted by this amount. *}
+. {* The bit position of the reloc value in the destination.
+. The relocated value is left shifted by this amount. *}
. unsigned int bitpos;
.
-. {* What type of overflow error should be checked for when
-. relocating. *}
+. {* What type of overflow error should be checked for when
+. relocating. *}
. enum complain_overflow complain_on_overflow;
.
-. {* If this field is non null, then the supplied function is
-. called rather than the normal function. This allows really
-. strange relocation methods to be accomodated (e.g., i960 callj
-. instructions). *}
+. {* If this field is non null, then the supplied function is
+. called rather than the normal function. This allows really
+. strange relocation methods to be accomodated (e.g., i960 callj
+. instructions). *}
. bfd_reloc_status_type (*special_function)
-. PARAMS ((bfd *abfd,
-. arelent *reloc_entry,
-. struct symbol_cache_entry *symbol,
-. PTR data,
-. asection *input_section,
-. bfd *output_bfd,
-. char **error_message));
+. PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR, asection *,
+. bfd *, char **));
.
-. {* The textual name of the relocation type. *}
+. {* The textual name of the relocation type. *}
. char *name;
.
-. {* Some formats record a relocation addend in the section contents
-. rather than with the relocation. For ELF formats this is the
-. distinction between USE_REL and USE_RELA (though the code checks
-. for USE_REL == 1/0). The value of this field is TRUE if the
-. addend is recorded with the section contents; when performing a
-. partial link (ld -r) the section contents (the data) will be
-. modified. The value of this field is FALSE if addends are
-. recorded with the relocation (in arelent.addend); when performing
-. a partial link the relocation will be modified.
-. All relocations for all ELF USE_RELA targets should set this field
-. to FALSE (values of TRUE should be looked on with suspicion).
-. However, the converse is not true: not all relocations of all ELF
-. USE_REL targets set this field to TRUE. Why this is so is peculiar
-. to each particular target. For relocs that aren't used in partial
-. links (e.g. GOT stuff) it doesn't matter what this is set to. *}
+. {* Some formats record a relocation addend in the section contents
+. rather than with the relocation. For ELF formats this is the
+. distinction between USE_REL and USE_RELA (though the code checks
+. for USE_REL == 1/0). The value of this field is TRUE if the
+. addend is recorded with the section contents; when performing a
+. partial link (ld -r) the section contents (the data) will be
+. modified. The value of this field is FALSE if addends are
+. recorded with the relocation (in arelent.addend); when performing
+. a partial link the relocation will be modified.
+. All relocations for all ELF USE_RELA targets should set this field
+. to FALSE (values of TRUE should be looked on with suspicion).
+. However, the converse is not true: not all relocations of all ELF
+. USE_REL targets set this field to TRUE. Why this is so is peculiar
+. to each particular target. For relocs that aren't used in partial
+. links (e.g. GOT stuff) it doesn't matter what this is set to. *}
. boolean partial_inplace;
.
-. {* The src_mask selects which parts of the read in data
-. are to be used in the relocation sum. E.g., if this was an 8 bit
-. byte of data which we read and relocated, this would be
-. 0x000000ff. When we have relocs which have an addend, such as
-. sun4 extended relocs, the value in the offset part of a
-. relocating field is garbage so we never use it. In this case
-. the mask would be 0x00000000. *}
+. {* The src_mask selects which parts of the read in data
+. are to be used in the relocation sum. E.g., if this was an 8 bit
+. byte of data which we read and relocated, this would be
+. 0x000000ff. When we have relocs which have an addend, such as
+. sun4 extended relocs, the value in the offset part of a
+. relocating field is garbage so we never use it. In this case
+. the mask would be 0x00000000. *}
. bfd_vma src_mask;
.
-. {* The dst_mask selects which parts of the instruction are replaced
-. into the instruction. In most cases src_mask == dst_mask,
-. except in the above special case, where dst_mask would be
-. 0x000000ff, and src_mask would be 0x00000000. *}
+. {* The dst_mask selects which parts of the instruction are replaced
+. into the instruction. In most cases src_mask == dst_mask,
+. except in the above special case, where dst_mask would be
+. 0x000000ff, and src_mask would be 0x00000000. *}
. bfd_vma dst_mask;
.
-. {* When some formats create PC relative instructions, they leave
-. the value of the pc of the place being relocated in the offset
-. slot of the instruction, so that a PC relative relocation can
-. be made just by adding in an ordinary offset (e.g., sun3 a.out).
-. Some formats leave the displacement part of an instruction
-. empty (e.g., m88k bcs); this flag signals the fact.*}
+. {* When some formats create PC relative instructions, they leave
+. the value of the pc of the place being relocated in the offset
+. slot of the instruction, so that a PC relative relocation can
+. be made just by adding in an ordinary offset (e.g., sun3 a.out).
+. Some formats leave the displacement part of an instruction
+. empty (e.g., m88k bcs); this flag signals the fact. *}
. boolean pcrel_offset;
-.
.};
*/
DESCRIPTION
The HOWTO define is horrible and will go away.
-.#define HOWTO(C, R,S,B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
-. {(unsigned)C,R,S,B, P, BI, O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
+.#define HOWTO(C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
+. { (unsigned) C, R, S, B, P, BI, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC }
DESCRIPTION
And will be replaced with the totally magic way. But for the
moment, we are compatible, so do it this way.
-.#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,complain_overflow_dont,FUNCTION, NAME,false,0,0,IN)
+.#define NEWHOWTO(FUNCTION, NAME, SIZE, REL, IN) \
+. HOWTO (0, 0, SIZE, 0, REL, 0, complain_overflow_dont, FUNCTION, \
+. NAME, false, 0, 0, IN)
.
DESCRIPTION
This is used to fill in an empty howto entry in an array.
.#define EMPTY_HOWTO(C) \
-. HOWTO((C),0,0,0,false,0,complain_overflow_dont,NULL,NULL,false,0,0,false)
+. HOWTO ((C), 0, 0, 0, false, 0, complain_overflow_dont, NULL, \
+. NULL, false, 0, 0, false)
.
DESCRIPTION
Helper routine to turn a symbol into a relocation value.
-.#define HOWTO_PREPARE(relocation, symbol) \
-. { \
-. if (symbol != (asymbol *)NULL) { \
-. if (bfd_is_com_section (symbol->section)) { \
-. relocation = 0; \
-. } \
-. else { \
-. relocation = symbol->value; \
-. } \
-. } \
-.}
+.#define HOWTO_PREPARE(relocation, symbol) \
+. { \
+. if (symbol != (asymbol *) NULL) \
+. { \
+. if (bfd_is_com_section (symbol->section)) \
+. { \
+. relocation = 0; \
+. } \
+. else \
+. { \
+. relocation = symbol->value; \
+. } \
+. } \
+. }
*/
How relocs are tied together in an <<asection>>:
-.typedef struct relent_chain {
+.typedef struct relent_chain
+.{
. arelent relent;
-. struct relent_chain *next;
+. struct relent_chain *next;
.} arelent_chain;
*/
{
short x = bfd_get_16 (abfd, (bfd_byte *) data + octets);
DOIT (x);
- bfd_put_16 (abfd, x, (unsigned char *) data + octets);
+ bfd_put_16 (abfd, (bfd_vma) x, (unsigned char *) data + octets);
}
break;
case 2:
{
long x = bfd_get_32 (abfd, (bfd_byte *) data + octets);
DOIT (x);
- bfd_put_32 (abfd, x, (bfd_byte *) data + octets);
+ bfd_put_32 (abfd, (bfd_vma) x, (bfd_byte *) data + octets);
}
break;
case -2:
long x = bfd_get_32 (abfd, (bfd_byte *) data + octets);
relocation = -relocation;
DOIT (x);
- bfd_put_32 (abfd, x, (bfd_byte *) data + octets);
+ bfd_put_32 (abfd, (bfd_vma) x, (bfd_byte *) data + octets);
}
break;
long x = bfd_get_16 (abfd, (bfd_byte *) data + octets);
relocation = -relocation;
DOIT (x);
- bfd_put_16 (abfd, x, (bfd_byte *) data + octets);
+ bfd_put_16 (abfd, (bfd_vma) x, (bfd_byte *) data + octets);
}
break;
{
short x = bfd_get_16 (abfd, (bfd_byte *) data);
DOIT (x);
- bfd_put_16 (abfd, x, (unsigned char *) data);
+ bfd_put_16 (abfd, (bfd_vma) x, (unsigned char *) data);
}
break;
case 2:
{
long x = bfd_get_32 (abfd, (bfd_byte *) data);
DOIT (x);
- bfd_put_32 (abfd, x, (bfd_byte *) data);
+ bfd_put_32 (abfd, (bfd_vma) x, (bfd_byte *) data);
}
break;
case -2:
long x = bfd_get_32 (abfd, (bfd_byte *) data);
relocation = -relocation;
DOIT (x);
- bfd_put_32 (abfd, x, (bfd_byte *) data);
+ bfd_put_32 (abfd, (bfd_vma) x, (bfd_byte *) data);
}
break;
ENUMX
BFD_RELOC_ALPHA_GPREL_LO16
ENUMDOC
- The GPREL_HI/LO relocations together form a 32-bit offset from the
- GP register.
+ The GPREL_HI/LO relocations together form a 32-bit offset from the
+ GP register.
ENUM
BFD_RELOC_MIPS_JMP
ENUMX
BFD_RELOC_PPC64_TOC
ENUMX
- BFD_RELOC_PPC64_PLTGOT16
+ BFD_RELOC_PPC64_PLTGOT16
ENUMX
BFD_RELOC_PPC64_PLTGOT16_LO
ENUMX
BFD_RELOC_390_GOTENT
ENUMDOC
32 bit rel. offset to GOT entry.
-
+
ENUM
BFD_RELOC_VTABLE_INHERIT
ENUMX
if (reloc_size < 0)
goto error_return;
- reloc_vector = (arelent **) bfd_malloc ((size_t) reloc_size);
+ reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
if (reloc_vector == NULL && reloc_size != 0)
goto error_return;
if (!bfd_get_section_contents (input_bfd,
input_section,
(PTR) data,
- 0,
+ (bfd_vma) 0,
input_section->_raw_size))
goto error_return;
/* 8 and 16 bit COFF relocation functions, for BFD.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001
Free Software Foundation, Inc.
Written by Cygnus Support.
}
boolean
-bfd_coff_reloc16_relax_section (abfd, i, link_info, again)
+bfd_coff_reloc16_relax_section (abfd, input_section, link_info, again)
bfd *abfd;
- asection *i;
+ asection *input_section;
struct bfd_link_info *link_info;
boolean *again;
{
/* Get enough memory to hold the stuff. */
- bfd *input_bfd = i->owner;
- asection *input_section = i;
- int *shrinks;
- int shrink = 0;
+ bfd *input_bfd = input_section->owner;
+ unsigned *shrinks;
+ unsigned shrink = 0;
long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section);
arelent **reloc_vector = NULL;
long reloc_count;
if (reloc_size < 0)
return false;
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
+ reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
if (!reloc_vector && reloc_size > 0)
return false;
if (reloc_count > 0)
{
int another_pass = 0;
+ bfd_size_type amt;
/* Allocate and initialize the shrinks array for this section.
The last element is used as an accumlator of shrinks. */
- shrinks = (int *) bfd_malloc ((reloc_count + 1) * sizeof (int));
- memset (shrinks, 0, (reloc_count + 1) * sizeof (int));
+ amt = reloc_count + 1;
+ amt *= sizeof (unsigned);
+ shrinks = (unsigned *) bfd_malloc (amt);
+ memset (shrinks, 0, (size_t) amt);
/* Loop until nothing changes in this section. */
do {
if (!bfd_get_section_contents(input_bfd,
input_section,
data,
- 0,
+ (bfd_vma) 0,
input_section->_raw_size))
return NULL;
- reloc_vector = (arelent **) bfd_malloc ((size_t) reloc_size);
+ reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
if (!reloc_vector && reloc_size != 0)
return NULL;
#define N_SHARED_LIB(x) ((x).a_info & MF_USES_SL)
/* Only a pure OMAGIC file has the minimal header */
-#define N_TXTOFF(x) \
- ((x).a_info == OMAGIC ? 32 \
- : (N_MAGIC(x) == ZMAGIC) ? TARGET_PAGE_SIZE \
- : 999)
-
-#define N_TXTADDR(x) \
- (N_MAGIC(x) != ZMAGIC ? 0 /* object file or NMAGIC */ \
+#define N_TXTOFF(x) \
+ ((x).a_info == OMAGIC \
+ ? 32 \
+ : (N_MAGIC(x) == ZMAGIC \
+ ? TARGET_PAGE_SIZE \
+ : 999))
+
+#define N_TXTADDR(x) \
+ (N_MAGIC(x) != ZMAGIC \
+ ? (bfd_vma) 0 /* object file or NMAGIC */ \
/* Programs with shared libs are loaded at the first page after all the \
text segments of the shared library programs. Without looking this \
up we can't know exactly what the address will be. A reasonable guess \
- is that a_entry will be in the first page of the executable. */ \
- : N_SHARED_LIB(x) ? ((x).a_entry & ~(TARGET_PAGE_SIZE - 1)) \
- : TEXT_START_ADDR)
+ is that a_entry will be in the first page of the executable. */ \
+ : (N_SHARED_LIB(x) \
+ ? ((x).a_entry & ~(bfd_vma) (TARGET_PAGE_SIZE - 1)) \
+ : (bfd_vma) TEXT_START_ADDR))
#define N_SYMOFF(x) \
(N_TXTOFF (x) + (x).a_text + (x).a_data + (x).a_trsize + (x).a_drsize)
#include "sysdep.h"
#include "libbfd.h"
-#define WRITE_HEADERS(abfd, execp) \
- { \
- bfd_size_type text_size; /* dummy vars */ \
- file_ptr text_end; \
- if (adata(abfd).magic == undecided_magic) \
- NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \
- \
- execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; \
- execp->a_entry = bfd_get_start_address (abfd); \
- \
- execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * \
- obj_reloc_entry_size (abfd)); \
- execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * \
- obj_reloc_entry_size (abfd)); \
- NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
- \
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
- if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
- != EXEC_BYTES_SIZE) \
- return false; \
- /* Now write out reloc info, followed by syms and strings */ \
- \
- if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \
- && bfd_get_symcount (abfd) != 0) \
- { \
+#define WRITE_HEADERS(abfd, execp) \
+ { \
+ bfd_size_type text_size; /* dummy vars */ \
+ file_ptr text_end; \
+ if (adata(abfd).magic == undecided_magic) \
+ NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end); \
+ \
+ execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE; \
+ execp->a_entry = bfd_get_start_address (abfd); \
+ \
+ execp->a_trsize = ((obj_textsec (abfd)->reloc_count) * \
+ obj_reloc_entry_size (abfd)); \
+ execp->a_drsize = ((obj_datasec (abfd)->reloc_count) * \
+ obj_reloc_entry_size (abfd)); \
+ NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
+ \
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 \
+ || bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, \
+ abfd) != EXEC_BYTES_SIZE) \
+ return false; \
+ /* Now write out reloc info, followed by syms and strings */ \
+ \
+ if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \
+ && bfd_get_symcount (abfd) != 0) \
+ { \
if (bfd_seek (abfd, (file_ptr) (N_SYMOFF(*execp)), SEEK_SET) != 0) \
- return false; \
- \
- if (! NAME(aout,write_syms) (abfd)) return false; \
- \
+ return false; \
+ \
+ if (! NAME(aout,write_syms) (abfd)) return false; \
+ \
if (bfd_seek (abfd, (file_ptr) (N_TRELOFF(*execp)), SEEK_SET) != 0) \
- return false; \
- \
- if (! riscix_squirt_out_relocs (abfd, obj_textsec (abfd))) \
- return false; \
+ return false; \
+ \
+ if (! riscix_squirt_out_relocs (abfd, obj_textsec (abfd))) \
+ return false; \
if (bfd_seek (abfd, (file_ptr) (N_DRELOFF(*execp)), SEEK_SET) != 0) \
- return false; \
- \
- if (!NAME(aout,squirt_out_relocs) (abfd, obj_datasec (abfd))) \
- return false; \
- } \
+ return false; \
+ \
+ if (!NAME(aout,squirt_out_relocs) (abfd, obj_datasec (abfd))) \
+ return false; \
+ } \
}
#include "libaout.h"
if ((relocation & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff)
flag = bfd_reloc_overflow;
}
- else if (relocation & ~0x03ffffff)
+ else if (relocation & ~ (bfd_vma) 0x03ffffff)
flag = bfd_reloc_overflow;
target &= ~0x00ffffff;
target |= (relocation >> 2) & 0x00ffffff;
- bfd_put_32 (abfd, target, (bfd_byte *) data + addr);
+ bfd_put_32 (abfd, (bfd_vma) target, (bfd_byte *) data + addr);
/* Now the ARM magic... Change the reloc type so that it is marked as done.
Strictly this is only necessary if we are doing a partial relocation. */
size_t each_size;
unsigned int count = section->reloc_count;
- size_t natsize;
+ bfd_size_type natsize;
if (count == 0) return true;
each_size = obj_reloc_entry_size (abfd);
- natsize = each_size * count;
+ natsize = each_size;
+ natsize *= count;
native = (unsigned char *) bfd_zalloc (abfd, natsize);
if (!native)
return false;
riscix_swap_std_reloc_out (abfd, *generic,
(struct reloc_std_external *) natptr);
- if ( bfd_write ((PTR) native, 1, natsize, abfd) != natsize)
+ if (bfd_bwrite ((PTR) native, natsize, abfd) != natsize)
{
- bfd_release(abfd, native);
+ bfd_release (abfd, native);
return false;
}
{
struct aout_data_struct *rawptr, *oldrawptr;
const bfd_target *result;
+ bfd_size_type amt = sizeof (struct aout_data_struct);
- rawptr = ((struct aout_data_struct *)
- bfd_zalloc (abfd, sizeof (struct aout_data_struct )));
+ rawptr = (struct aout_data_struct *) bfd_zalloc (abfd, amt);
if (rawptr == NULL)
return 0;
struct internal_exec exec; /* Cleaned-up exec header */
const bfd_target *target;
- if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
- != EXEC_BYTES_SIZE) {
- if (bfd_get_error () != bfd_error_system_call)
- bfd_set_error (bfd_error_wrong_format);
- return 0;
- }
+ if (bfd_bread ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE)
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
- exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
+ exec.a_info = H_GET_32 (abfd, exec_bytes.e_info);
if (N_BADMAG (exec)) return 0;
#ifdef MACHTYPE_OK
{
bfd_size_type size;
- if (bfd_seek (abfd, 0, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return false;
/* Read the leading portion that old and new core dump structures have in
common. */
- if (bfd_read (core, CORE_COMMONSZ, 1, abfd) != CORE_COMMONSZ)
+ size = CORE_COMMONSZ;
+ if (bfd_bread (core, size, abfd) != size)
return false;
/* Read the trailing portion of the structure. */
- size = CORE_NEW (*core) ? sizeof (core->new) : sizeof (core->old)
- - CORE_COMMONSZ;
- return bfd_read ((char *) core + CORE_COMMONSZ, size, 1, abfd) == size;
+ if (CORE_NEW (*core))
+ size = sizeof (core->new);
+ else
+ size = sizeof (core->old);
+ size -= CORE_COMMONSZ;
+ return bfd_bread ((char *) core + CORE_COMMONSZ, size, abfd) == size;
}
static asection *
make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos)
bfd *abfd;
- CONST char *name;
+ const char *name;
flagword flags;
bfd_size_type _raw_size;
bfd_vma vma;
/* Allocate core file header. */
size = CORE_NEW (core) ? sizeof (core.new) : sizeof (core.old);
- tmpptr = (char *) bfd_zalloc (abfd, size);
+ tmpptr = (char *) bfd_zalloc (abfd, (bfd_size_type) size);
if (!tmpptr)
return NULL;
{
if (bfd_seek (abfd, c_loader, SEEK_SET) != 0)
return NULL;
- if (bfd_read (&ldinfo, size, 1, abfd) != size)
+ if (bfd_bread (&ldinfo, size, abfd) != size)
return NULL;
if (proc64)
bfd_vma vminfo_addr;
size = CORE_NEW (core) ? sizeof (vminfo.new) : sizeof (vminfo.old);
- if (bfd_read (&vminfo, size, 1, abfd) != size)
+ if (bfd_bread (&vminfo, size, abfd) != size)
return NULL;
if (CORE_NEW (core))
return false;
alloc = 100;
- path = bfd_malloc (alloc);
+ path = bfd_malloc ((bfd_size_type) alloc);
if (path == NULL)
return false;
s = path;
while (1)
{
- if (bfd_read (s, 1, 1, core_bfd) != 1)
+ if (bfd_bread (s, (bfd_size_type) 1, core_bfd) != 1)
{
free (path);
return false;
char *n;
alloc *= 2;
- n = bfd_realloc (path, alloc);
+ n = bfd_realloc (path, (bfd_size_type) alloc);
if (n == NULL)
{
free (path);
/* BFD back end for SCO5 core files (U-area and raw sections)
- Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Written by Jouke Numan <jnuman@hiscom.nl>
This file is part of BFD, the Binary File Descriptor library.
sco5_core_make_empty_symbol (abfd)
bfd *abfd;
{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ asymbol *new;
+
+ new = (asymbol *) bfd_zalloc (abfd, (bfd_size_type) sizeof (asymbol));
if (new)
new->the_bfd = abfd;
return new;
{
struct sco5_core_struct *rawptr;
+ bfd_size_type amt = sizeof (struct sco5_core_struct);
- rawptr = ((struct sco5_core_struct *)
- bfd_zmalloc (sizeof (struct sco5_core_struct)));
+ rawptr = (struct sco5_core_struct *) bfd_zmalloc (amt);
if (rawptr == NULL)
return NULL;
abfd->tdata.sco5_core_data = rawptr;
- if ((bfd_seek (abfd, filepos, SEEK_SET) != 0)
- || (bfd_read ((void *)&rawptr->u, 1, sizeof rawptr->u, abfd)
- != sizeof rawptr->u))
+ if (bfd_seek (abfd, (file_ptr) filepos, SEEK_SET) != 0
+ || bfd_bread ((void *) &rawptr->u, (bfd_size_type) sizeof rawptr->u,
+ abfd) != sizeof rawptr->u)
{
bfd_set_error (bfd_error_wrong_format);
return NULL;
coresize = statbuf.st_size;
}
/* Last long in core is sizeof struct coreoffsets, read it */
- if ((bfd_seek (abfd, coresize-sizeof coffset_siz, SEEK_SET) != 0)
- || (bfd_read ((void *)&coffset_siz, 1, sizeof coffset_siz, abfd)
- != sizeof coffset_siz) )
+ if ((bfd_seek (abfd, (file_ptr) (coresize - sizeof coffset_siz),
+ SEEK_SET) != 0)
+ || bfd_bread ((void *) &coffset_siz, (bfd_size_type) sizeof coffset_siz,
+ abfd) != sizeof coffset_siz)
{
bfd_set_error (bfd_error_wrong_format);
return NULL;
/* Use it to seek start of coreoffsets region, read it and determine
validity */
- if ((bfd_seek (abfd, coresize-coffset_siz, SEEK_SET) != 0)
- || (bfd_read ((void *)&coffsets, 1, sizeof coffsets, abfd)
+ if ((bfd_seek (abfd, (file_ptr) (coresize - coffset_siz), SEEK_SET) != 0)
+ || (bfd_bread ((void *) &coffsets, (bfd_size_type) sizeof coffsets, abfd)
!= sizeof coffsets)
|| ((coffsets.u_info != 1) && (coffsets.u_info != C_VERSION)))
{
coresecthead and check its validity */
if ((bfd_seek (abfd,
- coresize - coffset_siz - 2 * sizeof coffset_siz,
+ (file_ptr) (coresize - coffset_siz - 2 * sizeof coffset_siz),
SEEK_SET) != 0)
- || (bfd_read ((void *)&nsecs, 1, sizeof nsecs, abfd) != sizeof nsecs)
- || (bfd_read ((void *)&cheadoffs, 1, sizeof cheadoffs, abfd)
- != sizeof cheadoffs)
- || (bfd_seek (abfd, cheadoffs, SEEK_SET) != 0)
- || (bfd_read ((void *)&chead, 1, sizeof chead, abfd) != sizeof chead)
+ || (bfd_bread ((void *) &nsecs, (bfd_size_type) sizeof nsecs, abfd)
+ != sizeof nsecs)
+ || (bfd_bread ((void *) &cheadoffs, (bfd_size_type) sizeof cheadoffs,
+ abfd) != sizeof cheadoffs)
+ || (bfd_seek (abfd, (file_ptr) cheadoffs, SEEK_SET) != 0)
+ || (bfd_bread ((void *) &chead, (bfd_size_type) sizeof chead, abfd)
+ != sizeof chead)
|| (chead.cs_stype != CORES_OFFSETS)
|| (chead.cs_x.csx_magic != COREMAGIC_NUMBER))
{
nsecs--; /* We've seen CORES_OFFSETS already */
for (; nsecs; nsecs--)
{
- if ((bfd_seek (abfd, chead.cs_hseek, SEEK_SET) != 0)
- || bfd_read ((void *)&chead, 1, sizeof chead, abfd) != sizeof chead)
+ if ((bfd_seek (abfd, (file_ptr) chead.cs_hseek, SEEK_SET) != 0)
+ || (bfd_bread ((void *) &chead, (bfd_size_type) sizeof chead, abfd)
+ != sizeof chead))
{
bfd_set_error (bfd_error_wrong_format);
return NULL;
/* ARGSUSED */
boolean
sco5_core_file_matches_executable_p (core_bfd, exec_bfd)
- bfd *core_bfd, *exec_bfd;
+ bfd *core_bfd ATTRIBUTE_UNUSED;
+ bfd *exec_bfd ATTRIBUTE_UNUSED;
{
return true; /* FIXME, We have no way of telling at this point */
}
char *sname;
len = strlen (templat);
- sname = bfd_malloc (len + 8);
+ sname = bfd_malloc ((bfd_size_type) len + 8);
if (sname == NULL)
return NULL;
strcpy (sname, templat);
sect = sect->next;
}
- newsect = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ newsect = (asection *) bfd_zalloc (abfd, (bfd_size_type) sizeof (asection));
if (newsect == NULL)
return NULL;
bfd_set_section_contents
SYNOPSIS
- boolean bfd_set_section_contents
- (bfd *abfd,
- asection *section,
- PTR data,
- file_ptr offset,
- bfd_size_type count);
+ boolean bfd_set_section_contents (bfd *abfd, asection *section,
+ PTR data, file_ptr offset,
+ bfd_size_type count);
DESCRIPTION
Sets the contents of the section @var{section} in BFD
return (false);
}
- if (offset < 0)
+ sz = bfd_get_section_size_now (abfd, section);
+ if ((bfd_size_type) offset > sz
+ || count > sz
+ || offset + count > sz
+ || count != (size_t) count)
{
- bad_val:
bfd_set_error (bfd_error_bad_value);
return false;
}
- sz = bfd_get_section_size_now (abfd, section);
- if ((bfd_size_type) offset > sz
- || count > sz
- || offset + count > sz)
- goto bad_val;
switch (abfd->direction)
{
/* Record a copy of the data in memory if desired. */
if (section->contents
&& location != section->contents + offset)
- memcpy (section->contents + offset, location, count);
+ memcpy (section->contents + offset, location, (size_t) count);
if (BFD_SEND (abfd, _bfd_set_section_contents,
(abfd, section, location, offset, count)))
bfd_get_section_contents
SYNOPSIS
- boolean bfd_get_section_contents
- (bfd *abfd, asection *section, PTR location,
- file_ptr offset, bfd_size_type count);
+ boolean bfd_get_section_contents (bfd *abfd, asection *section,
+ PTR location, file_ptr offset,
+ bfd_size_type count);
DESCRIPTION
Read data from @var{section} in BFD @var{abfd}
if (section->flags & SEC_CONSTRUCTOR)
{
- memset (location, 0, (unsigned) count);
+ memset (location, 0, (size_t) count);
return true;
}
- if (offset < 0)
+ /* Even if reloc_done is true, this function reads unrelocated
+ contents, so we want the raw size. */
+ sz = section->_raw_size;
+ if ((bfd_size_type) offset > sz
+ || count > sz
+ || offset + count > sz
+ || count != (size_t) count)
{
- bad_val:
bfd_set_error (bfd_error_bad_value);
return false;
}
- /* Even if reloc_done is true, this function reads unrelocated
- contents, so we want the raw size. */
- sz = section->_raw_size;
- if ((bfd_size_type) offset > sz || count > sz || offset + count > sz)
- goto bad_val;
if (count == 0)
/* Don't bother. */
if ((section->flags & SEC_HAS_CONTENTS) == 0)
{
- memset (location, 0, (unsigned) count);
+ memset (location, 0, (size_t) count);
return true;
}
bfd_copy_private_section_data
SYNOPSIS
- boolean bfd_copy_private_section_data(bfd *ibfd, asection *isec, bfd *obfd, asection *osec);
+ boolean bfd_copy_private_section_data (bfd *ibfd, asection *isec,
+ bfd *obfd, asection *osec);
DESCRIPTION
Copy private section information from @var{isec} in the BFD
/* Generic alignment macro. */
#define SOM_ALIGN(val, alignment) \
- (((val) + (alignment) - 1) & ~((alignment) - 1))
+ (((val) + (alignment) - 1) &~ ((unsigned long) (alignment) - 1))
/* SOM allows any one of the four previous relocations to be reused
with a "R_PREV_FIXUP" relocation entry. Since R_PREV_FIXUP
unsigned long));
static boolean som_find_nearest_line PARAMS ((bfd *, asection *,
asymbol **, bfd_vma,
- CONST char **,
- CONST char **,
+ const char **,
+ const char **,
unsigned int *));
static void som_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
static asection * bfd_section_from_som_symbol PARAMS ((bfd *,
static unsigned char * som_reloc_skip PARAMS ((bfd *, unsigned int,
unsigned char *, unsigned int *,
struct reloc_queue *));
-static unsigned char * som_reloc_addend PARAMS ((bfd *, int, unsigned char *,
+static unsigned char * som_reloc_addend PARAMS ((bfd *, bfd_vma,
+ unsigned char *,
unsigned int *,
struct reloc_queue *));
static unsigned char * som_reloc_call PARAMS ((bfd *, unsigned char *,
static const struct fixup_format som_fixup_formats[256] = {
/* R_NO_RELOCATION */
- 0, "LD1+4*=", /* 0x00 */
- 1, "LD1+4*=", /* 0x01 */
- 2, "LD1+4*=", /* 0x02 */
- 3, "LD1+4*=", /* 0x03 */
- 4, "LD1+4*=", /* 0x04 */
- 5, "LD1+4*=", /* 0x05 */
- 6, "LD1+4*=", /* 0x06 */
- 7, "LD1+4*=", /* 0x07 */
- 8, "LD1+4*=", /* 0x08 */
- 9, "LD1+4*=", /* 0x09 */
- 10, "LD1+4*=", /* 0x0a */
- 11, "LD1+4*=", /* 0x0b */
- 12, "LD1+4*=", /* 0x0c */
- 13, "LD1+4*=", /* 0x0d */
- 14, "LD1+4*=", /* 0x0e */
- 15, "LD1+4*=", /* 0x0f */
- 16, "LD1+4*=", /* 0x10 */
- 17, "LD1+4*=", /* 0x11 */
- 18, "LD1+4*=", /* 0x12 */
- 19, "LD1+4*=", /* 0x13 */
- 20, "LD1+4*=", /* 0x14 */
- 21, "LD1+4*=", /* 0x15 */
- 22, "LD1+4*=", /* 0x16 */
- 23, "LD1+4*=", /* 0x17 */
- 0, "LD8<b+1+4*=", /* 0x18 */
- 1, "LD8<b+1+4*=", /* 0x19 */
- 2, "LD8<b+1+4*=", /* 0x1a */
- 3, "LD8<b+1+4*=", /* 0x1b */
- 0, "LD16<c+1+4*=", /* 0x1c */
- 1, "LD16<c+1+4*=", /* 0x1d */
- 2, "LD16<c+1+4*=", /* 0x1e */
- 0, "Ld1+=", /* 0x1f */
+ { 0, "LD1+4*=" }, /* 0x00 */
+ { 1, "LD1+4*=" }, /* 0x01 */
+ { 2, "LD1+4*=" }, /* 0x02 */
+ { 3, "LD1+4*=" }, /* 0x03 */
+ { 4, "LD1+4*=" }, /* 0x04 */
+ { 5, "LD1+4*=" }, /* 0x05 */
+ { 6, "LD1+4*=" }, /* 0x06 */
+ { 7, "LD1+4*=" }, /* 0x07 */
+ { 8, "LD1+4*=" }, /* 0x08 */
+ { 9, "LD1+4*=" }, /* 0x09 */
+ { 10, "LD1+4*=" }, /* 0x0a */
+ { 11, "LD1+4*=" }, /* 0x0b */
+ { 12, "LD1+4*=" }, /* 0x0c */
+ { 13, "LD1+4*=" }, /* 0x0d */
+ { 14, "LD1+4*=" }, /* 0x0e */
+ { 15, "LD1+4*=" }, /* 0x0f */
+ { 16, "LD1+4*=" }, /* 0x10 */
+ { 17, "LD1+4*=" }, /* 0x11 */
+ { 18, "LD1+4*=" }, /* 0x12 */
+ { 19, "LD1+4*=" }, /* 0x13 */
+ { 20, "LD1+4*=" }, /* 0x14 */
+ { 21, "LD1+4*=" }, /* 0x15 */
+ { 22, "LD1+4*=" }, /* 0x16 */
+ { 23, "LD1+4*=" }, /* 0x17 */
+ { 0, "LD8<b+1+4*=" }, /* 0x18 */
+ { 1, "LD8<b+1+4*=" }, /* 0x19 */
+ { 2, "LD8<b+1+4*=" }, /* 0x1a */
+ { 3, "LD8<b+1+4*=" }, /* 0x1b */
+ { 0, "LD16<c+1+4*=" }, /* 0x1c */
+ { 1, "LD16<c+1+4*=" }, /* 0x1d */
+ { 2, "LD16<c+1+4*=" }, /* 0x1e */
+ { 0, "Ld1+=" }, /* 0x1f */
/* R_ZEROES */
- 0, "Lb1+4*=", /* 0x20 */
- 1, "Ld1+=", /* 0x21 */
+ { 0, "Lb1+4*=" }, /* 0x20 */
+ { 1, "Ld1+=" }, /* 0x21 */
/* R_UNINIT */
- 0, "Lb1+4*=", /* 0x22 */
- 1, "Ld1+=", /* 0x23 */
+ { 0, "Lb1+4*=" }, /* 0x22 */
+ { 1, "Ld1+=" }, /* 0x23 */
/* R_RELOCATION */
- 0, "L4=", /* 0x24 */
+ { 0, "L4=" }, /* 0x24 */
/* R_DATA_ONE_SYMBOL */
- 0, "L4=Sb=", /* 0x25 */
- 1, "L4=Sd=", /* 0x26 */
+ { 0, "L4=Sb=" }, /* 0x25 */
+ { 1, "L4=Sd=" }, /* 0x26 */
/* R_DATA_PLEBEL */
- 0, "L4=Sb=", /* 0x27 */
- 1, "L4=Sd=", /* 0x28 */
+ { 0, "L4=Sb=" }, /* 0x27 */
+ { 1, "L4=Sd=" }, /* 0x28 */
/* R_SPACE_REF */
- 0, "L4=", /* 0x29 */
+ { 0, "L4=" }, /* 0x29 */
/* R_REPEATED_INIT */
- 0, "L4=Mb1+4*=", /* 0x2a */
- 1, "Lb4*=Mb1+L*=", /* 0x2b */
- 2, "Lb4*=Md1+4*=", /* 0x2c */
- 3, "Ld1+=Me1+=", /* 0x2d */
- 0, "", /* 0x2e */
- 0, "", /* 0x2f */
+ { 0, "L4=Mb1+4*=" }, /* 0x2a */
+ { 1, "Lb4*=Mb1+L*=" }, /* 0x2b */
+ { 2, "Lb4*=Md1+4*=" }, /* 0x2c */
+ { 3, "Ld1+=Me1+=" }, /* 0x2d */
+ { 0, "" }, /* 0x2e */
+ { 0, "" }, /* 0x2f */
/* R_PCREL_CALL */
- 0, "L4=RD=Sb=", /* 0x30 */
- 1, "L4=RD=Sb=", /* 0x31 */
- 2, "L4=RD=Sb=", /* 0x32 */
- 3, "L4=RD=Sb=", /* 0x33 */
- 4, "L4=RD=Sb=", /* 0x34 */
- 5, "L4=RD=Sb=", /* 0x35 */
- 6, "L4=RD=Sb=", /* 0x36 */
- 7, "L4=RD=Sb=", /* 0x37 */
- 8, "L4=RD=Sb=", /* 0x38 */
- 9, "L4=RD=Sb=", /* 0x39 */
- 0, "L4=RD8<b+=Sb=",/* 0x3a */
- 1, "L4=RD8<b+=Sb=",/* 0x3b */
- 0, "L4=RD8<b+=Sd=",/* 0x3c */
- 1, "L4=RD8<b+=Sd=",/* 0x3d */
+ { 0, "L4=RD=Sb=" }, /* 0x30 */
+ { 1, "L4=RD=Sb=" }, /* 0x31 */
+ { 2, "L4=RD=Sb=" }, /* 0x32 */
+ { 3, "L4=RD=Sb=" }, /* 0x33 */
+ { 4, "L4=RD=Sb=" }, /* 0x34 */
+ { 5, "L4=RD=Sb=" }, /* 0x35 */
+ { 6, "L4=RD=Sb=" }, /* 0x36 */
+ { 7, "L4=RD=Sb=" }, /* 0x37 */
+ { 8, "L4=RD=Sb=" }, /* 0x38 */
+ { 9, "L4=RD=Sb=" }, /* 0x39 */
+ { 0, "L4=RD8<b+=Sb=" }, /* 0x3a */
+ { 1, "L4=RD8<b+=Sb=" }, /* 0x3b */
+ { 0, "L4=RD8<b+=Sd=" }, /* 0x3c */
+ { 1, "L4=RD8<b+=Sd=" }, /* 0x3d */
/* R_SHORT_PCREL_MODE */
- 0, "", /* 0x3e */
+ { 0, "" }, /* 0x3e */
/* R_LONG_PCREL_MODE */
- 0, "", /* 0x3f */
+ { 0, "" }, /* 0x3f */
/* R_ABS_CALL */
- 0, "L4=RD=Sb=", /* 0x40 */
- 1, "L4=RD=Sb=", /* 0x41 */
- 2, "L4=RD=Sb=", /* 0x42 */
- 3, "L4=RD=Sb=", /* 0x43 */
- 4, "L4=RD=Sb=", /* 0x44 */
- 5, "L4=RD=Sb=", /* 0x45 */
- 6, "L4=RD=Sb=", /* 0x46 */
- 7, "L4=RD=Sb=", /* 0x47 */
- 8, "L4=RD=Sb=", /* 0x48 */
- 9, "L4=RD=Sb=", /* 0x49 */
- 0, "L4=RD8<b+=Sb=",/* 0x4a */
- 1, "L4=RD8<b+=Sb=",/* 0x4b */
- 0, "L4=RD8<b+=Sd=",/* 0x4c */
- 1, "L4=RD8<b+=Sd=",/* 0x4d */
+ { 0, "L4=RD=Sb=" }, /* 0x40 */
+ { 1, "L4=RD=Sb=" }, /* 0x41 */
+ { 2, "L4=RD=Sb=" }, /* 0x42 */
+ { 3, "L4=RD=Sb=" }, /* 0x43 */
+ { 4, "L4=RD=Sb=" }, /* 0x44 */
+ { 5, "L4=RD=Sb=" }, /* 0x45 */
+ { 6, "L4=RD=Sb=" }, /* 0x46 */
+ { 7, "L4=RD=Sb=" }, /* 0x47 */
+ { 8, "L4=RD=Sb=" }, /* 0x48 */
+ { 9, "L4=RD=Sb=" }, /* 0x49 */
+ { 0, "L4=RD8<b+=Sb=" }, /* 0x4a */
+ { 1, "L4=RD8<b+=Sb=" }, /* 0x4b */
+ { 0, "L4=RD8<b+=Sd=" }, /* 0x4c */
+ { 1, "L4=RD8<b+=Sd=" }, /* 0x4d */
/* R_RESERVED */
- 0, "", /* 0x4e */
- 0, "", /* 0x4f */
+ { 0, "" }, /* 0x4e */
+ { 0, "" }, /* 0x4f */
/* R_DP_RELATIVE */
- 0, "L4=SD=", /* 0x50 */
- 1, "L4=SD=", /* 0x51 */
- 2, "L4=SD=", /* 0x52 */
- 3, "L4=SD=", /* 0x53 */
- 4, "L4=SD=", /* 0x54 */
- 5, "L4=SD=", /* 0x55 */
- 6, "L4=SD=", /* 0x56 */
- 7, "L4=SD=", /* 0x57 */
- 8, "L4=SD=", /* 0x58 */
- 9, "L4=SD=", /* 0x59 */
- 10, "L4=SD=", /* 0x5a */
- 11, "L4=SD=", /* 0x5b */
- 12, "L4=SD=", /* 0x5c */
- 13, "L4=SD=", /* 0x5d */
- 14, "L4=SD=", /* 0x5e */
- 15, "L4=SD=", /* 0x5f */
- 16, "L4=SD=", /* 0x60 */
- 17, "L4=SD=", /* 0x61 */
- 18, "L4=SD=", /* 0x62 */
- 19, "L4=SD=", /* 0x63 */
- 20, "L4=SD=", /* 0x64 */
- 21, "L4=SD=", /* 0x65 */
- 22, "L4=SD=", /* 0x66 */
- 23, "L4=SD=", /* 0x67 */
- 24, "L4=SD=", /* 0x68 */
- 25, "L4=SD=", /* 0x69 */
- 26, "L4=SD=", /* 0x6a */
- 27, "L4=SD=", /* 0x6b */
- 28, "L4=SD=", /* 0x6c */
- 29, "L4=SD=", /* 0x6d */
- 30, "L4=SD=", /* 0x6e */
- 31, "L4=SD=", /* 0x6f */
- 32, "L4=Sb=", /* 0x70 */
- 33, "L4=Sd=", /* 0x71 */
+ { 0, "L4=SD=" }, /* 0x50 */
+ { 1, "L4=SD=" }, /* 0x51 */
+ { 2, "L4=SD=" }, /* 0x52 */
+ { 3, "L4=SD=" }, /* 0x53 */
+ { 4, "L4=SD=" }, /* 0x54 */
+ { 5, "L4=SD=" }, /* 0x55 */
+ { 6, "L4=SD=" }, /* 0x56 */
+ { 7, "L4=SD=" }, /* 0x57 */
+ { 8, "L4=SD=" }, /* 0x58 */
+ { 9, "L4=SD=" }, /* 0x59 */
+ { 10, "L4=SD=" }, /* 0x5a */
+ { 11, "L4=SD=" }, /* 0x5b */
+ { 12, "L4=SD=" }, /* 0x5c */
+ { 13, "L4=SD=" }, /* 0x5d */
+ { 14, "L4=SD=" }, /* 0x5e */
+ { 15, "L4=SD=" }, /* 0x5f */
+ { 16, "L4=SD=" }, /* 0x60 */
+ { 17, "L4=SD=" }, /* 0x61 */
+ { 18, "L4=SD=" }, /* 0x62 */
+ { 19, "L4=SD=" }, /* 0x63 */
+ { 20, "L4=SD=" }, /* 0x64 */
+ { 21, "L4=SD=" }, /* 0x65 */
+ { 22, "L4=SD=" }, /* 0x66 */
+ { 23, "L4=SD=" }, /* 0x67 */
+ { 24, "L4=SD=" }, /* 0x68 */
+ { 25, "L4=SD=" }, /* 0x69 */
+ { 26, "L4=SD=" }, /* 0x6a */
+ { 27, "L4=SD=" }, /* 0x6b */
+ { 28, "L4=SD=" }, /* 0x6c */
+ { 29, "L4=SD=" }, /* 0x6d */
+ { 30, "L4=SD=" }, /* 0x6e */
+ { 31, "L4=SD=" }, /* 0x6f */
+ { 32, "L4=Sb=" }, /* 0x70 */
+ { 33, "L4=Sd=" }, /* 0x71 */
/* R_RESERVED */
- 0, "", /* 0x72 */
- 0, "", /* 0x73 */
- 0, "", /* 0x74 */
- 0, "", /* 0x75 */
- 0, "", /* 0x76 */
- 0, "", /* 0x77 */
+ { 0, "" }, /* 0x72 */
+ { 0, "" }, /* 0x73 */
+ { 0, "" }, /* 0x74 */
+ { 0, "" }, /* 0x75 */
+ { 0, "" }, /* 0x76 */
+ { 0, "" }, /* 0x77 */
/* R_DLT_REL */
- 0, "L4=Sb=", /* 0x78 */
- 1, "L4=Sd=", /* 0x79 */
+ { 0, "L4=Sb=" }, /* 0x78 */
+ { 1, "L4=Sd=" }, /* 0x79 */
/* R_RESERVED */
- 0, "", /* 0x7a */
- 0, "", /* 0x7b */
- 0, "", /* 0x7c */
- 0, "", /* 0x7d */
- 0, "", /* 0x7e */
- 0, "", /* 0x7f */
+ { 0, "" }, /* 0x7a */
+ { 0, "" }, /* 0x7b */
+ { 0, "" }, /* 0x7c */
+ { 0, "" }, /* 0x7d */
+ { 0, "" }, /* 0x7e */
+ { 0, "" }, /* 0x7f */
/* R_CODE_ONE_SYMBOL */
- 0, "L4=SD=", /* 0x80 */
- 1, "L4=SD=", /* 0x81 */
- 2, "L4=SD=", /* 0x82 */
- 3, "L4=SD=", /* 0x83 */
- 4, "L4=SD=", /* 0x84 */
- 5, "L4=SD=", /* 0x85 */
- 6, "L4=SD=", /* 0x86 */
- 7, "L4=SD=", /* 0x87 */
- 8, "L4=SD=", /* 0x88 */
- 9, "L4=SD=", /* 0x89 */
- 10, "L4=SD=", /* 0x8q */
- 11, "L4=SD=", /* 0x8b */
- 12, "L4=SD=", /* 0x8c */
- 13, "L4=SD=", /* 0x8d */
- 14, "L4=SD=", /* 0x8e */
- 15, "L4=SD=", /* 0x8f */
- 16, "L4=SD=", /* 0x90 */
- 17, "L4=SD=", /* 0x91 */
- 18, "L4=SD=", /* 0x92 */
- 19, "L4=SD=", /* 0x93 */
- 20, "L4=SD=", /* 0x94 */
- 21, "L4=SD=", /* 0x95 */
- 22, "L4=SD=", /* 0x96 */
- 23, "L4=SD=", /* 0x97 */
- 24, "L4=SD=", /* 0x98 */
- 25, "L4=SD=", /* 0x99 */
- 26, "L4=SD=", /* 0x9a */
- 27, "L4=SD=", /* 0x9b */
- 28, "L4=SD=", /* 0x9c */
- 29, "L4=SD=", /* 0x9d */
- 30, "L4=SD=", /* 0x9e */
- 31, "L4=SD=", /* 0x9f */
- 32, "L4=Sb=", /* 0xa0 */
- 33, "L4=Sd=", /* 0xa1 */
+ { 0, "L4=SD=" }, /* 0x80 */
+ { 1, "L4=SD=" }, /* 0x81 */
+ { 2, "L4=SD=" }, /* 0x82 */
+ { 3, "L4=SD=" }, /* 0x83 */
+ { 4, "L4=SD=" }, /* 0x84 */
+ { 5, "L4=SD=" }, /* 0x85 */
+ { 6, "L4=SD=" }, /* 0x86 */
+ { 7, "L4=SD=" }, /* 0x87 */
+ { 8, "L4=SD=" }, /* 0x88 */
+ { 9, "L4=SD=" }, /* 0x89 */
+ { 10, "L4=SD=" }, /* 0x8q */
+ { 11, "L4=SD=" }, /* 0x8b */
+ { 12, "L4=SD=" }, /* 0x8c */
+ { 13, "L4=SD=" }, /* 0x8d */
+ { 14, "L4=SD=" }, /* 0x8e */
+ { 15, "L4=SD=" }, /* 0x8f */
+ { 16, "L4=SD=" }, /* 0x90 */
+ { 17, "L4=SD=" }, /* 0x91 */
+ { 18, "L4=SD=" }, /* 0x92 */
+ { 19, "L4=SD=" }, /* 0x93 */
+ { 20, "L4=SD=" }, /* 0x94 */
+ { 21, "L4=SD=" }, /* 0x95 */
+ { 22, "L4=SD=" }, /* 0x96 */
+ { 23, "L4=SD=" }, /* 0x97 */
+ { 24, "L4=SD=" }, /* 0x98 */
+ { 25, "L4=SD=" }, /* 0x99 */
+ { 26, "L4=SD=" }, /* 0x9a */
+ { 27, "L4=SD=" }, /* 0x9b */
+ { 28, "L4=SD=" }, /* 0x9c */
+ { 29, "L4=SD=" }, /* 0x9d */
+ { 30, "L4=SD=" }, /* 0x9e */
+ { 31, "L4=SD=" }, /* 0x9f */
+ { 32, "L4=Sb=" }, /* 0xa0 */
+ { 33, "L4=Sd=" }, /* 0xa1 */
/* R_RESERVED */
- 0, "", /* 0xa2 */
- 0, "", /* 0xa3 */
- 0, "", /* 0xa4 */
- 0, "", /* 0xa5 */
- 0, "", /* 0xa6 */
- 0, "", /* 0xa7 */
- 0, "", /* 0xa8 */
- 0, "", /* 0xa9 */
- 0, "", /* 0xaa */
- 0, "", /* 0xab */
- 0, "", /* 0xac */
- 0, "", /* 0xad */
+ { 0, "" }, /* 0xa2 */
+ { 0, "" }, /* 0xa3 */
+ { 0, "" }, /* 0xa4 */
+ { 0, "" }, /* 0xa5 */
+ { 0, "" }, /* 0xa6 */
+ { 0, "" }, /* 0xa7 */
+ { 0, "" }, /* 0xa8 */
+ { 0, "" }, /* 0xa9 */
+ { 0, "" }, /* 0xaa */
+ { 0, "" }, /* 0xab */
+ { 0, "" }, /* 0xac */
+ { 0, "" }, /* 0xad */
/* R_MILLI_REL */
- 0, "L4=Sb=", /* 0xae */
- 1, "L4=Sd=", /* 0xaf */
+ { 0, "L4=Sb=" }, /* 0xae */
+ { 1, "L4=Sd=" }, /* 0xaf */
/* R_CODE_PLABEL */
- 0, "L4=Sb=", /* 0xb0 */
- 1, "L4=Sd=", /* 0xb1 */
+ { 0, "L4=Sb=" }, /* 0xb0 */
+ { 1, "L4=Sd=" }, /* 0xb1 */
/* R_BREAKPOINT */
- 0, "L4=", /* 0xb2 */
+ { 0, "L4=" }, /* 0xb2 */
/* R_ENTRY */
- 0, "Te=Ue=", /* 0xb3 */
- 1, "Uf=", /* 0xb4 */
+ { 0, "Te=Ue=" }, /* 0xb3 */
+ { 1, "Uf=" }, /* 0xb4 */
/* R_ALT_ENTRY */
- 0, "", /* 0xb5 */
+ { 0, "" }, /* 0xb5 */
/* R_EXIT */
- 0, "", /* 0xb6 */
+ { 0, "" }, /* 0xb6 */
/* R_BEGIN_TRY */
- 0, "", /* 0xb7 */
+ { 0, "" }, /* 0xb7 */
/* R_END_TRY */
- 0, "R0=", /* 0xb8 */
- 1, "Rb4*=", /* 0xb9 */
- 2, "Rd4*=", /* 0xba */
+ { 0, "R0=" }, /* 0xb8 */
+ { 1, "Rb4*=" }, /* 0xb9 */
+ { 2, "Rd4*=" }, /* 0xba */
/* R_BEGIN_BRTAB */
- 0, "", /* 0xbb */
+ { 0, "" }, /* 0xbb */
/* R_END_BRTAB */
- 0, "", /* 0xbc */
+ { 0, "" }, /* 0xbc */
/* R_STATEMENT */
- 0, "Nb=", /* 0xbd */
- 1, "Nc=", /* 0xbe */
- 2, "Nd=", /* 0xbf */
+ { 0, "Nb=" }, /* 0xbd */
+ { 1, "Nc=" }, /* 0xbe */
+ { 2, "Nd=" }, /* 0xbf */
/* R_DATA_EXPR */
- 0, "L4=", /* 0xc0 */
+ { 0, "L4=" }, /* 0xc0 */
/* R_CODE_EXPR */
- 0, "L4=", /* 0xc1 */
+ { 0, "L4=" }, /* 0xc1 */
/* R_FSEL */
- 0, "", /* 0xc2 */
+ { 0, "" }, /* 0xc2 */
/* R_LSEL */
- 0, "", /* 0xc3 */
+ { 0, "" }, /* 0xc3 */
/* R_RSEL */
- 0, "", /* 0xc4 */
+ { 0, "" }, /* 0xc4 */
/* R_N_MODE */
- 0, "", /* 0xc5 */
+ { 0, "" }, /* 0xc5 */
/* R_S_MODE */
- 0, "", /* 0xc6 */
+ { 0, "" }, /* 0xc6 */
/* R_D_MODE */
- 0, "", /* 0xc7 */
+ { 0, "" }, /* 0xc7 */
/* R_R_MODE */
- 0, "", /* 0xc8 */
+ { 0, "" }, /* 0xc8 */
/* R_DATA_OVERRIDE */
- 0, "V0=", /* 0xc9 */
- 1, "Vb=", /* 0xca */
- 2, "Vc=", /* 0xcb */
- 3, "Vd=", /* 0xcc */
- 4, "Ve=", /* 0xcd */
+ { 0, "V0=" }, /* 0xc9 */
+ { 1, "Vb=" }, /* 0xca */
+ { 2, "Vc=" }, /* 0xcb */
+ { 3, "Vd=" }, /* 0xcc */
+ { 4, "Ve=" }, /* 0xcd */
/* R_TRANSLATED */
- 0, "", /* 0xce */
+ { 0, "" }, /* 0xce */
/* R_AUX_UNWIND */
- 0, "Sd=Vf=Ef=", /* 0xcf */
+ { 0,"Sd=Vf=Ef=" }, /* 0xcf */
/* R_COMP1 */
- 0, "Ob=", /* 0xd0 */
+ { 0, "Ob=" }, /* 0xd0 */
/* R_COMP2 */
- 0, "Ob=Sd=", /* 0xd1 */
+ { 0, "Ob=Sd=" }, /* 0xd1 */
/* R_COMP3 */
- 0, "Ob=Ve=", /* 0xd2 */
+ { 0, "Ob=Ve=" }, /* 0xd2 */
/* R_PREV_FIXUP */
- 0, "P", /* 0xd3 */
- 1, "P", /* 0xd4 */
- 2, "P", /* 0xd5 */
- 3, "P", /* 0xd6 */
+ { 0, "P" }, /* 0xd3 */
+ { 1, "P" }, /* 0xd4 */
+ { 2, "P" }, /* 0xd5 */
+ { 3, "P" }, /* 0xd6 */
/* R_SEC_STMT */
- 0, "", /* 0xd7 */
+ { 0, "" }, /* 0xd7 */
/* R_N0SEL */
- 0, "", /* 0xd8 */
+ { 0, "" }, /* 0xd8 */
/* R_N1SEL */
- 0, "", /* 0xd9 */
+ { 0, "" }, /* 0xd9 */
/* R_LINETAB */
- 0, "Eb=Sd=Ve=", /* 0xda */
+ { 0, "Eb=Sd=Ve=" }, /* 0xda */
/* R_LINETAB_ESC */
- 0, "Eb=Mb=", /* 0xdb */
+ { 0, "Eb=Mb=" }, /* 0xdb */
/* R_LTP_OVERRIDE */
- 0, "", /* 0xdc */
+ { 0, "" }, /* 0xdc */
/* R_COMMENT */
- 0, "Ob=Ve=", /* 0xdd */
+ { 0, "Ob=Ve=" }, /* 0xdd */
/* R_RESERVED */
- 0, "", /* 0xde */
- 0, "", /* 0xdf */
- 0, "", /* 0xe0 */
- 0, "", /* 0xe1 */
- 0, "", /* 0xe2 */
- 0, "", /* 0xe3 */
- 0, "", /* 0xe4 */
- 0, "", /* 0xe5 */
- 0, "", /* 0xe6 */
- 0, "", /* 0xe7 */
- 0, "", /* 0xe8 */
- 0, "", /* 0xe9 */
- 0, "", /* 0xea */
- 0, "", /* 0xeb */
- 0, "", /* 0xec */
- 0, "", /* 0xed */
- 0, "", /* 0xee */
- 0, "", /* 0xef */
- 0, "", /* 0xf0 */
- 0, "", /* 0xf1 */
- 0, "", /* 0xf2 */
- 0, "", /* 0xf3 */
- 0, "", /* 0xf4 */
- 0, "", /* 0xf5 */
- 0, "", /* 0xf6 */
- 0, "", /* 0xf7 */
- 0, "", /* 0xf8 */
- 0, "", /* 0xf9 */
- 0, "", /* 0xfa */
- 0, "", /* 0xfb */
- 0, "", /* 0xfc */
- 0, "", /* 0xfd */
- 0, "", /* 0xfe */
- 0, "", /* 0xff */
+ { 0, "" }, /* 0xde */
+ { 0, "" }, /* 0xdf */
+ { 0, "" }, /* 0xe0 */
+ { 0, "" }, /* 0xe1 */
+ { 0, "" }, /* 0xe2 */
+ { 0, "" }, /* 0xe3 */
+ { 0, "" }, /* 0xe4 */
+ { 0, "" }, /* 0xe5 */
+ { 0, "" }, /* 0xe6 */
+ { 0, "" }, /* 0xe7 */
+ { 0, "" }, /* 0xe8 */
+ { 0, "" }, /* 0xe9 */
+ { 0, "" }, /* 0xea */
+ { 0, "" }, /* 0xeb */
+ { 0, "" }, /* 0xec */
+ { 0, "" }, /* 0xed */
+ { 0, "" }, /* 0xee */
+ { 0, "" }, /* 0xef */
+ { 0, "" }, /* 0xf0 */
+ { 0, "" }, /* 0xf1 */
+ { 0, "" }, /* 0xf2 */
+ { 0, "" }, /* 0xf3 */
+ { 0, "" }, /* 0xf4 */
+ { 0, "" }, /* 0xf5 */
+ { 0, "" }, /* 0xf6 */
+ { 0, "" }, /* 0xf7 */
+ { 0, "" }, /* 0xf8 */
+ { 0, "" }, /* 0xf9 */
+ { 0, "" }, /* 0xfa */
+ { 0, "" }, /* 0xfb */
+ { 0, "" }, /* 0xfc */
+ { 0, "" }, /* 0xfd */
+ { 0, "" }, /* 0xfe */
+ { 0, "" }, /* 0xff */
};
static const int comp1_opcodes[] = {
skip -= 0x1000000;
bfd_put_8 (abfd, R_NO_RELOCATION + 31, p);
bfd_put_8 (abfd, 0xff, p + 1);
- bfd_put_16 (abfd, 0xffff, p + 2);
+ bfd_put_16 (abfd, (bfd_vma) 0xffff, p + 2);
p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue);
while (skip >= 0x1000000)
{
else
{
bfd_put_8 (abfd, R_NO_RELOCATION + 28 + (((skip >> 2) - 1) >> 16), p);
- bfd_put_16 (abfd, (skip >> 2) - 1, p + 1);
+ bfd_put_16 (abfd, (bfd_vma) (skip >> 2) - 1, p + 1);
p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue);
}
}
{
bfd_put_8 (abfd, R_NO_RELOCATION + 31, p);
bfd_put_8 (abfd, (skip - 1) >> 16, p + 1);
- bfd_put_16 (abfd, skip - 1, p + 2);
+ bfd_put_16 (abfd, (bfd_vma) skip - 1, p + 2);
p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 4, queue);
}
return p;
static unsigned char *
som_reloc_addend (abfd, addend, p, subspace_reloc_sizep, queue)
bfd *abfd;
- int addend;
+ bfd_vma addend;
unsigned char *p;
unsigned int *subspace_reloc_sizep;
struct reloc_queue *queue;
{
- if ((unsigned) (addend) + 0x80 < 0x100)
+ if (addend + 0x80 < 0x100)
{
bfd_put_8 (abfd, R_DATA_OVERRIDE + 1, p);
bfd_put_8 (abfd, addend, p + 1);
p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 2, queue);
}
- else if ((unsigned) (addend) + 0x8000 < 0x10000)
+ else if (addend + 0x8000 < 0x10000)
{
bfd_put_8 (abfd, R_DATA_OVERRIDE + 2, p);
bfd_put_16 (abfd, addend, p + 1);
p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 3, queue);
}
- else if ((unsigned) (addend) + 0x800000 < 0x1000000)
+ else if (addend + 0x800000 < 0x1000000)
{
bfd_put_8 (abfd, R_DATA_OVERRIDE + 3, p);
bfd_put_8 (abfd, addend >> 16, p + 1);
else
{
bfd_put_8 (abfd, sym_num >> 16, p + 2);
- bfd_put_16 (abfd, sym_num, p + 3);
+ bfd_put_16 (abfd, (bfd_vma) sym_num, p + 3);
p = try_prev_fixup (abfd, subspace_reloc_sizep, p, 5, queue);
}
}
{
int *final_type, **final_types;
- final_types = (int **) bfd_alloc (abfd, sizeof (int *) * 6);
- final_type = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types = (int **) bfd_alloc (abfd, (bfd_size_type) sizeof (int *) * 6);
+ final_type = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types || !final_type)
return NULL;
case e_tsel:
case e_ltsel:
case e_rtsel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
if (field == e_tsel)
case e_lssel:
case e_rssel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
*final_types[0] = R_S_MODE;
case e_lsel:
case e_rsel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
*final_types[0] = R_N_MODE;
case e_ldsel:
case e_rdsel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
*final_types[0] = R_D_MODE;
case e_lrsel:
case e_rrsel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
*final_types[0] = R_R_MODE;
break;
case e_nsel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
*final_types[0] = R_N1SEL;
case e_nlsel:
case e_nlrsel:
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[0] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[0])
return NULL;
*final_types[0] = R_N0SEL;
- final_types[1] = (int *) bfd_alloc (abfd, sizeof (int));
+ final_types[1] = (int *) bfd_alloc (abfd, (bfd_size_type) sizeof (int));
if (!final_types[1])
return NULL;
if (field == e_nlsel)
/* The difference of two symbols needs *very* special handling. */
if (sym_diff)
{
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
- final_types[1] = (int *) bfd_alloc (abfd, sizeof (int));
- final_types[2] = (int *) bfd_alloc (abfd, sizeof (int));
- final_types[3] = (int *) bfd_alloc (abfd, sizeof (int));
+ bfd_size_type amt = sizeof (int);
+ final_types[0] = (int *) bfd_alloc (abfd, amt);
+ final_types[1] = (int *) bfd_alloc (abfd, amt);
+ final_types[2] = (int *) bfd_alloc (abfd, amt);
+ final_types[3] = (int *) bfd_alloc (abfd, amt);
if (!final_types[0] || !final_types[1] || !final_types[2])
return NULL;
if (field == e_fsel)
/* The difference of two symbols needs *very* special handling. */
if (sym_diff)
{
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
- final_types[1] = (int *) bfd_alloc (abfd, sizeof (int));
- final_types[2] = (int *) bfd_alloc (abfd, sizeof (int));
- final_types[3] = (int *) bfd_alloc (abfd, sizeof (int));
+ bfd_size_type amt = sizeof (int);
+ final_types[0] = (int *) bfd_alloc (abfd, amt);
+ final_types[1] = (int *) bfd_alloc (abfd, amt);
+ final_types[2] = (int *) bfd_alloc (abfd, amt);
+ final_types[3] = (int *) bfd_alloc (abfd, amt);
if (!final_types[0] || !final_types[1] || !final_types[2])
return NULL;
if (field == e_fsel)
/* If we have short and long pcrel modes, then generate the proper
mode selector, then the pcrel relocation. Redundant selectors
will be eliminted as the relocs are sized and emitted. */
- final_types[0] = (int *) bfd_alloc (abfd, sizeof (int));
+ bfd_size_type amt = sizeof (int);
+ final_types[0] = (int *) bfd_alloc (abfd, amt);
if (!final_types[0])
return NULL;
if (format == 17)
/* Allocate space to hold the saved exec header information. */
obj_som_exec_data (abfd) = (struct som_exec_data *)
- bfd_zalloc (abfd, sizeof (struct som_exec_data));
+ bfd_zalloc (abfd, (bfd_size_type) sizeof (struct som_exec_data));
if (obj_som_exec_data (abfd) == NULL)
return NULL;
unsigned int space_index, i;
unsigned int total_subspaces = 0;
asection **subspace_sections, *section;
+ bfd_size_type amt;
/* First, read in space names. */
- space_strings = bfd_malloc (file_hdr->space_strings_size);
- if (!space_strings && file_hdr->space_strings_size != 0)
+ amt = file_hdr->space_strings_size;
+ space_strings = bfd_malloc (amt);
+ if (!space_strings && amt != 0)
goto error_return;
if (bfd_seek (abfd, current_offset + file_hdr->space_strings_location,
- SEEK_SET) < 0)
+ SEEK_SET) != 0)
goto error_return;
- if (bfd_read (space_strings, 1, file_hdr->space_strings_size, abfd)
- != file_hdr->space_strings_size)
+ if (bfd_bread (space_strings, amt, abfd) != amt)
goto error_return;
/* Loop over all of the space dictionaries, building up sections. */
if (bfd_seek (abfd,
(current_offset + file_hdr->space_location
+ space_index * sizeof space),
- SEEK_SET) < 0)
+ SEEK_SET) != 0)
goto error_return;
- if (bfd_read (&space, 1, sizeof space, abfd) != sizeof space)
+ amt = sizeof space;
+ if (bfd_bread (&space, amt, abfd) != amt)
goto error_return;
/* Setup the space name string. */
space.name.n_name = space.name.n_strx + space_strings;
/* Make a section out of it. */
- newname = bfd_alloc (abfd, strlen (space.name.n_name) + 1);
+ amt = strlen (space.name.n_name) + 1;
+ newname = bfd_alloc (abfd, amt);
if (!newname)
goto error_return;
strcpy (newname, space.name.n_name);
if (bfd_seek (abfd,
(current_offset + file_hdr->subspace_location
+ space.subspace_index * sizeof subspace),
- SEEK_SET) < 0)
+ SEEK_SET) != 0)
goto error_return;
- if (bfd_read (&subspace, 1, sizeof subspace, abfd) != sizeof subspace)
+ amt = sizeof subspace;
+ if (bfd_bread (&subspace, amt, abfd) != amt)
goto error_return;
/* Seek back to the start of the subspaces for loop below. */
if (bfd_seek (abfd,
(current_offset + file_hdr->subspace_location
+ space.subspace_index * sizeof subspace),
- SEEK_SET) < 0)
+ SEEK_SET) != 0)
goto error_return;
/* Setup the start address and file loc from the first subspace
space_asect->vma = subspace.subspace_start;
space_asect->filepos = subspace.file_loc_init_value + current_offset;
space_asect->alignment_power = log2 (subspace.alignment);
- if (space_asect->alignment_power == -1)
+ if (space_asect->alignment_power == (unsigned) -1)
goto error_return;
/* Initialize save_subspace so we can reliably determine if this
asection *subspace_asect;
/* Read in the next subspace. */
- if (bfd_read (&subspace, 1, sizeof subspace, abfd)
- != sizeof subspace)
+ amt = sizeof subspace;
+ if (bfd_bread (&subspace, amt, abfd) != amt)
goto error_return;
/* Setup the subspace name string. */
subspace.name.n_name = subspace.name.n_strx + space_strings;
- newname = bfd_alloc (abfd, strlen (subspace.name.n_name) + 1);
+ amt = strlen (subspace.name.n_name) + 1;
+ newname = bfd_alloc (abfd, amt);
if (!newname)
goto error_return;
strcpy (newname, subspace.name.n_name);
= subspace.fixup_request_quantity;
/* We can not determine this yet. When we read in the
relocation table the correct value will be filled in. */
- subspace_asect->reloc_count = -1;
+ subspace_asect->reloc_count = (unsigned) -1;
}
/* Update save_subspace if appropriate. */
subspace_asect->filepos = (subspace.file_loc_init_value
+ current_offset);
subspace_asect->alignment_power = log2 (subspace.alignment);
- if (subspace_asect->alignment_power == -1)
+ if (subspace_asect->alignment_power == (unsigned) -1)
goto error_return;
}
}
/* Now that we've read in all the subspace records, we need to assign
a target index to each subspace. */
- subspace_sections = (asection **) bfd_malloc (total_subspaces
- * sizeof (asection *));
+ amt = total_subspaces;
+ amt *= sizeof (asection *);
+ subspace_sections = (asection **) bfd_malloc (amt);
if (subspace_sections == NULL)
goto error_return;
unsigned long current_offset = 0;
struct lst_header lst_header;
struct som_entry som_entry;
+ bfd_size_type amt;
#define ENTRY_SIZE sizeof (struct som_entry)
- if (bfd_read ((PTR) & file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE)
+ amt = FILE_HDR_SIZE;
+ if (bfd_bread ((PTR) &file_hdr, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
case EXECLIBMAGIC:
/* Read the lst header and determine where the SOM directory begins. */
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
return 0;
}
- if (bfd_read ((PTR) & lst_header, 1, SLSTHDR, abfd) != SLSTHDR)
+ amt = SLSTHDR;
+ if (bfd_bread ((PTR) &lst_header, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
/* Position to and read the first directory entry. */
- if (bfd_seek (abfd, lst_header.dir_loc, SEEK_SET) < 0)
+ if (bfd_seek (abfd, lst_header.dir_loc, SEEK_SET) != 0)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
return 0;
}
- if (bfd_read ((PTR) & som_entry, 1, ENTRY_SIZE, abfd) != ENTRY_SIZE)
+ amt = ENTRY_SIZE;
+ if (bfd_bread ((PTR) &som_entry, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
/* Now position to the first SOM. */
- if (bfd_seek (abfd, som_entry.location, SEEK_SET) < 0)
+ if (bfd_seek (abfd, som_entry.location, SEEK_SET) != 0)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
current_offset = som_entry.location;
/* And finally, re-read the som header. */
-
- if (bfd_read ((PTR) & file_hdr, 1, FILE_HDR_SIZE, abfd) != FILE_HDR_SIZE)
+ amt = FILE_HDR_SIZE;
+ if (bfd_bread ((PTR) &file_hdr, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
memset (&aux_hdr, 0, sizeof (struct som_exec_auxhdr));
if (file_hdr.aux_header_size != 0)
{
- if (bfd_read ((PTR) & aux_hdr, 1, AUX_HDR_SIZE, abfd) != AUX_HDR_SIZE)
+ amt = AUX_HDR_SIZE;
+ if (bfd_bread ((PTR) &aux_hdr, amt, abfd) != amt)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
{
/* Allocate memory to hold backend information. */
abfd->tdata.som_data = (struct som_data_struct *)
- bfd_zalloc (abfd, sizeof (struct som_data_struct));
+ bfd_zalloc (abfd, (bfd_size_type) sizeof (struct som_data_struct));
if (abfd->tdata.som_data == NULL)
return false;
return true;
{
struct header *file_hdr;
asection *section;
+ bfd_size_type amt = sizeof (struct header);
/* Make and attach a file header to the BFD. */
- file_hdr = (struct header *) bfd_zalloc (abfd, sizeof (struct header));
+ file_hdr = (struct header *) bfd_zalloc (abfd, amt);
if (file_hdr == NULL)
return false;
obj_som_file_hdr (abfd) = file_hdr;
{
/* Make and attach an exec header to the BFD. */
- obj_som_exec_hdr (abfd) = (struct som_exec_auxhdr *)
- bfd_zalloc (abfd, sizeof (struct som_exec_auxhdr));
+ amt = sizeof (struct som_exec_auxhdr);
+ obj_som_exec_hdr (abfd) =
+ (struct som_exec_auxhdr *) bfd_zalloc (abfd, amt);
if (obj_som_exec_hdr (abfd) == NULL)
return false;
if (som_is_space (section))
{
/* Allocate space for the space dictionary. */
+ amt = sizeof (struct space_dictionary_record);
som_section_data (section)->space_dict =
- (struct space_dictionary_record *)
- bfd_zalloc (abfd, sizeof (struct space_dictionary_record));
+ (struct space_dictionary_record *) bfd_zalloc (abfd, amt);
if (som_section_data (section)->space_dict == NULL)
return false;
/* Set space attributes. Note most attributes of SOM spaces
else
{
/* Allocate space for the subspace dictionary. */
- som_section_data (section)->subspace_dict
- = (struct subspace_dictionary_record *)
- bfd_zalloc (abfd, sizeof (struct subspace_dictionary_record));
+ amt = sizeof (struct subspace_dictionary_record);
+ som_section_data (section)->subspace_dict =
+ (struct subspace_dictionary_record *) bfd_zalloc (abfd, amt);
if (som_section_data (section)->subspace_dict == NULL)
return false;
asymbol **syms;
unsigned long num_syms;
{
- int i;
+ unsigned long i;
asection *section;
asymbol **sorted_syms;
+ bfd_size_type amt;
/* Most SOM relocations involving a symbol have a length which is
dependent on the index of the symbol. So symbols which are
of how often a given symbol is used in a relocation. */
for (section = abfd->sections; section != NULL; section = section->next)
{
- int i;
+ int j;
/* Does this section have any relocations? */
- if (section->reloc_count <= 0)
+ if ((int) section->reloc_count <= 0)
continue;
/* Walk through each relocation for this section. */
- for (i = 1; i < section->reloc_count; i++)
+ for (j = 1; j < (int) section->reloc_count; j++)
{
- arelent *reloc = section->orelocation[i];
+ arelent *reloc = section->orelocation[j];
int scale;
/* A relocation against a symbol in the *ABS* section really
/* Sort a copy of the symbol table, rather than the canonical
output symbol table. */
- sorted_syms = (asymbol **) bfd_zalloc (abfd, num_syms * sizeof (asymbol *));
+ amt = num_syms;
+ amt *= sizeof (asymbol *);
+ sorted_syms = (asymbol **) bfd_zalloc (abfd, amt);
memcpy (sorted_syms, syms, num_syms * sizeof (asymbol *));
qsort (sorted_syms, num_syms, sizeof (asymbol *), compare_syms);
obj_som_sorted_syms (abfd) = sorted_syms;
unsigned int subspace_reloc_size = 0;
unsigned int num_spaces = obj_som_file_hdr (abfd)->space_total;
asection *section = abfd->sections;
+ bfd_size_type amt;
memset (tmp_space, 0, SOM_TMP_BUFSIZE);
p = tmp_space;
subsection != NULL;
subsection = subsection->next)
{
- int reloc_offset, current_rounding_mode;
+ int reloc_offset;
+ unsigned int current_rounding_mode;
#ifndef NO_PCREL_MODES
int current_call_mode;
#endif
each subspace. Seek to the start of the relocation stream
for this subspace in preparation for writing out its fixup
stream. */
- if (bfd_seek (abfd, current_offset + total_reloc_size, SEEK_SET) < 0)
+ if (bfd_seek (abfd, current_offset + total_reloc_size, SEEK_SET) != 0)
return false;
/* Buffer space has already been allocated. Just perform some
upper limit, but leave lots of space for growth). */
if (p - tmp_space + 100 > SOM_TMP_BUFSIZE)
{
- if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
- != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) tmp_space, amt, abfd) != amt)
return false;
p = tmp_space;
{
bfd_put_8 (abfd, bfd_reloc->howto->type + 33, p);
bfd_put_8 (abfd, sym_num >> 16, p + 1);
- bfd_put_16 (abfd, sym_num, p + 2);
+ bfd_put_16 (abfd, (bfd_vma) sym_num, p + 2);
p = try_prev_fixup (abfd, &subspace_reloc_size,
p, 4, reloc_queue);
}
{
bfd_put_8 (abfd, bfd_reloc->howto->type + 1, p);
bfd_put_8 (abfd, sym_num >> 16, p + 1);
- bfd_put_16 (abfd, sym_num, p + 2);
+ bfd_put_16 (abfd, (bfd_vma) sym_num, p + 2);
p = try_prev_fixup (abfd, &subspace_reloc_size,
p, 4, reloc_queue);
}
case R_ENTRY:
{
- int tmp;
+ unsigned int tmp;
arelent *tmp_reloc = NULL;
bfd_put_8 (abfd, R_ENTRY, p);
bfd_put_8 (abfd, bfd_reloc->howto->type, p);
bfd_put_8 (abfd, 0x80, p + 1);
bfd_put_8 (abfd, sym_num >> 16, p + 2);
- bfd_put_16 (abfd, sym_num, p + 3);
+ bfd_put_16 (abfd, (bfd_vma) sym_num, p + 3);
p = try_prev_fixup (abfd, &subspace_reloc_size,
p, 5, reloc_queue);
break;
p, &subspace_reloc_size, reloc_queue);
/* Scribble out the relocations. */
- if (bfd_write ((PTR) tmp_space, p - tmp_space, 1, abfd)
- != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) tmp_space, amt, abfd) != amt)
return false;
p = tmp_space;
unsigned char *p = tmp_space;
unsigned int strings_size = 0;
asection *section;
+ bfd_size_type amt;
/* Seek to the start of the space strings in preparation for writing
them out. */
- if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0)
return false;
/* Walk through all the spaces and subspaces (order is not important)
if (p - tmp_space + 5 + length > tmp_space_size)
{
/* Flush buffer before refilling or reallocating. */
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
- != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt)
return false;
/* Reallocate if now empty buffer still too small. */
/* First element in a string table entry is the length of the
string. Alignment issues are already handled. */
- bfd_put_32 (abfd, length, p);
+ bfd_put_32 (abfd, (bfd_vma) length, p);
p += 4;
strings_size += 4;
/* Done with the space/subspace strings. Write out any information
contained in a partial block. */
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd) != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt)
return false;
*string_sizep = strings_size;
return true;
som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep,
compilation_unit)
bfd *abfd;
- unsigned long current_offset;
+ file_ptr current_offset;
asymbol **syms;
unsigned int num_syms;
unsigned int *string_sizep;
unsigned int strings_size = 0;
unsigned char *comp[4];
+ bfd_size_type amt;
/* This gets a bit gruesome because of the compilation unit. The
strings within the compilation unit are part of the symbol
/* Seek to the start of the space strings in preparation for writing
them out. */
- if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+ if (bfd_seek (abfd, current_offset, SEEK_SET) != 0)
return false;
if (compilation_unit)
if (p - tmp_space + 5 + length > tmp_space_size)
{
/* Flush buffer before refilling or reallocating. */
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
- != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt)
return false;
/* Reallocate if now empty buffer still too small. */
the string. This must always be 4 byte aligned. This is
also an appropriate time to fill in the string index
field in the symbol table entry. */
- bfd_put_32 (abfd, length, p);
+ bfd_put_32 (abfd, (bfd_vma) length, p);
strings_size += 4;
p += 4;
if (p - tmp_space + 5 + length > tmp_space_size)
{
/* Flush buffer before refilling or reallocating. */
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd)
- != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt)
return false;
/* Reallocate if now empty buffer still too small. */
string. This must always be 4 byte aligned. This is also
an appropriate time to fill in the string index field in the
symbol table entry. */
- bfd_put_32 (abfd, length, p);
+ bfd_put_32 (abfd, (bfd_vma) length, p);
strings_size += 4;
p += 4;
}
/* Scribble out any partial block. */
- if (bfd_write ((PTR) &tmp_space[0], p - tmp_space, 1, abfd) != p - tmp_space)
+ amt = p - tmp_space;
+ if (bfd_bwrite ((PTR) &tmp_space[0], amt, abfd) != amt)
return false;
*string_sizep = strings_size;
}
if (obj_som_version_hdr (abfd) != NULL)
{
- unsigned int len;
+ bfd_size_type len;
- if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0)
return false;
/* Write the aux_id structure and the string length. */
len = sizeof (struct aux_id) + sizeof (unsigned int);
obj_som_file_hdr (abfd)->aux_header_size += len;
current_offset += len;
- if (bfd_write ((PTR) obj_som_version_hdr (abfd), len, 1, abfd) != len)
+ if (bfd_bwrite ((PTR) obj_som_version_hdr (abfd), len, abfd) != len)
return false;
/* Write the version string. */
len = obj_som_version_hdr (abfd)->header_id.length - sizeof (int);
obj_som_file_hdr (abfd)->aux_header_size += len;
current_offset += len;
- if (bfd_write ((PTR) obj_som_version_hdr (abfd)->user_string,
- len, 1, abfd) != len)
+ if (bfd_bwrite ((PTR) obj_som_version_hdr (abfd)->user_string, len, abfd)
+ != len)
return false;
}
if (obj_som_copyright_hdr (abfd) != NULL)
{
- unsigned int len;
+ bfd_size_type len;
- if (bfd_seek (abfd, current_offset, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) current_offset, SEEK_SET) != 0)
return false;
/* Write the aux_id structure and the string length. */
len = sizeof (struct aux_id) + sizeof (unsigned int);
obj_som_file_hdr (abfd)->aux_header_size += len;
current_offset += len;
- if (bfd_write ((PTR) obj_som_copyright_hdr (abfd), len, 1, abfd) != len)
+ if (bfd_bwrite ((PTR) obj_som_copyright_hdr (abfd), len, abfd) != len)
return false;
/* Write the copyright string. */
len = obj_som_copyright_hdr (abfd)->header_id.length - sizeof (int);
obj_som_file_hdr (abfd)->aux_header_size += len;
current_offset += len;
- if (bfd_write ((PTR) obj_som_copyright_hdr (abfd)->copyright,
- len, 1, abfd) != len)
+ if (bfd_bwrite ((PTR) obj_som_copyright_hdr (abfd)->copyright, len, abfd)
+ != len)
return false;
}
zeros are filled in. Ugh. */
if (abfd->flags & (EXEC_P | DYNAMIC))
current_offset = SOM_ALIGN (current_offset, PA_PAGESIZE);
- if (bfd_seek (abfd, current_offset - 1, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) current_offset - 1, SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) "", 1, 1, abfd) != 1)
+ if (bfd_bwrite ((PTR) "", (bfd_size_type) 1, abfd) != 1)
return false;
obj_som_file_hdr (abfd)->unloadable_sp_size
asection *section;
unsigned long current_offset;
unsigned int total_reloc_size;
+ bfd_size_type amt;
/* Next is the symbol table. These are fixed length records.
/* Seek to the start of the subspace dictionary records. */
location = obj_som_file_hdr (abfd)->subspace_location;
- if (bfd_seek (abfd, location, SEEK_SET) < 0)
+ if (bfd_seek (abfd, location, SEEK_SET) != 0)
return false;
section = abfd->sections;
som_section_data (subsection)->subspace_dict->space_index = i;
/* Dump the current subspace header. */
- if (bfd_write ((PTR) som_section_data (subsection)->subspace_dict,
- sizeof (struct subspace_dictionary_record), 1, abfd)
- != sizeof (struct subspace_dictionary_record))
+ amt = sizeof (struct subspace_dictionary_record);
+ if (bfd_bwrite ((PTR) som_section_data (subsection)->subspace_dict,
+ amt, abfd) != amt)
return false;
}
/* Goto the next section. */
som_section_data (subsection)->subspace_dict->space_index = i;
/* Dump this subspace header. */
- if (bfd_write ((PTR) som_section_data (subsection)->subspace_dict,
- sizeof (struct subspace_dictionary_record), 1, abfd)
- != sizeof (struct subspace_dictionary_record))
+ amt = sizeof (struct subspace_dictionary_record);
+ if (bfd_bwrite ((PTR) som_section_data (subsection)->subspace_dict,
+ amt, abfd) != amt)
return false;
}
/* Goto the next section. */
Seek to the right location and start writing the space
dictionary records. */
location = obj_som_file_hdr (abfd)->space_location;
- if (bfd_seek (abfd, location, SEEK_SET) < 0)
+ if (bfd_seek (abfd, location, SEEK_SET) != 0)
return false;
section = abfd->sections;
section = section->next;
/* Dump its header. */
- if (bfd_write ((PTR) som_section_data (section)->space_dict,
- sizeof (struct space_dictionary_record), 1, abfd)
- != sizeof (struct space_dictionary_record))
+ amt = sizeof (struct space_dictionary_record);
+ if (bfd_bwrite ((PTR) som_section_data (section)->space_dict,
+ amt, abfd) != amt)
return false;
/* Goto the next section. */
if (obj_som_compilation_unit (abfd))
{
location = obj_som_file_hdr (abfd)->compiler_location;
- if (bfd_seek (abfd, location, SEEK_SET) < 0)
+ if (bfd_seek (abfd, location, SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) obj_som_compilation_unit (abfd),
- COMPUNITSZ, 1, abfd) != COMPUNITSZ)
+ amt = COMPUNITSZ;
+ if (bfd_bwrite ((PTR) obj_som_compilation_unit (abfd), amt, abfd) != amt)
return false;
}
/* Only thing left to do is write out the file header. It is always
at location zero. Seek there and write it. */
- if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) < 0)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) obj_som_file_hdr (abfd),
- sizeof (struct header), 1, abfd)
- != sizeof (struct header))
+ amt = sizeof (struct header);
+ if (bfd_bwrite ((PTR) obj_som_file_hdr (abfd), amt, abfd) != amt)
return false;
/* Now write the exec header. */
}
if (bfd_seek (abfd, obj_som_file_hdr (abfd)->aux_header_location,
- SEEK_SET) < 0)
+ SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) exec_header, AUX_HDR_SIZE, 1, abfd)
- != AUX_HDR_SIZE)
+ amt = AUX_HDR_SIZE;
+ if (bfd_bwrite ((PTR) exec_header, amt, abfd) != amt)
return false;
}
return true;
file_ptr symtab_location = obj_som_file_hdr (abfd)->symbol_location;
asymbol **bfd_syms = obj_som_sorted_syms (abfd);
struct symbol_dictionary_record *som_symtab = NULL;
- int i, symtab_size;
+ unsigned int i;
+ bfd_size_type symtab_size;
/* Compute total symbol table size and allocate a chunk of memory
to hold the symbol table as we build it. */
- symtab_size = num_syms * sizeof (struct symbol_dictionary_record);
+ symtab_size = num_syms;
+ symtab_size *= sizeof (struct symbol_dictionary_record);
som_symtab = (struct symbol_dictionary_record *) bfd_malloc (symtab_size);
if (som_symtab == NULL && symtab_size != 0)
goto error_return;
- memset (som_symtab, 0, symtab_size);
+ memset (som_symtab, 0, (size_t) symtab_size);
/* Walk over each symbol. */
for (i = 0; i < num_syms; i++)
if (bfd_seek (abfd, symtab_location, SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) som_symtab, symtab_size, 1, abfd) != symtab_size)
+ if (bfd_bwrite ((PTR) som_symtab, symtab_size, abfd) != symtab_size)
goto error_return;
if (som_symtab != NULL)
bfd *abfd;
{
char *stringtab;
+ bfd_size_type amt;
/* Use the saved version if its available. */
if (obj_som_stringtab (abfd) != NULL)
}
/* Allocate and read in the string table. */
- stringtab = bfd_malloc (obj_som_stringtab_size (abfd));
+ amt = obj_som_stringtab_size (abfd);
+ stringtab = bfd_malloc (amt);
if (stringtab == NULL)
return false;
memset (stringtab, 0, obj_som_stringtab_size (abfd));
- if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) < 0)
+ if (bfd_seek (abfd, obj_som_str_filepos (abfd), SEEK_SET) != 0)
return false;
- if (bfd_read (stringtab, obj_som_stringtab_size (abfd), 1, abfd)
- != obj_som_stringtab_size (abfd))
+ if (bfd_bread (stringtab, amt, abfd) != amt)
return false;
/* Save our results and return success. */
char *stringtab;
struct symbol_dictionary_record *buf = NULL, *bufp, *endbufp;
som_symbol_type *sym, *symbase;
+ bfd_size_type amt;
/* Return saved value if it exists. */
if (obj_som_symtab (abfd) != NULL)
stringtab = obj_som_stringtab (abfd);
- symbase = ((som_symbol_type *)
- bfd_malloc (symbol_count * sizeof (som_symbol_type)));
+ amt = symbol_count;
+ amt *= sizeof (som_symbol_type);
+ symbase = (som_symbol_type *) bfd_malloc (amt);
if (symbase == NULL)
goto error_return;
memset (symbase, 0, symbol_count * sizeof (som_symbol_type));
/* Read in the external SOM representation. */
- buf = bfd_malloc (symbol_count * symsize);
- if (buf == NULL && symbol_count * symsize != 0)
+ amt = symbol_count;
+ amt *= symsize;
+ buf = bfd_malloc (amt);
+ if (buf == NULL && amt != 0)
goto error_return;
- if (bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET) < 0)
+ if (bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET) != 0)
goto error_return;
- if (bfd_read (buf, symbol_count * symsize, 1, abfd)
- != symbol_count * symsize)
+ if (bfd_bread (buf, amt, abfd) != amt)
goto error_return;
/* Iterate over all the symbols and internalize them. */
som_make_empty_symbol (abfd)
bfd *abfd;
{
- som_symbol_type *new =
- (som_symbol_type *) bfd_zalloc (abfd, sizeof (som_symbol_type));
+ bfd_size_type amt = sizeof (som_symbol_type);
+ som_symbol_type *new = (som_symbol_type *) bfd_zalloc (abfd, amt);
if (new == NULL)
return 0;
new->symbol.the_bfd = abfd;
break;
case bfd_print_symbol_all:
{
- CONST char *section_name;
+ const char *section_name;
section_name = symbol->section ? symbol->section->name : "(*none*)";
bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
fprintf (file, " %s\t%s", section_name, symbol->name);
day if the need arises. */
section->contents = bfd_malloc (section->_raw_size);
if (section->contents == NULL)
- return -1;
+ return (unsigned) -1;
deallocate_contents = 1;
bfd_get_section_contents (section->owner,
section,
section->contents,
- 0,
+ (bfd_vma) 0,
section->_raw_size);
}
else if (rptr->addend == 0)
unsigned int fixup_stream_size;
arelent *internal_relocs;
unsigned int num_relocs;
+ bfd_size_type amt;
fixup_stream_size = som_section_data (section)->reloc_size;
/* If there were no relocations, then there is nothing to do. */
/* If reloc_count is -1, then the relocation stream has not been
parsed. We must do so now to know how many relocations exist. */
- if (section->reloc_count == -1)
+ if (section->reloc_count == (unsigned) -1)
{
- external_relocs = (char *) bfd_malloc (fixup_stream_size);
+ amt = fixup_stream_size;
+ external_relocs = (char *) bfd_malloc (amt);
if (external_relocs == (char *) NULL)
return false;
/* Read in the external forms. */
SEEK_SET)
!= 0)
return false;
- if (bfd_read (external_relocs, 1, fixup_stream_size, abfd)
- != fixup_stream_size)
+ if (bfd_bread (external_relocs, amt, abfd) != amt)
return false;
/* Let callers know how many relocations found.
if (section->relocation != (arelent *) NULL)
return true;
- internal_relocs = (arelent *)
- bfd_zalloc (abfd, (num_relocs * sizeof (arelent)));
+ amt = num_relocs;
+ amt *= sizeof (arelent);
+ internal_relocs = (arelent *) bfd_zalloc (abfd, (amt));
if (internal_relocs == (arelent *) NULL)
return false;
bfd *abfd;
asection *newsect;
{
- newsect->used_by_bfd =
- (PTR) bfd_zalloc (abfd, sizeof (struct som_section_data_struct));
+ bfd_size_type amt = sizeof (struct som_section_data_struct);
+ newsect->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (!newsect->used_by_bfd)
return false;
newsect->alignment_power = 3;
bfd *obfd;
asection *osection;
{
+ bfd_size_type amt;
+
/* One day we may try to grok other private data. */
if (ibfd->xvec->flavour != bfd_target_som_flavour
|| obfd->xvec->flavour != bfd_target_som_flavour
|| (!som_is_space (isection) && !som_is_subspace (isection)))
return true;
+ amt = sizeof (struct som_copyable_section_data_struct);
som_section_data (osection)->copy_data =
- (struct som_copyable_section_data_struct *)
- bfd_zalloc (obfd, sizeof (struct som_copyable_section_data_struct));
+ (struct som_copyable_section_data_struct *) bfd_zalloc (obfd, amt);
if (som_section_data (osection)->copy_data == NULL)
return false;
/* Allocate some memory to hold the data we need. */
obj_som_exec_data (obfd) = (struct som_exec_data *)
- bfd_zalloc (obfd, sizeof (struct som_exec_data));
+ bfd_zalloc (obfd, (bfd_size_type) sizeof (struct som_exec_data));
if (obj_som_exec_data (obfd) == NULL)
return false;
/* Allocate memory to hold the magic information. */
if (som_section_data (section)->copy_data == NULL)
{
+ bfd_size_type amt = sizeof (struct som_copyable_section_data_struct);
som_section_data (section)->copy_data =
- (struct som_copyable_section_data_struct *)
- bfd_zalloc (section->owner,
- sizeof (struct som_copyable_section_data_struct));
+ (struct som_copyable_section_data_struct *) bfd_zalloc (section->owner,
+ amt);
if (som_section_data (section)->copy_data == NULL)
return false;
}
/* Allocate memory to hold the magic information. */
if (som_section_data (section)->copy_data == NULL)
{
+ bfd_size_type amt = sizeof (struct som_copyable_section_data_struct);
som_section_data (section)->copy_data =
- (struct som_copyable_section_data_struct *)
- bfd_zalloc (section->owner,
- sizeof (struct som_copyable_section_data_struct));
+ (struct som_copyable_section_data_struct *) bfd_zalloc (section->owner,
+ amt);
if (som_section_data (section)->copy_data == NULL)
return false;
}
int type;
char *string;
{
+ bfd_size_type amt;
+
if (type == VERSION_AUX_ID)
{
- int len = strlen (string);
+ size_t len = strlen (string);
int pad = 0;
if (len % 4)
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);
+ amt = sizeof (struct aux_id) + sizeof (unsigned int) + len + pad;
+ obj_som_version_hdr (abfd) =
+ (struct user_string_aux_hdr *) bfd_zalloc (abfd, amt);
if (!obj_som_version_hdr (abfd))
return false;
obj_som_version_hdr (abfd)->header_id.type = VERSION_AUX_ID;
if (len % 4)
pad = (4 - (len % 4));
- obj_som_copyright_hdr (abfd) = (struct copyright_aux_hdr *)
- bfd_zalloc (abfd, sizeof (struct aux_id)
- + sizeof (unsigned int) + len + pad);
+ amt = sizeof (struct aux_id) + sizeof (unsigned int) + len + pad;
+ obj_som_copyright_hdr (abfd) =
+ (struct copyright_aux_hdr *) bfd_zalloc (abfd, amt);
if (!obj_som_copyright_hdr (abfd))
return false;
obj_som_copyright_hdr (abfd)->header_id.type = COPYRIGHT_AUX_ID;
const char *product_id;
const char *version_id;
{
- COMPUNIT *n = (COMPUNIT *) bfd_zalloc (abfd, COMPUNITSZ);
+ COMPUNIT *n = (COMPUNIT *) bfd_zalloc (abfd, (bfd_size_type) COMPUNITSZ);
if (n == NULL)
return false;
#define STRDUP(f) \
if (f != NULL) \
{ \
- n->f.n_name = bfd_alloc (abfd, strlen (f) + 1); \
+ n->f.n_name = bfd_alloc (abfd, (bfd_size_type) strlen (f) + 1); \
if (n->f.n_name == NULL) \
return false; \
strcpy (n->f.n_name, f); \
if (count == 0 || ((section->flags & SEC_HAS_CONTENTS) == 0))
return true;
if ((bfd_size_type) (offset+count) > section->_raw_size
- || bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) == -1
- || bfd_read (location, (bfd_size_type) 1, count, abfd) != count)
+ || bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
+ || bfd_bread (location, count, abfd) != count)
return (false); /* on error */
return (true);
}
/* Seek to the proper offset within the object file and write the
data. */
offset += som_section_data (section)->subspace_dict->file_loc_init_value;
- if (bfd_seek (abfd, offset, SEEK_SET) == -1)
+ if (bfd_seek (abfd, offset, SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) location, 1, count, abfd) != count)
+ if (bfd_bwrite ((PTR) location, count, abfd) != count)
return false;
return true;
}
asection *section ATTRIBUTE_UNUSED;
asymbol **symbols ATTRIBUTE_UNUSED;
bfd_vma offset ATTRIBUTE_UNUSED;
- CONST char **filename_ptr ATTRIBUTE_UNUSED;
- CONST char **functionname_ptr ATTRIBUTE_UNUSED;
+ const char **filename_ptr ATTRIBUTE_UNUSED;
+ const char **functionname_ptr ATTRIBUTE_UNUSED;
unsigned int *line_ptr ATTRIBUTE_UNUSED;
{
return (false);
{
unsigned int i;
unsigned int *hash_table = NULL;
+ bfd_size_type amt;
file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
- hash_table =
- (unsigned int *) bfd_malloc (lst_header->hash_size
- * sizeof (unsigned int));
+ amt = lst_header->hash_size;
+ amt *= sizeof (unsigned int);
+ hash_table = (unsigned int *) bfd_malloc (amt);
if (hash_table == NULL && lst_header->hash_size != 0)
goto error_return;
/* Read in the hash table. The has table is an array of 32bit file offsets
which point to the hash chains. */
- if (bfd_read ((PTR) hash_table, lst_header->hash_size, 4, abfd)
- != lst_header->hash_size * 4)
+ if (bfd_bread ((PTR) hash_table, amt, abfd) != amt)
goto error_return;
/* Walk each chain counting the number of symbols found on that particular
continue;
/* Seek to the first symbol in this hash chain. */
- if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) < 0)
+ if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) != 0)
goto error_return;
/* Read in this symbol and update the counter. */
- if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
- != sizeof (lst_symbol))
+ amt = sizeof (lst_symbol);
+ if (bfd_bread ((PTR) &lst_symbol, amt, abfd) != amt)
goto error_return;
(*count)++;
/* Seek to the next symbol. */
if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET)
- < 0)
+ != 0)
goto error_return;
/* Read the symbol in and update the counter. */
- if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
- != sizeof (lst_symbol))
+ amt = sizeof (lst_symbol);
+ if (bfd_bread ((PTR) &lst_symbol, amt, abfd) != amt)
goto error_return;
(*count)++;
carsym *set = syms[0];
unsigned int *hash_table = NULL;
struct som_entry *som_dict = NULL;
+ bfd_size_type amt;
file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
- hash_table =
- (unsigned int *) bfd_malloc (lst_header->hash_size
- * sizeof (unsigned int));
+ amt = lst_header->hash_size;
+ amt *= sizeof (unsigned int);
+ hash_table = (unsigned int *) bfd_malloc (amt);
if (hash_table == NULL && lst_header->hash_size != 0)
goto error_return;
- som_dict =
- (struct som_entry *) bfd_malloc (lst_header->module_count
- * sizeof (struct som_entry));
- if (som_dict == NULL && lst_header->module_count != 0)
- goto error_return;
-
/* Read in the hash table. The has table is an array of 32bit file offsets
which point to the hash chains. */
- if (bfd_read ((PTR) hash_table, lst_header->hash_size, 4, abfd)
- != lst_header->hash_size * 4)
+ if (bfd_bread ((PTR) hash_table, amt, abfd) != amt)
goto error_return;
/* Seek to and read in the SOM dictionary. We will need this to fill
in the carsym's filepos field. */
- if (bfd_seek (abfd, lst_filepos + lst_header->dir_loc, SEEK_SET) < 0)
+ if (bfd_seek (abfd, lst_filepos + lst_header->dir_loc, SEEK_SET) != 0)
+ goto error_return;
+
+ amt = lst_header->module_count;
+ amt *= sizeof (struct som_entry);
+ som_dict = (struct som_entry *) bfd_malloc (amt);
+ if (som_dict == NULL && lst_header->module_count != 0)
goto error_return;
- if (bfd_read ((PTR) som_dict, lst_header->module_count,
- sizeof (struct som_entry), abfd)
- != lst_header->module_count * sizeof (struct som_entry))
+ if (bfd_bread ((PTR) som_dict, amt, abfd) != amt)
goto error_return;
/* Walk each chain filling in the carsyms as we go along. */
continue;
/* Seek to and read the first symbol on the chain. */
- if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) < 0)
+ if (bfd_seek (abfd, lst_filepos + hash_table[i], SEEK_SET) != 0)
goto error_return;
- if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
- != sizeof (lst_symbol))
+ amt = sizeof (lst_symbol);
+ if (bfd_bread ((PTR) &lst_symbol, amt, abfd) != amt)
goto error_return;
/* Get the name of the symbol, first get the length which is stored
index can point *anywhere* in the archive to save space, so just
using the string table would not be safe. */
if (bfd_seek (abfd, lst_filepos + lst_header->string_loc
- + lst_symbol.name.n_strx - 4, SEEK_SET) < 0)
+ + lst_symbol.name.n_strx - 4, SEEK_SET) != 0)
goto error_return;
- if (bfd_read (&len, 1, 4, abfd) != 4)
+ if (bfd_bread (&len, (bfd_size_type) 4, abfd) != 4)
goto error_return;
/* Allocate space for the name and null terminate it too. */
- set->name = bfd_zalloc (abfd, len + 1);
+ set->name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
if (!set->name)
goto error_return;
- if (bfd_read (set->name, 1, len, abfd) != len)
+ if (bfd_bread (set->name, (bfd_size_type) len, abfd) != len)
goto error_return;
set->name[len] = 0;
while (lst_symbol.next_entry)
{
/* Seek to the next symbol and read it in. */
- if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET) <0)
+ if (bfd_seek (abfd, lst_filepos + lst_symbol.next_entry, SEEK_SET)
+ != 0)
goto error_return;
- if (bfd_read ((PTR) & lst_symbol, 1, sizeof (lst_symbol), abfd)
- != sizeof (lst_symbol))
+ amt = sizeof (lst_symbol);
+ if (bfd_bread ((PTR) &lst_symbol, amt, abfd) != amt)
goto error_return;
/* Seek to the name length & string and read them in. */
if (bfd_seek (abfd, lst_filepos + lst_header->string_loc
- + lst_symbol.name.n_strx - 4, SEEK_SET) < 0)
+ + lst_symbol.name.n_strx - 4, SEEK_SET) != 0)
goto error_return;
- if (bfd_read (&len, 1, 4, abfd) != 4)
+ if (bfd_bread (&len, (bfd_size_type) 4, abfd) != 4)
goto error_return;
/* Allocate space for the name and null terminate it too. */
- set->name = bfd_zalloc (abfd, len + 1);
+ set->name = bfd_zalloc (abfd, (bfd_size_type) len + 1);
if (!set->name)
goto error_return;
- if (bfd_read (set->name, 1, len, abfd) != len)
+ if (bfd_bread (set->name, (bfd_size_type) len, abfd) != len)
goto error_return;
set->name[len] = 0;
unsigned int parsed_size;
struct artdata *ardata = bfd_ardata (abfd);
char nextname[17];
- int i = bfd_read ((PTR) nextname, 1, 16, abfd);
+ bfd_size_type amt = 16;
+ int i = bfd_bread ((PTR) nextname, amt, abfd);
/* Special cases. */
if (i == 0)
if (i != 16)
return false;
- if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) < 0)
+ if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
return false;
/* For archives without .o files there is no symbol table. */
}
/* Read in and sanity check the archive header. */
- if (bfd_read ((PTR) &ar_header, 1, sizeof (struct ar_hdr), abfd)
- != sizeof (struct ar_hdr))
+ amt = sizeof (struct ar_hdr);
+ if (bfd_bread ((PTR) &ar_header, amt, abfd) != amt)
return false;
if (strncmp (ar_header.ar_fmag, ARFMAG, 2))
/* Read in the library symbol table. We'll make heavy use of this
in just a minute. */
- if (bfd_read ((PTR) & lst_header, 1, sizeof (struct lst_header), abfd)
- != sizeof (struct lst_header))
+ amt = sizeof (struct lst_header);
+ if (bfd_bread ((PTR) &lst_header, amt, abfd) != amt)
return false;
/* Sanity check. */
return false;
/* Get back to the start of the library symbol table. */
- if (bfd_seek (abfd, ardata->first_file_filepos - parsed_size
- + sizeof (struct lst_header), SEEK_SET) < 0)
+ if (bfd_seek (abfd, (ardata->first_file_filepos - parsed_size
+ + sizeof (struct lst_header)), SEEK_SET) != 0)
return false;
/* Initializae the cache and allocate space for the library symbols. */
ardata->cache = 0;
- ardata->symdefs = (carsym *) bfd_alloc (abfd,
- (ardata->symdef_count
- * sizeof (carsym)));
+ amt = ardata->symdef_count;
+ amt *= sizeof (carsym);
+ ardata->symdefs = (carsym *) bfd_alloc (abfd, amt);
if (!ardata->symdefs)
return false;
/* Seek back to the "first" file in the archive. Note the "first"
file may be the extended name table. */
- if (bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET) < 0)
+ if (bfd_seek (abfd, ardata->first_file_filepos, SEEK_SET) != 0)
return false;
/* Notify the generic archive code that we have a symbol map. */
struct som_entry *som_dict = NULL;
struct lst_symbol_record **last_hash_entry = NULL;
unsigned int curr_som_offset, som_index = 0;
+ bfd_size_type amt;
- hash_table =
- (unsigned int *) bfd_malloc (lst.hash_size * sizeof (unsigned int));
+ amt = lst.hash_size;
+ amt *= sizeof (unsigned int);
+ hash_table = (unsigned int *) bfd_malloc (amt);
if (hash_table == NULL && lst.hash_size != 0)
goto error_return;
- som_dict =
- (struct som_entry *) bfd_malloc (lst.module_count
- * sizeof (struct som_entry));
+
+ amt = lst.module_count;
+ amt *= sizeof (struct som_entry);
+ som_dict = (struct som_entry *) bfd_malloc (amt);
if (som_dict == NULL && lst.module_count != 0)
goto error_return;
- last_hash_entry =
- ((struct lst_symbol_record **)
- bfd_malloc (lst.hash_size * sizeof (struct lst_symbol_record *)));
+ amt = lst.hash_size;
+ amt *= sizeof (struct lst_symbol_record *);
+ last_hash_entry = ((struct lst_symbol_record **) bfd_malloc (amt));
if (last_hash_entry == NULL && lst.hash_size != 0)
goto error_return;
curr_som_offset = (curr_som_offset + 0x1) & ~0x1;
/* FIXME should be done with buffers just like everything else... */
- lst_syms = bfd_malloc (nsyms * sizeof (struct lst_symbol_record));
+ amt = nsyms;
+ amt *= sizeof (struct lst_symbol_record);
+ lst_syms = bfd_malloc (amt);
if (lst_syms == NULL && nsyms != 0)
goto error_return;
- strings = bfd_malloc (string_size);
+ strings = bfd_malloc ((bfd_size_type) string_size);
if (strings == NULL && string_size != 0)
goto error_return;
/* A particular object in the archive may have an odd length; the
linker requires objects begin on an even boundary. So round
up the current offset as necessary. */
- curr_som_offset = (curr_som_offset + 0x1) & ~0x1;
+ curr_som_offset = (curr_som_offset + 0x1) &~ (unsigned) 1;
curr_bfd = curr_bfd->next;
som_index++;
}
/* Now scribble out the hash table. */
- if (bfd_write ((PTR) hash_table, lst.hash_size, 4, abfd)
- != lst.hash_size * 4)
+ amt = lst.hash_size * 4;
+ if (bfd_bwrite ((PTR) hash_table, amt, abfd) != amt)
goto error_return;
/* Then the SOM dictionary. */
- if (bfd_write ((PTR) som_dict, lst.module_count,
- sizeof (struct som_entry), abfd)
- != lst.module_count * sizeof (struct som_entry))
+ amt = lst.module_count * sizeof (struct som_entry);
+ if (bfd_bwrite ((PTR) som_dict, amt, abfd) != amt)
goto error_return;
/* The library symbols. */
- if (bfd_write ((PTR) lst_syms, nsyms, sizeof (struct lst_symbol_record), abfd)
- != nsyms * sizeof (struct lst_symbol_record))
+ amt = nsyms * sizeof (struct lst_symbol_record);
+ if (bfd_bwrite ((PTR) lst_syms, amt, abfd) != amt)
goto error_return;
/* And finally the strings. */
- if (bfd_write ((PTR) strings, string_size, 1, abfd) != string_size)
+ amt = string_size;
+ if (bfd_bwrite ((PTR) strings, amt, abfd) != amt)
goto error_return;
if (hash_table != NULL)
struct ar_hdr hdr;
struct lst_header lst;
int *p;
+ bfd_size_type amt;
/* We'll use this for the archive's date and mode later. */
if (stat (abfd->filename, &statbuf) != 0)
(((char *) (&hdr))[i]) = ' ';
/* Scribble out the ar header. */
- if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), abfd)
- != sizeof (struct ar_hdr))
+ amt = sizeof (struct ar_hdr);
+ if (bfd_bwrite ((PTR) &hdr, amt, abfd) != amt)
return false;
/* Now scribble out the lst header. */
- if (bfd_write ((PTR) &lst, 1, sizeof (struct lst_header), abfd)
- != sizeof (struct lst_header))
+ amt = sizeof (struct lst_header);
+ if (bfd_bwrite ((PTR) &lst, amt, abfd) != amt)
return false;
/* Build and write the armap. */
- if (som_bfd_ar_write_symbol_stuff (abfd, nsyms, stringsize, lst, elength)
- == false)
+ if (!som_bfd_ar_write_symbol_stuff (abfd, nsyms, stringsize, lst, elength))
return false;
/* Done. */
for (o = abfd->sections; o != (asection *) NULL; o = o->next)
{
/* Free the native relocations. */
- o->reloc_count = -1;
+ o->reloc_count = (unsigned) -1;
FREE (som_section_data (o)->reloc_stream);
/* Free the generic relocations. */
FREE (o->relocation);
/* BFD back-end for linux flavored sparc a.out binaries.
- Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2000
+ Copyright 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
bfd *abfd;
{
struct linux_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct linux_link_hash_table);
- ret = ((struct linux_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct linux_link_hash_table)));
+ ret = (struct linux_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct linux_link_hash_table *) NULL)
return (struct bfd_link_hash_table *) NULL;
if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
if (! (_bfd_generic_link_add_one_symbol
(info, linux_hash_table (info)->dynobj, SHARABLE_CONFLICTS,
- BSF_GLOBAL | BSF_CONSTRUCTOR, s, 0, NULL, false, false, NULL)))
+ BSF_GLOBAL | BSF_CONSTRUCTOR, s, (bfd_vma) 0, NULL,
+ false, false, NULL)))
return false;
}
name = h->root.root.root.string + sizeof NEEDS_SHRLIB - 1;
p = strrchr (name, '_');
if (p != NULL)
- alloc = (char *) bfd_malloc (strlen (name) + 1);
+ alloc = (char *) bfd_malloc ((bfd_size_type) strlen (name) + 1);
if (p == NULL || alloc == NULL)
(*_bfd_error_handler) (_("Output file requires shared library `%s'\n"),
".linux-dynamic");
if (s != NULL)
{
- s->_raw_size = 8 + linux_hash_table (info)->fixup_count * 8;
+ s->_raw_size = linux_hash_table (info)->fixup_count + 1;
+ s->_raw_size *= 8;
s->contents = (bfd_byte *) bfd_alloc (output_bfd, s->_raw_size);
if (s->contents == NULL)
return false;
#endif
fixup_table = s->contents;
- bfd_put_32 (output_bfd, linux_hash_table (info)->fixup_count, fixup_table);
+ bfd_put_32 (output_bfd,
+ (bfd_vma) linux_hash_table (info)->fixup_count, fixup_table);
fixup_table += 4;
/* Fill in fixup table. */
{
/* Relative address */
new_addr = new_addr - (f->value + 5);
- bfd_put_32 (output_bfd, new_addr, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
fixup_table += 4;
bfd_put_32 (output_bfd, f->value + 1, fixup_table);
fixup_table += 4;
}
else
{
- bfd_put_32 (output_bfd, new_addr, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
fixup_table += 4;
bfd_put_32 (output_bfd, f->value, fixup_table);
fixup_table += 4;
if (linux_hash_table (info)->local_builtins != 0)
{
/* Special marker so we know to switch to the other type of fixup */
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
fixup_table += 4;
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
fixup_table += 4;
++fixups_written;
for (f = linux_hash_table (info)->fixup_list; f != NULL; f = f->next)
new_addr, f->value);
#endif
- bfd_put_32 (output_bfd, new_addr, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
fixup_table += 4;
bfd_put_32 (output_bfd, f->value, fixup_table);
fixup_table += 4;
(*_bfd_error_handler) (_("Warning: fixup count mismatch\n"));
while (linux_hash_table (info)->fixup_count > fixups_written)
{
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
fixup_table += 4;
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
fixup_table += 4;
++fixups_written;
}
printf ("Builtin fixup table at %x\n", new_addr);
#endif
- bfd_put_32 (output_bfd, new_addr, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) new_addr, fixup_table);
}
else
- bfd_put_32 (output_bfd, 0, fixup_table);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, fixup_table);
- if (bfd_seek (output_bfd, os->filepos + s->output_offset, SEEK_SET) != 0)
+ if (bfd_seek (output_bfd, (file_ptr) (os->filepos + s->output_offset),
+ SEEK_SET) != 0)
return false;
- if (bfd_write ((PTR) s->contents, 1, s->_raw_size, output_bfd)
+ if (bfd_bwrite ((PTR) s->contents, s->_raw_size, output_bfd)
!= s->_raw_size)
return false;
#include "aout/stab_gnu.h"
#include "aout/ar.h"
-void NAME (lynx,set_arch_mach) PARAMS ((bfd *, int));
+void NAME (lynx,set_arch_mach) PARAMS ((bfd *, unsigned long));
static void choose_reloc_size PARAMS ((bfd *));
static boolean NAME (aout,sparclynx_write_object_contents) PARAMS ((bfd *));
void
NAME(lynx,set_arch_mach) (abfd, machtype)
bfd *abfd;
- int machtype;
+ unsigned long machtype;
{
/* Determine the architecture and machine type of the object file. */
enum bfd_architecture arch;
- long machine;
+ unsigned long machine;
switch (machtype)
{
}
}
-static CONST struct aout_backend_data sparclynx_aout_backend =
+static const struct aout_backend_data sparclynx_aout_backend =
{
0, 1, 0, 1, 0, sparclynx_set_sizes, 0,
0, /* add_dynamic_symbols */
/* BFD back-end for s-record objects.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000
+ 2000, 2001
Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
static const bfd_target *symbolsrec_object_p PARAMS ((bfd *));
static boolean srec_read_section PARAMS ((bfd *, asection *, bfd_byte *));
-static boolean srec_write_record PARAMS ((bfd *, int, bfd_vma,
+static boolean srec_write_record PARAMS ((bfd *, unsigned int, bfd_vma,
const bfd_byte *,
const bfd_byte *));
static boolean srec_write_header PARAMS ((bfd *));
/* Macros for converting between hex and binary. */
-static CONST char digs[] = "0123456789ABCDEF";
+static const char digs[] = "0123456789ABCDEF";
#define NIBBLE(x) hex_value(x)
#define HEX(buffer) ((NIBBLE((buffer)[0])<<4) + NIBBLE((buffer)[1]))
if (abfd->tdata.srec_data == NULL)
{
- tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
+ bfd_size_type amt = sizeof (tdata_type);
+ tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, amt);
if (tdata == NULL)
return false;
abfd->tdata.srec_data = tdata;
{
bfd_byte c;
- if (bfd_read (&c, 1, 1, abfd) != 1)
+ if (bfd_bread (&c, (bfd_size_type) 1, abfd) != 1)
{
if (bfd_get_error () != bfd_error_file_truncated)
*errorptr = true;
bfd_vma val;
{
struct srec_symbol *n;
+ bfd_size_type amt = sizeof (struct srec_symbol);
- n = (struct srec_symbol *) bfd_alloc (abfd, sizeof (struct srec_symbol));
+ n = (struct srec_symbol *) bfd_alloc (abfd, amt);
if (n == NULL)
return false;
case ' ':
do
{
- unsigned int alc;
+ bfd_size_type alc;
char *p, *symname;
bfd_vma symval;
while ((c = srec_get_byte (abfd, &error)) != EOF
&& ! isspace (c))
{
- if ((unsigned int) (p - symbuf) >= alc)
+ if ((bfd_size_type) (p - symbuf) >= alc)
{
char *n;
}
*p++ = '\0';
- symname = bfd_alloc (abfd, p - symbuf);
+ symname = bfd_alloc (abfd, (bfd_size_type) (p - symbuf));
if (symname == NULL)
goto error_return;
strcpy (symname, symbuf);
pos = bfd_tell (abfd) - 1;
- if (bfd_read (hdr, 1, 3, abfd) != 3)
+ if (bfd_bread (hdr, (bfd_size_type) 3, abfd) != 3)
goto error_return;
if (! ISHEX (hdr[1]) || ! ISHEX (hdr[2]))
{
if (buf != NULL)
free (buf);
- buf = (bfd_byte *) bfd_malloc (bytes * 2);
+ buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2);
if (buf == NULL)
goto error_return;
bufsize = bytes * 2;
}
- if (bfd_read (buf, 1, bytes * 2, abfd) != bytes * 2)
+ if (bfd_bread (buf, (bfd_size_type) bytes * 2, abfd) != bytes * 2)
goto error_return;
/* Ignore the checksum byte. */
{
char secbuf[20];
char *secname;
+ bfd_size_type amt;
sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
- secname = (char *) bfd_alloc (abfd, strlen (secbuf) + 1);
+ amt = strlen (secbuf) + 1;
+ secname = (char *) bfd_alloc (abfd, amt);
strcpy (secname, secbuf);
sec = bfd_make_section (abfd, secname);
if (sec == NULL)
srec_init ();
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || bfd_read (b, 1, 4, abfd) != 4)
+ || bfd_bread (b, (bfd_size_type) 4, abfd) != 4)
return NULL;
if (b[0] != 'S' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3]))
srec_init ();
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || bfd_read (b, 1, 2, abfd) != 2)
+ || bfd_bread (b, (bfd_size_type) 2, abfd) != 2)
return NULL;
if (b[0] != '$' || b[1] != '$')
ought to know the exact format. */
BFD_ASSERT (c == 'S');
- if (bfd_read (hdr, 1, 3, abfd) != 3)
+ if (bfd_bread (hdr, (bfd_size_type) 3, abfd) != 3)
goto error_return;
BFD_ASSERT (ISHEX (hdr[1]) && ISHEX (hdr[2]));
{
if (buf != NULL)
free (buf);
- buf = (bfd_byte *) bfd_malloc (bytes * 2);
+ buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2);
if (buf == NULL)
goto error_return;
bufsize = bytes * 2;
}
- if (bfd_read (buf, 1, bytes * 2, abfd) != bytes * 2)
+ if (bfd_bread (buf, (bfd_size_type) bytes * 2, abfd) != bytes * 2)
goto error_return;
address = 0;
if (section->used_by_bfd == NULL)
{
section->used_by_bfd = bfd_alloc (abfd, section->_raw_size);
- if (section->used_by_bfd == NULL
- && section->_raw_size != 0)
+ if (section->used_by_bfd == NULL && section->_raw_size != 0)
return false;
if (! srec_read_section (abfd, section, section->used_by_bfd))
register srec_data_list_type *entry;
entry = ((srec_data_list_type *)
- bfd_alloc (abfd, sizeof (srec_data_list_type)));
+ bfd_alloc (abfd, (bfd_size_type) sizeof (srec_data_list_type)));
if (entry == NULL)
return false;
&& (section->flags & SEC_ALLOC)
&& (section->flags & SEC_LOAD))
{
- bfd_byte *data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do);
+ bfd_byte *data;
+
+ data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do);
if (data == NULL)
return false;
memcpy ((PTR) data, location, (size_t) bytes_to_do);
static boolean
srec_write_record (abfd, type, address, data, end)
bfd *abfd;
- int type;
+ unsigned int type;
bfd_vma address;
const bfd_byte *data;
const bfd_byte *end;
{
char buffer[MAXCHUNK];
unsigned int check_sum = 0;
- CONST bfd_byte *src = data;
+ const bfd_byte *src = data;
char *dst = buffer;
char *length;
bfd_size_type wrlen;
*dst++ = '\r';
*dst++ = '\n';
wrlen = dst - buffer;
- if (bfd_write ((PTR) buffer, 1, wrlen, abfd) != wrlen)
+ if (bfd_bwrite ((PTR) buffer, wrlen, abfd) != wrlen)
return false;
return true;
}
for (i = 0; i < 40 && abfd->filename[i]; i++)
*dst++ = abfd->filename[i];
- return srec_write_record (abfd, 0, 0, buffer, dst);
+ return srec_write_record (abfd, 0, (bfd_vma) 0, buffer, dst);
}
static boolean
if (count)
{
- size_t len;
+ bfd_size_type len;
asymbol **table = bfd_get_outsymbols (abfd);
sprintf (buffer, "$$ %s\r\n", abfd->filename);
len = strlen (buffer);
- if (bfd_write (buffer, len, 1, abfd) != len)
+ if (bfd_bwrite (buffer, len, abfd) != len)
return false;
for (i = 0; i < count; i++)
&& (s->flags & BSF_DEBUGGING) == 0)
{
/* Just dump out non debug symbols. */
- bfd_size_type l;
char buf2[40], *p;
sprintf_vma (buf2,
while (p[0] == '0' && p[1] != 0)
p++;
sprintf (buffer, " %s $%s\r\n", s->name, p);
- l = strlen (buffer);
- if (bfd_write (buffer, l, 1, abfd) != l)
+ len = strlen (buffer);
+ if (bfd_bwrite (buffer, len, abfd) != len)
return false;
}
}
sprintf (buffer, "$$ \r\n");
len = strlen (buffer);
- if (bfd_write (buffer, len, 1, abfd) != len)
+ if (bfd_bwrite (buffer, len, abfd) != len)
return false;
}
srec_make_empty_symbol (abfd)
bfd *abfd;
{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ asymbol *new;
+
+ new = (asymbol *) bfd_zalloc (abfd, (bfd_size_type) sizeof (asymbol));
if (new)
new->the_bfd = abfd;
return new;
bfd *abfd;
asymbol **alocation;
{
- unsigned int symcount = bfd_get_symcount (abfd);
+ bfd_size_type symcount = bfd_get_symcount (abfd);
asymbol *csymbols;
unsigned int i;
/* Stabs in sections linking support.
- Copyright 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001
+ Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
{
boolean first;
struct stab_info *sinfo;
- bfd_size_type count;
+ bfd_size_type count, amt;
struct stab_section_info *secinfo;
bfd_byte *stabbuf = NULL;
bfd_byte *stabstrbuf = NULL;
{
/* Initialize the stabs information we need to keep track of. */
first = true;
- *psinfo = (PTR) bfd_alloc (abfd, sizeof (struct stab_info));
+ amt = sizeof (struct stab_info);
+ *psinfo = (PTR) bfd_alloc (abfd, amt);
if (*psinfo == NULL)
goto error_return;
sinfo = (struct stab_info *) *psinfo;
count = stabsec->_raw_size / STABSIZE;
- *psecinfo = bfd_alloc (abfd,
- (sizeof (struct stab_section_info)
- + (count - 1) * sizeof (bfd_size_type)));
+ amt = sizeof (struct stab_section_info);
+ amt += (count - 1) * sizeof (bfd_size_type);
+ *psecinfo = bfd_alloc (abfd, amt);
if (*psecinfo == NULL)
goto error_return;
secinfo = (struct stab_section_info *) *psecinfo;
secinfo->excls = NULL;
secinfo->cumulative_skips = NULL;
- memset (secinfo->stridxs, 0, count * sizeof (bfd_size_type));
+ memset (secinfo->stridxs, 0, (size_t) count * sizeof (bfd_size_type));
/* Read the stabs information from abfd. */
if (stabbuf == NULL || stabstrbuf == NULL)
goto error_return;
- if (! bfd_get_section_contents (abfd, stabsec, stabbuf, 0,
+ if (! bfd_get_section_contents (abfd, stabsec, stabbuf, (bfd_vma) 0,
stabsec->_raw_size)
- || ! bfd_get_section_contents (abfd, stabstrsec, stabstrbuf, 0,
+ || ! bfd_get_section_contents (abfd, stabstrsec, stabstrbuf, (bfd_vma) 0,
stabstrsec->_raw_size))
goto error_return;
/* Record this symbol, so that we can set the value
correctly. */
- ne = (struct stab_excl_list *) bfd_alloc (abfd, sizeof *ne);
+ amt = sizeof *ne;
+ ne = (struct stab_excl_list *) bfd_alloc (abfd, amt);
if (ne == NULL)
goto error_return;
ne->offset = sym - stabbuf;
bfd_size_type i, offset;
bfd_size_type *pskips;
- secinfo->cumulative_skips =
- (bfd_size_type *) bfd_alloc (abfd, count * sizeof (bfd_size_type));
+ amt = count * sizeof (bfd_size_type);
+ secinfo->cumulative_skips = (bfd_size_type *) bfd_alloc (abfd, amt);
if (secinfo->cumulative_skips == NULL)
goto error_return;
if (secinfo == NULL)
return bfd_set_section_contents (output_bfd, stabsec->output_section,
- contents, stabsec->output_offset,
+ contents,
+ (file_ptr) stabsec->output_offset,
stabsec->_raw_size);
/* Handle each N_BINCL entry. */
BFD_ASSERT ((bfd_size_type) (tosym - contents) == stabsec->_cooked_size);
return bfd_set_section_contents (output_bfd, stabsec->output_section,
- contents, stabsec->output_offset,
+ contents, (file_ptr) stabsec->output_offset,
stabsec->_cooked_size);
}
<= sinfo->stabstr->output_section->_raw_size);
if (bfd_seek (output_bfd,
- (sinfo->stabstr->output_section->filepos
- + sinfo->stabstr->output_offset),
+ (file_ptr) (sinfo->stabstr->output_section->filepos
+ + sinfo->stabstr->output_offset),
SEEK_SET) != 0)
return false;
/* BFD backend for SunOS binaries.
- Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 2000
+ Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 2000, 2001
Free Software Foundation, Inc.
Written by Cygnus Support.
struct external_sun4_dynamic dyninfo;
unsigned long dynver;
struct external_sun4_dynamic_link linkinfo;
+ bfd_size_type amt;
if (obj_aout_dynamic_info (abfd) != (PTR) NULL)
return true;
return false;
}
- info = ((struct sunos_dynamic_info *)
- bfd_zalloc (abfd, sizeof (struct sunos_dynamic_info)));
+ amt = sizeof (struct sunos_dynamic_info);
+ info = (struct sunos_dynamic_info *) bfd_zalloc (abfd, amt);
if (!info)
return false;
info->valid = false;
if ((abfd->flags & DYNAMIC) == 0)
return true;
if (! bfd_get_section_contents (abfd, obj_datasec (abfd), (PTR) &dyninfo,
- (file_ptr) 0, sizeof dyninfo))
+ (file_ptr) 0,
+ (bfd_size_type) sizeof dyninfo))
return true;
dynver = GET_WORD (abfd, dyninfo.ld_version);
/* This executable appears to be dynamically linked in a way that we
can understand. */
- if (! bfd_get_section_contents (abfd, dynsec, (PTR) &linkinfo, dynoff,
+ if (! bfd_get_section_contents (abfd, dynsec, (PTR) &linkinfo,
+ (file_ptr) dynoff,
(bfd_size_type) sizeof linkinfo))
return true;
bfd *abfd;
{
struct sunos_dynamic_info *info;
+ bfd_size_type amt;
/* Get the general dynamic information. */
if (obj_aout_dynamic_info (abfd) == NULL)
/* Get the dynamic nlist structures. */
if (info->dynsym == (struct external_nlist *) NULL)
{
- info->dynsym = ((struct external_nlist *)
- bfd_alloc (abfd,
- (info->dynsym_count
- * EXTERNAL_NLIST_SIZE)));
+ amt = (bfd_size_type) info->dynsym_count * EXTERNAL_NLIST_SIZE;
+ info->dynsym = (struct external_nlist *) bfd_alloc (abfd, amt);
if (info->dynsym == NULL && info->dynsym_count != 0)
return false;
- if (bfd_seek (abfd, info->dyninfo.ld_stab, SEEK_SET) != 0
- || (bfd_read ((PTR) info->dynsym, info->dynsym_count,
- EXTERNAL_NLIST_SIZE, abfd)
- != info->dynsym_count * EXTERNAL_NLIST_SIZE))
+ if (bfd_seek (abfd, (file_ptr) info->dyninfo.ld_stab, SEEK_SET) != 0
+ || bfd_bread ((PTR) info->dynsym, amt, abfd) != amt)
{
if (info->dynsym != NULL)
{
/* Get the dynamic strings. */
if (info->dynstr == (char *) NULL)
{
- info->dynstr = (char *) bfd_alloc (abfd, info->dyninfo.ld_symb_size);
+ amt = info->dyninfo.ld_symb_size;
+ info->dynstr = (char *) bfd_alloc (abfd, amt);
if (info->dynstr == NULL && info->dyninfo.ld_symb_size != 0)
return false;
- if (bfd_seek (abfd, info->dyninfo.ld_symbols, SEEK_SET) != 0
- || (bfd_read ((PTR) info->dynstr, 1, info->dyninfo.ld_symb_size,
- abfd)
- != info->dyninfo.ld_symb_size))
+ if (bfd_seek (abfd, (file_ptr) info->dyninfo.ld_symbols, SEEK_SET) != 0
+ || bfd_bread ((PTR) info->dynstr, amt, abfd) != amt)
{
if (info->dynstr != NULL)
{
table = (bfd_byte *) bfd_malloc (table_size);
if (table == NULL && table_size != 0)
abort ();
- if (bfd_seek (abfd, info->dyninfo.ld_hash, SEEK_SET) != 0
- || bfd_read ((PTR) table, 1, table_size, abfd) != table_size)
+ if (bfd_seek (abfd, (file_ptr) info->dyninfo.ld_hash, SEEK_SET) != 0
+ || bfd_bread ((PTR) table, table_size, abfd) != table_size)
abort ();
for (i = 0; i < info->dynsym_count; i++)
{
structures. */
if (info->canonical_dynsym == (aout_symbol_type *) NULL)
{
- info->canonical_dynsym = ((aout_symbol_type *)
- bfd_alloc (abfd,
- (info->dynsym_count
- * sizeof (aout_symbol_type))));
+ bfd_size_type size;
+ bfd_size_type strsize = info->dyninfo.ld_symb_size;
+
+ size = (bfd_size_type) info->dynsym_count * sizeof (aout_symbol_type);
+ info->canonical_dynsym = (aout_symbol_type *) bfd_alloc (abfd, size);
if (info->canonical_dynsym == NULL && info->dynsym_count != 0)
return -1;
if (! aout_32_translate_symbol_table (abfd, info->canonical_dynsym,
- info->dynsym, info->dynsym_count,
- info->dynstr,
- info->dyninfo.ld_symb_size,
- true))
+ info->dynsym,
+ (bfd_size_type) info->dynsym_count,
+ info->dynstr, strsize, true))
{
if (info->canonical_dynsym != NULL)
{
{
struct sunos_dynamic_info *info;
unsigned long i;
+ bfd_size_type size;
/* Get the general dynamic information. */
if (obj_aout_dynamic_info (abfd) == (PTR) NULL)
/* Get the dynamic reloc information. */
if (info->dynrel == NULL)
{
- info->dynrel = (PTR) bfd_alloc (abfd,
- (info->dynrel_count
- * obj_reloc_entry_size (abfd)));
- if (info->dynrel == NULL && info->dynrel_count != 0)
+ size = (bfd_size_type) info->dynrel_count * obj_reloc_entry_size (abfd);
+ info->dynrel = (PTR) bfd_alloc (abfd, size);
+ if (info->dynrel == NULL && size != 0)
return -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)
- != info->dynrel_count * obj_reloc_entry_size (abfd)))
+ if (bfd_seek (abfd, (file_ptr) info->dyninfo.ld_rel, SEEK_SET) != 0
+ || bfd_bread ((PTR) info->dynrel, size, abfd) != size)
{
if (info->dynrel != NULL)
{
{
arelent *to;
- info->canonical_dynrel = ((arelent *)
- bfd_alloc (abfd,
- (info->dynrel_count
- * sizeof (arelent))));
+ size = (bfd_size_type) info->dynrel_count * sizeof (arelent);
+ info->canonical_dynrel = (arelent *) bfd_alloc (abfd, size);
if (info->canonical_dynrel == NULL && info->dynrel_count != 0)
return -1;
pend = p + info->dynrel_count;
for (; p < pend; p++, to++)
NAME(aout,swap_ext_reloc_in) (abfd, p, to, syms,
- info->dynsym_count);
+ (bfd_size_type) info->dynsym_count);
}
else
{
pend = p + info->dynrel_count;
for (; p < pend; p++, to++)
NAME(aout,swap_std_reloc_in) (abfd, p, to, syms,
- info->dynsym_count);
+ (bfd_size_type) info->dynsym_count);
}
}
};
/* save %sp, -96, %sp */
-#define SPARC_PLT_ENTRY_WORD0 0x9de3bfa0
+#define SPARC_PLT_ENTRY_WORD0 ((bfd_vma) 0x9de3bfa0)
/* call; address filled in later. */
-#define SPARC_PLT_ENTRY_WORD1 0x40000000
+#define SPARC_PLT_ENTRY_WORD1 ((bfd_vma) 0x40000000)
/* sethi; reloc index filled in later. */
-#define SPARC_PLT_ENTRY_WORD2 0x01000000
+#define SPARC_PLT_ENTRY_WORD2 ((bfd_vma) 0x01000000)
/* This sequence is used when for the jump table entry to a defined
symbol in a complete executable. It is used when linking PIC
compiled code which is not being put into a shared library. */
/* sethi <address to be filled in later>, %g1 */
-#define SPARC_PLT_PIC_WORD0 0x03000000
+#define SPARC_PLT_PIC_WORD0 ((bfd_vma) 0x03000000)
/* jmp %g1 + <address to be filled in later> */
-#define SPARC_PLT_PIC_WORD1 0x81c06000
+#define SPARC_PLT_PIC_WORD1 ((bfd_vma) 0x81c06000)
/* nop */
-#define SPARC_PLT_PIC_WORD2 0x01000000
+#define SPARC_PLT_PIC_WORD2 ((bfd_vma) 0x01000000)
/* An m68k procedure linkage table entry is 8 bytes. The first entry
in the table is a jump which is filled in the by the runtime
};
/* bsrl */
-#define M68K_PLT_ENTRY_WORD0 (0x61ff)
+#define M68K_PLT_ENTRY_WORD0 ((bfd_vma) 0x61ff)
/* Remaining words filled in later. */
/* An entry in the SunOS linker hash table. */
bfd *abfd;
{
struct sunos_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct sunos_link_hash_table);
- ret = ((struct sunos_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct sunos_link_hash_table)));
+ ret = (struct sunos_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct sunos_link_hash_table *) NULL)
return (struct bfd_link_hash_table *) NULL;
if (! NAME(aout,link_hash_table_init) (&ret->root, abfd,
bfd_size_type *sym_countp;
char **stringsp;
{
- asection *s;
bfd *dynobj;
struct sunos_dynamic_info *dinfo;
unsigned long need;
/* The .need section holds the list of names of shared objets
which must be included at runtime. The address of this
section is put in the ld_need field. */
- s = bfd_make_section (dynobj, ".need");
+ asection *s = bfd_make_section (dynobj, ".need");
if (s == NULL
|| ! bfd_set_section_flags (dynobj, s,
(SEC_ALLOC
/* The .rules section holds the path to search for shared
objects. The address of this section is put in the ld_rules
field. */
- s = bfd_make_section (dynobj, ".rules");
+ asection *s = bfd_make_section (dynobj, ".rules");
if (s == NULL
|| ! bfd_set_section_flags (dynobj, s,
(SEC_ALLOC
unsigned short major_vno, minor_vno;
struct bfd_link_needed_list *needed, **pp;
char *namebuf, *p;
- size_t alc;
+ bfd_size_type alc;
bfd_byte b;
char *namecopy;
- if (bfd_seek (abfd, need, SEEK_SET) != 0
- || bfd_read (buf, 1, 16, abfd) != 16)
+ if (bfd_seek (abfd, (file_ptr) need, SEEK_SET) != 0
+ || bfd_bread (buf, (bfd_size_type) 16, abfd) != 16)
return false;
/* For the format of an ld_need entry, see aout/sun4.h. We
name = bfd_get_32 (abfd, buf);
flags = bfd_get_32 (abfd, buf + 4);
- major_vno = (unsigned short)bfd_get_16 (abfd, buf + 8);
- minor_vno = (unsigned short)bfd_get_16 (abfd, buf + 10);
+ major_vno = (unsigned short) bfd_get_16 (abfd, buf + 8);
+ minor_vno = (unsigned short) bfd_get_16 (abfd, buf + 10);
need = bfd_get_32 (abfd, buf + 12);
- needed = ((struct bfd_link_needed_list *)
- bfd_alloc (abfd, sizeof (struct bfd_link_needed_list)));
+ alc = sizeof (struct bfd_link_needed_list);
+ needed = (struct bfd_link_needed_list *) bfd_alloc (abfd, alc);
if (needed == NULL)
return false;
needed->by = abfd;
*p++ = '-';
*p++ = 'l';
}
- if (bfd_seek (abfd, name, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) name, SEEK_SET) != 0)
{
free (namebuf);
return false;
do
{
- if (bfd_read (&b, 1, 1, abfd) != 1)
+ if (bfd_bread (&b, (bfd_size_type) 1, abfd) != 1)
{
free (namebuf);
return false;
}
- if ((size_t) (p - namebuf) >= alc)
+ if ((bfd_size_type) (p - namebuf) >= alc)
{
char *n;
strcat (p, minbuf);
}
- namecopy = bfd_alloc (abfd, strlen (namebuf) + 1);
+ namecopy = bfd_alloc (abfd, (bfd_size_type) strlen (namebuf) + 1);
if (namecopy == NULL)
{
free (namebuf);
asection **srulesptr;
{
bfd *dynobj;
- size_t dynsymcount;
+ bfd_size_type dynsymcount;
struct sunos_link_hash_entry *h;
asection *s;
size_t bucketcount;
- size_t hashalloc;
+ bfd_size_type hashalloc;
size_t i;
bfd *sub;
s->contents = (bfd_byte *) bfd_alloc (dynobj, hashalloc);
if (s->contents == NULL && dynsymcount > 0)
return false;
- memset (s->contents, 0, hashalloc);
+ memset (s->contents, 0, (size_t) hashalloc);
for (i = 0; i < bucketcount; i++)
PUT_WORD (output_bfd, (bfd_vma) -1, s->contents + i * HASH_ENTRY_SIZE);
s->_raw_size = bucketcount * HASH_ENTRY_SIZE;
add = 8 - (s->_raw_size & 7);
contents = (bfd_byte *) bfd_realloc (s->contents,
- (size_t) (s->_raw_size + add));
+ s->_raw_size + add);
if (contents == NULL)
return false;
memset (contents + s->_raw_size, 0, (size_t) add);
return true;
if (! info->keep_memory)
- relocs = free_relocs = bfd_malloc ((size_t) rel_size);
+ relocs = free_relocs = bfd_malloc (rel_size);
else
{
struct aout_section_data_struct *n;
+ bfd_size_type amt = sizeof (struct aout_section_data_struct);
- n = ((struct aout_section_data_struct *)
- bfd_alloc (abfd, sizeof (struct aout_section_data_struct)));
+ n = (struct aout_section_data_struct *) bfd_alloc (abfd, amt);
if (n == NULL)
relocs = NULL;
else
{
set_aout_section_data (sec, n);
- relocs = bfd_malloc ((size_t) rel_size);
+ relocs = bfd_malloc (rel_size);
aout_section_data (sec)->relocs = relocs;
}
}
return false;
if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
- || bfd_read (relocs, 1, rel_size, abfd) != rel_size)
+ || bfd_bread (relocs, rel_size, abfd) != rel_size)
goto error_return;
if (obj_reloc_entry_size (abfd) == RELOC_STD_SIZE)
asection *splt = NULL;
asection *sgot = NULL;
asection *srel = NULL;
+ bfd_size_type amt;
/* We only know how to handle SPARC plt entries. */
if (bfd_get_arch (abfd) != bfd_arch_sparc)
if (adata (abfd).local_got_offsets == NULL)
{
+ amt = bfd_get_symcount (abfd);
+ amt *= sizeof (bfd_vma);
adata (abfd).local_got_offsets =
- (bfd_vma *) bfd_zalloc (abfd,
- (bfd_get_symcount (abfd)
- * sizeof (bfd_vma)));
+ (bfd_vma *) bfd_zalloc (abfd, amt);
if (adata (abfd).local_got_offsets == NULL)
return false;
}
bfd *dynobj;
asection *splt;
bfd_byte *p;
- asection *s;
bfd_vma r_address;
dynobj = sunos_hash_table (info)->dynobj;
}
else
{
- bfd_vma val;
-
val = (h->root.root.u.def.section->output_section->vma
+ h->root.root.u.def.section->output_offset
+ h->root.root.u.def.value);
abort ();
bfd_put_16 (output_bfd, M68K_PLT_ENTRY_WORD0, p);
bfd_put_32 (output_bfd, (- (h->plt_offset + 2)), p + 2);
- bfd_put_16 (output_bfd, s->reloc_count, p + 6);
+ bfd_put_16 (output_bfd, (bfd_vma) s->reloc_count, p + 6);
r_address += 2;
break;
outsym = ((struct external_nlist *)
(s->contents + h->dynindx * EXTERNAL_NLIST_SIZE));
- bfd_h_put_8 (output_bfd, type, outsym->e_type);
- bfd_h_put_8 (output_bfd, 0, outsym->e_other);
+ H_PUT_8 (output_bfd, type, outsym->e_type);
+ H_PUT_8 (output_bfd, 0, outsym->e_other);
/* FIXME: The native linker doesn't use 0 for desc. It seems to use
one less than the desc value in the shared library, although that
seems unlikely. */
- bfd_h_put_16 (output_bfd, 0, outsym->e_desc);
+ H_PUT_16 (output_bfd, 0, outsym->e_desc);
PUT_WORD (output_bfd, h->dynstr_index, outsym->e_strx);
PUT_WORD (output_bfd, val, outsym->e_value);
}
*relocationp = (sgot->vma
- + (*got_offsetp &~ 1)
+ + (*got_offsetp &~ (bfd_vma) 1)
- sunos_hash_table (info)->got_base);
/* There is nothing else to do for a base relative reloc. */
BFD_ASSERT (o->output_section != NULL
&& o->output_section->owner == abfd);
if (! bfd_set_section_contents (abfd, o->output_section,
- o->contents, o->output_offset,
+ o->contents,
+ (file_ptr) o->output_offset,
o->_raw_size))
return false;
}
{
struct external_sun4_dynamic esd;
struct external_sun4_dynamic_link esdl;
+ file_ptr pos;
/* Finish up the dynamic link information. */
PUT_WORD (dynobj, (bfd_vma) 3, esd.ld_version);
esd.ld);
if (! bfd_set_section_contents (abfd, sdyn->output_section, &esd,
- sdyn->output_offset, sizeof esd))
+ (file_ptr) sdyn->output_offset,
+ (bfd_size_type) sizeof esd))
return false;
PUT_WORD (dynobj, (bfd_vma) 0, esdl.ld_loaded);
BFD_ALIGN (obj_textsec (abfd)->_raw_size, 0x2000),
esdl.ld_text);
+ pos = sdyn->output_offset;
+ pos += sizeof esd + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE;
if (! bfd_set_section_contents (abfd, sdyn->output_section, &esdl,
- (sdyn->output_offset
- + sizeof esd
- + EXTERNAL_SUN4_DYNAMIC_DEBUGGER_SIZE),
- sizeof esdl))
+ pos, (bfd_size_type) sizeof esdl))
return false;
abfd->flags |= DYNAMIC;
.
. {* The text of the symbol. The name is left alone, and not copied; the
. application may not alter it. *}
-. CONST char *name;
+. const char *name;
.
. {* The value of the symbol. This really should be a union of a
. numeric value with a pointer, since some flags indicate that
struct section_to_type
{
- CONST char *section;
+ const char *section;
char type;
};
/* Map section names to POSIX/BSD single-character symbol types.
This table is probably incomplete. It is sorted for convenience of
adding entries. Since it is so short, a linear search is used. */
-static CONST struct section_to_type stt[] =
+static const struct section_to_type stt[] =
{
{"*DEBUG*", 'N'},
{".bss", 'b'},
coff_section_type (s)
const char *s;
{
- CONST struct section_to_type *t;
+ const struct section_to_type *t;
for (t = &stt[0]; t->section; t++)
if (!strncmp (s, t->section, strlen (t->section)))
if (storage < 0)
goto error_return;
- syms = (asymbol **) bfd_malloc ((size_t) storage);
+ syms = (asymbol **) bfd_malloc ((bfd_size_type) storage);
if (syms == NULL)
goto error_return;
bfd_byte *last_stab = NULL;
bfd_size_type stroff;
struct indexentry *indexentry;
- char *directory_name, *file_name;
+ char *file_name;
+ char *directory_name;
int saw_fun;
*pfound = false;
arelent **reloc_vector;
int i;
char *name;
- char *file_name;
- char *directory_name;
char *function_name;
+ bfd_size_type amt = sizeof *info;
- info = (struct stab_find_info *) bfd_zalloc (abfd, sizeof *info);
+ info = (struct stab_find_info *) bfd_zalloc (abfd, amt);
if (info == NULL)
return false;
if (info->stabs == NULL || info->strs == NULL)
return false;
- if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs, 0,
- stabsize)
- || ! bfd_get_section_contents (abfd, info->strsec, info->strs, 0,
- strsize))
+ if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs,
+ (bfd_vma) 0, stabsize)
+ || ! bfd_get_section_contents (abfd, info->strsec, info->strs,
+ (bfd_vma) 0, strsize))
return false;
/* If this is a relocateable object file, we have to relocate
reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec);
if (reloc_size < 0)
return false;
- reloc_vector = (arelent **) bfd_malloc (reloc_size);
+ reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);
if (reloc_vector == NULL && reloc_size != 0)
return false;
reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector,
val &= r->howto->src_mask;
sym = *r->sym_ptr_ptr;
val += sym->value + sym->section->vma + r->addend;
- bfd_put_32 (abfd, val, info->stabs + r->address);
+ bfd_put_32 (abfd, (bfd_vma) val, info->stabs + r->address);
}
}
return true;
++info->indextablesize;
- info->indextable = ((struct indexentry *)
- bfd_alloc (abfd,
- (sizeof (struct indexentry)
- * info->indextablesize)));
+ amt = info->indextablesize;
+ amt *= sizeof (struct indexentry);
+ info->indextable = (struct indexentry *) bfd_alloc (abfd, amt);
if (info->indextable == NULL)
return false;
++i;
info->indextablesize = i;
- qsort (info->indextable, i, sizeof (struct indexentry), cmpindexentry);
+ qsort (info->indextable, (size_t) i, sizeof (struct indexentry),
+ cmpindexentry);
*pinfo = (PTR) info;
}
{
if (info->filename != NULL)
free (info->filename);
- info->filename = (char *) bfd_malloc (dirlen +
- strlen (file_name)
- + 1);
+ info->filename = (char *) bfd_malloc ((bfd_size_type) dirlen
+ + strlen (file_name) + 1);
if (info->filename == NULL)
return false;
strcpy (info->filename, directory_name);
entry points, since they don't take a BFD asthe first argument.
Certain other handlers could do the same.
-. bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
+. bfd_vma (*bfd_getx64) PARAMS ((const bfd_byte *));
. bfd_signed_vma (*bfd_getx_signed_64) PARAMS ((const bfd_byte *));
-. void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
-. bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *));
+. void (*bfd_putx64) PARAMS ((bfd_vma, bfd_byte *));
+. bfd_vma (*bfd_getx32) PARAMS ((const bfd_byte *));
. bfd_signed_vma (*bfd_getx_signed_32) PARAMS ((const bfd_byte *));
-. void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
-. bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *));
+. void (*bfd_putx32) PARAMS ((bfd_vma, bfd_byte *));
+. bfd_vma (*bfd_getx16) PARAMS ((const bfd_byte *));
. bfd_signed_vma (*bfd_getx_signed_16) PARAMS ((const bfd_byte *));
-. void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
+. void (*bfd_putx16) PARAMS ((bfd_vma, bfd_byte *));
Byte swapping for the headers
-. bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *));
+. bfd_vma (*bfd_h_getx64) PARAMS ((const bfd_byte *));
. bfd_signed_vma (*bfd_h_getx_signed_64) PARAMS ((const bfd_byte *));
-. void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
-. bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *));
+. void (*bfd_h_putx64) PARAMS ((bfd_vma, bfd_byte *));
+. bfd_vma (*bfd_h_getx32) PARAMS ((const bfd_byte *));
. bfd_signed_vma (*bfd_h_getx_signed_32) PARAMS ((const bfd_byte *));
-. void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
-. bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *));
+. void (*bfd_h_putx32) PARAMS ((bfd_vma, bfd_byte *));
+. bfd_vma (*bfd_h_getx16) PARAMS ((const bfd_byte *));
. bfd_signed_vma (*bfd_h_getx_signed_16) PARAMS ((const bfd_byte *));
-. void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
+. void (*bfd_h_putx16) PARAMS ((bfd_vma, bfd_byte *));
Format dependent routines: these are vectors of entry points
within the target vector structure, one for each format to check.
Set the format of a file being written.
-. boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
+. boolean (*_bfd_set_format[bfd_type_end]) PARAMS ((bfd *));
Write cached information into a file being written, at <<bfd_close>>.
-. boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
+. boolean (*_bfd_write_contents[bfd_type_end]) PARAMS ((bfd *));
The general target vector. These vectors are initialized using the
BFD_JUMP_TABLE macros.
.CAT(NAME,_get_section_contents_in_window)
.
. {* Called when the BFD is being closed to do any necessary cleanup. *}
-. boolean (*_close_and_cleanup) PARAMS ((bfd *));
+. boolean (*_close_and_cleanup) PARAMS ((bfd *));
. {* Ask the BFD to free all cached information. *}
-. boolean (*_bfd_free_cached_info) PARAMS ((bfd *));
+. boolean (*_bfd_free_cached_info) PARAMS ((bfd *));
. {* Called when a new section is created. *}
-. boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
+. boolean (*_new_section_hook) PARAMS ((bfd *, sec_ptr));
. {* Read the contents of a section. *}
-. boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
-. file_ptr, bfd_size_type));
-. boolean (*_bfd_get_section_contents_in_window)
-. PARAMS ((bfd *, sec_ptr, bfd_window *,
-. file_ptr, bfd_size_type));
+. boolean (*_bfd_get_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
+. file_ptr, bfd_size_type));
+. boolean (*_bfd_get_section_contents_in_window)
+. PARAMS ((bfd *, sec_ptr, bfd_window *, file_ptr, bfd_size_type));
.
. {* Entry points to copy private data. *}
.#define BFD_JUMP_TABLE_COPY(NAME)\
.CAT(NAME,_bfd_print_private_bfd_data)\
. {* Called to copy BFD general private data from one object file
. to another. *}
-. boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *));
+. boolean (*_bfd_copy_private_bfd_data) PARAMS ((bfd *, bfd *));
. {* Called to merge BFD general private data from one object file
. to a common output file when linking. *}
-. boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *));
+. boolean (*_bfd_merge_private_bfd_data) PARAMS ((bfd *, bfd *));
. {* Called to copy BFD private section data from one object file
. to another. *}
-. boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr,
-. bfd *, sec_ptr));
+. boolean (*_bfd_copy_private_section_data) PARAMS ((bfd *, sec_ptr,
+. bfd *, sec_ptr));
. {* Called to copy BFD private symbol data from one symbol
. to another. *}
-. boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *,
-. bfd *, asymbol *));
+. boolean (*_bfd_copy_private_symbol_data) PARAMS ((bfd *, asymbol *,
+. bfd *, asymbol *));
. {* Called to set private backend flags *}
-. boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
+. boolean (*_bfd_set_private_flags) PARAMS ((bfd *, flagword));
.
. {* Called to print private BFD data *}
-. boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
+. boolean (*_bfd_print_private_bfd_data) PARAMS ((bfd *, PTR));
.
. {* Core file entry points. *}
.#define BFD_JUMP_TABLE_CORE(NAME)\
. boolean (*_bfd_slurp_armap) PARAMS ((bfd *));
. boolean (*_bfd_slurp_extended_name_table) PARAMS ((bfd *));
. boolean (*_bfd_construct_extended_name_table)
-. PARAMS ((bfd *, char **, bfd_size_type *, const char **));
-. void (*_bfd_truncate_arname) PARAMS ((bfd *, CONST char *, char *));
-. boolean (*write_armap) PARAMS ((bfd *arch,
-. unsigned int elength,
-. struct orl *map,
-. unsigned int orl_count,
-. int stridx));
-. PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *));
-. bfd * (*openr_next_archived_file) PARAMS ((bfd *arch, bfd *prev));
+. PARAMS ((bfd *, char **, bfd_size_type *, const char **));
+. void (*_bfd_truncate_arname) PARAMS ((bfd *, const char *, char *));
+. boolean (*write_armap)
+. PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
+. PTR (*_bfd_read_ar_hdr_fn) PARAMS ((bfd *));
+. bfd * (*openr_next_archived_file) PARAMS ((bfd *, bfd *));
.#define bfd_get_elt_at_index(b,i) BFD_SEND(b, _bfd_get_elt_at_index, (b,i))
. bfd * (*_bfd_get_elt_at_index) PARAMS ((bfd *, symindex));
. int (*_bfd_stat_arch_elt) PARAMS ((bfd *, struct stat *));
.CAT(NAME,_bfd_make_debug_symbol),\
.CAT(NAME,_read_minisymbols),\
.CAT(NAME,_minisymbol_to_symbol)
-. long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *));
-. long (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
-. struct symbol_cache_entry **));
-. struct symbol_cache_entry *
-. (*_bfd_make_empty_symbol) PARAMS ((bfd *));
-. void (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
-. struct symbol_cache_entry *,
-. bfd_print_symbol_type));
+. long (*_bfd_get_symtab_upper_bound) PARAMS ((bfd *));
+. long (*_bfd_canonicalize_symtab) PARAMS ((bfd *,
+. struct symbol_cache_entry **));
+. struct symbol_cache_entry *
+. (*_bfd_make_empty_symbol) PARAMS ((bfd *));
+. void (*_bfd_print_symbol) PARAMS ((bfd *, PTR,
+. struct symbol_cache_entry *,
+. bfd_print_symbol_type));
.#define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
-. void (*_bfd_get_symbol_info) PARAMS ((bfd *,
-. struct symbol_cache_entry *,
-. symbol_info *));
+. void (*_bfd_get_symbol_info) PARAMS ((bfd *,
+. struct symbol_cache_entry *,
+. symbol_info *));
.#define bfd_get_symbol_info(b,p,e) BFD_SEND(b, _bfd_get_symbol_info, (b,p,e))
-. boolean (*_bfd_is_local_label_name) PARAMS ((bfd *, const char *));
+. boolean (*_bfd_is_local_label_name) PARAMS ((bfd *, const char *));
.
-. alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
-. boolean (*_bfd_find_nearest_line) PARAMS ((bfd *abfd,
-. struct sec *section, struct symbol_cache_entry **symbols,
-. bfd_vma offset, CONST char **file, CONST char **func,
-. unsigned int *line));
+. alent * (*_get_lineno) PARAMS ((bfd *, struct symbol_cache_entry *));
+. boolean (*_bfd_find_nearest_line)
+. PARAMS ((bfd *, struct sec *, struct symbol_cache_entry **, bfd_vma,
+. const char **, const char **, unsigned int *));
. {* Back-door to allow format-aware applications to create debug symbols
. while using BFD for everything else. Currently used by the assembler
. when creating COFF files. *}
-. asymbol * (*_bfd_make_debug_symbol) PARAMS ((
-. bfd *abfd,
-. void *ptr,
-. unsigned long size));
+. asymbol *(*_bfd_make_debug_symbol) PARAMS ((bfd *, void *,
+. unsigned long size));
.#define bfd_read_minisymbols(b, d, m, s) \
. BFD_SEND (b, _read_minisymbols, (b, d, m, s))
-. long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *,
-. unsigned int *));
+. long (*_read_minisymbols) PARAMS ((bfd *, boolean, PTR *,
+. unsigned int *));
.#define bfd_minisymbol_to_symbol(b, d, m, f) \
. BFD_SEND (b, _minisymbol_to_symbol, (b, d, m, f))
. asymbol *(*_minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
.CAT(NAME,_get_reloc_upper_bound),\
.CAT(NAME,_canonicalize_reloc),\
.CAT(NAME,_bfd_reloc_type_lookup)
-. long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
-. long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
-. struct symbol_cache_entry **));
+. long (*_get_reloc_upper_bound) PARAMS ((bfd *, sec_ptr));
+. long (*_bfd_canonicalize_reloc) PARAMS ((bfd *, sec_ptr, arelent **,
+. struct symbol_cache_entry **));
. {* See documentation on reloc types. *}
. reloc_howto_type *
-. (*reloc_type_lookup) PARAMS ((bfd *abfd,
-. bfd_reloc_code_real_type code));
+. (*reloc_type_lookup) PARAMS ((bfd *, bfd_reloc_code_real_type));
.
. {* Routines used when writing an object file. *}
.#define BFD_JUMP_TABLE_WRITE(NAME)\
.CAT(NAME,_set_arch_mach),\
.CAT(NAME,_set_section_contents)
-. boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
-. unsigned long));
-. boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
-. file_ptr, bfd_size_type));
+. boolean (*_bfd_set_arch_mach) PARAMS ((bfd *, enum bfd_architecture,
+. unsigned long));
+. boolean (*_bfd_set_section_contents) PARAMS ((bfd *, sec_ptr, PTR,
+. file_ptr, bfd_size_type));
.
. {* Routines used by the linker. *}
.#define BFD_JUMP_TABLE_LINK(NAME)\
.CAT(NAME,_bfd_link_split_section),\
.CAT(NAME,_bfd_gc_sections),\
.CAT(NAME,_bfd_merge_sections)
-. int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
-. bfd_byte * (*_bfd_get_relocated_section_contents) PARAMS ((bfd *,
-. struct bfd_link_info *, struct bfd_link_order *,
-. bfd_byte *data, boolean relocateable,
-. struct symbol_cache_entry **));
+. int (*_bfd_sizeof_headers) PARAMS ((bfd *, boolean));
+. bfd_byte *(*_bfd_get_relocated_section_contents)
+. PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
+. bfd_byte *, boolean, struct symbol_cache_entry **));
.
-. boolean (*_bfd_relax_section) PARAMS ((bfd *, struct sec *,
-. struct bfd_link_info *, boolean *again));
+. boolean (*_bfd_relax_section)
+. PARAMS ((bfd *, struct sec *, struct bfd_link_info *, boolean *));
.
. {* Create a hash table for the linker. Different backends store
. different information in this table. *}
. struct bfd_link_hash_table *(*_bfd_link_hash_table_create) PARAMS ((bfd *));
.
. {* Add symbols from this object file into the hash table. *}
-. boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
+. boolean (*_bfd_link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
.
. {* Do a link based on the link_order structures attached to each
. section of the BFD. *}
-. boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
+. boolean (*_bfd_final_link) PARAMS ((bfd *, struct bfd_link_info *));
.
. {* Should this section be split up into smaller pieces during linking. *}
-. boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *));
+. boolean (*_bfd_link_split_section) PARAMS ((bfd *, struct sec *));
.
. {* Remove sections that are not referenced from the output. *}
-. boolean (*_bfd_gc_sections) PARAMS ((bfd *, struct bfd_link_info *));
+. boolean (*_bfd_gc_sections) PARAMS ((bfd *, struct bfd_link_info *));
.
. {* Attempt to merge SEC_MERGE sections. *}
-. boolean (*_bfd_merge_sections) PARAMS ((bfd *, struct bfd_link_info *));
+. boolean (*_bfd_merge_sections) PARAMS ((bfd *, struct bfd_link_info *));
.
. {* Routines to handle dynamic symbols and relocs. *}
.#define BFD_JUMP_TABLE_DYNAMIC(NAME)\
.CAT(NAME,_get_dynamic_reloc_upper_bound),\
.CAT(NAME,_canonicalize_dynamic_reloc)
. {* Get the amount of memory required to hold the dynamic symbols. *}
-. long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *));
+. long (*_bfd_get_dynamic_symtab_upper_bound) PARAMS ((bfd *));
. {* Read in the dynamic symbols. *}
-. long (*_bfd_canonicalize_dynamic_symtab)
+. long (*_bfd_canonicalize_dynamic_symtab)
. PARAMS ((bfd *, struct symbol_cache_entry **));
. {* Get the amount of memory required to hold the dynamic relocs. *}
-. long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *));
+. long (*_bfd_get_dynamic_reloc_upper_bound) PARAMS ((bfd *));
. {* Read in the dynamic relocs. *}
-. long (*_bfd_canonicalize_dynamic_reloc)
+. long (*_bfd_canonicalize_dynamic_reloc)
. PARAMS ((bfd *, arelent **, struct symbol_cache_entry **));
.
extern const bfd_target bfd_elf64_ia64_little_vec;
extern const bfd_target bfd_elf64_little_generic_vec;
extern const bfd_target bfd_elf64_littlemips_vec;
-extern const bfd_target bfd_elf64_tradbigmips_vec;
-extern const bfd_target bfd_elf64_tradlittlemips_vec;
extern const bfd_target bfd_elf64_powerpc_vec;
extern const bfd_target bfd_elf64_powerpcle_vec;
extern const bfd_target bfd_elf64_s390_vec;
extern const bfd_target bfd_elf64_sparc_vec;
+extern const bfd_target bfd_elf64_tradbigmips_vec;
+extern const bfd_target bfd_elf64_tradlittlemips_vec;
extern const bfd_target bfd_elf64_x86_64_vec;
extern const bfd_target bfd_powerpc_pe_vec;
extern const bfd_target bfd_powerpc_pei_vec;
extern const bfd_target sparclynx_coff_vec;
extern const bfd_target sparcnetbsd_vec;
extern const bfd_target sunos_big_vec;
-extern const bfd_target tekhex_vec;
extern const bfd_target tic30_aout_vec;
extern const bfd_target tic30_coff_vec;
extern const bfd_target tic54x_coff0_beh_vec;
extern const bfd_target we32kcoff_vec;
extern const bfd_target z8kcoff_vec;
-/* srec is always included. */
+/* These are always included. */
extern const bfd_target srec_vec;
extern const bfd_target symbolsrec_vec;
-
-/* binary is always included. */
+extern const bfd_target tekhex_vec;
extern const bfd_target binary_vec;
-
-/* ihex is always included. */
extern const bfd_target ihex_vec;
/* All of the xvecs for core files. */
extern const bfd_target aix386_core_vec;
extern const bfd_target cisco_core_big_vec;
extern const bfd_target cisco_core_little_vec;
-extern const bfd_target hpux_core_vec;
extern const bfd_target hppabsd_core_vec;
+extern const bfd_target hpux_core_vec;
extern const bfd_target irix_core_vec;
extern const bfd_target netbsd_core_vec;
extern const bfd_target osf_core_vec;
+extern const bfd_target ptrace_core_vec;
extern const bfd_target sco5_core_vec;
extern const bfd_target trad_core_vec;
-extern const bfd_target ptrace_core_vec;
static const bfd_target * const _bfd_target_vector[] = {
it wasn't omitted by mistake. */
&a29kcoff_big_vec,
&a_out_adobe_vec,
-#if 0 /* No one seems to use this. */
+ &aout0_big_vec,
+#if 0
+ /* We have no way of distinguishing these from other a.out variants */
+ &aout_arm_big_vec,
+ &aout_arm_little_vec,
+ /* No one seems to use this. */
&aout_mips_big_vec,
#endif
&aout_mips_little_vec,
+#if 0
+ &apollocoff_vec,
+#endif
+ &arm_epoc_pe_big_vec,
+ &arm_epoc_pe_little_vec,
+ &arm_epoc_pei_big_vec,
+ &arm_epoc_pei_little_vec,
+ &armcoff_big_vec,
+ &armcoff_little_vec,
+ &armnetbsd_vec,
+ &armpe_big_vec,
+ &armpe_little_vec,
+ &armpei_big_vec,
+ &armpei_little_vec,
&b_out_vec_big_host,
&b_out_vec_little_host,
-
&bfd_efi_app_ia32_vec,
#ifdef BFD64
&bfd_efi_app_ia64_vec,
#endif
+ &bfd_elf32_avr_vec,
/* This, and other vectors, may not be used in any *.mt configuration.
But that does not mean they are unnecessary. If configured with
--enable-targets=all, objdump or gdb should be able to examine
the file even if we don't recognize the machine type. */
&bfd_elf32_big_generic_vec,
-#ifdef BFD64
- &bfd_elf64_alpha_vec,
- &bfd_elf64_hppa_vec,
- &bfd_elf64_hppa_linux_vec,
- &bfd_elf64_ia64_aix_little_vec,
- &bfd_elf64_ia64_aix_big_vec,
- &bfd_elf64_ia64_little_vec,
- &bfd_elf64_ia64_big_vec,
-#endif
- &bfd_elf32_avr_vec,
&bfd_elf32_bigarc_vec,
- &bfd_elf32_bigarm_vec,
- &bfd_elf32_bigarm_oabi_vec,
+ &bfd_elf32_bigarm_oabi_vec,
+ &bfd_elf32_bigarm_vec,
&bfd_elf32_bigmips_vec,
-#ifdef BFD64
- &bfd_elf64_bigmips_vec,
-#endif
&bfd_elf32_cris_vec,
- &bfd_elf32_us_cris_vec,
&bfd_elf32_d10v_vec,
&bfd_elf32_d30v_vec,
- &bfd_elf32_hppa_vec,
+ &bfd_elf32_fr30_vec,
&bfd_elf32_hppa_linux_vec,
+ &bfd_elf32_hppa_vec,
&bfd_elf32_i370_vec,
&bfd_elf32_i386_vec,
-#ifdef BFD64
- &bfd_elf64_x86_64_vec,
-#endif
- &bfd_elf32_i860_vec,
&bfd_elf32_i860_little_vec,
+ &bfd_elf32_i860_vec,
&bfd_elf32_i960_vec,
+#if 0
+ &bfd_elf32_ia64_big_vec,
+#endif
&bfd_elf32_little_generic_vec,
&bfd_elf32_littlearc_vec,
- &bfd_elf32_littlearm_vec,
- &bfd_elf32_littlearm_oabi_vec,
+ &bfd_elf32_littlearm_oabi_vec,
+ &bfd_elf32_littlearm_vec,
&bfd_elf32_littlemips_vec,
-#ifdef BFD64
- &bfd_elf64_littlemips_vec,
-#endif
&bfd_elf32_m32r_vec,
- &bfd_elf32_mn10200_vec,
- &bfd_elf32_mn10300_vec,
&bfd_elf32_m68hc11_vec,
&bfd_elf32_m68hc12_vec,
&bfd_elf32_m68k_vec,
&bfd_elf32_m88k_vec,
+ &bfd_elf32_mcore_big_vec,
+ &bfd_elf32_mcore_little_vec,
+ &bfd_elf32_mn10200_vec,
+ &bfd_elf32_mn10300_vec,
&bfd_elf32_openrisc_vec,
&bfd_elf32_pj_vec,
&bfd_elf32_pjl_vec,
&bfd_elf32_powerpc_vec,
&bfd_elf32_powerpcle_vec,
-#ifdef BFD64
- &bfd_elf64_powerpc_vec,
- &bfd_elf64_powerpcle_vec,
-#endif
+ &bfd_elf32_s390_vec,
+ &bfd_elf32_sh_vec,
+ &bfd_elf32_shblin_vec,
+ &bfd_elf32_shl_vec,
+ &bfd_elf32_shlin_vec,
&bfd_elf32_sparc_vec,
- &bfd_elf32_v850_vec,
- &bfd_elf32_fr30_vec,
- &bfd_elf32_mcore_big_vec,
- &bfd_elf32_mcore_little_vec,
&bfd_elf32_tradbigmips_vec,
&bfd_elf32_tradlittlemips_vec,
+ &bfd_elf32_us_cris_vec,
+ &bfd_elf32_v850_vec,
#ifdef BFD64
- &bfd_elf64_tradbigmips_vec,
- &bfd_elf64_tradlittlemips_vec,
- /* No one seems to use this. */
+ &bfd_elf64_alpha_vec,
&bfd_elf64_big_generic_vec,
+ &bfd_elf64_bigmips_vec,
+ &bfd_elf64_hppa_linux_vec,
+ &bfd_elf64_hppa_vec,
+ &bfd_elf64_ia64_aix_big_vec,
+ &bfd_elf64_ia64_aix_little_vec,
+ &bfd_elf64_ia64_big_vec,
+ &bfd_elf64_ia64_little_vec,
&bfd_elf64_little_generic_vec,
-#endif
+ &bfd_elf64_littlemips_vec,
+ &bfd_elf64_powerpc_vec,
+ &bfd_elf64_powerpcle_vec,
+ &bfd_elf64_s390_vec,
#if 0
&bfd_elf64_sparc_vec,
#endif
- /* We don't include cisco_core_*_vec. Although it has a magic number,
- the magic number isn't at the beginning of the file, and thus
- might spuriously match other kinds of files. */
-
- &cris_aout_vec,
+ &bfd_elf64_tradbigmips_vec,
+ &bfd_elf64_tradlittlemips_vec,
+ &bfd_elf64_x86_64_vec,
+#endif
+ &bfd_powerpc_pe_vec,
+ &bfd_powerpc_pei_vec,
+ &bfd_powerpcle_pe_vec,
+ &bfd_powerpcle_pei_vec,
+ &cris_aout_vec,
#ifdef BFD64
&demo_64_vec, /* Only compiled if host has long-long support */
#endif
&ecoff_big_vec,
- &ecoff_little_vec,
&ecoff_biglittle_vec,
+ &ecoff_little_vec,
#ifdef BFD64
&ecoffalpha_little_vec,
#endif
+ &go32coff_vec,
+ &go32stubbedcoff_vec,
&h8300coff_vec,
&h8500coff_vec,
#if 0
/* Since a.out files lack decent magic numbers, no way to recognize
which kind of a.out file it is. */
&host_aout_vec,
-#endif
-#if 0 /* Clashes with sunos_big_vec magic no. */
+ /* Clashes with sunos_big_vec magic no. */
&hp300bsd_vec,
#endif
&hp300hpux_vec,
-#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF)
- &som_vec,
-#endif
&i386aout_vec,
&i386bsd_vec,
&i386coff_vec,
+#if 0
+ &i386dynix_vec,
+#endif
&i386freebsd_vec,
- &i860coff_vec,
- &bfd_powerpc_pe_vec,
- &bfd_powerpcle_pe_vec,
- &bfd_powerpc_pei_vec,
- &bfd_powerpcle_pei_vec,
- &go32coff_vec,
- &go32stubbedcoff_vec,
#if 0
/* Since a.out files lack decent magic numbers, no way to recognize
which kind of a.out file it is. */
&i386os9k_vec,
&i386pe_vec,
&i386pei_vec,
- &armcoff_little_vec,
- &armcoff_big_vec,
- &armnetbsd_vec,
- &armpe_little_vec,
- &armpe_big_vec,
- &armpei_little_vec,
- &armpei_big_vec,
- &arm_epoc_pe_little_vec,
- &arm_epoc_pe_big_vec,
- &arm_epoc_pei_little_vec,
- &arm_epoc_pei_big_vec,
+ &i860coff_vec,
&icoff_big_vec,
&icoff_little_vec,
&ieee_vec,
+#if 0
+ &m68k4knetbsd_vec,
+ &m68kaux_coff_vec,
+#endif
&m68kcoff_vec,
&m68kcoffun_vec,
#if 0
&mcore_pe_little_vec,
&mcore_pei_big_vec,
&mcore_pei_little_vec,
+ &mipslpe_vec,
+ &mipslpei_vec,
&newsos3_vec,
- &nlm32_i386_vec,
- &nlm32_sparc_vec,
#ifdef BFD64
&nlm32_alpha_vec,
#endif
- &pc532netbsd_vec,
+ &nlm32_i386_vec,
+ &nlm32_powerpc_vec,
+ &nlm32_sparc_vec,
#if 0
/* We have no oasys tools anymore, so we can't test any of this
anymore. If you want to test the stuff yourself, go ahead...
&oasys_vec,
#endif
&pc532machaout_vec,
+ &pc532netbsd_vec,
&pdp11_aout_vec,
-#if 0
- /* We have no way of distinguishing these from other a.out variants */
- &aout_arm_big_vec,
- &aout_arm_little_vec,
- &riscix_vec,
-#endif
#if 0
/* This has the same magic number as RS/6000. */
&pmac_xcoff_vec,
#endif
- &rs6000coff_vec,
+ &ppcboot_vec,
+#if 0
+ /* We have no way of distinguishing these from other a.out variants */
+ &riscix_vec,
+#endif
#ifdef BFD64
&rs6000coff64_vec,
#endif
- &ppcboot_vec,
- &shcoff_vec,
- &shlcoff_vec,
+ &rs6000coff_vec,
&shcoff_small_vec,
+ &shcoff_vec,
&shlcoff_small_vec,
+ &shlcoff_vec,
+ &shlpe_vec,
+ &shlpei_vec,
+#if defined (HOST_HPPAHPUX) || defined (HOST_HPPABSD) || defined (HOST_HPPAOSF)
+ &som_vec,
+#endif
+ &sparccoff_vec,
&sparcle_aout_vec,
&sparclinux_vec,
&sparclynx_aout_vec,
&sparclynx_coff_vec,
&sparcnetbsd_vec,
&sunos_big_vec,
- &aout0_big_vec,
&tic30_aout_vec,
&tic30_coff_vec,
- &tic54x_coff0_vec,
&tic54x_coff0_beh_vec,
- &tic54x_coff1_vec,
+ &tic54x_coff0_vec,
&tic54x_coff1_beh_vec,
- &tic54x_coff2_vec,
+ &tic54x_coff1_vec,
&tic54x_coff2_beh_vec,
+ &tic54x_coff2_vec,
&tic80coff_vec,
&vaxnetbsd_vec,
&versados_vec,
&vms_alpha_vec,
#endif
&vms_vax_vec,
+ &w65_vec,
&we32kcoff_vec,
&z8kcoff_vec,
- &bfd_elf32_s390_vec,
-#ifdef BFD64
- &bfd_elf64_s390_vec,
-#endif
#endif /* not SELECT_VECS */
/* Always support S-records, for convenience. */
#ifdef AIX386_CORE
&aix386_core_vec,
#endif
-#ifdef HPUX_CORE
- &hpux_core_vec,
+#if 0
+ /* We don't include cisco_core_*_vec. Although it has a magic number,
+ the magic number isn't at the beginning of the file, and thus
+ might spuriously match other kinds of files. */
+ &cisco_core_big_vec,
+ &cisco_core_little_vec,
#endif
#ifdef HPPABSD_CORE
&hppabsd_core_vec,
#endif
+#ifdef HPUX_CORE
+ &hpux_core_vec,
+#endif
#ifdef IRIX_CORE
&irix_core_vec,
#endif
#ifdef OSF_CORE
&osf_core_vec,
#endif
+#ifdef PTRACE_CORE
+ &ptrace_core_vec,
+#endif
#ifdef SCO5_CORE
&sco5_core_vec,
#endif
-#ifdef TRAD_CORE
+#ifdef TRAD_CORE
&trad_core_vec,
#endif
-#ifdef PTRACE_CORE
- &ptrace_core_vec,
-#endif
-
NULL /* end of list marker */
};
const bfd_target * const *bfd_target_vector = _bfd_target_vector;
bfd_find_target
SYNOPSIS
- const bfd_target *bfd_find_target(CONST char *target_name, bfd *abfd);
+ const bfd_target *bfd_find_target(const char *target_name, bfd *abfd);
DESCRIPTION
Return a pointer to the transfer vector for the object target
bfd_target_list ()
{
int vec_length= 0;
+ bfd_size_type amt;
#if defined (HOST_HPPAHPUX) && ! defined (__STDC__)
/* The native compiler on the HP9000/700 has a bug which causes it
to loop endlessly when compiling this file. This avoids it. */
volatile
#endif
- const bfd_target * const *target;
- CONST char **name_list, **name_ptr;
+ const bfd_target * const *target;
+ const char **name_list, **name_ptr;
for (target = &bfd_target_vector[0]; *target != NULL; target++)
vec_length++;
- name_ptr = name_list = (CONST char **)
- bfd_zmalloc ((vec_length + 1) * sizeof (char **));
+ amt = (vec_length + 1) * sizeof (char **);
+ name_ptr = name_list = (const char **) bfd_zmalloc (amt);
if (name_list == NULL)
return NULL;
/* BFD backend for Extended Tektronix Hex Format objects.
- Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000
+ Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
static int tekhex_sizeof_headers PARAMS ((bfd *, boolean));
static boolean tekhex_write_object_contents PARAMS ((bfd *));
static void out PARAMS ((bfd *, int, char *, char *));
-static void writesym PARAMS ((char **, CONST char *));
+static void writesym PARAMS ((char **, const char *));
static void writevalue PARAMS ((char **, bfd_vma));
static boolean tekhex_set_section_contents
PARAMS ((bfd*, sec_ptr, PTR, file_ptr, bfd_size_type));
}
if (!d)
{
- char *sname = bfd_alloc (abfd, 12);
+ char *sname = bfd_alloc (abfd, (bfd_size_type) 12);
/* No chunk for this address, so make one up */
- d = (struct data_struct *)
- bfd_alloc (abfd, sizeof (struct data_struct));
+ d = ((struct data_struct *)
+ bfd_alloc (abfd, (bfd_size_type) sizeof (struct data_struct)));
if (!sname || !d)
return NULL;
char *src;
{
asection *section = bfd_abs_section_ptr;
- int len;
+ unsigned int len;
char sym[17]; /* A symbol can only be 16chars long */
switch (type)
section = bfd_get_section_by_name (abfd, sym);
if (section == (asection *) NULL)
{
- char *n = bfd_alloc (abfd, len + 1);
+ char *n = bfd_alloc (abfd, (bfd_size_type) len + 1);
if (!n)
abort (); /* FIXME */
case '8':
/* Symbols, add to section */
{
+ bfd_size_type amt = sizeof (tekhex_symbol_type);
tekhex_symbol_type *new =
- (tekhex_symbol_type *) bfd_alloc (abfd,
- sizeof (tekhex_symbol_type));
- char type = (*src);
+ (tekhex_symbol_type *) bfd_alloc (abfd, amt);
+ char stype = (*src);
if (!new)
abort (); /* FIXME */
new->prev = abfd->tdata.tekhex_data->symbols;
abfd->tdata.tekhex_data->symbols = new;
len = getsym (sym, &src);
- new->symbol.name = bfd_alloc (abfd, len + 1);
+ new->symbol.name = bfd_alloc (abfd, (bfd_size_type) len + 1);
if (!new->symbol.name)
abort (); /* FIXME */
memcpy ((char *) (new->symbol.name), sym, len + 1);
new->symbol.section = section;
- if (type <= '4')
+ if (stype <= '4')
new->symbol.flags = (BSF_GLOBAL | BSF_EXPORT);
else
new->symbol.flags = BSF_LOCAL;
char type;
/* Find first '%' */
- eof = (boolean) (bfd_read (src, 1, 1, abfd) != 1);
+ eof = (boolean) (bfd_bread (src, (bfd_size_type) 1, abfd) != 1);
while (*src != '%' && !eof)
{
- eof = (boolean) (bfd_read (src, 1, 1, abfd) != 1);
+ eof = (boolean) (bfd_bread (src, (bfd_size_type) 1, abfd) != 1);
}
if (eof)
break;
src++;
/* Fetch the type and the length and the checksum */
- if (bfd_read (src, 1, 5, abfd) != 5)
+ if (bfd_bread (src, (bfd_size_type) 5, abfd) != 5)
abort (); /* FIXME */
type = src[2];
chars_on_line = HEX (src) - 5; /* Already read five char */
- if (bfd_read (src, 1, chars_on_line, abfd) != chars_on_line)
+ if (bfd_bread (src, (bfd_size_type) chars_on_line, abfd) != chars_on_line)
abort (); /* FIXME */
src[chars_on_line] = 0; /* put a null at the end */
tekhex_mkobject (abfd)
bfd *abfd;
{
- tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
+ tdata_type *tdata;
+ tdata = (tdata_type *) bfd_alloc (abfd, (bfd_size_type) sizeof (tdata_type));
if (!tdata)
return false;
abfd->tdata.tekhex_data = tdata;
tekhex_init ();
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
- || bfd_read (b, 1, 4, abfd) != 4)
+ || bfd_bread (b, (bfd_size_type) 4, abfd) != 4)
return NULL;
if (b[0] != '%' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3]))
bfd *abfd;
asection *section;
PTR locationp;
- file_ptr offset ATTRIBUTE_UNUSED;
+ file_ptr offset;
bfd_size_type count;
boolean get;
{
bfd_vma prev_number = 1; /* Nothing can have this as a high bit*/
struct data_struct *d = (struct data_struct *) NULL;
+ BFD_ASSERT (offset == 0);
for (addr = section->vma; count != 0; count--, addr++)
{
-
- bfd_vma chunk_number = addr & ~CHUNK_MASK; /* Get high bits of address */
+ /* Get high bits of address. */
+ bfd_vma chunk_number = addr & ~(bfd_vma) CHUNK_MASK;
bfd_vma low_bits = addr & CHUNK_MASK;
if (chunk_number != prev_number)
{
if (s->flags & SEC_LOAD)
{
- for (vma = s->vma & ~CHUNK_MASK;
+ for (vma = s->vma & ~(bfd_vma) CHUNK_MASK;
vma < s->vma + s->_raw_size;
vma += CHUNK_MASK)
find_chunk (abfd, vma);
}
if (section->flags & (SEC_LOAD | SEC_ALLOC))
{
- move_section_contents (abfd, section, locationp, offset, bytes_to_do, false);
+ move_section_contents (abfd, section, locationp, offset, bytes_to_do,
+ false);
return true;
}
else
static void
writesym (dst, sym)
char **dst;
- CONST char *sym;
+ const char *sym;
{
char *p = *dst;
int len = (sym ? strlen (sym) : 0);
sum += sum_block[(unsigned char) front[2]];
sum += sum_block[(unsigned char) front[3]]; /* type */
TOHEX (front + 4, sum);
- if (bfd_write (front, 1, 6, abfd) != 6)
+ if (bfd_bwrite (front, (bfd_size_type) 6, abfd) != 6)
abort ();
end[0] = '\n';
wrlen = end - start + 1;
- if (bfd_write (start, 1, wrlen, abfd) != wrlen)
+ if (bfd_bwrite (start, wrlen, abfd) != wrlen)
abort ();
}
{
int low;
- CONST int span = 32;
+ const int span = 32;
int addr;
/* Write it in blocks of 32 bytes */
if (section_code != '?')
{ /* do not include debug symbols */
- asymbol *s = *p;
+ asymbol *sym = *p;
char *dst = buffer;
- writesym (&dst, s->section->name);
+ writesym (&dst, sym->section->name);
switch (section_code)
{
return false;
}
- writesym (&dst, s->name);
- writevalue (&dst, s->value + s->section->vma);
+ writesym (&dst, sym->name);
+ writevalue (&dst, sym->value + sym->section->vma);
out (abfd, '3', buffer, dst);
}
}
}
/* And the terminator */
- if (bfd_write ("%0781010\n", 1, 9, abfd) != 9)
+ if (bfd_bwrite ("%0781010\n", (bfd_size_type) 9, abfd) != 9)
abort ();
return true;
}
tekhex_make_empty_symbol (abfd)
bfd *abfd;
{
- tekhex_symbol_type *new =
- (tekhex_symbol_type *) bfd_zalloc (abfd, sizeof (struct tekhex_symbol_struct));
+ bfd_size_type amt = sizeof (struct tekhex_symbol_struct);
+ tekhex_symbol_type *new = (tekhex_symbol_type *) bfd_zalloc (abfd, amt);
if (!new)
return NULL;
case bfd_print_symbol_all:
{
- CONST char *section_name = symbol->section->name;
+ const char *section_name = symbol->section->name;
bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
/* BFD back end for traditional Unix core files (U-area and raw sections)
Copyright 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
- 2000
+ 2000, 2001
Free Software Foundation, Inc.
Written by John Gilmore of Cygnus Support.
int val;
struct user u;
struct trad_core_struct *rawptr;
+ bfd_size_type amt;
#ifdef TRAD_CORE_USER_OFFSET
/* If defined, this macro is the file position of the user struct. */
- if (bfd_seek (abfd, TRAD_CORE_USER_OFFSET, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) TRAD_CORE_USER_OFFSET, SEEK_SET) != 0)
return 0;
#endif
- val = bfd_read ((void *)&u, 1, sizeof u, abfd);
+ val = bfd_bread ((void *) &u, (bfd_size_type) sizeof u, abfd);
if (val != sizeof u)
{
/* Too small to be a core file */
/* Allocate both the upage and the struct core_data at once, so
a single free() will free them both. */
- rawptr = (struct trad_core_struct *)
- bfd_zmalloc (sizeof (struct trad_core_struct));
+ amt = sizeof (struct trad_core_struct);
+ rawptr = (struct trad_core_struct *) bfd_zmalloc (amt);
if (rawptr == NULL)
return 0;
/* Create the sections. This is raunchy, but bfd_close wants to free
them separately. */
- core_stacksec(abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ amt = sizeof (asection);
+ core_stacksec(abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_stacksec (abfd) == NULL)
return NULL;
- core_datasec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ amt = sizeof (asection);
+ core_datasec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_datasec (abfd) == NULL)
return NULL;
- core_regsec (abfd) = (asection *) bfd_zalloc (abfd, sizeof (asection));
+ amt = sizeof (asection);
+ core_regsec (abfd) = (asection *) bfd_zalloc (abfd, amt);
if (core_regsec (abfd) == NULL)
return NULL;
static boolean versados_scan PARAMS ((bfd *));
static const bfd_target *versados_object_p PARAMS ((bfd *));
static asymbol *versados_new_symbol PARAMS ((bfd *, int, const char *, bfd_vma, asection *));
-static char *new_symbol_string PARAMS ((bfd *, char *));
+static char *new_symbol_string PARAMS ((bfd *, const char *));
static const bfd_target *versados_object_p PARAMS ((bfd *));
static boolean versados_pass_2 PARAMS ((bfd *));
static boolean versados_get_section_contents
static asymbol *versados_make_empty_symbol PARAMS ((bfd *));
static long int versados_get_symtab_upper_bound PARAMS ((bfd *));
static long int versados_get_symtab PARAMS ((bfd *, asymbol **));
+static void versados_get_symbol_info
+ PARAMS ((bfd *, asymbol *, symbol_info *));
+static void versados_print_symbol
+ PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
+static long versados_get_reloc_upper_bound
+ PARAMS ((bfd *, sec_ptr));
+static long versados_canonicalize_reloc
+ PARAMS ((bfd *, sec_ptr, arelent **, asymbol **));
#define VHEADER '1'
#define VESTDEF '2'
{
if (abfd->tdata.versados_data == NULL)
{
- tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
+ bfd_size_type amt = sizeof (tdata_type);
+ tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, amt);
if (tdata == NULL)
return false;
abfd->tdata.versados_data = tdata;
bfd *abfd;
union ext_any *ptr;
{
- bfd_read (&ptr->size, 1, 1, abfd);
- if (bfd_read ((char *) ptr + 1, 1, ptr->size, abfd) != ptr->size)
+ if (bfd_bread (&ptr->size, (bfd_size_type) 1, abfd) != 1
+ || (bfd_bread ((char *) ptr + 1, (bfd_size_type) ptr->size, abfd)
+ != ptr->size))
return 0;
return 1;
}
static char *
new_symbol_string (abfd, name)
bfd *abfd;
- char *name;
+ const char *name;
{
char *n = VDATA (abfd)->strings;
strcpy (VDATA (abfd)->strings, name);
int esidx;
asymbol *s;
char *n = new_symbol_string (abfd, name);
- s = versados_new_symbol (abfd, snum, n, 0,
- &bfd_und_section);
+ s = versados_new_symbol (abfd, snum, n, (bfd_vma) 0,
+ bfd_und_section_ptr);
esidx = VDATA (abfd)->es_done++;
RDATA (abfd, esidx - ES_BASE) = s;
}
case ESD_XDEF_IN_SEC:
{
int snum = VDATA (abfd)->def_idx++;
- long val;
+ bfd_vma val;
get_10 (&ptr, name);
val = get_4 (&ptr);
if (pass == 1)
{
asymbol *s;
char *n = new_symbol_string (abfd, name);
- s = versados_new_symbol (abfd, snum + VDATA (abfd)->nrefs, n, val, sec);
+ s = versados_new_symbol (abfd, snum + VDATA (abfd)->nrefs, n,
+ val, sec);
s->flags |= BSF_GLOBAL;
}
}
int need_contents = 0;
unsigned int dst_idx = esdid->pc;
- for (shift = (1 << 31); shift && srcp < endp; shift >>= 1)
+ for (shift = ((unsigned long) 1 << 31); shift && srcp < endp; shift >>= 1)
{
if (bits & shift)
{
EDATA (abfd, otr->esdid - 1).pc = dst_idx;
if (!contents && need_contents)
- esdid->contents = (unsigned char *) bfd_alloc (abfd, esdid->section->_raw_size);
-
+ {
+ bfd_size_type size = esdid->section->_raw_size;
+ esdid->contents = (unsigned char *) bfd_alloc (abfd, size);
+ }
}
static boolean
int i;
int j;
int nsecs = 0;
+ bfd_size_type amt;
VDATA (abfd)->stringlen = 0;
VDATA (abfd)->nrefs = 0;
struct esdid *esdid = &EDATA (abfd, i);
if (esdid->section)
{
- esdid->section->relocation
- = (arelent *) bfd_alloc (abfd, sizeof (arelent) * esdid->relocs);
+ amt = (bfd_size_type) esdid->relocs * sizeof (arelent);
+ esdid->section->relocation = (arelent *) bfd_alloc (abfd, amt);
esdid->pc = 0;
abfd->symcount += nsecs;
- VDATA (abfd)->symbols = (asymbol *) bfd_alloc (abfd,
- sizeof (asymbol) * (abfd->symcount));
+ amt = abfd->symcount;
+ amt *= sizeof (asymbol);
+ VDATA (abfd)->symbols = (asymbol *) bfd_alloc (abfd, amt);
- VDATA (abfd)->strings = bfd_alloc (abfd, VDATA (abfd)->stringlen);
+ amt = VDATA (abfd)->stringlen;
+ VDATA (abfd)->strings = bfd_alloc (abfd, amt);
if ((VDATA (abfd)->symbols == NULL && abfd->symcount > 0)
|| (VDATA (abfd)->strings == NULL && VDATA (abfd)->stringlen > 0))
if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return NULL;
- if (bfd_read (&len, 1, 1, abfd) != 1)
+ if (bfd_bread (&len, (bfd_size_type) 1, abfd) != 1)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
- if (bfd_read (&ext.type, 1, len, abfd) != len)
+ if (bfd_bread (&ext.type, (bfd_size_type) len, abfd) != len)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
if (VDATA (abfd)->pass_2_done)
return 1;
- if (bfd_seek (abfd, 0, SEEK_SET) != 0)
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
return 0;
VDATA (abfd)->es_done = ES_BASE;
versados_make_empty_symbol (abfd)
bfd *abfd;
{
- asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
+ asymbol *new;
+
+ new = (asymbol *) bfd_zalloc (abfd, (bfd_size_type) sizeof (asymbol));
if (new)
new->the_bfd = abfd;
return new;
return symcount;
}
-void
+static void
versados_get_symbol_info (ignore_abfd, symbol, ret)
bfd *ignore_abfd ATTRIBUTE_UNUSED;
asymbol *symbol;
bfd_symbol_info (symbol, ret);
}
-void
+static void
versados_print_symbol (abfd, afile, symbol, how)
bfd *abfd;
PTR afile;
}
}
-long
+static long
versados_get_reloc_upper_bound (abfd, asect)
bfd *abfd ATTRIBUTE_UNUSED;
sec_ptr asect;
return (asect->reloc_count + 1) * sizeof (arelent *);
}
-long
+static long
versados_canonicalize_reloc (abfd, section, relptr, symbols)
bfd *abfd;
sec_ptr section;
/* Retrieve bfd section flags by name and size */
static flagword
-vms_secflag_by_name (abfd, section_flags, name, size)
+vms_secflag_by_name (abfd, section_flags, name, hassize)
bfd *abfd;
struct sec_flags_struct *section_flags;
char *name;
- int size;
+ int hassize;
{
int i = 0;
strcasecmp (name, section_flags[i].name):
strcmp (name, section_flags[i].name)) == 0)
{
- if (size > 0)
+ if (hassize)
return section_flags[i].flags_hassize;
else
return section_flags[i].flags_always;
}
i++;
}
- if (size > 0)
+ if (hassize)
return section_flags[i].flags_hassize;
return section_flags[i].flags_always;
}
/* Retrieve vms section flags by name and size */
static flagword
-vms_esecflag_by_name (section_flags, name, size)
+vms_esecflag_by_name (section_flags, name, hassize)
struct sec_flags_struct *section_flags;
char *name;
- int size;
+ int hassize;
{
int i = 0;
{
if (strcmp (name, section_flags[i].name) == 0)
{
- if (size > 0)
+ if (hassize)
return section_flags[i].vflags_hassize;
else
return section_flags[i].vflags_always;
}
i++;
}
- if (size > 0)
+ if (hassize)
return section_flags[i].vflags_hassize;
return section_flags[i].vflags_always;
}
switch (objtype)
{
- case EOBJ_S_C_EGSD:
- PRIV(vms_rec) += 8; /* skip type, size, l_temp */
- PRIV(rec_size) -= 8;
- break;
- case OBJ_S_C_GSD:
- PRIV(vms_rec) += 1;
- PRIV(rec_size) -= 1;
- break;
- default:
- return -1;
+ case EOBJ_S_C_EGSD:
+ PRIV(vms_rec) += 8; /* skip type, size, l_temp */
+ PRIV(rec_size) -= 8;
+ break;
+ case OBJ_S_C_GSD:
+ PRIV(vms_rec) += 1;
+ PRIV(rec_size) -= 1;
+ break;
+ default:
+ return -1;
}
/* calculate base address for each section */
return -1;
}
old_flags = bfd_getl16 (vms_rec + 2);
- section->_raw_size = bfd_getl32(vms_rec + 4); /* allocation */
- new_flags = vms_secflag_by_name (abfd, vax_section_flags, name, section->_raw_size);
+ section->_raw_size = bfd_getl32 (vms_rec + 4); /* allocation */
+ new_flags = vms_secflag_by_name (abfd, vax_section_flags, name,
+ section->_raw_size > 0);
if (old_flags & EGPS_S_V_REL)
new_flags |= SEC_RELOC;
if (old_flags & GPS_S_M_OVR)
else if (section->_raw_size > old_section->_raw_size)
{
section->contents = ((unsigned char *)
- bfd_realloc (old_section->contents, section->_raw_size));
+ bfd_realloc (old_section->contents,
+ section->_raw_size));
if (section->contents == NULL)
{
bfd_set_error (bfd_error_no_memory);
else
{
section->contents = ((unsigned char *)
- bfd_malloc (section->_raw_size));
+ bfd_malloc (section->_raw_size));
if (section->contents == NULL)
{
bfd_set_error (bfd_error_no_memory);
return -1;
}
- memset (section->contents, 0, (size_t)section->_raw_size);
+ memset (section->contents, 0, (size_t) section->_raw_size);
}
section->_cooked_size = section->_raw_size;
#if VMS_DEBUG
case GSD_S_C_SYM:
case GSD_S_C_SYMW:
{
- int name_offset, value_offset;
+ int name_offset = 0, value_offset = 0;
/*
* symbol specification (definition or reference)
switch (gsd_type)
{
- case GSD_S_C_EPM:
- name_offset = 11;
- value_offset = 5;
- new_flags |= BSF_FUNCTION;
- break;
- case GSD_S_C_EPMW:
- name_offset = 12;
- value_offset = 6;
- new_flags |= BSF_FUNCTION;
- break;
- case GSD_S_C_SYM:
- if (old_flags & GSY_S_M_DEF) /* symbol definition */
- name_offset = 9;
- else
- name_offset = 4;
- value_offset = 5;
- break;
- case GSD_S_C_SYMW:
- if (old_flags & GSY_S_M_DEF) /* symbol definition */
- name_offset = 10;
- else
- name_offset = 5;
- value_offset = 6;
- break;
+ case GSD_S_C_EPM:
+ name_offset = 11;
+ value_offset = 5;
+ new_flags |= BSF_FUNCTION;
+ break;
+ case GSD_S_C_EPMW:
+ name_offset = 12;
+ value_offset = 6;
+ new_flags |= BSF_FUNCTION;
+ break;
+ case GSD_S_C_SYM:
+ if (old_flags & GSY_S_M_DEF) /* symbol definition */
+ name_offset = 9;
+ else
+ name_offset = 4;
+ value_offset = 5;
+ break;
+ case GSD_S_C_SYMW:
+ if (old_flags & GSY_S_M_DEF) /* symbol definition */
+ name_offset = 10;
+ else
+ name_offset = 5;
+ value_offset = 6;
+ break;
}
/* save symbol in vms_symbol_table */
return -1;
old_flags = bfd_getl16 (vms_rec + 6);
section->_raw_size = bfd_getl32 (vms_rec + 8); /* allocation */
- new_flags = vms_secflag_by_name (abfd, evax_section_flags, name, (int) section->_raw_size);
+ new_flags = vms_secflag_by_name (abfd, evax_section_flags, name,
+ section->_raw_size > 0);
if (old_flags & EGPS_S_V_REL)
new_flags |= SEC_RELOC;
if (!bfd_set_section_flags (abfd, section, new_flags))
}
else
{
- new_flags = vms_esecflag_by_name (evax_section_flags, sname, section->_raw_size);
+ new_flags = vms_esecflag_by_name (evax_section_flags, sname,
+ section->_raw_size > 0);
}
_bfd_vms_output_short (abfd, new_flags);
- _bfd_vms_output_long (abfd, section->_raw_size);
+ _bfd_vms_output_long (abfd, (unsigned long) section->_raw_size);
_bfd_vms_output_counted (abfd, sname);
_bfd_vms_output_flush (abfd);
for (symnum = 0; symnum < abfd->symcount; symnum++)
{
+ char *hash;
symbol = abfd->outsymbols[symnum];
if (*(symbol->name) == '_')
}
_bfd_vms_output_short (abfd, new_flags);
- if (old_flags & (BSF_GLOBAL|BSF_WEAK)) /* symbol definition */
+ if (old_flags & (BSF_GLOBAL | BSF_WEAK)) /* symbol definition */
{
+ uquad code_address = 0;
+ unsigned long ca_psindx = 0;
+ unsigned long psindx;
+
if (old_flags & BSF_FUNCTION)
{
- _bfd_vms_output_quad (abfd, symbol->value);
- _bfd_vms_output_quad (abfd,
- ((asymbol *) (symbol->udata.p))->value);
- _bfd_vms_output_long (abfd,
- (((asymbol *) (symbol->udata.p))
- ->section->index));
- _bfd_vms_output_long (abfd, symbol->section->index);
- }
- else
- {
- _bfd_vms_output_quad (abfd, symbol->value); /* L_VALUE */
- _bfd_vms_output_quad (abfd, 0); /* L_CODE_ADDRESS */
- _bfd_vms_output_long (abfd, 0); /* L_CA_PSINDX */
- _bfd_vms_output_long (abfd, symbol->section->index);/* L_PSINDX */
+ code_address = ((asymbol *) (symbol->udata.p))->value;
+ ca_psindx = ((asymbol *) (symbol->udata.p))->section->index;
}
+ psindx = symbol->section->index;
+
+ _bfd_vms_output_quad (abfd, symbol->value);
+ _bfd_vms_output_quad (abfd, code_address);
+ _bfd_vms_output_long (abfd, ca_psindx);
+ _bfd_vms_output_long (abfd, psindx);
}
- _bfd_vms_output_counted (abfd, _bfd_vms_length_hash_symbol (abfd, symbol->name, EOBJ_S_C_SYMSIZ));
+ hash = _bfd_vms_length_hash_symbol (abfd, symbol->name, EOBJ_S_C_SYMSIZ);
+ _bfd_vms_output_counted (abfd, hash);
_bfd_vms_output_flush (abfd);
continue;
}
- _bfd_vms_output_dump (abfd, (unsigned char *)symbol->name, strlen (symbol->name));
+ _bfd_vms_output_dump (abfd, (unsigned char *) symbol->name,
+ (int) strlen (symbol->name));
if (had_case)
break;
had_file = 1;
static vms_section *add_new_contents PARAMS ((bfd *, sec_ptr));
static int hash_string PARAMS ((const char *));
static asymbol *new_symbol PARAMS ((bfd *, char *));
-
+
/*-----------------------------------------------------------------------------*/
#if VMS_DEBUG
/* debug functions */
if (bfd_tell (abfd) & 1)
{
- if (bfd_read (PRIV (vms_buf), 1, 1, abfd) != 1)
+ if (bfd_bread (PRIV (vms_buf), (bfd_size_type) 1, abfd) != 1)
{
bfd_set_error (bfd_error_file_truncated);
return 0;
/* read the record header on Alpha. */
if ((test_len != 0)
- && (bfd_read (PRIV (vms_buf), 1, test_len, abfd)
+ && (bfd_bread (PRIV (vms_buf), (bfd_size_type) test_len, abfd)
!= (bfd_size_type) test_len))
{
bfd_set_error (bfd_error_file_truncated);
if (PRIV (is_vax))
{
- PRIV (rec_length) = bfd_read (vms_buf, 1, PRIV (buf_size), abfd);
+ PRIV (rec_length) = bfd_bread (vms_buf, (bfd_size_type) PRIV (buf_size),
+ abfd);
if (PRIV (rec_length) <= 0)
{
bfd_set_error (bfd_error_file_truncated);
if (PRIV (rec_length) > PRIV (buf_size))
{
- PRIV (vms_buf) = (unsigned char *) realloc (vms_buf, PRIV (rec_length));
+ PRIV (vms_buf) = ((unsigned char *)
+ realloc (vms_buf, (size_t) PRIV (rec_length)));
vms_buf = PRIV (vms_buf);
if (vms_buf == 0)
{
remaining = PRIV (rec_length) - test_len + test_start;
#if VMS_DEBUG
- vms_debug (10, "bfd_read remaining %d\n", remaining);
+ vms_debug (10, "bfd_bread remaining %d\n", remaining);
#endif
- if (bfd_read (vms_buf + test_len, 1, remaining, abfd) !=
+ if (bfd_bread (vms_buf + test_len, (bfd_size_type) remaining, abfd) !=
(bfd_size_type) remaining)
{
bfd_set_error (bfd_error_file_truncated);
}
#if VMS_DEBUG
- vms_debug (11, "bfd_read rec_length %d\n", PRIV (rec_length));
+ vms_debug (11, "bfd_bread rec_length %d\n", PRIV (rec_length));
#endif
return PRIV (rec_length);
unsigned char *str;
int size;
{
- char *newstr = bfd_malloc (size + 1);
+ char *newstr = bfd_malloc ((bfd_size_type) size + 1);
if (newstr == NULL)
return 0;
- strncpy (newstr, (char *)str, size);
+ strncpy (newstr, (char *) str, (size_t) size);
newstr[size] = 0;
return newstr;
if (sptr != NULL)
return sptr;
- newptr = (vms_section *) bfd_malloc (sizeof (vms_section));
+ newptr = (vms_section *) bfd_malloc ((bfd_size_type) sizeof (vms_section));
if (newptr == (vms_section *) NULL)
return NULL;
- newptr->contents = (unsigned char *) bfd_alloc (abfd, (int)section->_raw_size);
- if (newptr->contents == (unsigned char *)NULL)
+ newptr->contents = (unsigned char *) bfd_alloc (abfd, section->_raw_size);
+ if (newptr->contents == (unsigned char *) NULL)
return NULL;
newptr->offset = 0;
newptr->size = section->_raw_size;
rechead);
#endif
- _bfd_vms_output_short (abfd,rectype);
+ _bfd_vms_output_short (abfd, (unsigned int) rectype);
/* save current output position to fill in lenght later */
PRIV (length_pos));
#endif
- _bfd_vms_output_short (abfd,0); /* placeholder for length */
+ _bfd_vms_output_short (abfd, 0); /* placeholder for length */
if (rechead != -1)
- _bfd_vms_output_short (abfd,rechead);
+ _bfd_vms_output_short (abfd, (unsigned int) rechead);
return;
}
/* put length to buffer */
PRIV (output_size) = PRIV (length_pos);
- _bfd_vms_output_short (abfd, (unsigned int)length);
+ _bfd_vms_output_short (abfd, (unsigned int) length);
if (PRIV (push_level) == 0)
{
#ifndef VMS
/* write length first, see FF_FOREIGN in the input routines */
- fwrite (PRIV (output_buf)+2, 2, 1, (FILE *)abfd->iostream);
+ fwrite (PRIV (output_buf) + 2, 2, 1, (FILE *) abfd->iostream);
#endif
- fwrite (PRIV (output_buf), real_size, 1, (FILE *)abfd->iostream);
+ fwrite (PRIV (output_buf), (size_t) real_size, 1,
+ (FILE *) abfd->iostream);
PRIV (output_size) = 0;
}
vms_debug (6, "_bfd_vms_output_short (%04x)\n", value);
#endif
- bfd_put_16 (abfd, value & 0xffff, PRIV (output_buf) + PRIV (output_size));
+ bfd_put_16 (abfd, (bfd_vma) value & 0xffff,
+ PRIV (output_buf) + PRIV (output_size));
PRIV (output_size) += 2;
return;
}
vms_debug (6, "_bfd_vms_output_long (%08lx)\n", value);
#endif
- bfd_put_32 (abfd, value, PRIV (output_buf) + PRIV (output_size));
+ bfd_put_32 (abfd, (bfd_vma) value, PRIV (output_buf) + PRIV (output_size));
PRIV (output_size) += 4;
return;
}
(*_bfd_error_handler) (_("_bfd_vms_output_counted called with too many bytes"));
return;
}
- _bfd_vms_output_byte (abfd, len & 0xff);
+ _bfd_vms_output_byte (abfd, (unsigned int) len & 0xff);
_bfd_vms_output_dump (abfd, (unsigned char *)value, len);
}
if (length == 0)
return;
- memcpy (PRIV (output_buf) + PRIV (output_size), data, length);
+ memcpy (PRIV (output_buf) + PRIV (output_size), data, (size_t) length);
PRIV (output_size) += length;
return;
if (count == 0)
return;
- memset (PRIV (output_buf) + PRIV (output_size), value, count);
+ memset (PRIV (output_buf) + PRIV (output_size), value, (size_t) count);
PRIV (output_size) += count;
return;
i = maxlen;
}
- strncpy (out, in, i);
+ strncpy (out, in, (size_t) i);
in += i;
out += i;
bfd *abfd;
int size;
{
- int offset;
+ bfd_size_type offset;
- offset = PRIV(image_ptr) - PRIV(image_section)->contents;
- if ((bfd_size_type) (offset + size) > PRIV(image_section)->_raw_size)
+ offset = PRIV (image_ptr) - PRIV (image_section)->contents;
+ if (offset + size > PRIV (image_section)->_raw_size)
{
- PRIV(image_section)->contents = bfd_realloc (PRIV(image_section)->contents, offset + size);
- if (PRIV(image_section)->contents == 0)
+ PRIV (image_section)->contents
+ = bfd_realloc (PRIV (image_section)->contents, offset + size);
+ if (PRIV (image_section)->contents == 0)
{
(*_bfd_error_handler) (_("No Mem !"));
return -1;
}
- PRIV(image_section)->_raw_size = offset + size;
- PRIV(image_ptr) = PRIV(image_section)->contents + offset;
+ PRIV (image_section)->_raw_size = offset + size;
+ PRIV (image_ptr) = PRIV (image_section)->contents + offset;
}
return 0;
{
#if VMS_DEBUG
_bfd_vms_debug (4, "image_set_ptr (%d=%s, %d)\n",
- psect, PRIV(sections)[psect]->name, offset);
+ psect, PRIV (sections)[psect]->name, offset);
#endif
- PRIV(image_ptr) = PRIV(sections)[psect]->contents + offset;
- PRIV(image_section) = PRIV(sections)[psect];
+ PRIV (image_ptr) = PRIV (sections)[psect]->contents + offset;
+ PRIV (image_section) = PRIV (sections)[psect];
return;
}
_bfd_vms_debug (4, "image_inc_ptr (%d)\n", offset);
#endif
- PRIV(image_ptr) += offset;
+ PRIV (image_ptr) += offset;
return;
}
int offset ATTRIBUTE_UNUSED;
{
#if VMS_DEBUG
- _bfd_vms_debug (8, "image_dump from (%p, %d) to (%p)\n", ptr, size, PRIV(image_ptr));
+ _bfd_vms_debug (8, "image_dump from (%p, %d) to (%p)\n", ptr, size,
+ PRIV (image_ptr));
_bfd_hexdump (9, ptr, size, offset);
#endif
- if (PRIV(is_vax) && check_section (abfd, size))
+ if (PRIV (is_vax) && check_section (abfd, size))
return;
while (size-- > 0)
- *PRIV(image_ptr)++ = *ptr++;
+ *PRIV (image_ptr)++ = *ptr++;
return;
}
unsigned int value;
{
#if VMS_DEBUG
- _bfd_vms_debug (6, "image_write_b(%02x)\n", (int)value);
+ _bfd_vms_debug (6, "image_write_b(%02x)\n", (int) value);
#endif
- if (PRIV(is_vax) && check_section (abfd, 1))
+ if (PRIV (is_vax) && check_section (abfd, 1))
return;
- *PRIV(image_ptr)++ = (value & 0xff);
+ *PRIV (image_ptr)++ = (value & 0xff);
return;
}
unsigned int value;
{
#if VMS_DEBUG
- _bfd_vms_debug (6, "image_write_w(%04x)\n", (int)value);
+ _bfd_vms_debug (6, "image_write_w(%04x)\n", (int) value);
#endif
- if (PRIV(is_vax) && check_section (abfd, 2))
+ if (PRIV (is_vax) && check_section (abfd, 2))
return;
- bfd_putl16 (value, PRIV(image_ptr));
- PRIV(image_ptr) += 2;
+ bfd_putl16 ((bfd_vma) value, PRIV (image_ptr));
+ PRIV (image_ptr) += 2;
return;
}
_bfd_vms_debug (6, "image_write_l (%08lx)\n", value);
#endif
- if (PRIV(is_vax) && check_section (abfd, 4))
+ if (PRIV (is_vax) && check_section (abfd, 4))
return;
- bfd_putl32 (value, PRIV(image_ptr));
- PRIV(image_ptr) += 4;
+ bfd_putl32 ((bfd_vma) value, PRIV (image_ptr));
+ PRIV (image_ptr) += 4;
return;
}
_bfd_vms_debug (6, "image_write_q (%016lx)\n", value);
#endif
- if (PRIV(is_vax) && check_section (abfd, 8))
+ if (PRIV (is_vax) && check_section (abfd, 8))
return;
- bfd_putl64 (value, PRIV(image_ptr));
- PRIV(image_ptr) += 8;
+ bfd_putl64 (value, PRIV (image_ptr));
+ PRIV (image_ptr) += 8;
return;
}
#if VMS_DEBUG
_bfd_vms_debug (5, "etir_sta %d/%x\n", cmd, cmd);
- _bfd_hexdump (8, ptr, 16, (int)ptr);
+ _bfd_hexdump (8, ptr, 16, (int) ptr);
#endif
switch (cmd)
/* stack */
/* stack global
- arg: cs symbol name
+ arg: cs symbol name
- stack 32 bit value of symbol (high bits set to 0) */
+ stack 32 bit value of symbol (high bits set to 0) */
- case ETIR_S_C_STA_GBL:
- {
- char *name;
- vms_symbol_entry *entry;
+ case ETIR_S_C_STA_GBL:
+ {
+ char *name;
+ vms_symbol_entry *entry;
- name = _bfd_vms_save_counted_string (ptr);
- entry = (vms_symbol_entry *)
- bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
- if (entry == (vms_symbol_entry *)NULL)
- {
+ name = _bfd_vms_save_counted_string (ptr);
+ entry = (vms_symbol_entry *)
+ bfd_hash_lookup (PRIV (vms_symbol_table), name, false, false);
+ if (entry == (vms_symbol_entry *) NULL)
+ {
#if VMS_DEBUG
- _bfd_vms_debug (3, "ETIR_S_C_STA_GBL: no symbol \"%s\"\n", name);
+ _bfd_vms_debug (3, "ETIR_S_C_STA_GBL: no symbol \"%s\"\n", name);
#endif
- _bfd_vms_push (abfd, (uquad)0, -1);
- }
- else
- {
- _bfd_vms_push (abfd, (uquad) (entry->symbol->value), -1);
- }
- }
+ _bfd_vms_push (abfd, (uquad) 0, -1);
+ }
+ else
+ {
+ _bfd_vms_push (abfd, (uquad) (entry->symbol->value), -1);
+ }
+ }
break;
- /* stack longword
- arg: lw value
+ /* stack longword
+ arg: lw value
- stack 32 bit value, sign extend to 64 bit */
+ stack 32 bit value, sign extend to 64 bit */
- case ETIR_S_C_STA_LW:
- _bfd_vms_push (abfd, (uquad)bfd_getl32 (ptr), -1);
+ case ETIR_S_C_STA_LW:
+ _bfd_vms_push (abfd, (uquad) bfd_getl32 (ptr), -1);
break;
- /* stack global
- arg: qw value
+ /* stack global
+ arg: qw value
- stack 64 bit value of symbol */
+ stack 64 bit value of symbol */
- case ETIR_S_C_STA_QW:
- _bfd_vms_push (abfd, (uquad)bfd_getl64(ptr), -1);
+ case ETIR_S_C_STA_QW:
+ _bfd_vms_push (abfd, (uquad) bfd_getl64 (ptr), -1);
break;
- /* stack psect base plus quadword offset
- arg: lw section index
- qw signed quadword offset (low 32 bits)
+ /* stack psect base plus quadword offset
+ arg: lw section index
+ qw signed quadword offset (low 32 bits)
- stack qw argument and section index
- (see ETIR_S_C_STO_OFF, ETIR_S_C_CTL_SETRB) */
+ stack qw argument and section index
+ (see ETIR_S_C_STO_OFF, ETIR_S_C_CTL_SETRB) */
- case ETIR_S_C_STA_PQ:
- {
- uquad dummy;
- unsigned int psect;
+ case ETIR_S_C_STA_PQ:
+ {
+ uquad dummy;
+ unsigned int psect;
- psect = bfd_getl32 (ptr);
- if (psect >= PRIV(section_count))
- {
- (*_bfd_error_handler) (_("Bad section index in ETIR_S_C_STA_PQ"));
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- dummy = bfd_getl64 (ptr+4);
- _bfd_vms_push (abfd, dummy, psect);
- }
+ psect = bfd_getl32 (ptr);
+ if (psect >= PRIV (section_count))
+ {
+ (*_bfd_error_handler) (_("Bad section index in ETIR_S_C_STA_PQ"));
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ dummy = bfd_getl64 (ptr+4);
+ _bfd_vms_push (abfd, dummy, (int) psect);
+ }
break;
- /* all not supported */
+ /* all not supported */
- case ETIR_S_C_STA_LI:
- case ETIR_S_C_STA_MOD:
- case ETIR_S_C_STA_CKARG:
+ case ETIR_S_C_STA_LI:
+ case ETIR_S_C_STA_MOD:
+ case ETIR_S_C_STA_CKARG:
- (*_bfd_error_handler) (_("Unsupported STA cmd %d"), cmd);
- return false;
+ (*_bfd_error_handler) (_("Unsupported STA cmd %d"), cmd);
+ return false;
break;
- default:
- (*_bfd_error_handler) (_("Reserved STA cmd %d"), cmd);
- return false;
+ default:
+ (*_bfd_error_handler) (_("Reserved STA cmd %d"), cmd);
+ return false;
break;
}
#if VMS_DEBUG
#if VMS_DEBUG
_bfd_vms_debug (5, "etir_sto %d/%x\n", cmd, cmd);
- _bfd_hexdump (8, ptr, 16, (int)ptr);
+ _bfd_hexdump (8, ptr, 16, (int) ptr);
#endif
switch (cmd)
if (is_share) /* FIXME */
(*_bfd_error_handler) ("ETIR_S_C_STO_B: byte fixups not supported");
#endif
- image_write_b (abfd, dummy & 0xff); /* FIXME: check top bits */
+ /* FIXME: check top bits */
+ image_write_b (abfd, (unsigned int) dummy & 0xff);
break;
/* store word: pop stack, write word
if (is_share) /* FIXME */
(*_bfd_error_handler) ("ETIR_S_C_STO_B: word fixups not supported");
#endif
- image_write_w (abfd, dummy & 0xffff); /* FIXME: check top bits */
+ /* FIXME: check top bits */
+ image_write_w (abfd, (unsigned int) dummy & 0xffff);
break;
/* store longword: pop stack, write longword
case ETIR_S_C_STO_LW:
dummy = _bfd_vms_pop (abfd, &psect);
- dummy += (PRIV(sections)[psect])->vma;
- image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
+ dummy += (PRIV (sections)[psect])->vma;
+ /* FIXME: check top bits */
+ image_write_l (abfd, (unsigned int) dummy & 0xffffffff);
break;
/* store quadword: pop stack, write quadword
case ETIR_S_C_STO_QW:
dummy = _bfd_vms_pop (abfd, &psect);
- dummy += (PRIV(sections)[psect])->vma;
+ dummy += (PRIV (sections)[psect])->vma;
image_write_q (abfd, dummy); /* FIXME: check top bits */
break;
case ETIR_S_C_STO_IMMR:
{
- unsigned long size;
+ int size;
size = bfd_getl32 (ptr);
- dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
- while (dummy-- > 0L)
+ dummy = (unsigned long) _bfd_vms_pop (abfd, NULL);
+ while (dummy-- > 0)
image_dump (abfd, ptr+4, size, 0);
}
break;
char *name;
name = _bfd_vms_save_counted_string (ptr);
- entry = (vms_symbol_entry *)bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
- if (entry == (vms_symbol_entry *)NULL)
+ entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV (vms_symbol_table),
+ name, false, false);
+ if (entry == (vms_symbol_entry *) NULL)
{
(*_bfd_error_handler) (_("ETIR_S_C_STO_GBL: no symbol \"%s\""),
name);
char *name;
name = _bfd_vms_save_counted_string (ptr);
- entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
- if (entry == (vms_symbol_entry *)NULL)
+ entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV (vms_symbol_table),
+ name, false, false);
+ if (entry == (vms_symbol_entry *) NULL)
{
(*_bfd_error_handler) (_("ETIR_S_C_STO_CA: no symbol \"%s\""),
name);
(*_bfd_error_handler) (_("ETIR_S_C_STO_RB/AB: Not supported"));
break;
- /* store offset to psect: pop stack, add low 32 bits to base of psect
- arg: - */
+ /* store offset to psect: pop stack, add low 32 bits to base of psect
+ arg: - */
case ETIR_S_C_STO_OFF:
{
uquad q;
- int psect;
+ int psect1;
- q = _bfd_vms_pop (abfd, &psect);
- q += (PRIV(sections)[psect])->vma;
+ q = _bfd_vms_pop (abfd, &psect1);
+ q += (PRIV (sections)[psect1])->vma;
image_write_q (abfd, q);
}
break;
}
break;
- /* this code is 'reserved to digital' according to the openVMS linker manual,
- however it is generated by the DEC C compiler and defined in the include file.
+ /* this code is 'reserved to digital' according to the openVMS
+ linker manual, however it is generated by the DEC C compiler
+ and defined in the include file.
FIXME, since the following is just a guess
store global longword: store 32bit value of symbol
arg: cs symbol name */
char *name;
name = _bfd_vms_save_counted_string (ptr);
- entry = (vms_symbol_entry *)bfd_hash_lookup (PRIV(vms_symbol_table), name, false, false);
- if (entry == (vms_symbol_entry *)NULL)
+ entry = (vms_symbol_entry *) bfd_hash_lookup (PRIV (vms_symbol_table),
+ name, false, false);
+ if (entry == (vms_symbol_entry *) NULL)
{
#if VMS_DEBUG
_bfd_vms_debug (3, "ETIR_S_C_STO_GBL_LW: no symbol \"%s\"\n", name);
#endif
- image_write_l (abfd, (unsigned long)0); /* FIXME, reloc */
+ image_write_l (abfd, (unsigned long) 0); /* FIXME, reloc */
}
else
image_write_l (abfd, (unsigned long) (entry->symbol->value)); /* FIXME, reloc */
(*_bfd_error_handler) (_("ETIR_S_C_STO_LP_PSB: Not supported"));
break;
- /* */
+ /* */
case ETIR_S_C_STO_HINT_GBL:
(*_bfd_error_handler) (_("ETIR_S_C_STO_HINT_GBL: not implemented"));
break;
- /* */
+ /* */
case ETIR_S_C_STO_HINT_PS:
(*_bfd_error_handler) (_("ETIR_S_C_STO_HINT_PS: not implemented"));
#if VMS_DEBUG
_bfd_vms_debug (5, "etir_opr %d/%x\n", cmd, cmd);
- _bfd_hexdump (8, ptr, 16, (int)ptr);
+ _bfd_hexdump (8, ptr, 16, (int) ptr);
#endif
switch (cmd)
/* add */
case ETIR_S_C_OPR_ADD:
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
_bfd_vms_push (abfd, (uquad) (op1 + op2), -1);
break;
/* subtract */
case ETIR_S_C_OPR_SUB:
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
_bfd_vms_push (abfd, (uquad) (op2 - op1), -1);
break;
/* multiply */
case ETIR_S_C_OPR_MUL:
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
_bfd_vms_push (abfd, (uquad) (op1 * op2), -1);
break;
/* divide */
case ETIR_S_C_OPR_DIV:
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
if (op2 == 0)
- _bfd_vms_push (abfd, (uquad)0L, -1);
+ _bfd_vms_push (abfd, (uquad) 0, -1);
else
_bfd_vms_push (abfd, (uquad) (op2 / op1), -1);
break;
/* logical and */
case ETIR_S_C_OPR_AND:
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
_bfd_vms_push (abfd, (uquad) (op1 & op2), -1);
break;
/* logical inclusive or */
case ETIR_S_C_OPR_IOR:
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
_bfd_vms_push (abfd, (uquad) (op1 | op2), -1);
break;
/* logical exclusive or */
case ETIR_S_C_OPR_EOR:
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
_bfd_vms_push (abfd, (uquad) (op1 ^ op2), -1);
break;
/* negate */
case ETIR_S_C_OPR_NEG:
- op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
_bfd_vms_push (abfd, (uquad) (-op1), -1);
break;
/* complement */
case ETIR_S_C_OPR_COM:
- op1 = (long)_bfd_vms_pop (abfd, NULL);
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
_bfd_vms_push (abfd, (uquad) (op1 ^ -1L), -1);
break;
/* insert field */
case ETIR_S_C_OPR_INSV:
- (void)_bfd_vms_pop (abfd, NULL);
+ (void) _bfd_vms_pop (abfd, NULL);
(*_bfd_error_handler) (_("ETIR_S_C_OPR_INSV: Not supported"));
break;
- /* arithmetic shift */
+ /* arithmetic shift */
case ETIR_S_C_OPR_ASH:
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
if (op2 < 0) /* shift right */
op1 >>= -op2;
else /* shift left */
op1 <<= op2;
- _bfd_vms_push (abfd, (uquad)op1, -1);
+ _bfd_vms_push (abfd, (uquad) op1, -1);
break;
/* unsigned shift */
/* select */
case ETIR_S_C_OPR_SEL:
- if ((long)_bfd_vms_pop (abfd, NULL) & 0x01L)
- (void)_bfd_vms_pop (abfd, NULL);
+ if ((long) _bfd_vms_pop (abfd, NULL) & 0x01L)
+ (void) _bfd_vms_pop (abfd, NULL);
else
{
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- (void)_bfd_vms_pop (abfd, NULL);
- _bfd_vms_push (abfd, (uquad)op1, -1);
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ (void) _bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad) op1, -1);
}
break;
#if VMS_DEBUG
_bfd_vms_debug (5, "etir_ctl %d/%x\n", cmd, cmd);
- _bfd_hexdump (8, ptr, 16, (int)ptr);
+ _bfd_hexdump (8, ptr, 16, (int) ptr);
#endif
switch (cmd)
#if VMS_DEBUG
_bfd_vms_debug (5, "etir_stc %d/%x\n", cmd, cmd);
- _bfd_hexdump (8, ptr, 16, (int)ptr);
+ _bfd_hexdump (8, ptr, 16, (int) ptr);
#endif
switch (cmd)
da signature */
case ETIR_S_C_STC_LP_PSB:
- image_inc_ptr (abfd, 16); /* skip entry,procval */
+ image_inc_ptr (abfd, (uquad) 16); /* skip entry,procval */
break;
/* 202 Store-conditional Address at global address
arg: */
case ETIR_S_C_STC_NBH_PS:
-/* FIXME (*_bfd_error_handler) ("ETIR_S_C_STC_xx: (%d) not supported", cmd); */
+ /* FIXME */
+#if 0
+ (*_bfd_error_handler) ("ETIR_S_C_STC_xx: (%d) not supported", cmd);
+#endif
break;
default:
#endif
sprintf (sname, SECTION_NAME_TEMPLATE, idx);
- name = bfd_malloc (strlen (sname) + 1);
+ name = bfd_malloc ((bfd_size_type) strlen (sname) + 1);
if (name == 0)
return 0;
strcpy (name, sname);
- section = bfd_malloc (sizeof (asection));
+ section = bfd_malloc ((bfd_size_type) sizeof (asection));
if (section == 0)
{
#if VMS_DEBUG
bfd *abfd;
unsigned int idx;
{
+ bfd_size_type amt;
+
#if VMS_DEBUG
_bfd_vms_debug (4, "alloc_section %d\n", idx);
#endif
- PRIV(sections) = ((asection **)
- bfd_realloc (PRIV(sections), (idx+1) * sizeof (asection *)));
- if (PRIV(sections) == 0)
+ amt = idx + 1;
+ amt *= sizeof (asection *);
+ PRIV (sections) = (asection **) bfd_realloc (PRIV (sections), amt);
+ if (PRIV (sections) == 0)
return -1;
- while (PRIV(section_count) <= idx)
+ while (PRIV (section_count) <= idx)
{
- PRIV(sections)[PRIV(section_count)] = new_section (abfd, PRIV(section_count));
- if (PRIV(sections)[PRIV(section_count)] == 0)
+ PRIV (sections)[PRIV (section_count)]
+ = new_section (abfd, (int) PRIV (section_count));
+ if (PRIV (sections)[PRIV (section_count)] == 0)
return -1;
- PRIV(section_count)++;
+ PRIV (section_count)++;
}
return 0;
switch (cmd)
{
- /* stack */
- case TIR_S_C_STA_GBL:
- /*
- * stack global
- * arg: cs symbol name
- *
- * stack 32 bit value of symbol (high bits set to 0)
- */
- {
- char *name;
- vms_symbol_entry *entry;
+ /* stack */
+ case TIR_S_C_STA_GBL:
+ /*
+ * stack global
+ * arg: cs symbol name
+ *
+ * stack 32 bit value of symbol (high bits set to 0)
+ */
+ {
+ char *name;
+ vms_symbol_entry *entry;
- name = _bfd_vms_save_counted_string (ptr);
+ name = _bfd_vms_save_counted_string (ptr);
- entry = _bfd_vms_enter_symbol (abfd, name);
- if (entry == (vms_symbol_entry *)NULL)
- return 0;
+ entry = _bfd_vms_enter_symbol (abfd, name);
+ if (entry == (vms_symbol_entry *) NULL)
+ return 0;
- _bfd_vms_push (abfd, (unsigned long) (entry->symbol->value), -1);
- ptr += *ptr + 1;
- }
+ _bfd_vms_push (abfd, (uquad) (entry->symbol->value), -1);
+ ptr += *ptr + 1;
+ }
break;
- case TIR_S_C_STA_SB:
- /*
- * stack signed byte
- * arg: by value
- *
- * stack byte value, sign extend to 32 bit
- */
- _bfd_vms_push (abfd, (long)*ptr++, -1);
- break;
-
- case TIR_S_C_STA_SW:
- /*
- * stack signed short word
- * arg: sh value
- *
- * stack 16 bit value, sign extend to 32 bit
- */
- _bfd_vms_push (abfd, (long)bfd_getl16(ptr), -1);
- ptr += 2;
+ case TIR_S_C_STA_SB:
+ /*
+ * stack signed byte
+ * arg: by value
+ *
+ * stack byte value, sign extend to 32 bit
+ */
+ _bfd_vms_push (abfd, (uquad) *ptr++, -1);
+ break;
+
+ case TIR_S_C_STA_SW:
+ /*
+ * stack signed short word
+ * arg: sh value
+ *
+ * stack 16 bit value, sign extend to 32 bit
+ */
+ _bfd_vms_push (abfd, (uquad) bfd_getl16 (ptr), -1);
+ ptr += 2;
+ break;
+
+ case TIR_S_C_STA_LW:
+ /*
+ * stack signed longword
+ * arg: lw value
+ *
+ * stack 32 bit value
+ */
+ _bfd_vms_push (abfd, (uquad) bfd_getl32 (ptr), -1);
+ ptr += 4;
+ break;
+
+ case TIR_S_C_STA_PB:
+ case TIR_S_C_STA_WPB:
+ /*
+ * stack psect base plus byte offset (word index)
+ * arg: by section index
+ * (sh section index)
+ * by signed byte offset
+ *
+ */
+ {
+ unsigned long dummy;
+ unsigned int psect;
+
+ if (cmd == TIR_S_C_STA_PB)
+ psect = *ptr++;
+ else
+ {
+ psect = bfd_getl16 (ptr);
+ ptr += 2;
+ }
+
+ if (psect >= PRIV (section_count))
+ {
+ alloc_section (abfd, psect);
+ }
+
+ dummy = (long) *ptr++;
+ dummy += (PRIV (sections)[psect])->vma;
+ _bfd_vms_push (abfd, (uquad) dummy, (int) psect);
+ }
break;
- case TIR_S_C_STA_LW:
- /*
- * stack signed longword
- * arg: lw value
- *
- * stack 32 bit value
- */
- _bfd_vms_push (abfd, (long)bfd_getl32 (ptr), -1);
- ptr += 4;
- break;
-
- case TIR_S_C_STA_PB:
- case TIR_S_C_STA_WPB:
- /*
- * stack psect base plus byte offset (word index)
- * arg: by section index
- * (sh section index)
- * by signed byte offset
- *
- */
- {
- unsigned long dummy;
- unsigned int psect;
-
- if (cmd == TIR_S_C_STA_PB)
- psect = *ptr++;
- else
- {
- psect = bfd_getl16(ptr);
- ptr += 2;
- }
+ case TIR_S_C_STA_PW:
+ case TIR_S_C_STA_WPW:
+ /*
+ * stack psect base plus word offset (word index)
+ * arg: by section index
+ * (sh section index)
+ * sh signed short offset
+ *
+ */
+ {
+ unsigned long dummy;
+ unsigned int psect;
- if (psect >= PRIV(section_count))
- {
- alloc_section (abfd, psect);
- }
+ if (cmd == TIR_S_C_STA_PW)
+ psect = *ptr++;
+ else
+ {
+ psect = bfd_getl16 (ptr);
+ ptr += 2;
+ }
- dummy = (long)*ptr++;
- dummy += (PRIV(sections)[psect])->vma;
- _bfd_vms_push (abfd, dummy, psect);
- }
- break;
-
- case TIR_S_C_STA_PW:
- case TIR_S_C_STA_WPW:
- /*
- * stack psect base plus word offset (word index)
- * arg: by section index
- * (sh section index)
- * sh signed short offset
- *
- */
- {
- unsigned long dummy;
- unsigned int psect;
-
- if (cmd == TIR_S_C_STA_PW)
- psect = *ptr++;
- else
- {
- psect = bfd_getl16(ptr);
- ptr += 2;
- }
+ if (psect >= PRIV (section_count))
+ {
+ alloc_section (abfd, psect);
+ }
- if (psect >= PRIV(section_count))
- {
- alloc_section (abfd, psect);
- }
+ dummy = bfd_getl16 (ptr); ptr+=2;
+ dummy += (PRIV (sections)[psect])->vma;
+ _bfd_vms_push (abfd, (uquad) dummy, (int) psect);
+ }
+ break;
- dummy = bfd_getl16(ptr); ptr+=2;
- dummy += (PRIV(sections)[psect])->vma;
- _bfd_vms_push (abfd, dummy, psect);
- }
- break;
-
- case TIR_S_C_STA_PL:
- case TIR_S_C_STA_WPL:
- /*
- * stack psect base plus long offset (word index)
- * arg: by section index
- * (sh section index)
- * lw signed longword offset
- *
- */
- {
- unsigned long dummy;
- unsigned int psect;
-
- if (cmd == TIR_S_C_STA_PL)
- psect = *ptr++;
- else
- {
- psect = bfd_getl16(ptr);
- ptr += 2;
- }
+ case TIR_S_C_STA_PL:
+ case TIR_S_C_STA_WPL:
+ /*
+ * stack psect base plus long offset (word index)
+ * arg: by section index
+ * (sh section index)
+ * lw signed longword offset
+ *
+ */
+ {
+ unsigned long dummy;
+ unsigned int psect;
- if (psect >= PRIV(section_count))
- {
- alloc_section (abfd, psect);
- }
+ if (cmd == TIR_S_C_STA_PL)
+ psect = *ptr++;
+ else
+ {
+ psect = bfd_getl16 (ptr);
+ ptr += 2;
+ }
- dummy = bfd_getl32 (ptr); ptr += 4;
- dummy += (PRIV(sections)[psect])->vma;
- _bfd_vms_push (abfd, dummy, psect);
- }
- break;
-
- case TIR_S_C_STA_UB:
- /*
- * stack unsigned byte
- * arg: by value
- *
- * stack byte value
- */
- _bfd_vms_push (abfd, (unsigned long)*ptr++, -1);
- break;
-
- case TIR_S_C_STA_UW:
- /*
- * stack unsigned short word
- * arg: sh value
- *
- * stack 16 bit value
- */
- _bfd_vms_push (abfd, (unsigned long)bfd_getl16(ptr), -1);
- ptr += 2;
+ if (psect >= PRIV (section_count))
+ {
+ alloc_section (abfd, psect);
+ }
+
+ dummy = bfd_getl32 (ptr); ptr += 4;
+ dummy += (PRIV (sections)[psect])->vma;
+ _bfd_vms_push (abfd, (uquad) dummy, (int) psect);
+ }
break;
- case TIR_S_C_STA_BFI:
- /*
- * stack byte from image
- * arg: -
- *
- */
- /*FALLTHRU*/
- case TIR_S_C_STA_WFI:
- /*
- * stack byte from image
- * arg: -
- *
- */
- /*FALLTHRU*/
- case TIR_S_C_STA_LFI:
- /*
- * stack byte from image
- * arg: -
- *
- */
- (*_bfd_error_handler) (_("Stack-from-image not implemented"));
- return NULL;
-
- case TIR_S_C_STA_EPM:
- /*
- * stack entry point mask
- * arg: cs symbol name
- *
- * stack (unsigned) entry point mask of symbol
- * err if symbol is no entry point
- */
- {
- char *name;
- vms_symbol_entry *entry;
+ case TIR_S_C_STA_UB:
+ /*
+ * stack unsigned byte
+ * arg: by value
+ *
+ * stack byte value
+ */
+ _bfd_vms_push (abfd, (uquad) *ptr++, -1);
+ break;
+
+ case TIR_S_C_STA_UW:
+ /*
+ * stack unsigned short word
+ * arg: sh value
+ *
+ * stack 16 bit value
+ */
+ _bfd_vms_push (abfd, (uquad) bfd_getl16 (ptr), -1);
+ ptr += 2;
+ break;
+
+ case TIR_S_C_STA_BFI:
+ /*
+ * stack byte from image
+ * arg: -
+ *
+ */
+ /*FALLTHRU*/
+ case TIR_S_C_STA_WFI:
+ /*
+ * stack byte from image
+ * arg: -
+ *
+ */
+ /*FALLTHRU*/
+ case TIR_S_C_STA_LFI:
+ /*
+ * stack byte from image
+ * arg: -
+ *
+ */
+ (*_bfd_error_handler) (_("Stack-from-image not implemented"));
+ return NULL;
+
+ case TIR_S_C_STA_EPM:
+ /*
+ * stack entry point mask
+ * arg: cs symbol name
+ *
+ * stack (unsigned) entry point mask of symbol
+ * err if symbol is no entry point
+ */
+ {
+ char *name;
+ vms_symbol_entry *entry;
- name = _bfd_vms_save_counted_string (ptr);
- entry = _bfd_vms_enter_symbol (abfd, name);
- if (entry == (vms_symbol_entry *)NULL)
- return 0;
+ name = _bfd_vms_save_counted_string (ptr);
+ entry = _bfd_vms_enter_symbol (abfd, name);
+ if (entry == (vms_symbol_entry *) NULL)
+ return 0;
- (*_bfd_error_handler) (_("Stack-entry-mask not fully implemented"));
- _bfd_vms_push (abfd, 0L, -1);
- ptr += *ptr + 1;
- }
+ (*_bfd_error_handler) (_("Stack-entry-mask not fully implemented"));
+ _bfd_vms_push (abfd, (uquad) 0, -1);
+ ptr += *ptr + 1;
+ }
break;
- case TIR_S_C_STA_CKARG:
- /*
- * compare procedure argument
- * arg: cs symbol name
- * by argument index
- * da argument descriptor
- *
- * compare argument descriptor with symbol argument (ARG$V_PASSMECH)
- * and stack TRUE (args match) or FALSE (args dont match) value
- */
- (*_bfd_error_handler) (_("PASSMECH not fully implemented"));
- _bfd_vms_push (abfd, 1L, -1);
- break;
+ case TIR_S_C_STA_CKARG:
+ /*
+ * compare procedure argument
+ * arg: cs symbol name
+ * by argument index
+ * da argument descriptor
+ *
+ * compare argument descriptor with symbol argument (ARG$V_PASSMECH)
+ * and stack TRUE (args match) or FALSE (args dont match) value
+ */
+ (*_bfd_error_handler) (_("PASSMECH not fully implemented"));
+ _bfd_vms_push (abfd, (uquad) 1, -1);
+ break;
+
+ case TIR_S_C_STA_LSY:
+ /*
+ * stack local symbol value
+ * arg: sh environment index
+ * cs symbol name
+ */
+ {
+ int envidx;
+ char *name;
+ vms_symbol_entry *entry;
- case TIR_S_C_STA_LSY:
- /*
- * stack local symbol value
- * arg: sh environment index
- * cs symbol name
- */
- {
- int envidx;
- char *name;
- vms_symbol_entry *entry;
-
- envidx = bfd_getl16(ptr); ptr += 2;
- name = _bfd_vms_save_counted_string (ptr);
- entry = _bfd_vms_enter_symbol (abfd, name);
- if (entry == (vms_symbol_entry *)NULL)
- return 0;
- (*_bfd_error_handler) (_("Stack-local-symbol not fully implemented"));
- _bfd_vms_push (abfd, 0L, -1);
- ptr += *ptr + 1;
- }
+ envidx = bfd_getl16 (ptr);
+ ptr += 2;
+ name = _bfd_vms_save_counted_string (ptr);
+ entry = _bfd_vms_enter_symbol (abfd, name);
+ if (entry == (vms_symbol_entry *) NULL)
+ return 0;
+ (*_bfd_error_handler) (_("Stack-local-symbol not fully implemented"));
+ _bfd_vms_push (abfd, (uquad) 0, -1);
+ ptr += *ptr + 1;
+ }
break;
- case TIR_S_C_STA_LIT:
- /*
- * stack literal
- * arg: by literal index
- *
- * stack literal
- */
- ptr++;
- _bfd_vms_push (abfd, 0L, -1);
- (*_bfd_error_handler) (_("Stack-literal not fully implemented"));
- break;
+ case TIR_S_C_STA_LIT:
+ /*
+ * stack literal
+ * arg: by literal index
+ *
+ * stack literal
+ */
+ ptr++;
+ _bfd_vms_push (abfd, (uquad) 0, -1);
+ (*_bfd_error_handler) (_("Stack-literal not fully implemented"));
+ break;
+
+ case TIR_S_C_STA_LEPM:
+ /*
+ * stack local symbol entry point mask
+ * arg: sh environment index
+ * cs symbol name
+ *
+ * stack (unsigned) entry point mask of symbol
+ * err if symbol is no entry point
+ */
+ {
+ int envidx;
+ char *name;
+ vms_symbol_entry *entry;
- case TIR_S_C_STA_LEPM:
- /*
- * stack local symbol entry point mask
- * arg: sh environment index
- * cs symbol name
- *
- * stack (unsigned) entry point mask of symbol
- * err if symbol is no entry point
- */
- {
- int envidx;
- char *name;
- vms_symbol_entry *entry;
-
- envidx = bfd_getl16(ptr); ptr += 2;
- name = _bfd_vms_save_counted_string (ptr);
- entry = _bfd_vms_enter_symbol (abfd, name);
- if (entry == (vms_symbol_entry *)NULL)
- return 0;
- (*_bfd_error_handler) (_("Stack-local-symbol-entry-point-mask not fully implemented"));
- _bfd_vms_push (abfd, 0L, -1);
- ptr += *ptr + 1;
- }
+ envidx = bfd_getl16 (ptr);
+ ptr += 2;
+ name = _bfd_vms_save_counted_string (ptr);
+ entry = _bfd_vms_enter_symbol (abfd, name);
+ if (entry == (vms_symbol_entry *) NULL)
+ return 0;
+ (*_bfd_error_handler) (_("Stack-local-symbol-entry-point-mask not fully implemented"));
+ _bfd_vms_push (abfd, (uquad) 0, -1);
+ ptr += *ptr + 1;
+ }
break;
- default:
- (*_bfd_error_handler) (_("Reserved STA cmd %d"), ptr[-1]);
- return NULL;
+ default:
+ (*_bfd_error_handler) (_("Reserved STA cmd %d"), ptr[-1]);
+ return NULL;
break;
- }
+ }
return ptr;
}
switch (*ptr++)
{
- case TIR_S_C_STO_SB:
- /*
- * store signed byte: pop stack, write byte
- * arg: -
- */
- dummy = _bfd_vms_pop (abfd, &psect);
- image_write_b (abfd, dummy & 0xff); /* FIXME: check top bits */
- break;
-
- case TIR_S_C_STO_SW:
- /*
- * store signed word: pop stack, write word
- * arg: -
- */
- dummy = _bfd_vms_pop (abfd, &psect);
- image_write_w (abfd, dummy & 0xffff); /* FIXME: check top bits */
- break;
-
- case TIR_S_C_STO_LW:
- /*
- * store longword: pop stack, write longword
- * arg: -
- */
- dummy = _bfd_vms_pop (abfd, &psect);
- image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
- break;
-
- case TIR_S_C_STO_BD:
- /*
- * store byte displaced: pop stack, sub lc+1, write byte
- * arg: -
- */
- dummy = _bfd_vms_pop (abfd, &psect);
- dummy -= ((PRIV(sections)[psect])->vma + 1);
- image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */
- break;
-
- case TIR_S_C_STO_WD:
- /*
- * store word displaced: pop stack, sub lc+2, write word
- * arg: -
- */
- dummy = _bfd_vms_pop (abfd, &psect);
- dummy -= ((PRIV(sections)[psect])->vma + 2);
- image_write_w (abfd, dummy & 0xffff);/* FIXME: check top bits */
- break;
- case TIR_S_C_STO_LD:
- /*
- * store long displaced: pop stack, sub lc+4, write long
- * arg: -
- */
- dummy = _bfd_vms_pop (abfd, &psect);
- dummy -= ((PRIV(sections)[psect])->vma + 4);
- image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
- break;
- case TIR_S_C_STO_LI:
- /*
- * store short literal: pop stack, write byte
- * arg: -
- */
- dummy = _bfd_vms_pop (abfd, &psect);
- image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */
- break;
- case TIR_S_C_STO_PIDR:
- /*
- * store position independent data reference: pop stack, write longword
- * arg: -
- * FIXME: incomplete !
- */
- dummy = _bfd_vms_pop (abfd, &psect);
- image_write_l (abfd, dummy & 0xffffffff);
- break;
- case TIR_S_C_STO_PICR:
- /*
- * store position independent code reference: pop stack, write longword
- * arg: -
- * FIXME: incomplete !
- */
- dummy = _bfd_vms_pop (abfd, &psect);
- image_write_b (abfd, 0x9f);
- image_write_l (abfd, dummy & 0xffffffff);
- break;
- case TIR_S_C_STO_RIVB:
- /*
- * store repeated immediate variable bytes
- * 1-byte count n field followed by n bytes of data
- * pop stack, write n bytes <stack> times
- */
- size = *ptr++;
- dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
- while (dummy-- > 0L)
- image_dump (abfd, ptr, size, 0);
- ptr += size;
- break;
- case TIR_S_C_STO_B:
- /*
- * store byte from top longword
- */
- dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
+ case TIR_S_C_STO_SB:
+ /*
+ * store signed byte: pop stack, write byte
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_write_b (abfd, dummy & 0xff); /* FIXME: check top bits */
+ break;
+
+ case TIR_S_C_STO_SW:
+ /*
+ * store signed word: pop stack, write word
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_write_w (abfd, dummy & 0xffff); /* FIXME: check top bits */
+ break;
+
+ case TIR_S_C_STO_LW:
+ /*
+ * store longword: pop stack, write longword
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_write_l (abfd, dummy & 0xffffffff); /* FIXME: check top bits */
+ break;
+
+ case TIR_S_C_STO_BD:
+ /*
+ * store byte displaced: pop stack, sub lc+1, write byte
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ dummy -= ((PRIV (sections)[psect])->vma + 1);
+ image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */
+ break;
+
+ case TIR_S_C_STO_WD:
+ /*
+ * store word displaced: pop stack, sub lc+2, write word
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ dummy -= ((PRIV (sections)[psect])->vma + 2);
+ image_write_w (abfd, dummy & 0xffff);/* FIXME: check top bits */
+ break;
+ case TIR_S_C_STO_LD:
+ /*
+ * store long displaced: pop stack, sub lc+4, write long
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ dummy -= ((PRIV (sections)[psect])->vma + 4);
+ image_write_l (abfd, dummy & 0xffffffff);/* FIXME: check top bits */
+ break;
+ case TIR_S_C_STO_LI:
+ /*
+ * store short literal: pop stack, write byte
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_write_b (abfd, dummy & 0xff);/* FIXME: check top bits */
+ break;
+ case TIR_S_C_STO_PIDR:
+ /*
+ * store position independent data reference: pop stack, write longword
+ * arg: -
+ * FIXME: incomplete !
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_write_l (abfd, dummy & 0xffffffff);
+ break;
+ case TIR_S_C_STO_PICR:
+ /*
+ * store position independent code reference: pop stack, write longword
+ * arg: -
+ * FIXME: incomplete !
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ image_write_b (abfd, 0x9f);
+ image_write_l (abfd, dummy & 0xffffffff);
+ break;
+ case TIR_S_C_STO_RIVB:
+ /*
+ * store repeated immediate variable bytes
+ * 1-byte count n field followed by n bytes of data
+ * pop stack, write n bytes <stack> times
+ */
+ size = *ptr++;
+ dummy = (unsigned long) _bfd_vms_pop (abfd, NULL);
+ while (dummy-- > 0L)
+ image_dump (abfd, ptr, size, 0);
+ ptr += size;
+ break;
+ case TIR_S_C_STO_B:
+ /*
+ * store byte from top longword
+ */
+ dummy = (unsigned long) _bfd_vms_pop (abfd, NULL);
+ image_write_b (abfd, dummy & 0xff);
+ break;
+ case TIR_S_C_STO_W:
+ /*
+ * store word from top longword
+ */
+ dummy = (unsigned long) _bfd_vms_pop (abfd, NULL);
+ image_write_w (abfd, dummy & 0xffff);
+ break;
+ case TIR_S_C_STO_RB:
+ /*
+ * store repeated byte from top longword
+ */
+ size = (unsigned long) _bfd_vms_pop (abfd, NULL);
+ dummy = (unsigned long) _bfd_vms_pop (abfd, NULL);
+ while (size-- > 0)
image_write_b (abfd, dummy & 0xff);
- break;
- case TIR_S_C_STO_W:
- /*
- * store word from top longword
- */
- dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
+ break;
+ case TIR_S_C_STO_RW:
+ /*
+ * store repeated word from top longword
+ */
+ size = (unsigned long) _bfd_vms_pop (abfd, NULL);
+ dummy = (unsigned long) _bfd_vms_pop (abfd, NULL);
+ while (size-- > 0)
image_write_w (abfd, dummy & 0xffff);
- break;
- case TIR_S_C_STO_RB:
- /*
- * store repeated byte from top longword
- */
- size = (unsigned long)_bfd_vms_pop (abfd, NULL);
- dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
- while (size-- > 0)
- image_write_b (abfd, dummy & 0xff);
- break;
- case TIR_S_C_STO_RW:
- /*
- * store repeated word from top longword
- */
- size = (unsigned long)_bfd_vms_pop (abfd, NULL);
- dummy = (unsigned long)_bfd_vms_pop (abfd, NULL);
- while (size-- > 0)
- image_write_w (abfd, dummy & 0xffff);
- break;
+ break;
- case TIR_S_C_STO_RSB:
- case TIR_S_C_STO_RSW:
- case TIR_S_C_STO_RL:
- case TIR_S_C_STO_VPS:
- case TIR_S_C_STO_USB:
- case TIR_S_C_STO_USW:
- case TIR_S_C_STO_RUB:
- case TIR_S_C_STO_RUW:
- case TIR_S_C_STO_PIRR:
- (*_bfd_error_handler) (_("Unimplemented STO cmd %d"), ptr[-1]);
+ case TIR_S_C_STO_RSB:
+ case TIR_S_C_STO_RSW:
+ case TIR_S_C_STO_RL:
+ case TIR_S_C_STO_VPS:
+ case TIR_S_C_STO_USB:
+ case TIR_S_C_STO_USW:
+ case TIR_S_C_STO_RUB:
+ case TIR_S_C_STO_RUW:
+ case TIR_S_C_STO_PIRR:
+ (*_bfd_error_handler) (_("Unimplemented STO cmd %d"), ptr[-1]);
break;
- default:
- (*_bfd_error_handler) (_("Reserved STO cmd %d"), ptr[-1]);
+ default:
+ (*_bfd_error_handler) (_("Reserved STO cmd %d"), ptr[-1]);
break;
- }
+ }
return ptr;
}
switch (*ptr++)
{
- /* operation */
- case TIR_S_C_OPR_NOP:
- /*
- * no-op
- */
- break;
-
- case TIR_S_C_OPR_ADD:
- /*
- * add
- */
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
- _bfd_vms_push (abfd, (unsigned long) (op1 + op2), -1);
- break;
-
- case TIR_S_C_OPR_SUB:
- /*
- * subtract
- */
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
- _bfd_vms_push (abfd, (unsigned long) (op2 - op1), -1);
- break;
-
- case TIR_S_C_OPR_MUL:
- /*
- * multiply
- */
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
- _bfd_vms_push (abfd, (unsigned long) (op1 * op2), -1);
- break;
-
- case TIR_S_C_OPR_DIV:
- /*
- * divide
- */
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
- if (op2 == 0)
- _bfd_vms_push (abfd, (unsigned long)0L, -1);
- else
- _bfd_vms_push (abfd, (unsigned long) (op2 / op1), -1);
- break;
-
- case TIR_S_C_OPR_AND:
- /*
- * logical and
- */
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
- _bfd_vms_push (abfd, (unsigned long) (op1 & op2), -1);
- break;
-
- case TIR_S_C_OPR_IOR:
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- /*
- * logical inclusive or
- */
- op2 = (long)_bfd_vms_pop (abfd, NULL);
- _bfd_vms_push (abfd, (unsigned long) (op1 | op2), -1);
- break;
-
- case TIR_S_C_OPR_EOR:
- /*
- * logical exclusive or
- */
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
- _bfd_vms_push (abfd, (unsigned long) (op1 ^ op2), -1);
- break;
-
- case TIR_S_C_OPR_NEG:
- /*
- * negate
- */
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- _bfd_vms_push (abfd, (unsigned long) (-op1), -1);
- break;
-
- case TIR_S_C_OPR_COM:
- /*
- * complement
- */
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- _bfd_vms_push (abfd, (unsigned long) (op1 ^ -1L), -1);
- break;
-
- case TIR_S_C_OPR_INSV:
- /*
- * insert field
- */
- (void)_bfd_vms_pop (abfd, NULL);
- (*_bfd_error_handler) ("TIR_S_C_OPR_INSV incomplete");
- break;
-
- case TIR_S_C_OPR_ASH:
- /*
- * arithmetic shift
- */
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
- if (HIGHBIT(op1)) /* shift right */
- op2 >>= op1;
- else /* shift left */
- op2 <<= op1;
- _bfd_vms_push (abfd, (unsigned long)op2, -1);
- (*_bfd_error_handler) (_("TIR_S_C_OPR_ASH incomplete"));
- break;
-
- case TIR_S_C_OPR_USH:
- /*
- * unsigned shift
- */
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
- if (HIGHBIT(op1)) /* shift right */
- op2 >>= op1;
- else /* shift left */
- op2 <<= op1;
- _bfd_vms_push (abfd, (unsigned long)op2, -1);
- (*_bfd_error_handler) (_("TIR_S_C_OPR_USH incomplete"));
- break;
-
- case TIR_S_C_OPR_ROT:
- /*
- * rotate
- */
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- op2 = (long)_bfd_vms_pop (abfd, NULL);
- if (HIGHBIT(0)) /* shift right */
- op2 >>= op1;
- else /* shift left */
- op2 <<= op1;
- _bfd_vms_push (abfd, (unsigned long)op2, -1);
- (*_bfd_error_handler) (_("TIR_S_C_OPR_ROT incomplete"));
- break;
-
- case TIR_S_C_OPR_SEL:
- /*
- * select
- */
- if ((long)_bfd_vms_pop (abfd, NULL) & 0x01L)
- (void)_bfd_vms_pop (abfd, NULL);
- else
- {
- op1 = (long)_bfd_vms_pop (abfd, NULL);
- (void)_bfd_vms_pop (abfd, NULL);
- _bfd_vms_push (abfd, (unsigned long)op1, -1);
- }
+ /* operation */
+ case TIR_S_C_OPR_NOP:
+ /*
+ * no-op
+ */
+ break;
+
+ case TIR_S_C_OPR_ADD:
+ /*
+ * add
+ */
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad) (op1 + op2), -1);
+ break;
+
+ case TIR_S_C_OPR_SUB:
+ /*
+ * subtract
+ */
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad) (op2 - op1), -1);
+ break;
+
+ case TIR_S_C_OPR_MUL:
+ /*
+ * multiply
+ */
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad) (op1 * op2), -1);
+ break;
+
+ case TIR_S_C_OPR_DIV:
+ /*
+ * divide
+ */
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
+ if (op2 == 0)
+ _bfd_vms_push (abfd, (uquad) 0, -1);
+ else
+ _bfd_vms_push (abfd, (uquad) (op2 / op1), -1);
+ break;
+
+ case TIR_S_C_OPR_AND:
+ /*
+ * logical and
+ */
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad) (op1 & op2), -1);
+ break;
+
+ case TIR_S_C_OPR_IOR:
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ /*
+ * logical inclusive or
+ */
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad) (op1 | op2), -1);
+ break;
+
+ case TIR_S_C_OPR_EOR:
+ /*
+ * logical exclusive or
+ */
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad) (op1 ^ op2), -1);
+ break;
+
+ case TIR_S_C_OPR_NEG:
+ /*
+ * negate
+ */
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad) (-op1), -1);
+ break;
+
+ case TIR_S_C_OPR_COM:
+ /*
+ * complement
+ */
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad) (op1 ^ -1L), -1);
break;
- case TIR_S_C_OPR_REDEF:
- /*
- * redefine symbol to current location
- */
- (*_bfd_error_handler) (_("TIR_S_C_OPR_REDEF not supported"));
+ case TIR_S_C_OPR_INSV:
+ /*
+ * insert field
+ */
+ (void) _bfd_vms_pop (abfd, NULL);
+ (*_bfd_error_handler) ("TIR_S_C_OPR_INSV incomplete");
break;
- case TIR_S_C_OPR_DFLIT:
- /*
- * define a literal
- */
- (*_bfd_error_handler) (_("TIR_S_C_OPR_DFLIT not supported"));
+ case TIR_S_C_OPR_ASH:
+ /*
+ * arithmetic shift
+ */
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
+ if (HIGHBIT (op1)) /* shift right */
+ op2 >>= op1;
+ else /* shift left */
+ op2 <<= op1;
+ _bfd_vms_push (abfd, (uquad) op2, -1);
+ (*_bfd_error_handler) (_("TIR_S_C_OPR_ASH incomplete"));
+ break;
+
+ case TIR_S_C_OPR_USH:
+ /*
+ * unsigned shift
+ */
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
+ if (HIGHBIT (op1)) /* shift right */
+ op2 >>= op1;
+ else /* shift left */
+ op2 <<= op1;
+ _bfd_vms_push (abfd, (uquad) op2, -1);
+ (*_bfd_error_handler) (_("TIR_S_C_OPR_USH incomplete"));
+ break;
+
+ case TIR_S_C_OPR_ROT:
+ /*
+ * rotate
+ */
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ op2 = (long) _bfd_vms_pop (abfd, NULL);
+ if (HIGHBIT (0)) /* shift right */
+ op2 >>= op1;
+ else /* shift left */
+ op2 <<= op1;
+ _bfd_vms_push (abfd, (uquad) op2, -1);
+ (*_bfd_error_handler) (_("TIR_S_C_OPR_ROT incomplete"));
+ break;
+
+ case TIR_S_C_OPR_SEL:
+ /*
+ * select
+ */
+ if ((long) _bfd_vms_pop (abfd, NULL) & 0x01L)
+ (void) _bfd_vms_pop (abfd, NULL);
+ else
+ {
+ op1 = (long) _bfd_vms_pop (abfd, NULL);
+ (void) _bfd_vms_pop (abfd, NULL);
+ _bfd_vms_push (abfd, (uquad) op1, -1);
+ }
+ break;
+
+ case TIR_S_C_OPR_REDEF:
+ /*
+ * redefine symbol to current location
+ */
+ (*_bfd_error_handler) (_("TIR_S_C_OPR_REDEF not supported"));
break;
- default:
- (*_bfd_error_handler) (_("Reserved OPR cmd %d"), ptr[-1]);
+ case TIR_S_C_OPR_DFLIT:
+ /*
+ * define a literal
+ */
+ (*_bfd_error_handler) (_("TIR_S_C_OPR_DFLIT not supported"));
+ break;
+
+ default:
+ (*_bfd_error_handler) (_("Reserved OPR cmd %d"), ptr[-1]);
break;
}
switch (*ptr++)
{
- case TIR_S_C_CTL_SETRB:
- /*
- * set relocation base: pop stack, set image location counter
- * arg: -
- */
- dummy = _bfd_vms_pop (abfd, &psect);
- if (psect >= PRIV(section_count))
- {
- alloc_section (abfd, psect);
- }
- image_set_ptr (abfd, psect, dummy);
- break;
- case TIR_S_C_CTL_AUGRB:
- /*
- * augment relocation base: increment image location counter by offset
- * arg: lw offset value
- */
- dummy = bfd_getl32 (ptr);
- image_inc_ptr (abfd, dummy);
- break;
- case TIR_S_C_CTL_DFLOC:
- /*
- * define location: pop index, save location counter under index
- * arg: -
- */
- dummy = _bfd_vms_pop (abfd, NULL);
- (*_bfd_error_handler) (_("TIR_S_C_CTL_DFLOC not fully implemented"));
- break;
- case TIR_S_C_CTL_STLOC:
- /*
- * set location: pop index, restore location counter from index
- * arg: -
- */
- dummy = _bfd_vms_pop (abfd, &psect);
- (*_bfd_error_handler) (_("TIR_S_C_CTL_STLOC not fully implemented"));
+ case TIR_S_C_CTL_SETRB:
+ /*
+ * set relocation base: pop stack, set image location counter
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ if (psect >= PRIV (section_count))
+ {
+ alloc_section (abfd, psect);
+ }
+ image_set_ptr (abfd, (int) psect, (uquad) dummy);
+ break;
+ case TIR_S_C_CTL_AUGRB:
+ /*
+ * augment relocation base: increment image location counter by offset
+ * arg: lw offset value
+ */
+ dummy = bfd_getl32 (ptr);
+ image_inc_ptr (abfd, (uquad) dummy);
+ break;
+ case TIR_S_C_CTL_DFLOC:
+ /*
+ * define location: pop index, save location counter under index
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, NULL);
+ (*_bfd_error_handler) (_("TIR_S_C_CTL_DFLOC not fully implemented"));
+ break;
+ case TIR_S_C_CTL_STLOC:
+ /*
+ * set location: pop index, restore location counter from index
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ (*_bfd_error_handler) (_("TIR_S_C_CTL_STLOC not fully implemented"));
break;
case TIR_S_C_CTL_STKDL:
- /*
- * stack defined location: pop index, push location counter from index
- * arg: -
- */
- dummy = _bfd_vms_pop (abfd, &psect);
- (*_bfd_error_handler) (_("TIR_S_C_CTL_STKDL not fully implemented"));
+ /*
+ * stack defined location: pop index, push location counter from index
+ * arg: -
+ */
+ dummy = _bfd_vms_pop (abfd, &psect);
+ (*_bfd_error_handler) (_("TIR_S_C_CTL_STKDL not fully implemented"));
break;
default:
- (*_bfd_error_handler) (_("Reserved CTL cmd %d"), ptr[-1]);
- break;
- }
+ (*_bfd_error_handler) (_("Reserved CTL cmd %d"), ptr[-1]);
+ break;
+ }
return ptr;
}
static unsigned char *
tir_cmd (bfd *abfd, unsigned char *ptr)
{
- struct {
+ struct
+ {
int mincod;
int maxcod;
unsigned char * (*explain) (bfd *, unsigned char *);
- } tir_table[] = {
- { 0, TIR_S_C_MAXSTACOD, tir_sta }
- ,{ TIR_S_C_MINSTOCOD, TIR_S_C_MAXSTOCOD, tir_sto }
- ,{ TIR_S_C_MINOPRCOD, TIR_S_C_MAXOPRCOD, tir_opr }
- ,{ TIR_S_C_MINCTLCOD, TIR_S_C_MAXCTLCOD, tir_ctl }
- ,{ -1, -1, NULL }
+ }
+ tir_table[] =
+ {
+ { 0, TIR_S_C_MAXSTACOD, tir_sta },
+ { TIR_S_C_MINSTOCOD, TIR_S_C_MAXSTOCOD, tir_sto },
+ { TIR_S_C_MINOPRCOD, TIR_S_C_MAXOPRCOD, tir_opr },
+ { TIR_S_C_MINCTLCOD, TIR_S_C_MAXCTLCOD, tir_ctl },
+ { -1, -1, NULL }
};
int i = 0;
#if VMS_DEBUG
_bfd_vms_debug (4, "tir_cmd %d/%x\n", *ptr, *ptr);
- _bfd_hexdump (8, ptr, 16, (int)ptr);
+ _bfd_hexdump (8, ptr, 16, (int) ptr);
#endif
if (*ptr & 0x80) /* store immediate */
while (tir_table[i].mincod >= 0)
{
if ( (tir_table[i].mincod <= *ptr)
- && (*ptr <= tir_table[i].maxcod))
+ && (*ptr <= tir_table[i].maxcod))
{
ptr = tir_table[i].explain (abfd, ptr);
break;
int cmd;
unsigned char *ptr;
{
- static struct {
+ static struct
+ {
int mincod;
int maxcod;
- boolean (*explain) PARAMS((bfd *, int, unsigned char *));
- } etir_table[] = {
+ boolean (*explain) PARAMS ((bfd *, int, unsigned char *));
+ }
+ etir_table[] =
+ {
{ ETIR_S_C_MINSTACOD, ETIR_S_C_MAXSTACOD, etir_sta },
{ ETIR_S_C_MINSTOCOD, ETIR_S_C_MAXSTOCOD, etir_sto },
{ ETIR_S_C_MINOPRCOD, ETIR_S_C_MAXOPRCOD, etir_opr },
#if VMS_DEBUG
_bfd_vms_debug (4, "etir_cmd %d/%x\n", cmd, cmd);
- _bfd_hexdump (8, ptr, 16, (int)ptr);
+ _bfd_hexdump (8, ptr, 16, (int) ptr);
#endif
while (etir_table[i].mincod >= 0)
{
if ( (etir_table[i].mincod <= cmd)
- && (cmd <= etir_table[i].maxcod))
+ && (cmd <= etir_table[i].maxcod))
{
if (!etir_table[i].explain (abfd, cmd, ptr))
return -1;
switch (objtype)
{
- case EOBJ_S_C_ETIR:
- PRIV(vms_rec) += 4; /* skip type, size */
- PRIV(rec_size) -= 4;
- result = analyze_etir (abfd, PRIV(vms_rec), PRIV(rec_size));
- break;
- case OBJ_S_C_TIR:
- PRIV(vms_rec) += 1; /* skip type */
- PRIV(rec_size) -= 1;
- result = analyze_tir (abfd, PRIV(vms_rec), PRIV(rec_size));
- break;
- default:
- result = -1;
- break;
+ case EOBJ_S_C_ETIR:
+ PRIV (vms_rec) += 4; /* skip type, size */
+ PRIV (rec_size) -= 4;
+ result = analyze_etir (abfd, PRIV (vms_rec), (unsigned) PRIV (rec_size));
+ break;
+ case OBJ_S_C_TIR:
+ PRIV (vms_rec) += 1; /* skip type */
+ PRIV (rec_size) -= 1;
+ result = analyze_tir (abfd, PRIV (vms_rec), (unsigned) PRIV (rec_size));
+ break;
+ default:
+ result = -1;
+ break;
}
return result;
#if VMS_DEBUG
_bfd_vms_debug (8, "sto_imm %d bytes\n", sptr->size);
- _bfd_hexdump (9, sptr->contents, (int)sptr->size, (int)vaddr);
+ _bfd_hexdump (9, sptr->contents, (int) sptr->size, (int) vaddr);
#endif
ssize = sptr->size;
#if VMS_DEBUG
_bfd_vms_debug (10, "dumped %d bytes\n", size);
- _bfd_hexdump (10, cptr, (int)size, (int)vaddr);
+ _bfd_hexdump (10, cptr, (int) size, (int) vaddr);
#endif
vaddr += size;
}
_bfd_vms_output_begin (abfd, ETIR_S_C_STA_PQ, -1); /* push start offset */
- _bfd_vms_output_long (abfd, (unsigned long)index);
- _bfd_vms_output_quad (abfd, (uquad)offset);
+ _bfd_vms_output_long (abfd, (unsigned long) index);
+ _bfd_vms_output_quad (abfd, (uquad) offset);
_bfd_vms_output_flush (abfd);
_bfd_vms_output_begin (abfd, ETIR_S_C_CTL_SETRB, -1); /* start = pop () */
_bfd_vms_output_alignment (abfd, 4);
nextoffset = 0;
- PRIV(vms_linkage_index) = 1;
+ PRIV (vms_linkage_index) = 1;
/* dump all other sections */
{
#if VMS_DEBUG
- _bfd_vms_debug (4, "writing %d. section '%s' (%d bytes)\n", section->index, section->name, (int) (section->_raw_size));\r
+ _bfd_vms_debug (4, "writing %d. section '%s' (%d bytes)\n",
+ section->index, section->name,
+ (int) (section->_raw_size));
#endif
if (section->flags & SEC_RELOC)
while (i-- > 0)
{
_bfd_vms_debug (4, "sym %s in sec %s, value %08lx, addr %08lx, off %08lx, len %d: %s\n",
- (*(*rptr)->sym_ptr_ptr)->name,
- (*(*rptr)->sym_ptr_ptr)->section->name,
- (long) (*(*rptr)->sym_ptr_ptr)->value,
- (*rptr)->address, (*rptr)->addend,
- bfd_get_reloc_size((*rptr)->howto),
- (*rptr)->howto->name);
+ (*(*rptr)->sym_ptr_ptr)->name,
+ (*(*rptr)->sym_ptr_ptr)->section->name,
+ (long) (*(*rptr)->sym_ptr_ptr)->value,
+ (*rptr)->address, (*rptr)->addend,
+ bfd_get_reloc_size ((*rptr)->howto),
+ (*rptr)->howto->name);
rptr++;
}
}
}
if ((section->flags & SEC_HAS_CONTENTS)
- && (! bfd_is_com_section (section)))
+ && (! bfd_is_com_section (section)))
{
bfd_vma vaddr; /* virtual addr in section */
start_etir_record (abfd, section->index, (uquad) sptr->offset,
false);
- while (sptr != NULL) /* one STA_PQ, CTL_SETRB per vms_section */
+ while (sptr != NULL) /* one STA_PQ, CTL_SETRB per vms_section */
{
- if (section->flags & SEC_RELOC) /* check for relocs */
+ if (section->flags & SEC_RELOC) /* check for relocs */
{
arelent **rptr = section->orelocation;
int i = section->reloc_count;
{
bfd_size_type addr = (*rptr)->address;
bfd_size_type len = bfd_get_reloc_size ((*rptr)->howto);
- if (sptr->offset < addr) /* sptr starts before reloc */
+ if (sptr->offset < addr) /* sptr starts before reloc */
{
bfd_size_type before = addr - sptr->offset;
- if (sptr->size <= before) /* complete before */
+ if (sptr->size <= before) /* complete before */
{
sto_imm (abfd, sptr, vaddr, section->index);
vaddr += sptr->size;
sptr->size = after;
}
}
- else if (sptr->offset == addr) /* sptr starts at reloc */
+ else if (sptr->offset == addr) /* sptr starts at reloc */
{
asymbol *sym = *(*rptr)->sym_ptr_ptr;
asection *sec = sym->section;
{
if (bfd_is_und_section (sym->section))
{
- if (_bfd_vms_output_check (abfd,
- strlen((char *)sym->name))
- < 0)
+ int slen = strlen ((char *) sym->name);
+ char *hash;
+
+ if (_bfd_vms_output_check (abfd, slen) < 0)
{
end_etir_record (abfd);
start_etir_record (abfd,
vaddr, false);
}
_bfd_vms_output_begin (abfd,
- ETIR_S_C_STO_GBL_LW,
- -1);
- _bfd_vms_output_counted (abfd,
- _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ ETIR_S_C_STO_GBL_LW,
+ -1);
+ hash = (_bfd_vms_length_hash_symbol
+ (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ _bfd_vms_output_counted (abfd, hash);
_bfd_vms_output_flush (abfd);
}
else if (bfd_is_abs_section (sym->section))
vaddr, false);
}
_bfd_vms_output_begin (abfd,
- ETIR_S_C_STA_LW,
- -1);
+ ETIR_S_C_STA_LW,
+ -1);
_bfd_vms_output_quad (abfd,
- (uquad)sym->value);
+ (uquad) sym->value);
_bfd_vms_output_flush (abfd);
_bfd_vms_output_begin (abfd,
- ETIR_S_C_STO_LW,
- -1);
+ ETIR_S_C_STO_LW,
+ -1);
_bfd_vms_output_flush (abfd);
}
else
vaddr, false);
}
_bfd_vms_output_begin (abfd,
- ETIR_S_C_STA_PQ,
- -1);
+ ETIR_S_C_STA_PQ,
+ -1);
_bfd_vms_output_long (abfd,
- (unsigned long) (sec->index));
+ (unsigned long) (sec->index));
_bfd_vms_output_quad (abfd,
- ((uquad) (*rptr)->addend
- + (uquad)sym->value));
+ ((uquad) (*rptr)->addend
+ + (uquad) sym->value));
_bfd_vms_output_flush (abfd);
_bfd_vms_output_begin (abfd,
- ETIR_S_C_STO_LW,
- -1);
+ ETIR_S_C_STO_LW,
+ -1);
_bfd_vms_output_flush (abfd);
}
}
{
if (bfd_is_und_section (sym->section))
{
- if (_bfd_vms_output_check (abfd,
- strlen((char *)sym->name))
- < 0)
+ int slen = strlen ((char *) sym->name);
+ char *hash;
+ if (_bfd_vms_output_check (abfd, slen) < 0)
{
end_etir_record (abfd);
start_etir_record (abfd,
vaddr, false);
}
_bfd_vms_output_begin (abfd,
- ETIR_S_C_STO_GBL,
- -1);
- _bfd_vms_output_counted (abfd,
- _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ ETIR_S_C_STO_GBL,
+ -1);
+ hash = (_bfd_vms_length_hash_symbol
+ (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ _bfd_vms_output_counted (abfd, hash);
_bfd_vms_output_flush (abfd);
}
else if (bfd_is_abs_section (sym->section))
vaddr, false);
}
_bfd_vms_output_begin (abfd,
- ETIR_S_C_STA_QW,
- -1);
+ ETIR_S_C_STA_QW,
+ -1);
_bfd_vms_output_quad (abfd,
- (uquad)sym->value);
+ (uquad) sym->value);
_bfd_vms_output_flush (abfd);
_bfd_vms_output_begin (abfd,
- ETIR_S_C_STO_QW,
- -1);
+ ETIR_S_C_STO_QW,
+ -1);
_bfd_vms_output_flush (abfd);
}
else
vaddr, false);
}
_bfd_vms_output_begin (abfd,
- ETIR_S_C_STA_PQ,
- -1);
+ ETIR_S_C_STA_PQ,
+ -1);
_bfd_vms_output_long (abfd,
- (unsigned long) (sec->index));
+ (unsigned long) (sec->index));
_bfd_vms_output_quad (abfd,
- ((uquad) (*rptr)->addend
- + (uquad)sym->value));
+ ((uquad) (*rptr)->addend
+ + (uquad) sym->value));
_bfd_vms_output_flush (abfd);
_bfd_vms_output_begin (abfd,
- ETIR_S_C_STO_OFF,
- -1);
+ ETIR_S_C_STO_OFF,
+ -1);
_bfd_vms_output_flush (abfd);
}
}
case ALPHA_R_HINT:
{
int hint_size;
+ char *hash ATTRIBUTE_UNUSED;
hint_size = sptr->size;
sptr->size = len;
sto_imm (abfd, sptr, vaddr, section->index);
sptr->size = hint_size;
#if 0
- vms_output_begin(abfd, ETIR_S_C_STO_HINT_GBL, -1);
- vms_output_long(abfd, (unsigned long) (sec->index));
- vms_output_quad(abfd, (uquad)addr);
+ vms_output_begin (abfd,
+ ETIR_S_C_STO_HINT_GBL, -1);
+ vms_output_long (abfd,
+ (unsigned long) (sec->index));
+ vms_output_quad (abfd, (uquad) addr);
- vms_output_counted(abfd, _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
- vms_output_flush(abfd);
+ hash = (_bfd_vms_length_hash_symbol
+ (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ vms_output_counted (abfd, hash);
+
+ vms_output_flush (abfd);
#endif
}
break;
case ALPHA_R_LINKAGE:
{
+ char *hash;
+
if (_bfd_vms_output_check (abfd, 64) < 0)
{
end_etir_record (abfd);
vaddr, false);
}
_bfd_vms_output_begin (abfd,
- ETIR_S_C_STC_LP_PSB,
- -1);
+ ETIR_S_C_STC_LP_PSB,
+ -1);
_bfd_vms_output_long (abfd,
- (unsigned long)PRIV(vms_linkage_index));
- PRIV(vms_linkage_index) += 2;
- _bfd_vms_output_counted (abfd,
- _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ (unsigned long) PRIV (vms_linkage_index));
+ PRIV (vms_linkage_index) += 2;
+ hash = (_bfd_vms_length_hash_symbol
+ (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ _bfd_vms_output_counted (abfd, hash);
_bfd_vms_output_byte (abfd, 0);
_bfd_vms_output_flush (abfd);
}
case ALPHA_R_CODEADDR:
{
- if (_bfd_vms_output_check (abfd,
- strlen((char *)sym->name))
- < 0)
+ int slen = strlen ((char *) sym->name);
+ char *hash;
+ if (_bfd_vms_output_check (abfd, slen) < 0)
{
end_etir_record (abfd);
start_etir_record (abfd,
vaddr, false);
}
_bfd_vms_output_begin (abfd,
- ETIR_S_C_STO_CA,
- -1);
- _bfd_vms_output_counted (abfd,
- _bfd_vms_length_hash_symbol (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ ETIR_S_C_STO_CA,
+ -1);
+ hash = (_bfd_vms_length_hash_symbol
+ (abfd, sym->name, EOBJ_S_C_SYMSIZ));
+ _bfd_vms_output_counted (abfd, hash);
_bfd_vms_output_flush (abfd);
}
break;
rptr++;
}
}
- else /* sptr starts after reloc */
+ else /* sptr starts after reloc */
{
- i--; /* check next reloc */
+ i--; /* check next reloc */
rptr++;
}
- if (i==0) /* all reloc checked */
+ if (i==0) /* all reloc checked */
{
if (sptr->size > 0)
{
- sto_imm (abfd, sptr, vaddr, section->index); /* dump rest */
+ /* dump rest */
+ sto_imm (abfd, sptr, vaddr, section->index);
vaddr += sptr->size;
}
break;
}
} /* for (;;) */
} /* if SEC_RELOC */
- else /* no relocs, just dump */
+ else /* no relocs, just dump */
{
sto_imm (abfd, sptr, vaddr, section->index);
vaddr += sptr->size;
section = section->next;
}
- _bfd_vms_output_alignment(abfd, 2);
+ _bfd_vms_output_alignment (abfd, 2);
return 0;
}
PARAMS ((bfd *abfd, char **tabloc, bfd_size_type *tablen,
const char **name));
static void vms_truncate_arname
- PARAMS ((bfd *abfd, CONST char *pathname, char *arhdr));
+ PARAMS ((bfd *abfd, const char *pathname, char *arhdr));
static boolean vms_write_armap
PARAMS ((bfd *arch, unsigned int elength, struct orl *map,
unsigned int orl_count, int stridx));
static bfd *vms_get_elt_at_index PARAMS ((bfd *abfd, symindex index));
static bfd *vms_openr_next_archived_file PARAMS ((bfd *arch, bfd *prev));
static boolean vms_update_armap_timestamp PARAMS ((bfd *abfd));
-static int vms_generic_stat_arch_elt PARAMS ((bfd *abfd, struct stat *stat));
+static int vms_generic_stat_arch_elt PARAMS ((bfd *, struct stat *));
static long vms_get_symtab_upper_bound PARAMS ((bfd *abfd));
static long vms_get_symtab PARAMS ((bfd *abfd, asymbol **symbols));
static void vms_print_symbol
bfd *abfd;
{
int i;
+ bfd_size_type amt;
if (abfd->tdata.any != 0)
return true;
- bfd_set_start_address (abfd, (bfd_vma)-1);
+ bfd_set_start_address (abfd, (bfd_vma) -1);
- abfd->tdata.any = ((struct vms_private_data_struct*)
- bfd_malloc (sizeof (struct vms_private_data_struct)));
+ amt = sizeof (struct vms_private_data_struct);
+ abfd->tdata.any = (struct vms_private_data_struct*) bfd_malloc (amt);
if (abfd->tdata.any == 0)
return false;
PRIV (fixup_done) = false;
PRIV (sections) = NULL;
- PRIV (stack) = ((struct stack_struct *)
- bfd_malloc (sizeof (struct stack_struct) * STACKSIZE));
+ amt = sizeof (struct stack_struct) * STACKSIZE;
+ PRIV (stack) = (struct stack_struct *) bfd_malloc (amt);
if (PRIV (stack) == 0)
{
vms_init_no_mem1:
}
PRIV (stackptr) = 0;
- PRIV (vms_symbol_table) = ((struct bfd_hash_table *)
- bfd_malloc (sizeof (struct bfd_hash_table)));
+ amt = sizeof (struct bfd_hash_table);
+ PRIV (vms_symbol_table) = (struct bfd_hash_table *) bfd_malloc (amt);
if (PRIV (vms_symbol_table) == 0)
{
vms_init_no_mem2:
if (!bfd_hash_table_init (PRIV (vms_symbol_table), _bfd_vms_hash_newfunc))
return false;
- PRIV (location_stack) = ((struct location_struct *)
- bfd_malloc (sizeof (struct location_struct)
- * LOCATION_SAVE_SIZE));
+ amt = sizeof (struct location_struct) * LOCATION_SAVE_SIZE;
+ PRIV (location_stack) = (struct location_struct *) bfd_malloc (amt);
if (PRIV (location_stack) == 0)
{
vms_init_no_mem3:
return 0;
}
- if (bfd_seek (abfd, 0L, SEEK_SET))
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET))
{
bfd_set_error (bfd_error_file_truncated);
return 0;
if (abfd->section_count > PRIV (section_count))
{
- PRIV (sections) = ((asection **)
- bfd_realloc (PRIV (sections), abfd->section_count * sizeof (asection *)));
+ bfd_size_type amt = abfd->section_count;
+ amt *= sizeof (asection *);
+ PRIV (sections) = (asection **) bfd_realloc (PRIV (sections), amt);
if (PRIV (sections) == 0)
return false;
PRIV (section_count) = abfd->section_count;
static void
vms_truncate_arname (abfd, pathname, arhdr)
bfd *abfd ATTRIBUTE_UNUSED;
- CONST char *pathname ATTRIBUTE_UNUSED;
+ const char *pathname ATTRIBUTE_UNUSED;
char *arhdr ATTRIBUTE_UNUSED;
{
#if VMS_DEBUG
-> bfd_generic_stat_arch_elt */
static int
-vms_generic_stat_arch_elt (abfd, stat)
+vms_generic_stat_arch_elt (abfd, st)
bfd *abfd;
- struct stat *stat;
+ struct stat *st;
{
#if VMS_DEBUG
- vms_debug (1, "vms_generic_stat_arch_elt(%p, %p)\n", abfd, stat);
+ vms_debug (1, "vms_generic_stat_arch_elt(%p, %p)\n", abfd, st);
#endif
- return bfd_generic_stat_arch_elt(abfd, stat);
+ return bfd_generic_stat_arch_elt (abfd, st);
}
/* This is a new function in bfd 2.5 */
_bfd_vms_make_empty_symbol (abfd)
bfd *abfd;
{
- asymbol *symbol = (asymbol *)bfd_zalloc(abfd, sizeof (asymbol));
+ asymbol *symbol;
+
+ symbol = (asymbol *) bfd_zalloc(abfd, (bfd_size_type) sizeof (asymbol));
#if VMS_DEBUG
vms_debug (1, "_bfd_vms_make_empty_symbol(%p)\n", abfd);
case bfd_print_symbol_all:
{
- CONST char *section_name = symbol->section->name;
+ const char *section_name = symbol->section->name;
bfd_print_symbol_vandf (abfd, (PTR)file, symbol);
asection *section ATTRIBUTE_UNUSED;
asymbol **symbols ATTRIBUTE_UNUSED;
bfd_vma offset ATTRIBUTE_UNUSED;
- CONST char **file ATTRIBUTE_UNUSED;
- CONST char **func ATTRIBUTE_UNUSED;
+ const char **file ATTRIBUTE_UNUSED;
+ const char **func ATTRIBUTE_UNUSED;
unsigned int *line ATTRIBUTE_UNUSED;
{
#if VMS_DEBUG
#undef vms
/* vms.h -- Header file for VMS (Alpha and Vax) support.
- Copyright 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001
+ Free Software Foundation, Inc.
Written by Klaus K"ampf (kkaempf@rmi.de)
/* POWER/PowerPC XCOFF linker support.
- Copyright 1995, 1996, 1997, 1998, 1999, 2000
+ Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@cygnus.com>, Cygnus Support.
/* The list of import files. */
-struct xcoff_import_file {
+struct xcoff_import_file
+{
/* The next entry in the list. */
struct xcoff_import_file *next;
/* The path. */
/* Information we keep for each section in the output file during the
final link phase. */
-struct xcoff_link_section_info {
+struct xcoff_link_section_info
+{
/* The relocs to be output. */
struct internal_reloc *relocs;
/* For each reloc against a global symbol whose index was not known
/* Information that we pass around while doing the final link step. */
-struct xcoff_final_link_info {
+struct xcoff_final_link_info
+{
/* General link information. */
struct bfd_link_info *info;
/* Output BFD. */
if (coff_section_data (abfd, sec) == NULL)
{
- sec->used_by_bfd = bfd_zalloc (abfd,
- sizeof (struct coff_section_tdata));
+ bfd_size_type amt = sizeof (struct coff_section_tdata);
+ sec->used_by_bfd = bfd_zalloc (abfd, amt);
if (sec->used_by_bfd == NULL)
return false;
}
if (coff_section_data (abfd, sec)->contents == NULL)
{
- coff_section_data (abfd, sec)->contents =
- (bfd_byte *) bfd_malloc (sec->_raw_size);
+ coff_section_data (abfd, sec)->contents = ((bfd_byte *)
+ bfd_malloc (sec->_raw_size));
if (coff_section_data (abfd, sec)->contents == NULL)
return false;
{
char *c;
- c = bfd_alloc (abfd, SYMNMLEN + 1);
+ c = bfd_alloc (abfd, (bfd_size_type) SYMNMLEN + 1);
if (c == NULL)
return -1;
memcpy (c, ldsym._l._l_name, SYMNMLEN);
elrel = contents + bfd_xcoff_loader_reloc_offset(abfd, &ldhdr);
elrelend = elrel + ldhdr.l_nreloc * bfd_xcoff_ldrelsz(abfd);
- for (; elrel < elrelend; elrel += bfd_xcoff_ldrelsz(abfd), relbuf++,
- prelocs++)
+ for (; elrel < elrelend; elrel += bfd_xcoff_ldrelsz(abfd), relbuf++,
+ prelocs++)
{
struct internal_ldrel ldrel;
bfd *abfd;
{
struct xcoff_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct xcoff_link_hash_table);
- ret = ((struct xcoff_link_hash_table *)
- bfd_alloc (abfd, sizeof (struct xcoff_link_hash_table)));
+ ret = (struct xcoff_link_hash_table *) bfd_alloc (abfd, amt);
if (ret == (struct xcoff_link_hash_table *) NULL)
return (struct bfd_link_hash_table *) NULL;
if (! _bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc))
undefined references in shared objects. */
if (h != (struct bfd_link_hash_entry *) NULL
&& h->type == bfd_link_hash_undefined
- && (info->hash->creator != abfd->xvec
+ && (info->hash->creator != abfd->xvec
|| (((struct xcoff_link_hash_entry *) h)->flags
& XCOFF_DEF_DYNAMIC) == 0))
{
}
-/*
- * xcoff_link_create_extra_sections
- *
- * Takes care of creating the .loader, .gl, .ds, .debug and sections
- */
+/* xcoff_link_create_extra_sections
+
+ Takes care of creating the .loader, .gl, .ds, .debug and sections. */
+
static boolean
-xcoff_link_create_extra_sections(bfd * abfd, struct bfd_link_info *info) {
+xcoff_link_create_extra_sections(bfd * abfd, struct bfd_link_info *info)
+{
boolean return_value = false;
- if (info->hash->creator == abfd->xvec) {
+ if (info->hash->creator == abfd->xvec)
+ {
/* We need to build a .loader section, so we do it here. This
won't work if we're producing an XCOFF output file with no
XCOFF input files. FIXME. */
- if (xcoff_hash_table (info)->loader_section == NULL) {
- asection *lsec;
-
- lsec = bfd_make_section_anyway (abfd, ".loader");
- if (lsec == NULL) {
- goto end_return;
+ if (xcoff_hash_table (info)->loader_section == NULL)
+ {
+ asection *lsec;
+
+ lsec = bfd_make_section_anyway (abfd, ".loader");
+ if (lsec == NULL)
+ {
+ goto end_return;
+ }
+ xcoff_hash_table (info)->loader_section = lsec;
+ lsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY;
}
- xcoff_hash_table (info)->loader_section = lsec;
- lsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY;
- }
/* Likewise for the linkage section. */
- if (xcoff_hash_table (info)->linkage_section == NULL) {
- asection *lsec;
+ if (xcoff_hash_table (info)->linkage_section == NULL)
+ {
+ asection *lsec;
- lsec = bfd_make_section_anyway (abfd, ".gl");
- if (lsec == NULL) {
- goto end_return;
- }
+ lsec = bfd_make_section_anyway (abfd, ".gl");
+ if (lsec == NULL)
+ {
+ goto end_return;
+ }
- xcoff_hash_table (info)->linkage_section = lsec;
- lsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY);
- lsec->alignment_power = 2;
- }
+ xcoff_hash_table (info)->linkage_section = lsec;
+ lsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY);
+ lsec->alignment_power = 2;
+ }
/* Likewise for the TOC section. */
- if (xcoff_hash_table (info)->toc_section == NULL) {
- asection *tsec;
-
- tsec = bfd_make_section_anyway (abfd, ".tc");
- if (tsec == NULL) {
- goto end_return;
- }
+ if (xcoff_hash_table (info)->toc_section == NULL)
+ {
+ asection *tsec;
- xcoff_hash_table (info)->toc_section = tsec;
- tsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY);
- tsec->alignment_power = 2;
- }
+ tsec = bfd_make_section_anyway (abfd, ".tc");
+ if (tsec == NULL)
+ {
+ goto end_return;
+ }
- /* Likewise for the descriptor section. */
- if (xcoff_hash_table (info)->descriptor_section == NULL) {
- asection *dsec;
-
- dsec = bfd_make_section_anyway (abfd, ".ds");
- if (dsec == NULL) {
- goto end_return;
+ xcoff_hash_table (info)->toc_section = tsec;
+ tsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY);
+ tsec->alignment_power = 2;
}
- xcoff_hash_table (info)->descriptor_section = dsec;
- dsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
- | SEC_IN_MEMORY);
- dsec->alignment_power = 2;
- }
+ /* Likewise for the descriptor section. */
+ if (xcoff_hash_table (info)->descriptor_section == NULL)
+ {
+ asection *dsec;
+
+ dsec = bfd_make_section_anyway (abfd, ".ds");
+ if (dsec == NULL)
+ {
+ goto end_return;
+ }
+
+ xcoff_hash_table (info)->descriptor_section = dsec;
+ dsec->flags |= (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY);
+ dsec->alignment_power = 2;
+ }
/* Likewise for the .debug section. */
if (xcoff_hash_table (info)->debug_section == NULL
- && info->strip != strip_all) {
- asection *dsec;
+ && info->strip != strip_all)
+ {
+ asection *dsec;
- dsec = bfd_make_section_anyway (abfd, ".debug");
- if (dsec == NULL) {
- goto end_return;
+ dsec = bfd_make_section_anyway (abfd, ".debug");
+ if (dsec == NULL)
+ {
+ goto end_return;
+ }
+ xcoff_hash_table (info)->debug_section = dsec;
+ dsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY;
}
- xcoff_hash_table (info)->debug_section = dsec;
- dsec->flags |= SEC_HAS_CONTENTS | SEC_IN_MEMORY;
- }
- }
-
+ }
+
return_value = true;
end_return:
bfd_size_type symesz;
bfd_byte *esym;
bfd_byte *esym_end;
- struct reloc_info_struct
+ struct reloc_info_struct
{
struct internal_reloc *relocs;
asection **csects;
bfd_byte *linenos;
} *reloc_info = NULL;
+ bfd_size_type amt;
keep_syms = obj_coff_keep_syms (abfd);
if ((abfd->flags & DYNAMIC) != 0
- && ! info->static_link) {
- if (! xcoff_link_add_dynamic_symbols (abfd, info)) {
- return false;
+ && ! info->static_link)
+ {
+ if (! xcoff_link_add_dynamic_symbols (abfd, info))
+ {
+ return false;
+ }
}
- }
/* create the loader, toc, gl, ds and debug sections, if needed */
- if (false == xcoff_link_create_extra_sections(abfd, info)) {
- goto error_return;
- }
+ if (false == xcoff_link_create_extra_sections(abfd, info))
+ {
+ goto error_return;
+ }
if ((abfd->flags & DYNAMIC) != 0
&& ! info->static_link)
else
default_copy = true;
- symcount = obj_raw_syment_count (abfd);
+ symcount = obj_raw_syment_count (abfd);
/* We keep a list of the linker hash table entries that correspond
to each external symbol. */
- sym_hash = ((struct xcoff_link_hash_entry **)
- bfd_alloc (abfd,
- (symcount
- * sizeof (struct xcoff_link_hash_entry *))));
+ amt = symcount * sizeof (struct xcoff_link_hash_entry *);
+ sym_hash = (struct xcoff_link_hash_entry **) bfd_alloc (abfd, amt);
if (sym_hash == NULL && symcount != 0)
goto error_return;
coff_data (abfd)->sym_hashes = (struct coff_link_hash_entry **) sym_hash;
- memset (sym_hash, 0,
- (size_t) symcount * sizeof (struct xcoff_link_hash_entry *));
+ memset (sym_hash, 0, (size_t) amt);
/* Because of the weird stuff we are doing with XCOFF csects, we can
not easily determine which section a symbol is in, so we store
the information in the tdata for the input file. */
- csect_cache = ((asection **)
- bfd_alloc (abfd, symcount * sizeof (asection *)));
+ amt = symcount * sizeof (asection *);
+ csect_cache = (asection **) bfd_alloc (abfd, amt);
if (csect_cache == NULL && symcount != 0)
goto error_return;
xcoff_data (abfd)->csects = csect_cache;
- memset (csect_cache, 0, (size_t) symcount * sizeof (asection *));
+ memset (csect_cache, 0, (size_t) amt);
/* While splitting sections into csects, we need to assign the
relocs correctly. The relocs and the csects must both be in
order by VMA within a given section, so we handle this by
scanning along the relocs as we process the csects. We index
into reloc_info using the section target_index. */
- reloc_info = ((struct reloc_info_struct *)
- bfd_malloc ((abfd->section_count + 1)
- * sizeof (struct reloc_info_struct)));
+ amt = abfd->section_count + 1;
+ amt *= sizeof (struct reloc_info_struct);
+ reloc_info = (struct reloc_info_struct *) bfd_malloc (amt);
if (reloc_info == NULL)
goto error_return;
- memset ((PTR) reloc_info, 0,
- (abfd->section_count + 1) * sizeof (struct reloc_info_struct));
+ memset ((PTR) reloc_info, 0, (size_t) amt);
/* Read in the relocs and line numbers for each section. */
linesz = bfd_coff_linesz (abfd);
last_real = NULL;
- for (o = abfd->sections; o != NULL; o = o->next) {
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
- last_real = o;
- if ((o->flags & SEC_RELOC) != 0) {
+ last_real = o;
+ if ((o->flags & SEC_RELOC) != 0)
+ {
- reloc_info[o->target_index].relocs =
- xcoff_read_internal_relocs (abfd, o, true, (bfd_byte *) NULL,
- false, (struct internal_reloc *) NULL);
- reloc_info[o->target_index].csects =
- (asection **) bfd_malloc (o->reloc_count * sizeof (asection *));
- if (reloc_info[o->target_index].csects == NULL)
- goto error_return;
- memset (reloc_info[o->target_index].csects, 0,
- o->reloc_count * sizeof (asection *));
-
- }
+ reloc_info[o->target_index].relocs =
+ xcoff_read_internal_relocs (abfd, o, true, (bfd_byte *) NULL,
+ false, (struct internal_reloc *) NULL);
+ amt = o->reloc_count;
+ amt *= sizeof (asection *);
+ reloc_info[o->target_index].csects = (asection **) bfd_malloc (amt);
+ if (reloc_info[o->target_index].csects == NULL)
+ goto error_return;
+ memset (reloc_info[o->target_index].csects, 0, (size_t) amt);
- if ((info->strip == strip_none || info->strip == strip_some)
- && o->lineno_count > 0) {
+ }
- bfd_byte *linenos;
+ if ((info->strip == strip_none || info->strip == strip_some)
+ && o->lineno_count > 0)
+ {
- linenos = (bfd_byte *) bfd_malloc (o->lineno_count * linesz);
- if (linenos == NULL)
- goto error_return;
- reloc_info[o->target_index].linenos = linenos;
- if (bfd_seek (abfd, o->line_filepos, SEEK_SET) != 0
- || (bfd_read (linenos, linesz, o->lineno_count, abfd)
- != linesz * o->lineno_count))
- goto error_return;
-
+ bfd_byte *linenos;
+
+ amt = linesz * o->lineno_count;
+ linenos = (bfd_byte *) bfd_malloc (amt);
+ if (linenos == NULL)
+ goto error_return;
+ reloc_info[o->target_index].linenos = linenos;
+ if (bfd_seek (abfd, o->line_filepos, SEEK_SET) != 0
+ || bfd_bread (linenos, amt, abfd) != amt)
+ goto error_return;
+
+ }
}
- }
/* Don't let the linker relocation routines discard the symbols. */
esym = (bfd_byte *) obj_coff_external_syms (abfd);
esym_end = esym + symcount * symesz;
- while (esym < esym_end) {
- struct internal_syment sym;
- union internal_auxent aux;
- const char *name;
- char buf[SYMNMLEN + 1];
- int smtyp;
- flagword flags;
- asection *section;
- bfd_vma value;
- struct xcoff_link_hash_entry *set_toc;
-
- bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &sym);
-
- /* In this pass we are only interested in symbols with csect
- information. */
- if (sym.n_sclass != C_EXT && sym.n_sclass != C_HIDEXT) {
-
- /*
- * Set csect_cache,
- * Normally csect is a .pr, .rw etc. created in the loop
- * If C_FILE or first time, handle special
- *
- * Advance esym, sym_hash, csect_hash ptr's
- * Keep track of the last_symndx for the current file
- */
- if (sym.n_sclass == C_FILE && csect != NULL) {
- xcoff_section_data (abfd, csect)->last_symndx =
- ((esym
- - (bfd_byte *) obj_coff_external_syms (abfd))
- / symesz);
- csect = NULL;
- }
+ while (esym < esym_end)
+ {
+ struct internal_syment sym;
+ union internal_auxent aux;
+ const char *name;
+ char buf[SYMNMLEN + 1];
+ int smtyp;
+ flagword flags;
+ asection *section;
+ bfd_vma value;
+ struct xcoff_link_hash_entry *set_toc;
- if (csect != NULL)
- *csect_cache = csect;
- else if (first_csect == NULL || sym.n_sclass == C_FILE)
- *csect_cache = coff_section_from_bfd_index (abfd, sym.n_scnum);
- else
- *csect_cache = NULL;
- esym += (sym.n_numaux + 1) * symesz;
- sym_hash += sym.n_numaux + 1;
- csect_cache += sym.n_numaux + 1;
-
- continue;
- }
+ bfd_coff_swap_sym_in (abfd, (PTR) esym, (PTR) &sym);
+
+ /* In this pass we are only interested in symbols with csect
+ information. */
+ if (sym.n_sclass != C_EXT && sym.n_sclass != C_HIDEXT)
+ {
- name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
+ /* Set csect_cache,
+ Normally csect is a .pr, .rw etc. created in the loop
+ If C_FILE or first time, handle special
- if (name == NULL)
- goto error_return;
+ Advance esym, sym_hash, csect_hash ptr's
+ Keep track of the last_symndx for the current file. */
+ if (sym.n_sclass == C_FILE && csect != NULL)
+ {
+ xcoff_section_data (abfd, csect)->last_symndx =
+ ((esym
+ - (bfd_byte *) obj_coff_external_syms (abfd))
+ / symesz);
+ csect = NULL;
+ }
+
+ if (csect != NULL)
+ *csect_cache = csect;
+ else if (first_csect == NULL || sym.n_sclass == C_FILE)
+ *csect_cache = coff_section_from_bfd_index (abfd, sym.n_scnum);
+ else
+ *csect_cache = NULL;
+ esym += (sym.n_numaux + 1) * symesz;
+ sym_hash += sym.n_numaux + 1;
+ csect_cache += sym.n_numaux + 1;
+
+ continue;
+ }
+
+ name = _bfd_coff_internal_syment_name (abfd, &sym, buf);
+
+ if (name == NULL)
+ goto error_return;
/* If this symbol has line number information attached to it,
and we're not stripping it, count the number of entries and
we are going to attach line number information by symbol,
rather than by section, in order to more easily handle
garbage collection. */
- if ((info->strip == strip_none || info->strip == strip_some) &&
- (sym.n_numaux > 1) &&
- (csect != NULL) &&
- (ISFCN (sym.n_type))) {
+ if ((info->strip == strip_none || info->strip == strip_some)
+ && sym.n_numaux > 1
+ && csect != NULL
+ && ISFCN (sym.n_type))
+ {
- union internal_auxent auxlin;
+ union internal_auxent auxlin;
- bfd_coff_swap_aux_in (abfd, (PTR) (esym + symesz),
- sym.n_type, sym.n_sclass,
- 0, sym.n_numaux, (PTR) &auxlin);
-
- if (auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr != 0) {
- asection *enclosing;
- bfd_signed_vma linoff;
-
- enclosing = xcoff_section_data (abfd, csect)->enclosing;
- if (enclosing == NULL) {
- (*_bfd_error_handler)
- (_("%s: `%s' has line numbers but no enclosing section"),
- bfd_get_filename (abfd), name);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
- linoff = (auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr
- - enclosing->line_filepos);
- /* explict cast to bfd_signed_vma for compiler */
- if (linoff < (bfd_signed_vma)(enclosing->lineno_count * linesz)) {
- struct internal_lineno lin;
- bfd_byte *linpstart;
-
- linpstart = (reloc_info[enclosing->target_index].linenos
- + linoff);
- bfd_coff_swap_lineno_in (abfd, (PTR) linpstart, (PTR) &lin);
- if (lin.l_lnno == 0
- && ((bfd_size_type) lin.l_addr.l_symndx
- == ((esym
- - (bfd_byte *) obj_coff_external_syms (abfd))
- / symesz))) {
- bfd_byte *linpend, *linp;
-
- linpend = (reloc_info[enclosing->target_index].linenos
- + enclosing->lineno_count * linesz);
- for (linp = linpstart + linesz; linp < linpend; linp += linesz) {
- bfd_coff_swap_lineno_in (abfd, (PTR) linp,
- (PTR) &lin);
- if (lin.l_lnno == 0)
- break;
+ bfd_coff_swap_aux_in (abfd, (PTR) (esym + symesz),
+ sym.n_type, sym.n_sclass,
+ 0, sym.n_numaux, (PTR) &auxlin);
+
+ if (auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr != 0)
+ {
+ asection *enclosing;
+ bfd_signed_vma linoff;
+
+ enclosing = xcoff_section_data (abfd, csect)->enclosing;
+ if (enclosing == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%s: `%s' has line numbers but no enclosing section"),
+ bfd_get_filename (abfd), name);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
+ linoff = (auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr
+ - enclosing->line_filepos);
+ /* explict cast to bfd_signed_vma for compiler */
+ if (linoff < (bfd_signed_vma) (enclosing->lineno_count * linesz))
+ {
+ struct internal_lineno lin;
+ bfd_byte *linpstart;
+
+ linpstart = (reloc_info[enclosing->target_index].linenos
+ + linoff);
+ bfd_coff_swap_lineno_in (abfd, (PTR) linpstart, (PTR) &lin);
+ if (lin.l_lnno == 0
+ && ((bfd_size_type) lin.l_addr.l_symndx
+ == ((esym
+ - (bfd_byte *) obj_coff_external_syms (abfd))
+ / symesz)))
+ {
+ bfd_byte *linpend, *linp;
+
+ linpend = (reloc_info[enclosing->target_index].linenos
+ + enclosing->lineno_count * linesz);
+ for (linp = linpstart + linesz;
+ linp < linpend;
+ linp += linesz)
+ {
+ bfd_coff_swap_lineno_in (abfd, (PTR) linp,
+ (PTR) &lin);
+ if (lin.l_lnno == 0)
+ break;
+ }
+ csect->lineno_count += (linp - linpstart) / linesz;
+ /* The setting of line_filepos will only be
+ useful if all the line number entries for a
+ csect are contiguous; this only matters for
+ error reporting. */
+ if (csect->line_filepos == 0)
+ csect->line_filepos =
+ auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr;
+ }
+ }
}
- csect->lineno_count += (linp - linpstart) / linesz;
- /* The setting of line_filepos will only be
- useful if all the line number entries for a
- csect are contiguous; this only matters for
- error reporting. */
- if (csect->line_filepos == 0)
- csect->line_filepos =
- auxlin.x_sym.x_fcnary.x_fcn.x_lnnoptr;
- }
}
- }
- }
- /* Pick up the csect auxiliary information. */
+ /* Pick up the csect auxiliary information. */
- if (sym.n_numaux == 0) {
- (*_bfd_error_handler)
- (_("%s: class %d symbol `%s' has no aux entries"),
- bfd_get_filename (abfd), sym.n_sclass, name);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
+ if (sym.n_numaux == 0)
+ {
+ (*_bfd_error_handler)
+ (_("%s: class %d symbol `%s' has no aux entries"),
+ bfd_get_filename (abfd), sym.n_sclass, name);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
- bfd_coff_swap_aux_in (abfd,
- (PTR) (esym + symesz * sym.n_numaux),
- sym.n_type, sym.n_sclass,
+ bfd_coff_swap_aux_in (abfd,
+ (PTR) (esym + symesz * sym.n_numaux),
+ sym.n_type, sym.n_sclass,
sym.n_numaux - 1, sym.n_numaux,
(PTR) &aux);
if (csect != NULL)
{
xcoff_section_data (abfd, csect)->last_symndx =
- ((esym
- - (bfd_byte *) obj_coff_external_syms (abfd))
- / symesz);
+ ((esym - (bfd_byte *) obj_coff_external_syms (abfd)) / symesz);
}
csect = NULL;
- csect_index = -1;
+ csect_index = -(unsigned) 1;
/* When we see a TOC anchor, we record the TOC value. */
if (aux.x_csect.x_smclas == XMC_TC0)
xcoff_data (abfd)->toc = sym.n_value;
}
- /*
- * We must merge TOC entries for the same symbol. We can
- * merge two TOC entries if they are both C_HIDEXT, they
- * both have the same name, they are both 4 or 8 bytes long, and
- * they both have a relocation table entry for an external
- * symbol with the same name. Unfortunately, this means
- * that we must look through the relocations. Ick.
- *
- * Logic for 32 bit vs 64 bit.
- * 32 bit has a csect length of 4 for TOC
- * 64 bit has a csect length of 8 for TOC
- *
- * The conditions to get past the if-check are not that bad.
- * They are what is used to create the TOC csects in the first
- * place
- */
- if ((aux.x_csect.x_smclas == XMC_TC) &&
- (sym.n_sclass == C_HIDEXT) &&
- (info->hash->creator == abfd->xvec) &&
- (((bfd_xcoff_is_xcoff32(abfd)) &&
- (aux.x_csect.x_scnlen.l == 4)) ||
- ((bfd_xcoff_is_xcoff64(abfd)) &&
- (aux.x_csect.x_scnlen.l == 8)))) {
+ /* We must merge TOC entries for the same symbol. We can
+ merge two TOC entries if they are both C_HIDEXT, they
+ both have the same name, they are both 4 or 8 bytes long, and
+ they both have a relocation table entry for an external
+ symbol with the same name. Unfortunately, this means
+ that we must look through the relocations. Ick.
+
+ Logic for 32 bit vs 64 bit.
+ 32 bit has a csect length of 4 for TOC
+ 64 bit has a csect length of 8 for TOC
+
+ The conditions to get past the if-check are not that bad.
+ They are what is used to create the TOC csects in the first
+ place. */
+ if (aux.x_csect.x_smclas == XMC_TC
+ && sym.n_sclass == C_HIDEXT
+ && info->hash->creator == abfd->xvec
+ && ((bfd_xcoff_is_xcoff32 (abfd)
+ && aux.x_csect.x_scnlen.l == 4)
+ || (bfd_xcoff_is_xcoff64 (abfd)
+ && aux.x_csect.x_scnlen.l == 8)))
+ {
+ asection *enclosing;
+ struct internal_reloc *relocs;
+ bfd_size_type relindx;
+ struct internal_reloc *rel;
- asection *enclosing;
- struct internal_reloc *relocs;
- bfd_size_type relindx;
- struct internal_reloc *rel;
+ enclosing = coff_section_from_bfd_index (abfd, sym.n_scnum);
+ if (enclosing == NULL)
+ goto error_return;
- enclosing = coff_section_from_bfd_index (abfd, sym.n_scnum);
- if (enclosing == NULL)
- goto error_return;
+ relocs = reloc_info[enclosing->target_index].relocs;
+ amt = enclosing->reloc_count;
+ relindx = xcoff_find_reloc (relocs, amt, sym.n_value);
+ rel = relocs + relindx;
- relocs = reloc_info[enclosing->target_index].relocs;
- relindx = xcoff_find_reloc (relocs, enclosing->reloc_count,
- sym.n_value);
- rel = relocs + relindx;
-
- /*
- * 32 bit R_POS r_size is 31
- * 64 bit R_POS r_size is 63
- */
- if ((relindx < enclosing->reloc_count) &&
- (rel->r_vaddr == (bfd_vma) sym.n_value) &&
- (rel->r_type == R_POS) &&
- (((bfd_xcoff_is_xcoff32(abfd)) &&
- (rel->r_size == 31)) ||
- ((bfd_xcoff_is_xcoff64(abfd)) &&
- (rel->r_size == 63)))) {
-
- bfd_byte *erelsym;
-
- struct internal_syment relsym;
-
- erelsym = ((bfd_byte *) obj_coff_external_syms (abfd)
- + rel->r_symndx * symesz);
- bfd_coff_swap_sym_in (abfd, (PTR) erelsym, (PTR) &relsym);
- if (relsym.n_sclass == C_EXT) {
- const char *relname;
- char relbuf[SYMNMLEN + 1];
- boolean copy;
- struct xcoff_link_hash_entry *h;
-
- /* At this point we know that the TOC entry is
- for an externally visible symbol. */
-
- relname = _bfd_coff_internal_syment_name (abfd, &relsym,
- relbuf);
- if (relname == NULL)
- goto error_return;
-
- /* We only merge TOC entries if the TC name is
- the same as the symbol name. This handles
- the normal case, but not common cases like
- SYM.P4 which gcc generates to store SYM + 4
- in the TOC. FIXME. */
-
- if (strcmp (name, relname) == 0) {
- copy = (! info->keep_memory
- || relsym._n._n_n._n_zeroes != 0
- || relsym._n._n_n._n_offset == 0);
- h = xcoff_link_hash_lookup (xcoff_hash_table (info),
- relname, true, copy,
- false);
- if (h == NULL)
- goto error_return;
-
- /* At this point h->root.type could be
- bfd_link_hash_new. That should be OK,
- since we know for sure that we will come
- across this symbol as we step through the
- file. */
-
- /* We store h in *sym_hash for the
- convenience of the relocate_section
- function. */
- *sym_hash = h;
-
- if (h->toc_section != NULL) {
- asection **rel_csects;
-
- /* We already have a TOC entry for this
- symbol, so we can just ignore this
- one. */
- rel_csects =
- reloc_info[enclosing->target_index].csects;
- rel_csects[relindx] = bfd_und_section_ptr;
- break;
- }
-
- /* We are about to create a TOC entry for
- this symbol. */
- set_toc = h;
- } /* merge toc reloc */
- } /* c_ext */
- } /* reloc */
- } /* merge toc */
+ /* 32 bit R_POS r_size is 31
+ 64 bit R_POS r_size is 63 */
+ if (relindx < enclosing->reloc_count
+ && rel->r_vaddr == (bfd_vma) sym.n_value
+ && rel->r_type == R_POS
+ && ((bfd_xcoff_is_xcoff32 (abfd)
+ && rel->r_size == 31)
+ || (bfd_xcoff_is_xcoff64 (abfd)
+ && rel->r_size == 63)))
+ {
+ bfd_byte *erelsym;
+
+ struct internal_syment relsym;
+
+ erelsym = ((bfd_byte *) obj_coff_external_syms (abfd)
+ + rel->r_symndx * symesz);
+ bfd_coff_swap_sym_in (abfd, (PTR) erelsym, (PTR) &relsym);
+ if (relsym.n_sclass == C_EXT)
+ {
+ const char *relname;
+ char relbuf[SYMNMLEN + 1];
+ boolean copy;
+ struct xcoff_link_hash_entry *h;
+
+ /* At this point we know that the TOC entry is
+ for an externally visible symbol. */
+
+ relname = _bfd_coff_internal_syment_name (abfd, &relsym,
+ relbuf);
+ if (relname == NULL)
+ goto error_return;
+
+ /* We only merge TOC entries if the TC name is
+ the same as the symbol name. This handles
+ the normal case, but not common cases like
+ SYM.P4 which gcc generates to store SYM + 4
+ in the TOC. FIXME. */
+
+ if (strcmp (name, relname) == 0)
+ {
+ copy = (! info->keep_memory
+ || relsym._n._n_n._n_zeroes != 0
+ || relsym._n._n_n._n_offset == 0);
+ h = xcoff_link_hash_lookup (xcoff_hash_table (info),
+ relname, true, copy,
+ false);
+ if (h == NULL)
+ goto error_return;
+
+ /* At this point h->root.type could be
+ bfd_link_hash_new. That should be OK,
+ since we know for sure that we will come
+ across this symbol as we step through the
+ file. */
+
+ /* We store h in *sym_hash for the
+ convenience of the relocate_section
+ function. */
+ *sym_hash = h;
+
+ if (h->toc_section != NULL)
+ {
+ asection **rel_csects;
+
+ /* We already have a TOC entry for this
+ symbol, so we can just ignore this
+ one. */
+ rel_csects =
+ reloc_info[enclosing->target_index].csects;
+ rel_csects[relindx] = bfd_und_section_ptr;
+ break;
+ }
+
+ /* We are about to create a TOC entry for
+ this symbol. */
+ set_toc = h;
+ } /* merge toc reloc */
+ } /* c_ext */
+ } /* reloc */
+ } /* merge toc */
{
accumulate similar csects together. */
csect = bfd_xcoff_create_csect_from_smclas(abfd, &aux, name);
- if (NULL == csect) {
- goto error_return;
- }
+ if (NULL == csect)
+ {
+ goto error_return;
+ }
- /*
- * The enclosing section is the main section : .data, .text
- * or .bss that the csect is coming from
- */
+ /* The enclosing section is the main section : .data, .text
+ or .bss that the csect is coming from. */
enclosing = coff_section_from_bfd_index (abfd, sym.n_scnum);
if (enclosing == NULL)
goto error_return;
- if (! bfd_is_abs_section (enclosing) &&
- ((bfd_vma) sym.n_value < enclosing->vma ||
- ((bfd_vma) sym.n_value + aux.x_csect.x_scnlen.l
- > enclosing->vma + enclosing->_raw_size))) {
- (*_bfd_error_handler)
- (_("%s: csect `%s' not in enclosing section"),
- bfd_get_filename (abfd), name);
- bfd_set_error (bfd_error_bad_value);
- goto error_return;
- }
+ if (! bfd_is_abs_section (enclosing)
+ && ((bfd_vma) sym.n_value < enclosing->vma
+ || ((bfd_vma) sym.n_value + aux.x_csect.x_scnlen.l
+ > enclosing->vma + enclosing->_raw_size)))
+ {
+ (*_bfd_error_handler)
+ (_("%s: csect `%s' not in enclosing section"),
+ bfd_get_filename (abfd), name);
+ bfd_set_error (bfd_error_bad_value);
+ goto error_return;
+ }
csect->vma = sym.n_value;
csect->filepos = (enclosing->filepos
+ sym.n_value
/* Record the enclosing section in the tdata for this new
section. */
- csect->used_by_bfd =
- (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));
+ amt = sizeof (struct coff_section_tdata);
+ csect->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (csect->used_by_bfd == NULL)
goto error_return;
- coff_section_data (abfd, csect)->tdata =
- bfd_zalloc (abfd, sizeof (struct xcoff_section_tdata));
+ amt = sizeof (struct xcoff_section_tdata);
+ coff_section_data (abfd, csect)->tdata = bfd_zalloc (abfd, amt);
if (coff_section_data (abfd, csect)->tdata == NULL)
goto error_return;
xcoff_section_data (abfd, csect)->enclosing = enclosing;
xcoff_section_data (abfd, csect)->lineno_count =
enclosing->lineno_count;
- if (enclosing->owner == abfd) {
- struct internal_reloc *relocs;
- bfd_size_type relindx;
- struct internal_reloc *rel;
- asection **rel_csect;
-
- relocs = reloc_info[enclosing->target_index].relocs;
- relindx = xcoff_find_reloc (relocs, enclosing->reloc_count,
- csect->vma);
+ if (enclosing->owner == abfd)
+ {
+ struct internal_reloc *relocs;
+ bfd_size_type relindx;
+ struct internal_reloc *rel;
+ asection **rel_csect;
+
+ relocs = reloc_info[enclosing->target_index].relocs;
+ amt = enclosing->reloc_count;
+ relindx = xcoff_find_reloc (relocs, amt, csect->vma);
+
+ rel = relocs + relindx;
+ rel_csect = (reloc_info[enclosing->target_index].csects
+ + relindx);
+
+ csect->rel_filepos = (enclosing->rel_filepos
+ + relindx * bfd_coff_relsz (abfd));
+ while (relindx < enclosing->reloc_count
+ && *rel_csect == NULL
+ && rel->r_vaddr < csect->vma + csect->_raw_size)
+ {
- rel = relocs + relindx;
- rel_csect = (reloc_info[enclosing->target_index].csects
- + relindx);
-
- csect->rel_filepos = (enclosing->rel_filepos
- + relindx * bfd_coff_relsz (abfd));
- while (relindx < enclosing->reloc_count &&
- *rel_csect == NULL &&
- rel->r_vaddr < csect->vma + csect->_raw_size) {
-
- *rel_csect = csect;
- csect->flags |= SEC_RELOC;
- ++csect->reloc_count;
- ++relindx;
- ++rel;
- ++rel_csect;
+ *rel_csect = csect;
+ csect->flags |= SEC_RELOC;
+ ++csect->reloc_count;
+ ++relindx;
+ ++rel;
+ ++rel_csect;
+ }
}
- }
/* There are a number of other fields and section flags
which we do not bother to set. */
case XTY_LD:
/* This is a label definition. The x_scnlen field is the
- symbol index of the csect. Usually the XTY_LD symbol will
+ symbol index of the csect. Usually the XTY_LD symbol will
follow its appropriate XTY_SD symbol. The .set pseudo op can
cause the XTY_LD to not follow the XTY_SD symbol. */
{
/ symesz);
}
- if (aux.x_csect.x_smclas == XMC_TD) {
- /*
- * The linker script puts the .td section in the data
- * section after the .tc section
- */
- csect = bfd_make_section_anyway (abfd, ".td");
+ if (aux.x_csect.x_smclas == XMC_TD)
+ {
+ /* The linker script puts the .td section in the data
+ section after the .tc section. */
+ csect = bfd_make_section_anyway (abfd, ".td");
- } else {
- csect = bfd_make_section_anyway (abfd, ".bss");
- }
+ }
+ else
+ {
+ csect = bfd_make_section_anyway (abfd, ".bss");
+ }
if (csect == NULL)
goto error_return;
csect->vma = sym.n_value;
- (bfd_byte *) obj_coff_external_syms (abfd))
/ symesz);
- csect->used_by_bfd =
- (PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata));
+ amt = sizeof (struct coff_section_tdata);
+ csect->used_by_bfd = (PTR) bfd_zalloc (abfd, amt);
if (csect->used_by_bfd == NULL)
goto error_return;
- coff_section_data (abfd, csect)->tdata =
- bfd_zalloc (abfd, sizeof (struct xcoff_section_tdata));
+ amt = sizeof (struct xcoff_section_tdata);
+ coff_section_data (abfd, csect)->tdata = bfd_zalloc (abfd, amt);
if (coff_section_data (abfd, csect)->tdata == NULL)
goto error_return;
xcoff_section_data (abfd, csect)->first_symndx = csect_index;
}
/* Check for magic symbol names. */
- if ((smtyp == XTY_SD || smtyp == XTY_CM) &&
- (aux.x_csect.x_smclas != XMC_TC) &&
- (aux.x_csect.x_smclas != XMC_TD)) {
-
- int i = -1;
-
- if (name[0] == '_') {
- if (strcmp (name, "_text") == 0)
- i = XCOFF_SPECIAL_SECTION_TEXT;
- else if (strcmp (name, "_etext") == 0)
- i = XCOFF_SPECIAL_SECTION_ETEXT;
- else if (strcmp (name, "_data") == 0)
- i = XCOFF_SPECIAL_SECTION_DATA;
- else if (strcmp (name, "_edata") == 0)
- i = XCOFF_SPECIAL_SECTION_EDATA;
- else if (strcmp (name, "_end") == 0)
- i = XCOFF_SPECIAL_SECTION_END;
- } else if (name[0] == 'e' && strcmp (name, "end") == 0) {
- i = XCOFF_SPECIAL_SECTION_END2;
- }
-
- if (i != -1) {
- xcoff_hash_table (info)->special_sections[i] = csect;
- }
- }
+ if ((smtyp == XTY_SD || smtyp == XTY_CM)
+ && aux.x_csect.x_smclas != XMC_TC
+ && aux.x_csect.x_smclas != XMC_TD)
+ {
+
+ int i = -1;
+
+ if (name[0] == '_')
+ {
+ if (strcmp (name, "_text") == 0)
+ i = XCOFF_SPECIAL_SECTION_TEXT;
+ else if (strcmp (name, "_etext") == 0)
+ i = XCOFF_SPECIAL_SECTION_ETEXT;
+ else if (strcmp (name, "_data") == 0)
+ i = XCOFF_SPECIAL_SECTION_DATA;
+ else if (strcmp (name, "_edata") == 0)
+ i = XCOFF_SPECIAL_SECTION_EDATA;
+ else if (strcmp (name, "_end") == 0)
+ i = XCOFF_SPECIAL_SECTION_END;
+ }
+ else if (name[0] == 'e' && strcmp (name, "end") == 0)
+ {
+ i = XCOFF_SPECIAL_SECTION_END2;
+ }
+
+ if (i != -1)
+ {
+ xcoff_hash_table (info)->special_sections[i] = csect;
+ }
+ }
/* Now we have enough information to add the symbol to the
linker hash table. */
shared object, which will cause symbol redefinitions,
although this is an easier case to detect. */
- if (info->hash->creator == abfd->xvec)
+ if (info->hash->creator == abfd->xvec)
{
if (! bfd_is_und_section (section))
*sym_hash = xcoff_link_hash_lookup (xcoff_hash_table (info),
not an error. */
if (! ((*info->callbacks->multiple_definition)
(info, (*sym_hash)->root.root.string,
- (bfd *) NULL, (asection *) NULL, 0,
+ (bfd *) NULL, (asection *) NULL, (bfd_vma) 0,
(*sym_hash)->root.u.def.section->owner,
(*sym_hash)->root.u.def.section,
(*sym_hash)->root.u.def.value)))
else
{
(*sym_hash)->root.u.c.p->alignment_power
- = csect->alignment_power;
+ = csect->alignment_power;
}
}
- if (info->hash->creator == abfd->xvec)
+ if (info->hash->creator == abfd->xvec)
{
int flag;
/* We identify all symbols which are called, so that we
can create glue code for calls to functions imported
from dynamic objects. */
- if (info->hash->creator == abfd->xvec
+ if (info->hash->creator == abfd->xvec
&& *rel_csect != bfd_und_section_ptr
&& (rel->r_type == R_BR
|| rel->r_type == R_RBR)
if (reloc_info[o->target_index].linenos != NULL)
free (reloc_info[o->target_index].linenos);
}
- free (reloc_info);
+ free (reloc_info);
}
obj_coff_keep_syms (abfd) = keep_syms;
return false;
/* We can only handle a dynamic object if we are generating an XCOFF
output file. */
- if (info->hash->creator != abfd->xvec)
+ if (info->hash->creator != abfd->xvec)
{
(*_bfd_error_handler)
(_("%s: XCOFF shared object when not producing XCOFF output"),
bfd_get_filename (abfd));
- bfd_set_error (bfd_error_invalid_operation);
+ bfd_set_error (bfd_error_invalid_operation);
return false;
}
-
+
/* The symbols we use from a dynamic object are not the symbols in
the normal symbol table, but, rather, the symbols in the export
table. If there is a global symbol in a dynamic object which is
{
char *dsnm;
- dsnm = bfd_malloc (strlen (name) + 2);
+ dsnm = bfd_malloc ((bfd_size_type) strlen (name) + 2);
if (dsnm == NULL)
return false;
dsnm[0] = '.';
/* Record this file in the import files. */
n = ((struct xcoff_import_file *)
- bfd_alloc (abfd, sizeof (struct xcoff_import_file)));
+ bfd_alloc (abfd, (bfd_size_type) sizeof (struct xcoff_import_file)));
if (n == NULL)
return false;
n->next = NULL;
{
struct xcoff_link_hash_entry *h = (struct xcoff_link_hash_entry *) harg;
struct xcoff_link_size_list *n;
+ bfd_size_type amt;
if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
return true;
per global symbol, so instead the size is kept on a linked list
attached to the hash table. */
- n = ((struct xcoff_link_size_list *)
- bfd_alloc (output_bfd, sizeof (struct xcoff_link_size_list)));
+ amt = sizeof (struct xcoff_link_size_list);
+ n = (struct xcoff_link_size_list *) bfd_alloc (output_bfd, amt);
if (n == NULL)
return false;
n->next = xcoff_hash_table (info)->size_list;
if (*pp == NULL)
{
struct xcoff_import_file *n;
+ bfd_size_type amt = sizeof (struct xcoff_import_file);
- n = ((struct xcoff_import_file *)
- bfd_alloc (output_bfd, sizeof (struct xcoff_import_file)));
+ n = (struct xcoff_import_file *) bfd_alloc (output_bfd, amt);
if (n == NULL)
return false;
n->next = NULL;
{
char *fnname;
struct xcoff_link_hash_entry *hfn;
+ bfd_size_type amt = strlen (h->root.root.string) + 2;
- fnname = (char *) bfd_malloc (strlen (h->root.root.string) + 2);
+ fnname = (char *) bfd_malloc (amt);
if (fnname == NULL)
return false;
fnname[0] = '.';
bfd *sub;
struct bfd_strtab_hash *debug_strtab;
bfd_byte *debug_contents = NULL;
+ bfd_size_type amt;
- if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour) {
+ if (bfd_get_flavour (output_bfd) != bfd_target_xcoff_flavour)
+ {
- for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++)
- special_sections[i] = NULL;
- return true;
- }
+ for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++)
+ special_sections[i] = NULL;
+ return true;
+ }
ldinfo.failed = false;
ldinfo.output_bfd = output_bfd;
xcoff_hash_table (info)->file_align = file_align;
xcoff_hash_table (info)->textro = textro;
- if (entry == NULL) {
- hentry = NULL;
- } else {
- hentry = xcoff_link_hash_lookup (xcoff_hash_table (info), entry,
- false, false, true);
- if (hentry != NULL)
- hentry->flags |= XCOFF_ENTRY;
- }
+ if (entry == NULL)
+ {
+ hentry = NULL;
+ }
+ else
+ {
+ hentry = xcoff_link_hash_lookup (xcoff_hash_table (info), entry,
+ false, false, true);
+ if (hentry != NULL)
+ hentry->flags |= XCOFF_ENTRY;
+ }
/* __rtinit */
if (info->init_function || info->fini_function) {
struct xcoff_link_hash_entry *hrtinit;
struct internal_ldsym *ldsym;
- hrtinit = xcoff_link_hash_lookup (xcoff_hash_table (info),
+ hrtinit = xcoff_link_hash_lookup (xcoff_hash_table (info),
"__rtinit",
false, false, true);
- if (hrtinit != NULL) {
- xcoff_mark_symbol (info, hrtinit);
- hrtinit->flags |= (XCOFF_DEF_REGULAR | XCOFF_RTINIT);
- } else {
- (*_bfd_error_handler)
- (_("error: undefined symbol __rtinit"));
-
- return false;
- }
+ if (hrtinit != NULL)
+ {
+ xcoff_mark_symbol (info, hrtinit);
+ hrtinit->flags |= (XCOFF_DEF_REGULAR | XCOFF_RTINIT);
+ }
+ else
+ {
+ (*_bfd_error_handler)
+ (_("error: undefined symbol __rtinit"));
+
+ return false;
+ }
+
+ /* __rtinit initalized here
+ Some information, like the location of the .initfini seciton will
+ be filled in later.
+
+ name or offset taken care of below with bfd_xcoff_put_ldsymbol_name. */
+ amt = sizeof (struct internal_ldsym);
+ ldsym = (struct internal_ldsym *) bfd_malloc (amt);
- /*
- *
- * __rtinit initalized here
- * Some information, like the location of the .initfini seciton will
- * be filled in later
- *
- * name or offset taken case of below with bfd_xcoff_put_ldsymbol_name
- */
- ldsym = (struct internal_ldsym *)
- bfd_malloc(sizeof (struct internal_ldsym));
-
ldsym->l_value = 0; /* will be filled in later */
ldsym->l_scnum = 2; /* data section */
ldsym->l_smtype = XTY_SD; /* csect section definition */
ldsym->l_smclas = 5; /* .rw */
ldsym->l_ifile = 0; /* special system loader symbol */
ldsym->l_parm = 0; /* NA */
-
- /*
- * Force __rtinit to be the first symbol in the loader symbol table
- * See xcoff_build_ldsyms
- *
- * The first 3 symbol table indices are reserved to indicate the data,
- * text and bss sections.
- */
+
+ /* Force __rtinit to be the first symbol in the loader symbol table
+ See xcoff_build_ldsyms
+
+ The first 3 symbol table indices are reserved to indicate the data,
+ text and bss sections. */
BFD_ASSERT (0 == ldinfo.ldsym_count);
-
+
hrtinit->ldindx = 3;
ldinfo.ldsym_count = 1;
hrtinit->ldsym = ldsym;
-
+
if (false == bfd_xcoff_put_ldsymbol_name (ldinfo.output_bfd, &ldinfo,
- hrtinit->ldsym,
- hrtinit->root.root.string)) {
- return false;
- }
+ hrtinit->ldsym,
+ hrtinit->root.root.string))
+ {
+ return false;
+ }
- /*
- * This symbol is written out by xcoff_write_global_symbol
- * Set stuff up so xcoff_write_global_symbol logic works.
- */
+ /* This symbol is written out by xcoff_write_global_symbol
+ Set stuff up so xcoff_write_global_symbol logic works. */
hrtinit->flags |= XCOFF_DEF_REGULAR | XCOFF_MARK;
hrtinit->root.type = bfd_link_hash_defined;
- hrtinit->root.u.def.value = 0;
+ hrtinit->root.u.def.value = 0;
}
/* Garbage collect unused sections. */
}
/* Return special sections to the caller. */
- for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++) {
- asection *sec;
-
- sec = xcoff_hash_table (info)->special_sections[i];
-
- if ((sec != NULL) &&
- (gc && (sec->flags & SEC_MARK) == 0)) {
- sec = NULL;
+ for (i = 0; i < XCOFF_NUMBER_OF_SPECIAL_SECTIONS; i++)
+ {
+ sec = xcoff_hash_table (info)->special_sections[i];
+
+ if (sec != NULL
+ && gc
+ && (sec->flags & SEC_MARK) == 0)
+ {
+ sec = NULL;
+ }
+ special_sections[i] = sec;
}
- special_sections[i] = sec;
- }
- if (info->input_bfds == NULL) {
- /* I'm not sure what to do in this bizarre case. */
- return true;
- }
+ if (info->input_bfds == NULL)
+ {
+ /* I'm not sure what to do in this bizarre case. */
+ return true;
+ }
xcoff_link_hash_traverse (xcoff_hash_table (info), xcoff_build_ldsyms,
(PTR) &ldinfo);
else
ldhdr->l_stoff = stoff;
- /*
- * 64 bit elements to ldhdr
- * The swap out routine for 32 bit will ignore them.
- * Nothing fancy, symbols come after the header and relocs come after symbols
- */
- ldhdr->l_symoff = bfd_xcoff_ldhdrsz(output_bfd);
- ldhdr->l_rldoff = bfd_xcoff_ldhdrsz(output_bfd) +
- (ldhdr->l_nsyms * bfd_xcoff_ldsymsz(output_bfd));
+ /* 64 bit elements to ldhdr
+ The swap out routine for 32 bit will ignore them.
+ Nothing fancy, symbols come after the header and relocs come
+ after symbols. */
+ ldhdr->l_symoff = bfd_xcoff_ldhdrsz (output_bfd);
+ ldhdr->l_rldoff = (bfd_xcoff_ldhdrsz (output_bfd)
+ + ldhdr->l_nsyms * bfd_xcoff_ldsymsz (output_bfd));
/* We now know the final size of the .loader section. Allocate
space for it. */
symbols are written out in xcoff_link_input_bfd or
xcoff_write_global_symbol. The .loader relocs are written out
when the corresponding normal relocs are handled in
- xcoff_link_input_bfd.
+ xcoff_link_input_bfd.
*/
/* Allocate space for the magic sections. */
PTR p;
{
struct xcoff_loader_info *ldinfo = (struct xcoff_loader_info *) p;
-
- /*
- * __rtinit
- * Special handling of this symbol to make is the first symbol in the
- * loader symbol table. Make sure this pass through does not undo it
- */
- if (h->flags & XCOFF_RTINIT) {
- return true;
- }
+ bfd_size_type amt;
+
+ /* __rtinit
+ Special handling of this symbol to make is the first symbol in
+ the loader symbol table. Make sure this pass through does not
+ undo it. */
+ if (h->flags & XCOFF_RTINIT)
+ {
+ return true;
+ }
/* If this is a final link, and the symbol was defined as a common
symbol in a regular object file, and there was no definition in
|| hds->root.type == bfd_link_hash_undefweak)
&& (hds->flags & XCOFF_DEF_REGULAR) == 0);
hds->flags |= XCOFF_MARK;
- if (hds->toc_section == NULL) {
- int byte_size;
-
- /*
- * 32 vs 64
- * xcoff32 uses 4 bytes in the toc
- * xcoff64 uses 8 bytes in the toc
- */
- if (bfd_xcoff_is_xcoff64(ldinfo->output_bfd)) {
- byte_size = 8;
- } else if (bfd_xcoff_is_xcoff32(ldinfo->output_bfd)) {
- byte_size = 4;
- } else {
- return false;
- }
+ if (hds->toc_section == NULL)
+ {
+ int byte_size;
- hds->toc_section = xcoff_hash_table (ldinfo->info)->toc_section;
- hds->u.toc_offset = hds->toc_section->_raw_size;
- hds->toc_section->_raw_size += byte_size;
- ++xcoff_hash_table (ldinfo->info)->ldrel_count;
- ++hds->toc_section->reloc_count;
- hds->indx = -2;
- hds->flags |= XCOFF_SET_TOC | XCOFF_LDREL;
-
- /*
- * We need to call xcoff_build_ldsyms recursively here,
- * because we may already have passed hds on the traversal.
- */
- xcoff_build_ldsyms (hds, p);
- }
+ /* 32 vs 64
+ xcoff32 uses 4 bytes in the toc.
+ xcoff64 uses 8 bytes in the toc. */
+ if (bfd_xcoff_is_xcoff64 (ldinfo->output_bfd))
+ {
+ byte_size = 8;
+ }
+ else if (bfd_xcoff_is_xcoff32 (ldinfo->output_bfd))
+ {
+ byte_size = 4;
+ }
+ else
+ {
+ return false;
+ }
+
+ hds->toc_section = xcoff_hash_table (ldinfo->info)->toc_section;
+ hds->u.toc_offset = hds->toc_section->_raw_size;
+ hds->toc_section->_raw_size += byte_size;
+ ++xcoff_hash_table (ldinfo->info)->ldrel_count;
+ ++hds->toc_section->reloc_count;
+ hds->indx = -2;
+ hds->flags |= XCOFF_SET_TOC | XCOFF_LDREL;
+
+ /* We need to call xcoff_build_ldsyms recursively here,
+ because we may already have passed hds on the traversal. */
+ xcoff_build_ldsyms (hds, p);
+ }
}
/* If this symbol is exported, but not defined, we need to try to
h->smclas = XMC_DS;
h->flags |= XCOFF_DEF_REGULAR;
- /*
- * The size of the function descriptor depends if this is an
- * xcoff32 (12) or xcoff64 (24)
- */
- sec->_raw_size +=
+ /* The size of the function descriptor depends if this is an
+ xcoff32 (12) or xcoff64 (24). */
+ sec->_raw_size +=
bfd_xcoff_function_descriptor_size(ldinfo->output_bfd);
- /*
- * A function descriptor uses two relocs: one for the
- * associated code, and one for the TOC address.
- */
+ /* A function descriptor uses two relocs: one for the
+ associated code, and one for the TOC address. */
xcoff_hash_table (ldinfo->info)->ldrel_count += 2;
sec->reloc_count += 2;
- /*
- * We handle writing out the contents of the descriptor in
- * xcoff_write_global_symbol.
- */
+ /* We handle writing out the contents of the descriptor in
+ xcoff_write_global_symbol. */
}
else
{
/* We need to add this symbol to the .loader symbols. */
BFD_ASSERT (h->ldsym == NULL);
- h->ldsym = ((struct internal_ldsym *)
- bfd_zalloc (ldinfo->output_bfd,
- sizeof (struct internal_ldsym)));
+ amt = sizeof (struct internal_ldsym);
+ h->ldsym = (struct internal_ldsym *) bfd_zalloc (ldinfo->output_bfd, amt);
if (h->ldsym == NULL)
{
ldinfo->failed = true;
if ((h->flags & XCOFF_IMPORT) != 0)
h->ldsym->l_ifile = h->ldindx;
- /*
- * The first 3 symbol table indices are reserved to indicate the data,
- * text and bss sections.
- */
+ /* The first 3 symbol table indices are reserved to indicate the
+ data, text and bss sections. */
h->ldindx = ldinfo->ldsym_count + 3;
++ldinfo->ldsym_count;
if (false == bfd_xcoff_put_ldsymbol_name (ldinfo->output_bfd, ldinfo,
- h->ldsym,
- h->root.root.string)) {
- return false;
- }
+ h->ldsym,
+ h->root.root.string))
+ {
+ return false;
+ }
h->flags |= XCOFF_BUILT_LDSYM;
struct xcoff_final_link_info finfo;
asection *o;
struct bfd_link_order *p;
- size_t max_contents_size;
- size_t max_sym_count;
- size_t max_lineno_count;
- size_t max_reloc_count;
- size_t max_output_reloc_count;
+ bfd_size_type max_contents_size;
+ bfd_size_type max_sym_count;
+ bfd_size_type max_lineno_count;
+ bfd_size_type max_reloc_count;
+ bfd_size_type max_output_reloc_count;
file_ptr rel_filepos;
unsigned int relsz;
file_ptr line_filepos;
bfd *sub;
bfd_byte *external_relocs = NULL;
char strbuf[STRING_SIZE_SIZE];
+ file_ptr pos;
+ bfd_size_type amt;
if (info->shared)
abfd->flags |= DYNAMIC;
finfo.contents = NULL;
finfo.external_relocs = NULL;
- finfo.ldsym = xcoff_hash_table (info)->loader_section->contents +
- bfd_xcoff_ldhdrsz(abfd);
- finfo.ldrel = xcoff_hash_table (info)->loader_section->contents +
- bfd_xcoff_ldhdrsz(abfd) +
- xcoff_hash_table (info)->ldhdr.l_nsyms * bfd_xcoff_ldsymsz(abfd);
+ finfo.ldsym = (xcoff_hash_table (info)->loader_section->contents
+ + bfd_xcoff_ldhdrsz (abfd));
+ finfo.ldrel = (xcoff_hash_table (info)->loader_section->contents
+ + bfd_xcoff_ldhdrsz(abfd)
+ + (xcoff_hash_table (info)->ldhdr.l_nsyms
+ * bfd_xcoff_ldsymsz(abfd)));
xcoff_data (abfd)->coff.link_info = info;
sofar = bfd_coff_filhsz (abfd);
sofar += bfd_coff_aoutsz (abfd);
sofar += abfd->section_count * bfd_coff_scnhsz (abfd);
- for (o = abfd->sections; o != NULL; o = o->next) {
- if ((true ==
- bfd_xcoff_is_reloc_count_overflow(abfd, o->reloc_count)) ||
- (true ==
- bfd_xcoff_is_lineno_count_overflow(abfd, o->lineno_count))) {
-
+ for (o = abfd->sections; o != NULL; o = o->next)
+ if ((bfd_xcoff_is_reloc_count_overflow
+ (abfd, (bfd_vma) o->reloc_count))
+ || (bfd_xcoff_is_lineno_count_overflow
+ (abfd, (bfd_vma) o->lineno_count)))
/* 64 does not overflow, need to check if 32 does */
sofar += bfd_coff_scnhsz (abfd);
- }
- }
+
for (o = abfd->sections; o != NULL; o = o->next)
{
if (strcmp (o->name, ".pad") == 0)
/* We use section_count + 1, rather than section_count, because
the target_index fields are 1 based. */
- finfo.section_info =
- ((struct xcoff_link_section_info *)
- bfd_malloc ((abfd->section_count + 1)
- * sizeof (struct xcoff_link_section_info)));
+ amt = abfd->section_count + 1;
+ amt *= sizeof (struct xcoff_link_section_info);
+ finfo.section_info = (struct xcoff_link_section_info *) bfd_malloc (amt);
if (finfo.section_info == NULL)
goto error_return;
for (i = 0; i <= abfd->section_count; i++)
memory until the end of the link. This wastes memory.
We could backpatch the file later, I suppose, although it
would be slow. */
+ amt = o->reloc_count;
+ amt *= sizeof (struct internal_reloc);
finfo.section_info[o->target_index].relocs =
- ((struct internal_reloc *)
- bfd_malloc (o->reloc_count * sizeof (struct internal_reloc)));
+ (struct internal_reloc *) bfd_malloc (amt);
+
+ amt = o->reloc_count;
+ amt *= sizeof (struct xcoff_link_hash_entry *);
finfo.section_info[o->target_index].rel_hashes =
- ((struct xcoff_link_hash_entry **)
- bfd_malloc (o->reloc_count
- * sizeof (struct xcoff_link_hash_entry *)));
+ (struct xcoff_link_hash_entry **) bfd_malloc (amt);
+
if (finfo.section_info[o->target_index].relocs == NULL
|| finfo.section_info[o->target_index].rel_hashes == NULL)
goto error_return;
max_sym_count = 6;
for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
{
- size_t sz;
+ bfd_size_type sz;
sub->output_has_begun = false;
sz = obj_raw_syment_count (sub);
}
/* Allocate some buffers used while linking. */
- finfo.internal_syms = ((struct internal_syment *)
- bfd_malloc (max_sym_count
- * sizeof (struct internal_syment)));
-
- finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
- finfo.outsyms = ((bfd_byte *)
- bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
- finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
- * bfd_coff_linesz (abfd));
- finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
- finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
+ amt = max_sym_count * sizeof (struct internal_syment);
+ finfo.internal_syms = (struct internal_syment *) bfd_malloc (amt);
+
+ amt = max_sym_count * sizeof (long);
+ finfo.sym_indices = (long *) bfd_malloc (amt);
+
+ amt = (max_sym_count + 1) * symesz;
+ finfo.outsyms = (bfd_byte *) bfd_malloc (amt);
+
+ amt = max_lineno_count * bfd_coff_linesz (abfd);
+ finfo.linenos = (bfd_byte *) bfd_malloc (amt);
+
+ amt = max_contents_size;
+ finfo.contents = (bfd_byte *) bfd_malloc (amt);
+
+ amt = max_reloc_count * relsz;
+ finfo.external_relocs = (bfd_byte *) bfd_malloc (amt);
+
if ((finfo.internal_syms == NULL && max_sym_count > 0)
|| (finfo.sym_indices == NULL && max_sym_count > 0)
|| finfo.outsyms == NULL
/* Free up the buffers used by xcoff_link_input_bfd. */
- if (finfo.internal_syms != NULL) {
- free (finfo.internal_syms);
- finfo.internal_syms = NULL;
- }
- if (finfo.sym_indices != NULL) {
- free (finfo.sym_indices);
- finfo.sym_indices = NULL;
- }
- if (finfo.linenos != NULL) {
- free (finfo.linenos);
- finfo.linenos = NULL;
- }
- if (finfo.contents != NULL) {
- free (finfo.contents);
- finfo.contents = NULL;
- }
- if (finfo.external_relocs != NULL) {
- free (finfo.external_relocs);
- finfo.external_relocs = NULL;
- }
+ if (finfo.internal_syms != NULL)
+ {
+ free (finfo.internal_syms);
+ finfo.internal_syms = NULL;
+ }
+ if (finfo.sym_indices != NULL)
+ {
+ free (finfo.sym_indices);
+ finfo.sym_indices = NULL;
+ }
+ if (finfo.linenos != NULL)
+ {
+ free (finfo.linenos);
+ finfo.linenos = NULL;
+ }
+ if (finfo.contents != NULL)
+ {
+ free (finfo.contents);
+ finfo.contents = NULL;
+ }
+ if (finfo.external_relocs != NULL)
+ {
+ free (finfo.external_relocs);
+ finfo.external_relocs = NULL;
+ }
/* The value of the last C_FILE symbol is supposed to be -1. Write
it out again. */
- if (finfo.last_file_index != -1) {
- finfo.last_file.n_value = -1;
- bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
- (PTR) finfo.outsyms);
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + finfo.last_file_index * symesz),
- SEEK_SET) != 0
- || bfd_write (finfo.outsyms, symesz, 1, abfd) != symesz)
- goto error_return;
- }
+ if (finfo.last_file_index != -1)
+ {
+ finfo.last_file.n_value = -(bfd_vma) 1;
+ bfd_coff_swap_sym_out (abfd, (PTR) &finfo.last_file,
+ (PTR) finfo.outsyms);
+ pos = obj_sym_filepos (abfd) + finfo.last_file_index * symesz;
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (finfo.outsyms, symesz, abfd) != symesz)
+ goto error_return;
+ }
/* init-fini */
- if (info->init_function || info->fini_function) {
- struct xcoff_link_hash_entry *hrtinit;
+ if (info->init_function || info->fini_function)
+ {
+ struct xcoff_link_hash_entry *hrtinit;
- hrtinit = xcoff_link_hash_lookup (xcoff_hash_table (info),
- "__rtinit",
- false, false, true);
- }
+ hrtinit = xcoff_link_hash_lookup (xcoff_hash_table (info),
+ "__rtinit",
+ false, false, true);
+ }
/* Write out all the global symbols which do not come from XCOFF
/* Now that we have written out all the global symbols, we know the
symbol indices to use for relocs against them, and we can finally
write out the relocs. */
- external_relocs = (bfd_byte *) bfd_malloc (max_output_reloc_count * relsz);
+ amt = max_output_reloc_count * relsz;
+ external_relocs = (bfd_byte *) bfd_malloc (amt);
if (external_relocs == NULL && max_output_reloc_count != 0)
goto error_return;
- for (o = abfd->sections; o != NULL; o = o->next) {
- struct internal_reloc *irel;
- struct internal_reloc *irelend;
- struct xcoff_link_hash_entry **rel_hash;
- struct xcoff_toc_rel_hash *toc_rel_hash;
- bfd_byte *erel;
-
- /* A stripped file has no relocs. */
- if (info->strip == strip_all) {
- o->reloc_count = 0;
- continue;
- }
-
- if (o->reloc_count == 0)
- continue;
-
- irel = finfo.section_info[o->target_index].relocs;
- irelend = irel + o->reloc_count;
- rel_hash = finfo.section_info[o->target_index].rel_hashes;
- for (; irel < irelend; irel++, rel_hash++, erel += relsz) {
- if (*rel_hash != NULL) {
- if ((*rel_hash)->indx < 0) {
- if (! ((*info->callbacks->unattached_reloc)
- (info, (*rel_hash)->root.root.string,
- (bfd *) NULL, o, irel->r_vaddr)))
- goto error_return;
- (*rel_hash)->indx = 0;
+ for (o = abfd->sections; o != NULL; o = o->next)
+ {
+ struct internal_reloc *irel;
+ struct internal_reloc *irelend;
+ struct xcoff_link_hash_entry **rel_hash;
+ struct xcoff_toc_rel_hash *toc_rel_hash;
+ bfd_byte *erel;
+ bfd_size_type rel_size;
+
+ /* A stripped file has no relocs. */
+ if (info->strip == strip_all)
+ {
+ o->reloc_count = 0;
+ continue;
}
- irel->r_symndx = (*rel_hash)->indx;
- }
- }
- for (toc_rel_hash = finfo.section_info[o->target_index].toc_rel_hashes;
- toc_rel_hash != NULL;
- toc_rel_hash = toc_rel_hash->next) {
- if (toc_rel_hash->h->u.toc_indx < 0) {
- if (! ((*info->callbacks->unattached_reloc)
- (info, toc_rel_hash->h->root.root.string,
- (bfd *) NULL, o, toc_rel_hash->rel->r_vaddr)))
- goto error_return;
- toc_rel_hash->h->u.toc_indx = 0;
- }
- toc_rel_hash->rel->r_symndx = toc_rel_hash->h->u.toc_indx;
- }
+ if (o->reloc_count == 0)
+ continue;
- /* XCOFF requires that the relocs be sorted by address. We tend
- to produce them in the order in which their containing csects
- appear in the symbol table, which is not necessarily by
- address. So we sort them here. There may be a better way to
- do this. */
- qsort ((PTR) finfo.section_info[o->target_index].relocs,
- o->reloc_count, sizeof (struct internal_reloc),
- xcoff_sort_relocs);
-
- irel = finfo.section_info[o->target_index].relocs;
- irelend = irel + o->reloc_count;
- erel = external_relocs;
- for (; irel < irelend; irel++, rel_hash++, erel += relsz)
- bfd_coff_swap_reloc_out (abfd, (PTR) irel, (PTR) erel);
-
- if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
- || bfd_write ((PTR) external_relocs, relsz, o->reloc_count,
- abfd) != relsz * o->reloc_count)
- goto error_return;
- }
+ irel = finfo.section_info[o->target_index].relocs;
+ irelend = irel + o->reloc_count;
+ rel_hash = finfo.section_info[o->target_index].rel_hashes;
+ for (; irel < irelend; irel++, rel_hash++, erel += relsz)
+ {
+ if (*rel_hash != NULL)
+ {
+ if ((*rel_hash)->indx < 0)
+ {
+ if (! ((*info->callbacks->unattached_reloc)
+ (info, (*rel_hash)->root.root.string,
+ (bfd *) NULL, o, irel->r_vaddr)))
+ goto error_return;
+ (*rel_hash)->indx = 0;
+ }
+ irel->r_symndx = (*rel_hash)->indx;
+ }
+ }
- if (external_relocs != NULL) {
- free (external_relocs);
- external_relocs = NULL;
- }
+ for (toc_rel_hash = finfo.section_info[o->target_index].toc_rel_hashes;
+ toc_rel_hash != NULL;
+ toc_rel_hash = toc_rel_hash->next)
+ {
+ if (toc_rel_hash->h->u.toc_indx < 0)
+ {
+ if (! ((*info->callbacks->unattached_reloc)
+ (info, toc_rel_hash->h->root.root.string,
+ (bfd *) NULL, o, toc_rel_hash->rel->r_vaddr)))
+ goto error_return;
+ toc_rel_hash->h->u.toc_indx = 0;
+ }
+ toc_rel_hash->rel->r_symndx = toc_rel_hash->h->u.toc_indx;
+ }
+
+ /* XCOFF requires that the relocs be sorted by address. We tend
+ to produce them in the order in which their containing csects
+ appear in the symbol table, which is not necessarily by
+ address. So we sort them here. There may be a better way to
+ do this. */
+ qsort ((PTR) finfo.section_info[o->target_index].relocs,
+ o->reloc_count, sizeof (struct internal_reloc),
+ xcoff_sort_relocs);
+
+ irel = finfo.section_info[o->target_index].relocs;
+ irelend = irel + o->reloc_count;
+ erel = external_relocs;
+ for (; irel < irelend; irel++, rel_hash++, erel += relsz)
+ bfd_coff_swap_reloc_out (abfd, (PTR) irel, (PTR) erel);
+
+ rel_size = relsz * o->reloc_count;
+ if (bfd_seek (abfd, o->rel_filepos, SEEK_SET) != 0
+ || bfd_bwrite ((PTR) external_relocs, rel_size, abfd) != rel_size)
+ goto error_return;
+ }
+
+ if (external_relocs != NULL)
+ {
+ free (external_relocs);
+ external_relocs = NULL;
+ }
/* Free up the section information. */
- if (finfo.section_info != NULL) {
- unsigned int i;
+ if (finfo.section_info != NULL)
+ {
+ unsigned int i;
- for (i = 0; i < abfd->section_count; i++) {
- if (finfo.section_info[i].relocs != NULL)
- free (finfo.section_info[i].relocs);
- if (finfo.section_info[i].rel_hashes != NULL)
- free (finfo.section_info[i].rel_hashes);
+ for (i = 0; i < abfd->section_count; i++)
+ {
+ if (finfo.section_info[i].relocs != NULL)
+ free (finfo.section_info[i].relocs);
+ if (finfo.section_info[i].rel_hashes != NULL)
+ free (finfo.section_info[i].rel_hashes);
+ }
+ free (finfo.section_info);
+ finfo.section_info = NULL;
}
- free (finfo.section_info);
- finfo.section_info = NULL;
- }
/* Write out the loader section contents. */
BFD_ASSERT ((bfd_byte *) finfo.ldrel
== (xcoff_hash_table (info)->loader_section->contents
+ xcoff_hash_table (info)->ldhdr.l_impoff));
o = xcoff_hash_table (info)->loader_section;
- if (! bfd_set_section_contents (abfd, o->output_section,
- o->contents, o->output_offset,
- o->_raw_size))
+ if (! bfd_set_section_contents (abfd, o->output_section, o->contents,
+ (file_ptr) o->output_offset, o->_raw_size))
goto error_return;
/* Write out the magic sections. */
o = xcoff_hash_table (info)->linkage_section;
if (o->_raw_size > 0
&& ! bfd_set_section_contents (abfd, o->output_section, o->contents,
- o->output_offset, o->_raw_size))
+ (file_ptr) o->output_offset,
+ o->_raw_size))
goto error_return;
o = xcoff_hash_table (info)->toc_section;
if (o->_raw_size > 0
&& ! bfd_set_section_contents (abfd, o->output_section, o->contents,
- o->output_offset, o->_raw_size))
+ (file_ptr) o->output_offset,
+ o->_raw_size))
goto error_return;
o = xcoff_hash_table (info)->descriptor_section;
if (o->_raw_size > 0
&& ! bfd_set_section_contents (abfd, o->output_section, o->contents,
- o->output_offset, o->_raw_size))
+ (file_ptr) o->output_offset,
+ o->_raw_size))
goto error_return;
/* Write out the string table. */
- if (bfd_seek (abfd,
- (obj_sym_filepos (abfd)
- + obj_raw_syment_count (abfd) * symesz),
- SEEK_SET) != 0)
+ pos = obj_sym_filepos (abfd) + obj_raw_syment_count (abfd) * symesz;
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0)
goto error_return;
- bfd_h_put_32 (abfd,
- _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
- (bfd_byte *) strbuf);
- if (bfd_write (strbuf, 1, STRING_SIZE_SIZE, abfd) != STRING_SIZE_SIZE)
+ H_PUT_32 (abfd,
+ _bfd_stringtab_size (finfo.strtab) + STRING_SIZE_SIZE,
+ strbuf);
+ amt = STRING_SIZE_SIZE;
+ if (bfd_bwrite (strbuf, amt, abfd) != amt)
goto error_return;
if (! _bfd_stringtab_emit (abfd, finfo.strtab))
goto error_return;
/* Write out the debugging string table. */
o = xcoff_hash_table (info)->debug_section;
- if (o != NULL) {
- struct bfd_strtab_hash *debug_strtab;
-
- debug_strtab = xcoff_hash_table (info)->debug_strtab;
- BFD_ASSERT (o->output_section->_raw_size - o->output_offset
- >= _bfd_stringtab_size (debug_strtab));
- if (bfd_seek (abfd,
- o->output_section->filepos + o->output_offset,
- SEEK_SET) != 0)
- goto error_return;
- if (! _bfd_stringtab_emit (abfd, debug_strtab))
- goto error_return;
- }
-
+ if (o != NULL)
+ {
+ struct bfd_strtab_hash *debug_strtab;
+
+ debug_strtab = xcoff_hash_table (info)->debug_strtab;
+ BFD_ASSERT (o->output_section->_raw_size - o->output_offset
+ >= _bfd_stringtab_size (debug_strtab));
+ pos = o->output_section->filepos + o->output_offset;
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0)
+ goto error_return;
+ if (! _bfd_stringtab_emit (abfd, debug_strtab))
+ goto error_return;
+ }
+
/* Setting bfd_get_symcount to 0 will cause write_object_contents to
not try to write out the symbols. */
bfd_get_symcount (abfd) = 0;
-
+
return true;
error_return:
if (finfo.strtab != NULL)
_bfd_stringtab_free (finfo.strtab);
-
- if (finfo.section_info != NULL) {
- unsigned int i;
-
- for (i = 0; i < abfd->section_count; i++) {
- if (finfo.section_info[i].relocs != NULL)
- free (finfo.section_info[i].relocs);
- if (finfo.section_info[i].rel_hashes != NULL)
- free (finfo.section_info[i].rel_hashes);
+
+ if (finfo.section_info != NULL)
+ {
+ unsigned int i;
+
+ for (i = 0; i < abfd->section_count; i++)
+ {
+ if (finfo.section_info[i].relocs != NULL)
+ free (finfo.section_info[i].relocs);
+ if (finfo.section_info[i].rel_hashes != NULL)
+ free (finfo.section_info[i].rel_hashes);
+ }
+ free (finfo.section_info);
}
- free (finfo.section_info);
- }
-
+
if (finfo.internal_syms != NULL)
free (finfo.internal_syms);
if (finfo.sym_indices != NULL)
BFD_ASSERT (h->ldindx >= 0);
bfd_xcoff_swap_ldsym_out (finfo->output_bfd, ldsym,
- finfo->ldsym + (h->ldindx - 3) *
- bfd_xcoff_ldsymsz(finfo->output_bfd));
+ (finfo->ldsym
+ + ((h->ldindx - 3)
+ * bfd_xcoff_ldsymsz (finfo->output_bfd))));
h->ldsym = NULL;
/* Fill in snentry now that we know the target_index. */
- if ((h->flags & XCOFF_ENTRY) != 0 &&
- (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)) {
- xcoff_data (output_bfd)->snentry =
- h->root.u.def.section->output_section->target_index;
- }
+ if ((h->flags & XCOFF_ENTRY) != 0
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
+ {
+ xcoff_data (output_bfd)->snentry =
+ h->root.u.def.section->output_section->target_index;
+ }
}
*indexp = -1;
inp != NULL;
inp = inp->link_next)
{
- asection *o;
for (o = inp->sections; o != NULL; o = o->next)
if (strcmp (o->name, ".tocbss") == 0)
xcoff_data (finfo->output_bfd)->sntoc =
(*csectpp)->output_section->target_index;
require = true;
-
+
}
}
/* We have already written out the last C_FILE
symbol. We need to write it out again. We
borrow *outsym temporarily. */
+ file_ptr pos;
+
bfd_coff_swap_sym_out (output_bfd,
(PTR) &finfo->last_file,
(PTR) outsym);
- if (bfd_seek (output_bfd,
- (obj_sym_filepos (output_bfd)
- + finfo->last_file_index * osymesz),
- SEEK_SET) != 0
- || (bfd_write (outsym, osymesz, 1, output_bfd)
+
+ pos = obj_sym_filepos (output_bfd);
+ pos += finfo->last_file_index * osymesz;
+ if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
+ || (bfd_bwrite (outsym, osymesz, output_bfd)
!= osymesz))
return false;
}
if (SMTYP_SMTYP (aux.x_csect.x_smtyp) == XTY_LD)
{
- bfd_signed_vma indx;
-
+ unsigned long indx;
- indx = aux.x_csect.x_scnlen.l;
+ indx = aux.x_csect.x_scnlen.l;
if (indx < obj_raw_syment_count (input_bfd))
{
long symindx;
symindx = finfo->sym_indices[indx];
- if (symindx < 0) {
- aux.x_csect.x_scnlen.l = 0;
- } else {
- aux.x_csect.x_scnlen.l = symindx;
- }
+ if (symindx < 0)
+ {
+ aux.x_csect.x_scnlen.l = 0;
+ }
+ else
+ {
+ aux.x_csect.x_scnlen.l = symindx;
+ }
}
}
}
enc_count = xcoff_section_data (abfd, o)->lineno_count;
if (oline != enclosing)
{
- if (bfd_seek (input_bfd,
- enclosing->line_filepos,
- SEEK_SET) != 0
- || (bfd_read (finfo->linenos, linesz,
- enc_count, input_bfd)
- != linesz * enc_count))
+ file_ptr pos = enclosing->line_filepos;
+ bfd_size_type amt = linesz * enc_count;
+ if (bfd_seek (input_bfd, pos, SEEK_SET) != 0
+ || (bfd_bread (finfo->linenos, amt, input_bfd)
+ != amt))
return false;
oline = enclosing;
}
if (bfd_seek (output_bfd,
aux.x_sym.x_fcnary.x_fcn.x_lnnoptr,
SEEK_SET) != 0
- || (bfd_write (finfo->linenos + linoff,
- linesz, count, output_bfd)
+ || (bfd_bwrite (finfo->linenos + linoff,
+ linesz * count, output_bfd)
!= linesz * count))
return false;
/* Write the modified symbols to the output file. */
if (outsym > finfo->outsyms)
{
- if (bfd_seek (output_bfd,
- obj_sym_filepos (output_bfd) + syment_base * osymesz,
- SEEK_SET) != 0
- || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1,
- output_bfd)
- != (bfd_size_type) (outsym - finfo->outsyms)))
+ file_ptr pos = obj_sym_filepos (output_bfd) + syment_base * osymesz;
+ bfd_size_type amt = outsym - finfo->outsyms;
+ if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (finfo->outsyms, amt, output_bfd) != amt)
return false;
BFD_ASSERT ((obj_raw_syment_count (output_bfd)
obj_coff_keep_syms (input_bfd) = true;
/* Relocate the contents of each section. */
- for (o = input_bfd->sections; o != NULL; o = o->next) {
-
- bfd_byte *contents;
+ for (o = input_bfd->sections; o != NULL; o = o->next)
+ {
- if (! o->linker_mark){
- /* This section was omitted from the link. */
- continue;
- }
+ bfd_byte *contents;
- if ((o->flags & SEC_HAS_CONTENTS) == 0
- || o->_raw_size == 0
- || (o->flags & SEC_IN_MEMORY) != 0)
- continue;
-
- /* We have set filepos correctly for the sections we created to
- represent csects, so bfd_get_section_contents should work. */
- if (coff_section_data (input_bfd, o) != NULL
- && coff_section_data (input_bfd, o)->contents != NULL)
- contents = coff_section_data (input_bfd, o)->contents;
- else {
- if (! bfd_get_section_contents (input_bfd, o, finfo->contents,
- (file_ptr) 0, o->_raw_size))
- return false;
- contents = finfo->contents;
- }
+ if (! o->linker_mark)
+ {
+ /* This section was omitted from the link. */
+ continue;
+ }
- if ((o->flags & SEC_RELOC) != 0) {
- int target_index;
- struct internal_reloc *internal_relocs;
- struct internal_reloc *irel;
- bfd_vma offset;
- struct internal_reloc *irelend;
- struct xcoff_link_hash_entry **rel_hash;
- long r_symndx;
-
- /* Read in the relocs. */
- target_index = o->output_section->target_index;
- internal_relocs = (xcoff_read_internal_relocs
- (input_bfd, o, false, finfo->external_relocs,
- true,
- (finfo->section_info[target_index].relocs
- + o->output_section->reloc_count)));
- if (internal_relocs == NULL)
- return false;
+ if ((o->flags & SEC_HAS_CONTENTS) == 0
+ || o->_raw_size == 0
+ || (o->flags & SEC_IN_MEMORY) != 0)
+ continue;
- /* Call processor specific code to relocate the section
- contents. */
- if (! bfd_coff_relocate_section (output_bfd, finfo->info,
- input_bfd, o,
- contents,
- internal_relocs,
- finfo->internal_syms,
- xcoff_data (input_bfd)->csects))
- return false;
+ /* We have set filepos correctly for the sections we created to
+ represent csects, so bfd_get_section_contents should work. */
+ if (coff_section_data (input_bfd, o) != NULL
+ && coff_section_data (input_bfd, o)->contents != NULL)
+ contents = coff_section_data (input_bfd, o)->contents;
+ else {
+ if (! bfd_get_section_contents (input_bfd, o, finfo->contents,
+ (file_ptr) 0, o->_raw_size))
+ return false;
+ contents = finfo->contents;
+ }
- offset = o->output_section->vma + o->output_offset - o->vma;
- irel = internal_relocs;
- irelend = irel + o->reloc_count;
- rel_hash = (finfo->section_info[target_index].rel_hashes
- + o->output_section->reloc_count);
- for (; irel < irelend; irel++, rel_hash++) {
- struct xcoff_link_hash_entry *h = NULL;
- struct internal_ldrel ldrel;
- boolean quiet;
+ if ((o->flags & SEC_RELOC) != 0)
+ {
+ int target_index;
+ struct internal_reloc *internal_relocs;
+ struct internal_reloc *irel;
+ bfd_vma offset;
+ struct internal_reloc *irelend;
+ struct xcoff_link_hash_entry **rel_hash;
+ long r_symndx;
+
+ /* Read in the relocs. */
+ target_index = o->output_section->target_index;
+ internal_relocs = (xcoff_read_internal_relocs
+ (input_bfd, o, false, finfo->external_relocs,
+ true,
+ (finfo->section_info[target_index].relocs
+ + o->output_section->reloc_count)));
+ if (internal_relocs == NULL)
+ return false;
- *rel_hash = NULL;
+ /* Call processor specific code to relocate the section
+ contents. */
+ if (! bfd_coff_relocate_section (output_bfd, finfo->info,
+ input_bfd, o,
+ contents,
+ internal_relocs,
+ finfo->internal_syms,
+ xcoff_data (input_bfd)->csects))
+ return false;
- /* Adjust the reloc address and symbol index. */
+ offset = o->output_section->vma + o->output_offset - o->vma;
+ irel = internal_relocs;
+ irelend = irel + o->reloc_count;
+ rel_hash = (finfo->section_info[target_index].rel_hashes
+ + o->output_section->reloc_count);
+ for (; irel < irelend; irel++, rel_hash++)
+ {
+ struct xcoff_link_hash_entry *h = NULL;
+ struct internal_ldrel ldrel;
+ boolean quiet;
- irel->r_vaddr += offset;
+ *rel_hash = NULL;
- r_symndx = irel->r_symndx;
+ /* Adjust the reloc address and symbol index. */
- if (r_symndx == -1)
- h = NULL;
- else
- h = obj_xcoff_sym_hashes (input_bfd)[r_symndx];
+ irel->r_vaddr += offset;
- if (r_symndx != -1 && finfo->info->strip != strip_all)
- {
- if (h != NULL
- && h->smclas != XMC_TD
- && (irel->r_type == R_TOC
- || irel->r_type == R_GL
- || irel->r_type == R_TCL
- || irel->r_type == R_TRL
- || irel->r_type == R_TRLA))
- {
- /* This is a TOC relative reloc with a symbol
- attached. The symbol should be the one which
- this reloc is for. We want to make this
- reloc against the TOC address of the symbol,
- not the symbol itself. */
- BFD_ASSERT (h->toc_section != NULL);
- BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
- if (h->u.toc_indx != -1)
- irel->r_symndx = h->u.toc_indx;
- else
- {
- struct xcoff_toc_rel_hash *n;
- struct xcoff_link_section_info *si;
+ r_symndx = irel->r_symndx;
- n = ((struct xcoff_toc_rel_hash *)
- bfd_alloc (finfo->output_bfd,
- sizeof (struct xcoff_toc_rel_hash)));
- if (n == NULL)
- return false;
- si = finfo->section_info + target_index;
- n->next = si->toc_rel_hashes;
- n->h = h;
- n->rel = irel;
- si->toc_rel_hashes = n;
- }
- }
- else if (h != NULL)
- {
- /* This is a global symbol. */
- if (h->indx >= 0)
- irel->r_symndx = h->indx;
- else
- {
- /* This symbol is being written at the end
- of the file, and we do not yet know the
- symbol index. We save the pointer to the
- hash table entry in the rel_hash list.
- We set the indx field to -2 to indicate
- that this symbol must not be stripped. */
- *rel_hash = h;
- h->indx = -2;
- }
- }
- else
- {
- long indx;
+ if (r_symndx == -1)
+ h = NULL;
+ else
+ h = obj_xcoff_sym_hashes (input_bfd)[r_symndx];
- indx = finfo->sym_indices[r_symndx];
+ if (r_symndx != -1 && finfo->info->strip != strip_all)
+ {
+ if (h != NULL
+ && h->smclas != XMC_TD
+ && (irel->r_type == R_TOC
+ || irel->r_type == R_GL
+ || irel->r_type == R_TCL
+ || irel->r_type == R_TRL
+ || irel->r_type == R_TRLA))
+ {
+ /* This is a TOC relative reloc with a symbol
+ attached. The symbol should be the one which
+ this reloc is for. We want to make this
+ reloc against the TOC address of the symbol,
+ not the symbol itself. */
+ BFD_ASSERT (h->toc_section != NULL);
+ BFD_ASSERT ((h->flags & XCOFF_SET_TOC) == 0);
+ if (h->u.toc_indx != -1)
+ irel->r_symndx = h->u.toc_indx;
+ else
+ {
+ struct xcoff_toc_rel_hash *n;
+ struct xcoff_link_section_info *si;
+ bfd_size_type amt;
+
+ amt = sizeof (struct xcoff_toc_rel_hash);
+ n = ((struct xcoff_toc_rel_hash *)
+ bfd_alloc (finfo->output_bfd, amt));
+ if (n == NULL)
+ return false;
+ si = finfo->section_info + target_index;
+ n->next = si->toc_rel_hashes;
+ n->h = h;
+ n->rel = irel;
+ si->toc_rel_hashes = n;
+ }
+ }
+ else if (h != NULL)
+ {
+ /* This is a global symbol. */
+ if (h->indx >= 0)
+ irel->r_symndx = h->indx;
+ else
+ {
+ /* This symbol is being written at the end
+ of the file, and we do not yet know the
+ symbol index. We save the pointer to the
+ hash table entry in the rel_hash list.
+ We set the indx field to -2 to indicate
+ that this symbol must not be stripped. */
+ *rel_hash = h;
+ h->indx = -2;
+ }
+ }
+ else
+ {
+ long indx;
- if (indx == -1)
- {
- struct internal_syment *is;
-
- /* Relocations against a TC0 TOC anchor are
- automatically transformed to be against
- the TOC anchor in the output file. */
- is = finfo->internal_syms + r_symndx;
- if (is->n_sclass == C_HIDEXT
- && is->n_numaux > 0)
- {
- PTR auxptr;
- union internal_auxent aux;
-
- auxptr = ((PTR)
- (((bfd_byte *)
- obj_coff_external_syms (input_bfd))
- + ((r_symndx + is->n_numaux)
- * isymesz)));
- bfd_coff_swap_aux_in (input_bfd, auxptr,
- is->n_type, is->n_sclass,
- is->n_numaux - 1,
- is->n_numaux,
- (PTR) &aux);
- if (SMTYP_SMTYP (aux.x_csect.x_smtyp) == XTY_SD
- && aux.x_csect.x_smclas == XMC_TC0)
- indx = finfo->toc_symindx;
- }
- }
+ indx = finfo->sym_indices[r_symndx];
- if (indx != -1)
- irel->r_symndx = indx;
- else
- {
+ if (indx == -1)
+ {
+ struct internal_syment *is;
+
+ /* Relocations against a TC0 TOC anchor are
+ automatically transformed to be against
+ the TOC anchor in the output file. */
+ is = finfo->internal_syms + r_symndx;
+ if (is->n_sclass == C_HIDEXT
+ && is->n_numaux > 0)
+ {
+ PTR auxptr;
+ union internal_auxent aux;
+
+ auxptr = ((PTR)
+ (((bfd_byte *)
+ obj_coff_external_syms (input_bfd))
+ + ((r_symndx + is->n_numaux)
+ * isymesz)));
+ bfd_coff_swap_aux_in (input_bfd, auxptr,
+ is->n_type, is->n_sclass,
+ is->n_numaux - 1,
+ is->n_numaux,
+ (PTR) &aux);
+ if (SMTYP_SMTYP (aux.x_csect.x_smtyp) == XTY_SD
+ && aux.x_csect.x_smclas == XMC_TC0)
+ indx = finfo->toc_symindx;
+ }
+ }
- struct internal_syment *is;
+ if (indx != -1)
+ irel->r_symndx = indx;
+ else
+ {
- const char *name;
- char buf[SYMNMLEN + 1];
+ struct internal_syment *is;
- /* This reloc is against a symbol we are
- stripping. It would be possible to handle
- this case, but I don't think it's worth it. */
- is = finfo->internal_syms + r_symndx;
+ const char *name;
+ char buf[SYMNMLEN + 1];
- name = (_bfd_coff_internal_syment_name
- (input_bfd, is, buf));
+ /* This reloc is against a symbol we are
+ stripping. It would be possible to handle
+ this case, but I don't think it's worth it. */
+ is = finfo->internal_syms + r_symndx;
- if (name == NULL)
- return false;
+ name = (_bfd_coff_internal_syment_name
+ (input_bfd, is, buf));
+
+ if (name == NULL)
+ return false;
+
+ if (! ((*finfo->info->callbacks->unattached_reloc)
+ (finfo->info, name, input_bfd, o,
+ irel->r_vaddr)))
+ return false;
+ }
+ }
+ }
- if (! ((*finfo->info->callbacks->unattached_reloc)
- (finfo->info, name, input_bfd, o,
- irel->r_vaddr)))
+ quiet = false;
+ switch (irel->r_type)
+ {
+ default:
+ if (h == NULL
+ || h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak
+ || h->root.type == bfd_link_hash_common)
+ break;
+ /* Fall through. */
+ case R_POS:
+ case R_NEG:
+ case R_RL:
+ case R_RLA:
+ /* This reloc needs to be copied into the .loader
+ section. */
+ ldrel.l_vaddr = irel->r_vaddr;
+ if (r_symndx == -1)
+ ldrel.l_symndx = -(bfd_size_type ) 1;
+ else if (h == NULL
+ || (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak
+ || h->root.type == bfd_link_hash_common))
+ {
+ asection *sec;
+
+ if (h == NULL)
+ sec = xcoff_data (input_bfd)->csects[r_symndx];
+ else if (h->root.type == bfd_link_hash_common)
+ sec = h->root.u.c.p->section;
+ else
+ sec = h->root.u.def.section;
+ sec = sec->output_section;
+
+ if (strcmp (sec->name, ".text") == 0)
+ ldrel.l_symndx = 0;
+ else if (strcmp (sec->name, ".data") == 0)
+ ldrel.l_symndx = 1;
+ else if (strcmp (sec->name, ".bss") == 0)
+ ldrel.l_symndx = 2;
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: loader reloc in unrecognized section `%s'"),
+ bfd_get_filename (input_bfd),
+ sec->name);
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return false;
+ }
+ }
+ else
+ {
+ if (! finfo->info->relocateable
+ && (h->flags & XCOFF_DEF_DYNAMIC) == 0
+ && (h->flags & XCOFF_IMPORT) == 0)
+ {
+ /* We already called the undefined_symbol
+ callback for this relocation, in
+ _bfd_ppc_xcoff_relocate_section. Don't
+ issue any more warnings. */
+ quiet = true;
+ }
+ if (h->ldindx < 0 && ! quiet)
+ {
+ (*_bfd_error_handler)
+ (_("%s: `%s' in loader reloc but not loader sym"),
+ bfd_get_filename (input_bfd),
+ h->root.root.string);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ ldrel.l_symndx = h->ldindx;
+ }
+ ldrel.l_rtype = (irel->r_size << 8) | irel->r_type;
+ ldrel.l_rsecnm = o->output_section->target_index;
+ if (xcoff_hash_table (finfo->info)->textro
+ && strcmp (o->output_section->name, ".text") == 0
+ && ! quiet)
+ {
+ (*_bfd_error_handler)
+ (_("%s: loader reloc in read-only section %s"),
+ bfd_get_filename (input_bfd),
+ bfd_get_section_name (finfo->output_bfd,
+ o->output_section));
+ bfd_set_error (bfd_error_invalid_operation);
return false;
- }
- }
- }
+ }
+ bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel,
+ finfo->ldrel);
- quiet = false;
- switch (irel->r_type)
- {
- default:
- if (h == NULL
- || h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak
- || h->root.type == bfd_link_hash_common)
- break;
- /* Fall through. */
- case R_POS:
- case R_NEG:
- case R_RL:
- case R_RLA:
- /* This reloc needs to be copied into the .loader
- section. */
- ldrel.l_vaddr = irel->r_vaddr;
- if (r_symndx == -1)
- ldrel.l_symndx = -1;
- else if (h == NULL
- || (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak
- || h->root.type == bfd_link_hash_common))
- {
- asection *sec;
-
- if (h == NULL)
- sec = xcoff_data (input_bfd)->csects[r_symndx];
- else if (h->root.type == bfd_link_hash_common)
- sec = h->root.u.c.p->section;
- else
- sec = h->root.u.def.section;
- sec = sec->output_section;
-
- if (strcmp (sec->name, ".text") == 0)
- ldrel.l_symndx = 0;
- else if (strcmp (sec->name, ".data") == 0)
- ldrel.l_symndx = 1;
- else if (strcmp (sec->name, ".bss") == 0)
- ldrel.l_symndx = 2;
- else
- {
- (*_bfd_error_handler)
- (_("%s: loader reloc in unrecognized section `%s'"),
- bfd_get_filename (input_bfd),
- sec->name);
- bfd_set_error (bfd_error_nonrepresentable_section);
- return false;
- }
- }
- else
- {
- if (! finfo->info->relocateable
- && (h->flags & XCOFF_DEF_DYNAMIC) == 0
- && (h->flags & XCOFF_IMPORT) == 0)
- {
- /* We already called the undefined_symbol
- callback for this relocation, in
- _bfd_ppc_xcoff_relocate_section. Don't
- issue any more warnings. */
- quiet = true;
- }
- if (h->ldindx < 0 && ! quiet)
- {
- (*_bfd_error_handler)
- (_("%s: `%s' in loader reloc but not loader sym"),
- bfd_get_filename (input_bfd),
- h->root.root.string);
- bfd_set_error (bfd_error_bad_value);
- return false;
- }
- ldrel.l_symndx = h->ldindx;
- }
- ldrel.l_rtype = (irel->r_size << 8) | irel->r_type;
- ldrel.l_rsecnm = o->output_section->target_index;
- if (xcoff_hash_table (finfo->info)->textro
- && strcmp (o->output_section->name, ".text") == 0
- && ! quiet)
- {
- (*_bfd_error_handler)
- (_("%s: loader reloc in read-only section %s"),
- bfd_get_filename (input_bfd),
- bfd_get_section_name (finfo->output_bfd,
- o->output_section));
- bfd_set_error (bfd_error_invalid_operation);
- return false;
- }
- bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel,
- finfo->ldrel);
+ finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd);
+ break;
- finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd);
- break;
+ case R_TOC:
+ case R_GL:
+ case R_TCL:
+ case R_TRL:
+ case R_TRLA:
+ /* We should never need a .loader reloc for a TOC
+ relative reloc. */
+ break;
+ }
+ }
- case R_TOC:
- case R_GL:
- case R_TCL:
- case R_TRL:
- case R_TRLA:
- /* We should never need a .loader reloc for a TOC
- relative reloc. */
- break;
- }
- }
+ o->output_section->reloc_count += o->reloc_count;
+ }
- o->output_section->reloc_count += o->reloc_count;
+ /* Write out the modified section contents. */
+ if (! bfd_set_section_contents (output_bfd, o->output_section,
+ contents, (file_ptr) o->output_offset,
+ (o->_cooked_size != 0
+ ? o->_cooked_size
+ : o->_raw_size)))
+ return false;
}
- /* Write out the modified section contents. */
- if (! bfd_set_section_contents (output_bfd, o->output_section,
- contents, o->output_offset,
- (o->_cooked_size != 0
- ? o->_cooked_size
- : o->_raw_size)))
- return false;
- }
-
obj_coff_keep_syms (input_bfd) = keep_syms;
if (! finfo->info->keep_memory)
static boolean
-xcoff_write_global_symbol (h, p)
+xcoff_write_global_symbol (h, inf)
struct xcoff_link_hash_entry *h;
- PTR p;
+ PTR inf;
{
- struct xcoff_final_link_info *finfo = (struct xcoff_final_link_info *) p;
+ struct xcoff_final_link_info *finfo = (struct xcoff_final_link_info *) inf;
bfd *output_bfd;
bfd_byte *outsym;
struct internal_syment isym;
union internal_auxent aux;
boolean result;
+ file_ptr pos;
+ bfd_size_type amt;
output_bfd = finfo->output_bfd;
outsym = finfo->outsyms;
return true;
/* If we need a .loader section entry, write it out. */
- if (h->ldsym != NULL) {
- struct internal_ldsym *ldsym;
- bfd *impbfd;
-
- ldsym = h->ldsym;
+ if (h->ldsym != NULL)
+ {
+ struct internal_ldsym *ldsym;
+ bfd *impbfd;
- if (h->root.type == bfd_link_hash_undefined ||
- h->root.type == bfd_link_hash_undefweak) {
+ ldsym = h->ldsym;
- ldsym->l_value = 0;
- ldsym->l_scnum = N_UNDEF;
- ldsym->l_smtype = XTY_ER;
- impbfd = h->root.u.undef.abfd;
+ if (h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak)
+ {
- } else if (h->root.type == bfd_link_hash_defined ||
- h->root.type == bfd_link_hash_defweak) {
+ ldsym->l_value = 0;
+ ldsym->l_scnum = N_UNDEF;
+ ldsym->l_smtype = XTY_ER;
+ impbfd = h->root.u.undef.abfd;
- asection *sec;
-
- sec = h->root.u.def.section;
- ldsym->l_value = (sec->output_section->vma
- + sec->output_offset
- + h->root.u.def.value);
- ldsym->l_scnum = sec->output_section->target_index;
- ldsym->l_smtype = XTY_SD;
- impbfd = sec->owner;
-
- } else {
- abort ();
- }
+ }
+ else if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
- if (((h->flags & XCOFF_DEF_REGULAR) == 0 &&
- (h->flags & XCOFF_DEF_DYNAMIC) != 0) ||
- (h->flags & XCOFF_IMPORT) != 0) {
- /* Clear l_smtype
- Import symbols are defined so the check above will make the l_smtype
- XTY_SD. But this is not correct, it should be cleared. */
- ldsym->l_smtype = L_IMPORT;
- }
+ asection *sec;
- if (((h->flags & XCOFF_DEF_REGULAR) != 0 &&
- (h->flags & XCOFF_DEF_DYNAMIC) != 0) ||
- (h->flags & XCOFF_EXPORT) != 0) {
- ldsym->l_smtype |= L_EXPORT;
- }
+ sec = h->root.u.def.section;
+ ldsym->l_value = (sec->output_section->vma
+ + sec->output_offset
+ + h->root.u.def.value);
+ ldsym->l_scnum = sec->output_section->target_index;
+ ldsym->l_smtype = XTY_SD;
+ impbfd = sec->owner;
- if ((h->flags & XCOFF_ENTRY) != 0) {
- ldsym->l_smtype |= L_ENTRY;
- }
+ }
+ else
+ abort ();
- if ((h->flags & XCOFF_RTINIT) != 0) {
- ldsym->l_smtype = XTY_SD;
- }
+ if (((h->flags & XCOFF_DEF_REGULAR) == 0
+ && (h->flags & XCOFF_DEF_DYNAMIC) != 0)
+ || (h->flags & XCOFF_IMPORT) != 0)
+ {
+ /* Clear l_smtype
+ Import symbols are defined so the check above will make
+ the l_smtype XTY_SD. But this is not correct, it should
+ be cleared. */
+ ldsym->l_smtype |= L_IMPORT;
+ }
- ldsym->l_smclas = h->smclas;
+ if (((h->flags & XCOFF_DEF_REGULAR) != 0
+ && (h->flags & XCOFF_DEF_DYNAMIC) != 0)
+ || (h->flags & XCOFF_EXPORT) != 0)
+ {
+ ldsym->l_smtype |= L_EXPORT;
+ }
- if (ldsym->l_smtype & L_IMPORT)
- {
- if ((h->root.type == bfd_link_hash_defined ||
- h->root.type == bfd_link_hash_defweak) &&
- (h->root.u.def.value != 0))
- {
- ldsym->l_smclas = XMC_XO;
- }
- else if ((h->flags & (XCOFF_SYSCALL32 | XCOFF_SYSCALL64)) ==
- (XCOFF_SYSCALL32 | XCOFF_SYSCALL64))
- {
- ldsym->l_smclas = XMC_SV3264;
- }
- else if (h->flags & XCOFF_SYSCALL32)
- {
- ldsym->l_smclas = XMC_SV;
- }
- else if (h->flags & XCOFF_SYSCALL64)
- {
- ldsym->l_smclas = XMC_SV64;
- }
- }
-
- if (ldsym->l_ifile == (bfd_size_type) -1) {
- ldsym->l_ifile = 0;
-
- } else if (ldsym->l_ifile == 0) {
- if ((ldsym->l_smtype & L_IMPORT) == 0) {
- ldsym->l_ifile = 0;
- } else if (impbfd == NULL) {
- ldsym->l_ifile = 0;
- } else {
- BFD_ASSERT (impbfd->xvec == output_bfd->xvec);
- ldsym->l_ifile = xcoff_data (impbfd)->import_file_id;
- }
+ if ((h->flags & XCOFF_ENTRY) != 0)
+ {
+ ldsym->l_smtype |= L_ENTRY;
+ }
+
+ if ((h->flags & XCOFF_RTINIT) != 0)
+ {
+ ldsym->l_smtype = XTY_SD;
+ }
+
+ ldsym->l_smclas = h->smclas;
+
+ if (ldsym->l_smtype & L_IMPORT)
+ {
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && (h->root.u.def.value != 0))
+ {
+ ldsym->l_smclas = XMC_XO;
+ }
+ else if ((h->flags & (XCOFF_SYSCALL32 | XCOFF_SYSCALL64)) ==
+ (XCOFF_SYSCALL32 | XCOFF_SYSCALL64))
+ {
+ ldsym->l_smclas = XMC_SV3264;
+ }
+ else if (h->flags & XCOFF_SYSCALL32)
+ {
+ ldsym->l_smclas = XMC_SV;
+ }
+ else if (h->flags & XCOFF_SYSCALL64)
+ {
+ ldsym->l_smclas = XMC_SV64;
+ }
+ }
+
+ if (ldsym->l_ifile == -(bfd_size_type) 1)
+ {
+ ldsym->l_ifile = 0;
+ }
+ else if (ldsym->l_ifile == 0)
+ {
+ if ((ldsym->l_smtype & L_IMPORT) == 0)
+ {
+ ldsym->l_ifile = 0;
+ }
+ else if (impbfd == NULL)
+ {
+ ldsym->l_ifile = 0;
+ }
+ else
+ {
+ BFD_ASSERT (impbfd->xvec == output_bfd->xvec);
+ ldsym->l_ifile = xcoff_data (impbfd)->import_file_id;
+ }
+ }
+
+ ldsym->l_parm = 0;
+
+ BFD_ASSERT (h->ldindx >= 0);
+
+ bfd_xcoff_swap_ldsym_out (output_bfd, ldsym,
+ (finfo->ldsym +
+ (h->ldindx - 3)
+ * bfd_xcoff_ldsymsz(finfo->output_bfd)));
+ h->ldsym = NULL;
}
-
- ldsym->l_parm = 0;
-
- BFD_ASSERT (h->ldindx >= 0);
-
- bfd_xcoff_swap_ldsym_out (output_bfd, ldsym, finfo->ldsym +
- (h->ldindx - 3) *
- bfd_xcoff_ldsymsz(finfo->output_bfd));
- h->ldsym = NULL;
- }
-
+
/* If this symbol needs global linkage code, write it out. */
- if (h->root.type == bfd_link_hash_defined &&
- (h->root.u.def.section ==
- xcoff_hash_table (finfo->info)->linkage_section)) {
+ if (h->root.type == bfd_link_hash_defined
+ && (h->root.u.def.section
+ == xcoff_hash_table (finfo->info)->linkage_section))
+ {
+ bfd_byte *p;
+ bfd_vma tocoff;
+ unsigned int i;
- bfd_byte *p;
- bfd_vma tocoff;
- unsigned int i;
-
- p = h->root.u.def.section->contents + h->root.u.def.value;
+ p = h->root.u.def.section->contents + h->root.u.def.value;
- /* The first instruction in the global linkage code loads a
- specific TOC element. */
- tocoff = (h->descriptor->toc_section->output_section->vma
- + h->descriptor->toc_section->output_offset
- - xcoff_data (output_bfd)->toc);
+ /* The first instruction in the global linkage code loads a
+ specific TOC element. */
+ tocoff = (h->descriptor->toc_section->output_section->vma
+ + h->descriptor->toc_section->output_offset
+ - xcoff_data (output_bfd)->toc);
- if ((h->descriptor->flags & XCOFF_SET_TOC) != 0) {
- tocoff += h->descriptor->u.toc_offset;
- }
-
-
- /*
- * The first instruction in the glink code needs to be cooked to
- * to hold the correct offset in the toc. The rest are just outputted
- * raw.
- */
- bfd_put_32 (output_bfd,
- bfd_xcoff_glink_code(output_bfd, 0) | (tocoff & 0xffff), p);
-
- /*
- * Start with i == 1 to get past the first instruction done above
- * The /4 is because the glink code is in bytes and we are going 4
- * at a pop
- */
- for (i = 1; i < bfd_xcoff_glink_code_size(output_bfd) / 4; i++) {
- bfd_put_32 (output_bfd, bfd_xcoff_glink_code(output_bfd, i),
- &p[4 * i]);
+ if ((h->descriptor->flags & XCOFF_SET_TOC) != 0)
+ {
+ tocoff += h->descriptor->u.toc_offset;
+ }
+
+
+ /* The first instruction in the glink code needs to be
+ cooked to to hold the correct offset in the toc. The
+ rest are just output raw. */
+ bfd_put_32 (output_bfd,
+ bfd_xcoff_glink_code(output_bfd, 0) | (tocoff & 0xffff), p);
+
+ /* Start with i == 1 to get past the first instruction done above
+ The /4 is because the glink code is in bytes and we are going
+ 4 at a pop. */
+ for (i = 1; i < bfd_xcoff_glink_code_size(output_bfd) / 4; i++)
+ {
+ bfd_put_32 (output_bfd,
+ (bfd_vma) bfd_xcoff_glink_code(output_bfd, i),
+ &p[4 * i]);
+ }
}
- }
/* If we created a TOC entry for this symbol, write out the required
relocs. */
+ h->u.toc_offset);
- if (h->indx >= 0) {
- irel->r_symndx = h->indx;
- } else {
- h->indx = -2;
- irel->r_symndx = obj_raw_syment_count (output_bfd);
- }
-
+ if (h->indx >= 0)
+ {
+ irel->r_symndx = h->indx;
+ }
+ else
+ {
+ h->indx = -2;
+ irel->r_symndx = obj_raw_syment_count (output_bfd);
+ }
+
BFD_ASSERT (h->ldindx >= 0);
- /*
- * Initialize the aux union here instead of closer to when it is
- * written out below because the length of the csect depends on
- * whether the output is 32 or 64 bit
- */
+ /* Initialize the aux union here instead of closer to when it is
+ written out below because the length of the csect depends on
+ whether the output is 32 or 64 bit. */
memset (&iraux, 0, sizeof iraux);
iraux.x_csect.x_smtyp = XTY_SD;
/* iraux.x_csect.x_scnlen.l = 4 or 8, see below */
iraux.x_csect.x_smclas = XMC_TC;
+ /* 32 bit uses a 32 bit R_POS to do the relocations
+ 64 bit uses a 64 bit R_POS to do the relocations
- /*
- * 32 bit uses a 32 bit R_POS to do the relocations
- * 64 bit uses a 64 bit R_POS to do the relocations
- *
- * Also needs to change the csect size : 4 for 32 bit, 8 for 64 bit
- *
- * Which one is determined by the backend
- */
- if (bfd_xcoff_is_xcoff64(output_bfd)) {
- irel->r_size = 63;
- iraux.x_csect.x_scnlen.l = 8;
- } else if (bfd_xcoff_is_xcoff32(output_bfd)) {
- irel->r_size = 31;
- iraux.x_csect.x_scnlen.l = 4;
- } else {
- return false;
- }
+ Also needs to change the csect size : 4 for 32 bit, 8 for 64 bit
+
+ Which one is determined by the backend. */
+ if (bfd_xcoff_is_xcoff64 (output_bfd))
+ {
+ irel->r_size = 63;
+ iraux.x_csect.x_scnlen.l = 8;
+ }
+ else if (bfd_xcoff_is_xcoff32 (output_bfd))
+ {
+ irel->r_size = 31;
+ iraux.x_csect.x_scnlen.l = 4;
+ }
+ else
+ {
+ return false;
+ }
irel->r_type = R_POS;
finfo->section_info[oindx].rel_hashes[osec->reloc_count] = NULL;
++osec->reloc_count;
bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd);
- /* We need to emit a symbol to define a csect which holds the reloc. */
- if (finfo->info->strip != strip_all) {
+ /* We need to emit a symbol to define a csect which holds
+ the reloc. */
+ if (finfo->info->strip != strip_all)
+ {
- result = bfd_xcoff_put_symbol_name (output_bfd, finfo->strtab, &irsym,
- h->root.root.string);
- if (false == result) {
- return false;
- }
+ result = bfd_xcoff_put_symbol_name (output_bfd, finfo->strtab,
+ &irsym, h->root.root.string);
+ if (false == result)
+ {
+ return false;
+ }
- irsym.n_value = irel->r_vaddr;
- irsym.n_scnum = osec->target_index;
- irsym.n_sclass = C_HIDEXT;
- irsym.n_type = T_NULL;
- irsym.n_numaux = 1;
+ irsym.n_value = irel->r_vaddr;
+ irsym.n_scnum = osec->target_index;
+ irsym.n_sclass = C_HIDEXT;
+ irsym.n_type = T_NULL;
+ irsym.n_numaux = 1;
- bfd_coff_swap_sym_out (output_bfd, (PTR) &irsym, (PTR) outsym);
- outsym += bfd_coff_symesz (output_bfd);
+ bfd_coff_swap_sym_out (output_bfd, (PTR) &irsym, (PTR) outsym);
+ outsym += bfd_coff_symesz (output_bfd);
- /* note : iraux is initialized above */
- bfd_coff_swap_aux_out (output_bfd, (PTR) &iraux, T_NULL, C_HIDEXT,
- 0, 1, (PTR) outsym);
- outsym += bfd_coff_auxesz (output_bfd);
+ /* note : iraux is initialized above */
+ bfd_coff_swap_aux_out (output_bfd, (PTR) &iraux, T_NULL, C_HIDEXT,
+ 0, 1, (PTR) outsym);
+ outsym += bfd_coff_auxesz (output_bfd);
- if (h->indx >= 0)
- {
- /* We aren't going to write out the symbols below, so we
+ if (h->indx >= 0)
+ {
+ /* We aren't going to write out the symbols below, so we
need to write them out now. */
- if (bfd_seek (output_bfd,
- (obj_sym_filepos (output_bfd)
- + (obj_raw_syment_count (output_bfd)
- * bfd_coff_symesz (output_bfd))),
- SEEK_SET) != 0
- || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1,
- output_bfd)
- != (bfd_size_type) (outsym - finfo->outsyms)))
+ pos = obj_sym_filepos (output_bfd);
+ pos += (obj_raw_syment_count (output_bfd)
+ * bfd_coff_symesz (output_bfd));
+ amt = outsym - finfo->outsyms;
+ if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (finfo->outsyms, amt, output_bfd) != amt)
return false;
obj_raw_syment_count (output_bfd) +=
(outsym - finfo->outsyms) / bfd_coff_symesz (output_bfd);
}
}
- /*
- * If this symbol is a specially defined function descriptor, write
- * it out. The first word is the address of the function code
- * itself, the second word is the address of the TOC, and the third
- * word is zero.
- *
- * 32 bit vs 64 bit
- * The addresses for the 32 bit will take 4 bytes and the addresses
- * for 64 bit will take 8 bytes. Similar for the relocs. This type
- * of logic was also done above to create a TOC entry in
- * xcoff_write_global_symbol
- */
+ /* If this symbol is a specially defined function descriptor, write
+ it out. The first word is the address of the function code
+ itself, the second word is the address of the TOC, and the third
+ word is zero.
+
+ 32 bit vs 64 bit
+ The addresses for the 32 bit will take 4 bytes and the addresses
+ for 64 bit will take 8 bytes. Similar for the relocs. This type
+ of logic was also done above to create a TOC entry in
+ xcoff_write_global_symbol. */
if ((h->flags & XCOFF_DESCRIPTOR) != 0
&& h->root.type == bfd_link_hash_defined
&& (h->root.u.def.section
asection *tsec;
unsigned int reloc_size, byte_size;
- if (bfd_xcoff_is_xcoff64(output_bfd)) {
- reloc_size = 63;
- byte_size = 8;
- } else if (bfd_xcoff_is_xcoff32(output_bfd)) {
- reloc_size = 31;
- byte_size = 4;
- } else {
- return false;
- }
+ if (bfd_xcoff_is_xcoff64 (output_bfd))
+ {
+ reloc_size = 63;
+ byte_size = 8;
+ }
+ else if (bfd_xcoff_is_xcoff32 (output_bfd))
+ {
+ reloc_size = 31;
+ byte_size = 4;
+ }
+ else
+ {
+ return false;
+ }
sec = h->root.u.def.section;
osec = sec->output_section;
bfd_xcoff_swap_ldrel_out (output_bfd, &ldrel, finfo->ldrel);
finfo->ldrel += bfd_xcoff_ldrelsz(output_bfd);
- /*
- * There are three items to write out,
- * the address of the code
- * the address of the toc anchor
- * the environment pointer.
- * We are ignoring the environment pointer. So set it to zero
- */
- if (bfd_xcoff_is_xcoff64(output_bfd)) {
- bfd_put_64 (output_bfd, (esec->output_section->vma +
- esec->output_offset +
- hentry->root.u.def.value), p);
- bfd_put_64 (output_bfd, xcoff_data (output_bfd)->toc, p + 8);
- bfd_put_64 (output_bfd, 0, p + 16);
- } else {
- /*
- * 32 bit backend
- *
- * This logic was already called above so the error case where
- * the backend is neither has already been checked
- */
- bfd_put_32 (output_bfd, (esec->output_section->vma +
- esec->output_offset +
- hentry->root.u.def.value), p);
- bfd_put_32 (output_bfd, xcoff_data (output_bfd)->toc, p + 4);
- bfd_put_32 (output_bfd, 0, p + 8);
- }
-
+ /* There are three items to write out,
+ the address of the code
+ the address of the toc anchor
+ the environment pointer.
+ We are ignoring the environment pointer. So set it to zero. */
+ if (bfd_xcoff_is_xcoff64 (output_bfd))
+ {
+ bfd_put_64 (output_bfd,
+ (esec->output_section->vma + esec->output_offset
+ + hentry->root.u.def.value),
+ p);
+ bfd_put_64 (output_bfd, xcoff_data (output_bfd)->toc, p + 8);
+ bfd_put_64 (output_bfd, (bfd_vma) 0, p + 16);
+ }
+ else
+ {
+ /* 32 bit backend
+ This logic was already called above so the error case where
+ the backend is neither has already been checked. */
+ bfd_put_32 (output_bfd,
+ (esec->output_section->vma + esec->output_offset
+ + hentry->root.u.def.value),
+ p);
+ bfd_put_32 (output_bfd, xcoff_data (output_bfd)->toc, p + 4);
+ bfd_put_32 (output_bfd, (bfd_vma) 0, p + 8);
+ }
+
tsec = coff_section_from_bfd_index (output_bfd,
xcoff_data (output_bfd)->sntoc);
if (h->indx != -2
&& (finfo->info->strip == strip_all
|| (finfo->info->strip == strip_some
- && (bfd_hash_lookup (finfo->info->keep_hash,
- h->root.root.string, false, false)
- == NULL))))
+ && bfd_hash_lookup (finfo->info->keep_hash, h->root.root.string,
+ false, false) == NULL)))
{
BFD_ASSERT (outsym == finfo->outsyms);
return true;
h->indx = obj_raw_syment_count (output_bfd);
- result = bfd_xcoff_put_symbol_name (output_bfd, finfo->strtab, &isym,
+ result = bfd_xcoff_put_symbol_name (output_bfd, finfo->strtab, &isym,
h->root.root.string);
- if (false == result) {
- return false;
- }
+ if (false == result)
+ {
+ return false;
+ }
if (h->root.type == bfd_link_hash_undefined
|| h->root.type == bfd_link_hash_undefweak)
outsym += bfd_coff_auxesz (output_bfd);
}
- if (bfd_seek (output_bfd,
- (obj_sym_filepos (output_bfd)
- + (obj_raw_syment_count (output_bfd)
- * bfd_coff_symesz (output_bfd))),
- SEEK_SET) != 0
- || (bfd_write (finfo->outsyms, outsym - finfo->outsyms, 1, output_bfd)
- != (bfd_size_type) (outsym - finfo->outsyms)))
+ pos = obj_sym_filepos (output_bfd);
+ pos += obj_raw_syment_count (output_bfd) * bfd_coff_symesz (output_bfd);
+ amt = outsym - finfo->outsyms;
+ if (bfd_seek (output_bfd, pos, SEEK_SET) != 0
+ || bfd_bwrite (finfo->outsyms, amt, output_bfd) != amt)
return false;
obj_raw_syment_count (output_bfd) +=
(outsym - finfo->outsyms) / bfd_coff_symesz (output_bfd);