From dc810e3900d47ab2eea86d50231ff2e70b596847 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 18 Sep 2001 09:57:26 +0000 Subject: Touches most files in bfd/, so likely will be blamed for everything.. o bfd_read and bfd_write lose an unnecessary param and become bfd_bread and bfd_bwrite. o bfd_*alloc now all take a bfd_size_type arg, and will error if size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files or bugs in linker scripts etc. o file_ptr becomes a bfd_signed_vma. Besides matching sizes with various other types involved in handling sections, this should make it easier for bfd to support a 64 bit off_t on 32 bit hosts that provide it. o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*) generally available. They now cast their args to bfd_vma and bfd_byte * as appropriate, which removes a swag of casts from the source. o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and aout-encap.c. o Zillions of formatting and -Wconversion fixes. --- bfd/ChangeLog | 547 ++++++++++ bfd/aix386-core.c | 62 +- bfd/aout-adobe.c | 60 +- bfd/aout-arm.c | 65 +- bfd/aout-cris.c | 6 +- bfd/aout-encap.c | 82 +- bfd/aout-ns32k.c | 21 +- bfd/aout-target.h | 19 +- bfd/aout-tic30.c | 35 +- bfd/aoutf1.h | 141 ++- bfd/aoutx.h | 259 +++-- bfd/archive.c | 223 ++-- bfd/archures.c | 9 +- bfd/bfd-in.h | 63 +- bfd/bfd-in2.h | 563 +++++----- bfd/bfd.c | 12 +- bfd/binary.c | 13 +- bfd/bout.c | 93 +- bfd/cache.c | 4 +- bfd/cisco-core.c | 39 +- bfd/coff-a29k.c | 12 +- bfd/coff-alpha.c | 126 ++- bfd/coff-arm.c | 219 ++-- bfd/coff-h8300.c | 52 +- bfd/coff-h8500.c | 10 +- bfd/coff-i386.c | 4 +- bfd/coff-i860.c | 4 +- bfd/coff-i960.c | 21 +- bfd/coff-ia64.c | 23 +- bfd/coff-m68k.c | 8 +- bfd/coff-m88k.c | 14 +- bfd/coff-mcore.c | 2 +- bfd/coff-mips.c | 77 +- bfd/coff-ppc.c | 189 ++-- bfd/coff-rs6000.c | 611 +++++------ bfd/coff-sh.c | 80 +- bfd/coff-sparc.c | 10 +- bfd/coff-stgo32.c | 15 +- bfd/coff-tic30.c | 4 +- bfd/coff-tic54x.c | 4 +- bfd/coff-tic80.c | 4 +- bfd/coff-w65.c | 12 +- bfd/coff-z8k.c | 6 +- bfd/coff64-rs6000.c | 2359 +++++++++++++++++++++--------------------- bfd/coffcode.h | 697 ++++++------- bfd/coffgen.c | 192 ++-- bfd/cofflink.c | 236 ++--- bfd/coffswap.h | 808 +++++++-------- bfd/configure | 195 ++-- bfd/configure.in | 169 ++- bfd/corefile.c | 4 +- bfd/cpu-arc.c | 2 + bfd/cpu-h8300.c | 2 - bfd/cpu-h8500.c | 7 +- bfd/cpu-i960.c | 10 +- bfd/cpu-ia64-opc.c | 2 +- bfd/cpu-ns32k.c | 150 +-- bfd/cpu-pdp11.c | 2 +- bfd/cpu-pj.c | 5 +- bfd/cpu-sh.c | 6 +- bfd/cpu-w65.c | 5 +- bfd/cpu-z8k.c | 9 +- bfd/dwarf1.c | 36 +- bfd/dwarf2.c | 109 +- bfd/ecoff.c | 308 +++--- bfd/ecofflink.c | 120 ++- bfd/ecoffswap.h | 439 ++++---- bfd/elf-bfd.h | 482 +++++---- bfd/elf-hppa.h | 54 +- bfd/elf-m10200.c | 40 +- bfd/elf-m10300.c | 114 +- bfd/elf.c | 366 +++---- bfd/elf32-arc.c | 2 +- bfd/elf32-arm.h | 170 +-- bfd/elf32-avr.c | 6 +- bfd/elf32-cris.c | 79 +- bfd/elf32-fr30.c | 17 +- bfd/elf32-gen.c | 2 +- bfd/elf32-h8300.c | 68 +- bfd/elf32-hppa.c | 105 +- bfd/elf32-i370.c | 31 +- bfd/elf32-i386.c | 42 +- bfd/elf32-i860.c | 17 +- bfd/elf32-m32r.c | 49 +- bfd/elf32-m68k.c | 54 +- bfd/elf32-mcore.c | 4 +- bfd/elf32-mips.c | 382 ++++--- bfd/elf32-openrisc.c | 6 +- bfd/elf32-pj.c | 12 +- bfd/elf32-ppc.c | 69 +- bfd/elf32-s390.c | 167 +-- bfd/elf32-sh-lin.c | 4 +- bfd/elf32-sh.c | 121 ++- bfd/elf32-sparc.c | 40 +- bfd/elf32-v850.c | 39 +- bfd/elf64-alpha.c | 148 +-- bfd/elf64-hppa.c | 77 +- bfd/elf64-mips.c | 95 +- bfd/elf64-ppc.c | 53 +- bfd/elf64-s390.c | 71 +- bfd/elf64-sparc.c | 141 +-- bfd/elf64-x86-64.c | 50 +- bfd/elfarm-nabi.c | 2 +- bfd/elfcode.h | 287 ++--- bfd/elfcore.h | 18 +- bfd/elflink.c | 10 +- bfd/elflink.h | 501 ++++----- bfd/elfxx-ia64.c | 122 ++- bfd/elfxx-target.h | 5 +- bfd/format.c | 11 +- bfd/hash.c | 14 +- bfd/hp300hpux.c | 55 +- bfd/hppabsd-core.c | 12 +- bfd/hpux-core.c | 42 +- bfd/i386aout.c | 4 +- bfd/i386dynix.c | 4 +- bfd/i386linux.c | 49 +- bfd/i386lynx.c | 35 +- bfd/i386mach3.c | 2 +- bfd/i386msdos.c | 29 +- bfd/i386os9k.c | 58 +- bfd/ieee.c | 237 +++-- bfd/ihex.c | 71 +- bfd/irix-core.c | 25 +- bfd/libaout.h | 330 +++--- bfd/libbfd-in.h | 23 +- bfd/libbfd.c | 251 +++-- bfd/libbfd.h | 27 +- bfd/libcoff-in.h | 103 +- bfd/libcoff.h | 598 +++++------ bfd/libecoff.h | 5 +- bfd/libieee.h | 22 +- bfd/libnlm.h | 6 +- bfd/libpei.h | 140 +-- bfd/libxcoff.h | 52 +- bfd/linker.c | 103 +- bfd/lynx-core.c | 26 +- bfd/m68klinux.c | 41 +- bfd/merge.c | 61 +- bfd/mipsbsd.c | 19 +- bfd/netbsd-core.c | 232 +++-- bfd/nlm.c | 6 +- bfd/nlm32-alpha.c | 51 +- bfd/nlm32-i386.c | 24 +- bfd/nlm32-ppc.c | 54 +- bfd/nlm32-sparc.c | 33 +- bfd/nlmcode.h | 422 ++++---- bfd/nlmswap.h | 140 +-- bfd/ns32k.h | 14 +- bfd/oasys.c | 269 +++-- bfd/opncls.c | 51 +- bfd/osf-core.c | 29 +- bfd/pc532-mach.c | 16 +- bfd/pdp11.c | 219 ++-- bfd/pe-mips.c | 28 +- bfd/peXXigen.c | 436 ++++---- bfd/peicode.h | 165 ++- bfd/ppcboot.c | 21 +- bfd/ptrace-core.c | 14 +- bfd/reloc.c | 237 ++--- bfd/reloc16.c | 26 +- bfd/riscix.c | 132 +-- bfd/rs6000-core.c | 28 +- bfd/sco5-core.c | 49 +- bfd/section.c | 54 +- bfd/som.c | 1079 +++++++++---------- bfd/sparclinux.c | 40 +- bfd/sparclynx.c | 8 +- bfd/srec.c | 74 +- bfd/stabs.c | 36 +- bfd/sunos.c | 176 ++-- bfd/syms.c | 45 +- bfd/targets.c | 403 ++++---- bfd/tekhex.c | 73 +- bfd/trad-core.c | 20 +- bfd/versados.c | 68 +- bfd/vms-gsd.c | 138 +-- bfd/vms-hdr.c | 3 +- bfd/vms-misc.c | 54 +- bfd/vms-tir.c | 1784 ++++++++++++++++---------------- bfd/vms.c | 51 +- bfd/vms.h | 3 +- bfd/xcofflink.c | 2816 ++++++++++++++++++++++++++------------------------ 183 files changed, 13588 insertions(+), 12305 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 2dcc025..8d65726 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,550 @@ +2001-09-18 Alan Modra + + * 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 for binutils headers. + (encap_object_p): Half baked attempt to fix compile errors in + code dealing with "magic". + + * aout-ns32k.c: Include "file", not 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 * elflink.h (elf_link_input_bfd): Fix typo in error message. diff --git a/bfd/aix386-core.c b/bfd/aix386-core.c index 09d4098..10cfb51 100644 --- a/bfd/aix386-core.c +++ b/bfd/aix386-core.c @@ -1,7 +1,8 @@ /* 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 . Converted to back end form by Ian Lance Taylor . @@ -72,14 +73,16 @@ aix386_core_file_p (abfd) { 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); @@ -89,19 +92,21 @@ aix386_core_file_p (abfd) 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; } @@ -111,38 +116,23 @@ aix386_core_file_p (abfd) /* 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) { @@ -193,8 +183,8 @@ aix386_core_file_p (abfd) 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 = @@ -243,15 +233,15 @@ swap_abort () 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), diff --git a/bfd/aout-adobe.c b/bfd/aout-adobe.c index b31640a..5a168b0 100644 --- a/bfd/aout-adobe.c +++ b/bfd/aout-adobe.c @@ -39,16 +39,17 @@ static void aout_adobe_write_section PARAMS ((bfd *abfd, sec_ptr sect)); 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) @@ -59,7 +60,7 @@ 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); @@ -72,10 +73,9 @@ aout_adobe_swap_exec_header_in (abfd, raw_bytes, execp) /* 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; @@ -86,7 +86,7 @@ aout_adobe_swap_exec_header_out (abfd, execp, 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); @@ -103,16 +103,16 @@ aout_adobe_object_p (abfd) 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 @@ -154,7 +154,7 @@ aout_adobe_callback (abfd) 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); @@ -163,7 +163,8 @@ aout_adobe_callback (abfd) /* 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); @@ -215,7 +216,8 @@ aout_adobe_callback (abfd) /* 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); @@ -226,11 +228,11 @@ aout_adobe_callback (abfd) 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. */ @@ -273,8 +275,9 @@ aout_adobe_mkobject (abfd) 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; @@ -297,6 +300,7 @@ aout_adobe_write_object_contents (abfd) 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; @@ -334,9 +338,9 @@ aout_adobe_write_object_contents (abfd) 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 @@ -355,8 +359,8 @@ aout_adobe_write_object_contents (abfd) 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. */ @@ -454,10 +458,10 @@ aout_adobe_set_section_contents (abfd, section, location, offset, count) 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 diff --git a/bfd/aout-arm.c b/bfd/aout-arm.c index cec21ff..5ac8a61 100644 --- a/bfd/aout-arm.c +++ b/bfd/aout-arm.c @@ -25,14 +25,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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 @@ -47,15 +47,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 *)); reloc_howto_type MY(howto_table)[] = { @@ -139,7 +154,7 @@ 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; { @@ -248,7 +263,7 @@ MY(fix_pcrel_26) (abfd, reloc_entry, symbol, data, input_section, { 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. */ @@ -280,10 +295,10 @@ MY(fix_pcrel_26) (abfd, reloc_entry, symbol, data, input_section, 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); @@ -307,7 +322,7 @@ MY(bfd_reloc_type_lookup) (abfd,code) code = BFD_RELOC_32; break; default: - return (CONST struct reloc_howto_struct *) 0; + return (const struct reloc_howto_struct *) 0; } switch (code) @@ -319,7 +334,7 @@ MY(bfd_reloc_type_lookup) (abfd,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; } } @@ -345,7 +360,7 @@ MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount) 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); @@ -539,7 +554,7 @@ const bfd_target aout_arm_big_vec = BFD_JUMP_TABLE_WRITE (MY), BFD_JUMP_TABLE_LINK (MY), BFD_JUMP_TABLE_DYNAMIC (MY), - + & aout_arm_little_vec, (PTR) MY_backend_data, diff --git a/bfd/aout-cris.c b/bfd/aout-cris.c index 32357f4..ab92df5 100644 --- a/bfd/aout-cris.c +++ b/bfd/aout-cris.c @@ -1,5 +1,5 @@ /* 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. @@ -37,7 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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 @@ -158,7 +158,7 @@ MY(swap_ext_reloc_out) (abfd, g, natptr) 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; diff --git a/bfd/aout-encap.c b/bfd/aout-encap.c index 77d6358..921bdd3 100644 --- a/bfd/aout-encap.c +++ b/bfd/aout-encap.c @@ -1,5 +1,6 @@ /* 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. @@ -27,9 +28,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #endif #include "bfd.h" -#include +#include "sysdep.h" #include "libbfd.h" -#include +#include "aout/aout64.h" #include "aout/stab_gnu.h" #include "aout/ar.h" #include "libaout.h" /* BFD a.out internal data structures */ @@ -45,33 +46,34 @@ encap_object_p (abfd) 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); @@ -90,24 +92,26 @@ encap_real_callback (abfd) 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 */ @@ -127,10 +131,10 @@ encap_write_object_contents (abfd) 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. diff --git a/bfd/aout-ns32k.c b/bfd/aout-ns32k.c index e431339..dd0e0fb 100644 --- a/bfd/aout-ns32k.c +++ b/bfd/aout-ns32k.c @@ -59,7 +59,7 @@ 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 *, +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. @@ -78,16 +78,16 @@ MY(put_reloc) PARAMS ((bfd *, int, int, long, reloc_howto_type *, 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. */ @@ -180,14 +180,15 @@ MY(reloc_howto) (abfd, rel, r_index, r_extern, r_pcrel) 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; { @@ -219,7 +220,7 @@ MY(put_reloc) (abfd, r_extern, r_index, value, howto, reloc) #define MY_final_link_relocate _bfd_ns32k_final_link_relocate #define MY_relocate_contents _bfd_ns32k_relocate_contents -#include +#include "aoutx.h" reloc_howto_type * MY(bfd_reloc_type_lookup) (abfd,code) @@ -280,7 +281,7 @@ MY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount) 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); @@ -349,8 +350,8 @@ _bfd_ns32k_relocate_contents (howto, input_bfd, relocation, location) 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) { diff --git a/bfd/aout-target.h b/bfd/aout-target.h index 6cf185a..ccedb93 100644 --- a/bfd/aout-target.h +++ b/bfd/aout-target.h @@ -88,9 +88,9 @@ MY(callback) (abfd) /* 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 @@ -146,13 +146,14 @@ MY(object_p) (abfd) 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); @@ -328,7 +329,7 @@ MY(set_sizes) (abfd) #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, diff --git a/bfd/aout-tic30.c b/bfd/aout-tic30.c index 5d25c20..3fad7ac 100644 --- a/bfd/aout-tic30.c +++ b/bfd/aout-tic30.c @@ -57,13 +57,18 @@ static const bfd_target *tic30_aout_object_p PARAMS ((bfd *)); 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) @@ -107,7 +112,7 @@ boolean tic30_aout_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, unsigne #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, @@ -352,7 +357,7 @@ tic30_aout_callback (abfd) #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 @@ -496,7 +501,9 @@ tic30_aout_relocate_contents (howto, input_bfd, relocation, location) 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; @@ -538,9 +545,9 @@ tic30_aout_object_p (abfd) 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); @@ -550,7 +557,7 @@ tic30_aout_object_p (abfd) #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)) @@ -638,9 +645,11 @@ tic30_aout_write_object_contents (abfd) 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; } diff --git a/bfd/aoutf1.h b/bfd/aoutf1.h index 5dbcdda..ff02136 100644 --- a/bfd/aoutf1.h +++ b/bfd/aoutf1.h @@ -1,5 +1,6 @@ /* 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. @@ -75,7 +76,7 @@ The name put into the target vector. #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 *)); @@ -113,11 +114,11 @@ sunos_merge_private_bfd_data (ibfd, obfd) 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) { @@ -422,8 +423,8 @@ swapcore_sun3 (abfd, ext, intcore) { 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 @@ -432,20 +433,21 @@ swapcore_sun3 (abfd, ext, intcore) 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 */ } @@ -458,8 +460,8 @@ swapcore_sparc (abfd, ext, intcore) { 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 @@ -468,20 +470,21 @@ swapcore_sparc (abfd, ext, intcore) 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. */ @@ -499,8 +502,7 @@ swapcore_sparc (abfd, ext, intcore) #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 @@ -518,8 +520,8 @@ swapcore_solaris_bcp (abfd, ext, intcore) 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); @@ -534,12 +536,11 @@ swapcore_solaris_bcp (abfd, ext, intcore) 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); @@ -547,9 +548,10 @@ swapcore_solaris_bcp (abfd, ext, intcore) 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. */ @@ -567,8 +569,7 @@ swapcore_solaris_bcp (abfd, ext, intcore) #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 @@ -598,7 +599,7 @@ sunos4_core_file_p (abfd) 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; @@ -607,37 +608,38 @@ sunos4_core_file_p (abfd) 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; } @@ -659,8 +661,7 @@ sunos4_core_file_p (abfd) 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; @@ -668,33 +669,23 @@ sunos4_core_file_p (abfd) /* 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"; @@ -822,7 +813,7 @@ sunos4_set_sizes (abfd) #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 */ diff --git a/bfd/aoutx.h b/bfd/aoutx.h index e343f99..2403485 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -367,7 +367,7 @@ NAME(aout,swap_exec_header_in) (abfd, raw_bytes, execp) 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); @@ -402,7 +402,7 @@ NAME(aout,swap_exec_header_out) (abfd, execp, raw_bytes) 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); @@ -455,8 +455,9 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p) { 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; @@ -674,22 +675,21 @@ boolean 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; } @@ -943,7 +943,7 @@ adjust_z_magic (abfd, execp) { 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); @@ -1271,7 +1271,7 @@ NAME(aout,set_section_contents) (abfd, section, location, offset, count) 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; } @@ -1288,6 +1288,7 @@ aout_get_external_symbols (abfd) { bfd_size_type count; struct external_nlist *syms; + bfd_size_type amt; count = exec_hdr (abfd)->a_syms / EXTERNAL_NLIST_SIZE; @@ -1302,13 +1303,13 @@ aout_get_external_symbols (abfd) 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; @@ -1325,11 +1326,11 @@ aout_get_external_symbols (abfd) 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); @@ -1339,15 +1340,14 @@ aout_get_external_symbols (abfd) 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; @@ -1478,6 +1478,7 @@ translate_from_native_sym_flags (abfd, cache_ptr) 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 @@ -1494,7 +1495,8 @@ translate_from_native_sym_flags (abfd, cache_ptr) { 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; @@ -1504,7 +1506,8 @@ translate_from_native_sym_flags (abfd, cache_ptr) 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; @@ -1735,8 +1738,8 @@ asymbol * 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; @@ -1779,9 +1782,9 @@ NAME(aout,translate_symbol_table) (abfd, in, ext, count, str, strsize, dynamic) 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)) @@ -1804,7 +1807,7 @@ NAME(aout,slurp_symbol_table) (abfd) { 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) @@ -1815,13 +1818,13 @@ NAME(aout,slurp_symbol_table) (abfd) 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) @@ -1915,10 +1918,11 @@ emit_stringtab (abfd, tab) 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); @@ -1941,6 +1945,7 @@ NAME(aout,write_syms) (abfd) 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) @@ -1949,22 +1954,22 @@ NAME(aout,write_syms) (abfd) 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 @@ -2112,7 +2117,7 @@ NAME(aout,swap_ext_reloc_out) (abfd, g, natptr) 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; @@ -2282,7 +2287,7 @@ NAME(aout,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount) 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)) { @@ -2340,13 +2345,14 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols) 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; @@ -2373,19 +2379,20 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols) 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); @@ -2395,21 +2402,19 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols) 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); @@ -2432,13 +2437,13 @@ NAME(aout,squirt_out_relocs) (abfd, section) 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; @@ -2461,10 +2466,11 @@ NAME(aout,squirt_out_relocs) (abfd, section) 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; @@ -2609,7 +2615,7 @@ NAME(aout,print_symbol) (abfd, afile, symbol, how) 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); @@ -2710,21 +2716,21 @@ NAME(aout,find_nearest_line) 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; @@ -2873,7 +2879,7 @@ NAME(aout,find_nearest_line) 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 @@ -2886,9 +2892,9 @@ NAME(aout,find_nearest_line) 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; } @@ -2998,9 +3004,9 @@ NAME(aout,link_hash_table_create) (abfd) 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, @@ -3136,7 +3142,7 @@ aout_link_check_ar_symbols (abfd, info, pneeded) 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; @@ -3300,6 +3306,7 @@ aout_link_add_symbols (abfd, info) 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); @@ -3320,10 +3327,8 @@ aout_link_add_symbols (abfd, info) 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; @@ -3345,7 +3350,7 @@ aout_link_add_symbols (abfd, info) *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) @@ -3635,9 +3640,9 @@ NAME(aout,final_link) (abfd, info, callback) 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; @@ -3669,7 +3674,7 @@ NAME(aout,final_link) (abfd, info, callback) 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) { @@ -3938,14 +3943,12 @@ NAME(aout,final_link) (abfd, info, callback) && 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; } @@ -4066,9 +4069,9 @@ aout_link_write_symbols (finfo, input_bfd) 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) @@ -4089,7 +4092,7 @@ aout_link_write_symbols (finfo, input_bfd) 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; @@ -4112,7 +4115,7 @@ aout_link_write_symbols (finfo, input_bfd) 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; @@ -4383,7 +4386,7 @@ aout_link_write_symbols (finfo, input_bfd) { 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) @@ -4452,7 +4455,7 @@ aout_link_write_symbols (finfo, input_bfd) { 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) @@ -4473,11 +4476,9 @@ aout_link_write_symbols (finfo, input_bfd) /* 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) { @@ -4503,17 +4504,16 @@ aout_link_write_symbols (finfo, input_bfd) /* 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; @@ -4533,6 +4533,7 @@ aout_link_write_other_symbol (h, data) bfd_vma val; struct external_nlist outsym; bfd_size_type indx; + bfd_size_type amt; output_bfd = finfo->output_bfd; @@ -4609,12 +4610,12 @@ aout_link_write_other_symbol (h, data) 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 (); @@ -4622,9 +4623,9 @@ aout_link_write_other_symbol (h, data) 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 (); @@ -4668,7 +4669,7 @@ aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr, 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; } } @@ -4693,7 +4694,7 @@ aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr, 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; @@ -4703,8 +4704,7 @@ aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr, { 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; @@ -5362,7 +5362,7 @@ aout_link_input_section_ext (finfo, input_bfd, input_section, relocs, /* 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); @@ -5523,6 +5523,7 @@ aout_link_reloc_link_order (finfo, o, p) struct reloc_std_external srel; struct reloc_ext_external erel; PTR rel_ptr; + bfd_size_type amt; pr = p->u.reloc.p; @@ -5652,7 +5653,7 @@ aout_link_reloc_link_order (finfo, o, 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: @@ -5675,10 +5676,8 @@ aout_link_reloc_link_order (finfo, o, p) } 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; @@ -5711,17 +5710,15 @@ aout_link_reloc_link_order (finfo, o, p) | (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); diff --git a/bfd/archive.c b/bfd/archive.c index daa135e..1faf0c7 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -1,6 +1,6 @@ /* 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. @@ -173,9 +173,9 @@ boolean _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; @@ -284,10 +284,9 @@ _bfd_add_bfd_to_archive_cache (arch_bfd, filepos, new_elt) 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; @@ -358,14 +357,14 @@ _bfd_generic_read_ar_hdr_mag (abfd, mag) { 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) @@ -421,7 +420,7 @@ _bfd_generic_read_ar_hdr_mag (abfd, mag) 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); @@ -476,7 +475,7 @@ _bfd_generic_read_ar_hdr_mag (abfd, mag) 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'; } @@ -601,10 +600,11 @@ bfd_generic_archive_p (abfd) { 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); @@ -622,8 +622,8 @@ bfd_generic_archive_p (abfd) /* 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; @@ -700,7 +700,7 @@ bfd_generic_archive_p (abfd) /* 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 @@ -725,7 +725,7 @@ do_slurp_bsd_armap (abfd) 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); @@ -738,7 +738,7 @@ do_slurp_bsd_armap (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); @@ -747,7 +747,7 @@ do_slurp_bsd_armap (abfd) 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) @@ -762,9 +762,8 @@ do_slurp_bsd_armap (abfd) 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; @@ -772,8 +771,8 @@ do_slurp_bsd_armap (abfd) 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); @@ -796,13 +795,14 @@ do_slurp_coff_armap (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) @@ -810,7 +810,7 @@ do_slurp_coff_armap (abfd) 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); @@ -855,8 +855,8 @@ do_slurp_coff_armap (abfd) 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); @@ -886,7 +886,7 @@ do_slurp_coff_armap (abfd) { 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) { @@ -894,7 +894,7 @@ do_slurp_coff_armap (abfd) && 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); } @@ -917,14 +917,14 @@ bfd_slurp_armap (abfd) 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) @@ -961,8 +961,9 @@ bfd_slurp_bsd_armap_f2 (abfd) 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; @@ -970,7 +971,7 @@ bfd_slurp_bsd_armap_f2 (abfd) 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) @@ -987,7 +988,8 @@ bfd_slurp_bsd_armap_f2 (abfd) 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: @@ -995,8 +997,7 @@ bfd_slurp_bsd_armap_f2 (abfd) 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); @@ -1005,7 +1006,7 @@ bfd_slurp_bsd_armap_f2 (abfd) 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) @@ -1017,15 +1018,14 @@ bfd_slurp_bsd_armap_f2 (abfd) 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; @@ -1033,8 +1033,8 @@ bfd_slurp_bsd_armap_f2 (abfd) 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); @@ -1065,13 +1065,14 @@ _bfd_slurp_extended_name_table (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 && @@ -1085,8 +1086,8 @@ _bfd_slurp_extended_name_table (abfd) 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: @@ -1094,8 +1095,7 @@ _bfd_slurp_extended_name_table (abfd) 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); @@ -1145,8 +1145,8 @@ normalize (abfd, file) bfd *abfd; const char *file; { - CONST char *first; - CONST char *last; + const char *first; + const char *last; char *copy; first = file + strlen (file) - 1; @@ -1164,7 +1164,7 @@ normalize (abfd, file) 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; @@ -1242,7 +1242,7 @@ _bfd_construct_extended_name_table (abfd, trailing_slash, tabloc, tablen) 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; @@ -1390,6 +1390,7 @@ bfd_ar_hdr_from_filesystem (abfd, filename, member) struct areltdata *ared; struct ar_hdr *hdr; char *temp, *temp1; + bfd_size_type amt; if (member && (member->flags & BFD_IN_MEMORY) != 0) { @@ -1407,8 +1408,8 @@ bfd_ar_hdr_from_filesystem (abfd, filename, member) 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)); @@ -1535,7 +1536,7 @@ bfd_generic_stat_arch_elt (abfd, buf) 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. @@ -1575,13 +1576,13 @@ bfd_dont_truncate_arname (abfd, pathname, arhdr) 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 { @@ -1626,13 +1627,13 @@ bfd_bsd_truncate_arname (abfd, pathname, arhdr) 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 { @@ -1731,16 +1732,16 @@ _bfd_write_archive_contents (arch) 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; } @@ -1752,18 +1753,18 @@ _bfd_write_archive_contents (arch) 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; } } @@ -1775,7 +1776,8 @@ _bfd_write_archive_contents (arch) 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; @@ -1785,19 +1787,19 @@ _bfd_write_archive_contents (arch) 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; } } @@ -1835,25 +1837,27 @@ _bfd_compute_and_write_armap (arch, elength) 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; @@ -1885,7 +1889,7 @@ _bfd_compute_and_write_armap (arch, elength) 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; } @@ -1906,16 +1910,15 @@ _bfd_compute_and_write_armap (arch, elength) 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; @@ -1923,17 +1926,16 @@ _bfd_compute_and_write_armap (arch, elength) } 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; @@ -2011,18 +2013,18 @@ bsd_write_armap (arch, elength, map, orl_count, stridx) 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 { @@ -2030,25 +2032,26 @@ bsd_write_armap (arch, elength, map, orl_count, stridx) 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; } @@ -2056,7 +2059,7 @@ bsd_write_armap (arch, elength, map, orl_count, stridx) 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; } @@ -2105,7 +2108,7 @@ _bfd_archive_bsd_update_armap_timestamp (arch) 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. */ @@ -2146,7 +2149,7 @@ coff_write_armap (arch, elength, map, symbol_count, stridx) 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; @@ -2178,7 +2181,7 @@ coff_write_armap (arch, elength, map, symbol_count, stridx) /* 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; @@ -2197,7 +2200,7 @@ coff_write_armap (arch, elength, map, symbol_count, stridx) /* 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++; @@ -2215,7 +2218,7 @@ coff_write_armap (arch, elength, map, symbol_count, stridx) { 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; } @@ -2223,7 +2226,7 @@ coff_write_armap (arch, elength, map, symbol_count, stridx) 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; } diff --git a/bfd/archures.c b/bfd/archures.c index 49418b8..1a7ecbf 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -458,6 +458,7 @@ bfd_arch_list () 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; @@ -470,8 +471,8 @@ bfd_arch_list () } } - 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; @@ -751,7 +752,7 @@ bfd_default_scan (info, string) 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] == ':') @@ -773,7 +774,7 @@ bfd_default_scan (info, string) Attempt to match: ? */ 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) diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 079761f..bf81b5a 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -113,16 +113,6 @@ typedef enum bfd_boolean {false, true} boolean; 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 . - For now, try to avoid breaking stuff by not including 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 @@ -190,6 +180,17 @@ typedef unsigned long bfd_size_type; #endif /* not BFD64 */ +/* A pointer to a position in a file. */ +/* FIXME: This should be using off_t from . + For now, try to avoid breaking stuff by not including 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)); @@ -300,7 +301,10 @@ typedef struct carsym { 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 */ }; @@ -352,11 +356,11 @@ typedef struct _symbol_info { 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. */ @@ -482,14 +486,31 @@ extern void bfd_hash_traverse PARAMS ((struct bfd_hash_table *, /* 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. */ diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index b725dd4..4df6f1d 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -113,16 +113,6 @@ typedef enum bfd_boolean {false, true} boolean; 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 . - For now, try to avoid breaking stuff by not including 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 @@ -190,6 +180,17 @@ typedef unsigned long bfd_size_type; #endif /* not BFD64 */ +/* A pointer to a position in a file. */ +/* FIXME: This should be using off_t from . + For now, try to avoid breaking stuff by not including 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)); @@ -300,7 +301,10 @@ typedef struct carsym { 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 */ }; @@ -352,11 +356,11 @@ typedef struct _symbol_info { 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. */ @@ -482,14 +486,31 @@ extern void bfd_hash_traverse PARAMS ((struct bfd_hash_table *, /* 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. */ @@ -796,16 +817,16 @@ void 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)); @@ -814,7 +835,7 @@ boolean 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)); @@ -830,9 +851,9 @@ bfd_make_readable 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))) @@ -879,40 +900,88 @@ bfd_make_readable PARAMS ((bfd *abfd)); /* 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 @@ -1347,18 +1416,18 @@ boolean 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, \ @@ -1629,31 +1698,31 @@ bfd_arch_mach_octets_per_byte PARAMS ((enum bfd_architecture arch, 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; @@ -1661,155 +1730,156 @@ typedef enum bfd_reloc_status 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, @@ -2034,7 +2104,7 @@ which is filled by the linker. */ 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, @@ -2183,7 +2253,7 @@ to compensate for the borrow when the low bits are added. */ 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, @@ -2844,7 +2914,7 @@ typedef struct symbol_cache_entry /* 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 @@ -3024,7 +3094,7 @@ struct _bfd /* 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) */ @@ -3062,7 +3132,7 @@ struct _bfd 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. */ @@ -3330,7 +3400,7 @@ bfd_set_archive_head PARAMS ((bfd *output, bfd *new_head)); bfd * bfd_openr_next_archived_file PARAMS ((bfd *archive, bfd *previous)); -CONST char * +const char * bfd_core_file_failing_command PARAMS ((bfd *abfd)); int @@ -3396,27 +3466,27 @@ typedef struct bfd_target 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)\ @@ -3427,17 +3497,16 @@ CAT(NAME,_get_section_contents),\ 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)\ @@ -3449,23 +3518,23 @@ CAT(NAME,_bfd_set_private_flags),\ 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)\ @@ -3491,15 +3560,12 @@ CAT(NAME,_update_armap_timestamp) 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 *)); @@ -3518,37 +3584,34 @@ CAT(NAME,_find_nearest_line),\ 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, @@ -3559,22 +3622,21 @@ CAT(NAME,_minisymbol_to_symbol) 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)\ @@ -3587,34 +3649,33 @@ CAT(NAME,_bfd_final_link),\ 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)\ @@ -3623,14 +3684,14 @@ CAT(NAME,_canonicalize_dynamic_symtab),\ 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. */ @@ -3643,7 +3704,7 @@ boolean 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)); diff --git a/bfd/bfd.c b/bfd/bfd.c index aa3dd2a..067c021 100644 --- a/bfd/bfd.c +++ b/bfd/bfd.c @@ -70,7 +70,7 @@ CODE_FRAGMENT . {* 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) *} . @@ -108,7 +108,7 @@ CODE_FRAGMENT . 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. *} @@ -1235,14 +1235,14 @@ bfd_record_phdr (abfd, type, flags_valid, flags, at_valid, at, 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; diff --git a/bfd/binary.c b/bfd/binary.c index 7fd01b3..4d2fe03 100644 --- a/bfd/binary.c +++ b/bfd/binary.c @@ -1,5 +1,5 @@ /* 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, @@ -111,7 +111,7 @@ binary_object_p (abfd) && (bfd_external_binary_architecture != bfd_arch_unknown)) bfd_set_arch_info (abfd, bfd_lookup_arch (bfd_external_binary_architecture, 0)); } - + return abfd->xvec; } @@ -130,7 +130,7 @@ binary_get_section_contents (abfd, section, location, offset, count) 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; } @@ -151,7 +151,7 @@ mangle_name (abfd, suffix) bfd *abfd; char *suffix; { - int size; + bfd_size_type size; char *buf; char *p; @@ -183,8 +183,9 @@ binary_get_symtab (abfd, alocation) 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; @@ -225,7 +226,7 @@ static asymbol * 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 diff --git a/bfd/bout.c b/bfd/bout.c index fb6b475..012d844 100644 --- a/bfd/bout.c +++ b/bfd/bout.c @@ -67,7 +67,7 @@ bout_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); @@ -95,7 +95,7 @@ bout_swap_exec_header_out (abfd, execp, raw_bytes) 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); @@ -117,16 +117,16 @@ b_out_object_p (abfd) { 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)) { @@ -206,17 +206,18 @@ b_out_mkobject (abfd) 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; } @@ -257,6 +258,7 @@ b_out_write_object_contents (abfd) bfd *abfd; { struct external_exec swapped_hdr; + bfd_size_type amt; if (! aout_32_make_sections (abfd)) return false; @@ -282,9 +284,9 @@ b_out_write_object_contents (abfd) 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 */ @@ -311,7 +313,8 @@ b_out_write_object_contents (abfd) } 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) @@ -321,7 +324,8 @@ b_out_write_object_contents (abfd) 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; @@ -372,7 +376,7 @@ calljx_callback (abfd, link_info, reloc_entry, src, dst, input_section) 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)); @@ -380,7 +384,7 @@ calljx_callback (abfd, link_info, reloc_entry, src, dst, input_section) word += value + reloc_entry->addend; - bfd_put_32 (abfd, word, dst); + bfd_put_32 (abfd, (bfd_vma) word, dst); return bfd_reloc_ok; } @@ -445,7 +449,7 @@ callj_callback (abfd, link_info, reloc_entry, data, srcidx, dstidx, - 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; } @@ -520,14 +524,14 @@ b_out_slurp_reloc_table (abfd, asect, symbols) 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; @@ -559,7 +563,7 @@ b_out_slurp_reloc_table (abfd, asect, symbols) 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); @@ -567,15 +571,16 @@ b_out_slurp_reloc_table (abfd, asect, symbols) 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) @@ -611,7 +616,7 @@ b_out_slurp_reloc_table (abfd, asect, symbols) 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)) @@ -750,13 +755,14 @@ b_out_squirt_out_relocs (abfd, section) 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; @@ -789,7 +795,7 @@ b_out_squirt_out_relocs (abfd, section) 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; @@ -861,7 +867,7 @@ b_out_squirt_out_relocs (abfd, section) 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; @@ -965,10 +971,10 @@ b_out_set_section_contents (abfd, section, location, offset, count) 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 @@ -1151,7 +1157,7 @@ aligncode (abfd, input_section, r, shrink) 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 @@ -1196,10 +1202,10 @@ b_out_bfd_relax_section (abfd, i, link_info, again) /* 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; @@ -1212,7 +1218,7 @@ b_out_bfd_relax_section (abfd, i, link_info, again) { 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; @@ -1242,7 +1248,7 @@ b_out_bfd_relax_section (abfd, i, link_info, again) link_info); break; case ABS32CODE_SHRUNK: - shrink+=4; + shrink += 4; break; } } @@ -1287,7 +1293,7 @@ b_out_bfd_get_relocated_section_contents (output_bfd, link_info, link_order, 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; @@ -1297,7 +1303,7 @@ b_out_bfd_get_relocated_section_contents (output_bfd, link_info, link_order, 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, @@ -1366,7 +1372,8 @@ b_out_bfd_get_relocated_section_contents (output_bfd, link_info, link_order, 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); @@ -1394,7 +1401,7 @@ b_out_bfd_get_relocated_section_contents (output_bfd, link_info, link_order, + 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; @@ -1414,7 +1421,7 @@ b_out_bfd_get_relocated_section_contents (output_bfd, link_info, link_order, - 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; } diff --git a/bfd/cache.c b/bfd/cache.c index da16409..4e5ef2e 100644 --- a/bfd/cache.c +++ b/bfd/cache.c @@ -364,7 +364,9 @@ bfd_cache_lookup_worker (abfd) { 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; } diff --git a/bfd/cisco-core.c b/bfd/cisco-core.c index 97aad52..f9878a2 100644 --- a/bfd/cisco-core.c +++ b/bfd/cisco-core.c @@ -1,6 +1,5 @@ /* 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. @@ -65,11 +64,17 @@ typedef struct { 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; - + 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 *)); /* Examine the file for a crash info struct at the offset given by CRASH_INFO_LOC. */ @@ -88,11 +93,12 @@ cisco_core_file_validate (abfd, 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) @@ -101,14 +107,14 @@ cisco_core_file_validate (abfd, crash_info_loc) } 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) @@ -147,9 +153,8 @@ cisco_core_file_validate (abfd, crash_info_loc) /* 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; @@ -238,7 +243,7 @@ cisco_core_file_validate (abfd, crash_info_loc) /* 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"; @@ -257,7 +262,7 @@ cisco_core_file_validate (abfd, crash_info_loc) /* 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"; @@ -272,7 +277,7 @@ cisco_core_file_validate (abfd, crash_info_loc) /* 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"; @@ -322,22 +327,22 @@ cisco_core_file_p (abfd) 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; } diff --git a/bfd/coff-a29k.c b/bfd/coff-a29k.c index d4ae1e1..e1e193a 100644 --- a/bfd/coff-a29k.c +++ b/bfd/coff-a29k.c @@ -154,14 +154,14 @@ a29k_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, } 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); @@ -187,7 +187,7 @@ a29k_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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); @@ -201,12 +201,12 @@ a29k_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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"); @@ -482,7 +482,7 @@ coff_a29k_relocate_section (output_bfd, info, input_bfd, input_section, 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: diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index cad190f..49bf017 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -76,32 +76,32 @@ static bfd *alpha_ecoff_get_elt_at_index PARAMS ((bfd *, symindex)); 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 @@ -530,8 +530,8 @@ alpha_ecoff_swap_reloc_in (abfd, ext_ptr, intern) { 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)); @@ -603,8 +603,8 @@ alpha_ecoff_swap_reloc_out (abfd, intern, dst) 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)); @@ -771,7 +771,7 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order, 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; @@ -1277,7 +1277,7 @@ alpha_convert_external_reloc (output_bfd, info, input_bfd, ext_rel, h) 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': @@ -1356,8 +1356,7 @@ alpha_convert_external_reloc (output_bfd, info, input_bfd, ext_rel, h) } /* 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; } @@ -1384,6 +1383,7 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, 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 @@ -1391,10 +1391,8 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, 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; @@ -1451,9 +1449,9 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, 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; } @@ -1522,8 +1520,8 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, 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); @@ -1552,9 +1550,8 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, 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; @@ -1751,8 +1748,7 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, 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 { @@ -1979,12 +1975,12 @@ alpha_relocate_section (output_bfd, info, input_bfd, input_section, 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) @@ -2062,12 +2058,12 @@ alpha_ecoff_read_ar_hdr (abfd) /* 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; @@ -2105,20 +2101,20 @@ alpha_ecoff_get_elt_at_filepos (archive, filepos) 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; @@ -2137,7 +2133,7 @@ alpha_ecoff_get_elt_at_filepos (archive, filepos) 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 @@ -2148,7 +2144,7 @@ alpha_ecoff_get_elt_at_filepos (archive, filepos) 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; @@ -2160,7 +2156,7 @@ alpha_ecoff_get_elt_at_filepos (archive, filepos) 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; } @@ -2183,7 +2179,7 @@ alpha_ecoff_get_elt_at_filepos (archive, filepos) /* 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; diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c index 6488ee7..8dcb3bb 100644 --- a/bfd/coff-arm.c +++ b/bfd/coff-arm.c @@ -36,18 +36,39 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* 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])) @@ -79,20 +100,21 @@ static boolean coff_arm_adjust_symndx 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 *)); @@ -146,8 +168,9 @@ coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, 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) { @@ -168,7 +191,7 @@ coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, { short x = bfd_get_16 (abfd, addr); DOIT (x); - bfd_put_16 (abfd, x, addr); + bfd_put_16 (abfd, (bfd_vma) x, addr); } break; @@ -176,7 +199,7 @@ coff_arm_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, { long x = bfd_get_32 (abfd, addr); DOIT (x); - bfd_put_32 (abfd, x, addr); + bfd_put_32 (abfd, (bfd_vma) x, addr); } break; @@ -636,12 +659,12 @@ aoutarm_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section, 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. */ @@ -757,16 +780,18 @@ coff_thumb_pcrel_common (abfd, reloc_entry, symbol, data, input_section, 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. */ @@ -788,7 +813,8 @@ coff_thumb_pcrel_23 (abfd, reloc_entry, symbol, data, input_section, 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 @@ -803,7 +829,8 @@ coff_thumb_pcrel_12 (abfd, reloc_entry, symbol, data, input_section, 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 @@ -818,10 +845,11 @@ coff_thumb_pcrel_9 (abfd, reloc_entry, symbol, data, input_section, 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; @@ -835,7 +863,7 @@ coff_arm_reloc_type_lookup (abfd, code) code = BFD_RELOC_32; break; default: - return (CONST struct reloc_howto_struct *) 0; + return (const struct reloc_howto_struct *) 0; } switch (code) @@ -860,7 +888,7 @@ coff_arm_reloc_type_lookup (abfd, 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; } } @@ -881,10 +909,10 @@ struct coff_arm_link_hash_table 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; @@ -904,9 +932,9 @@ coff_arm_link_hash_table_create (abfd) 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; @@ -992,7 +1020,8 @@ insert_thumb_branch (br_insn, rel_off) 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; @@ -1000,15 +1029,15 @@ insert_thumb_branch (br_insn, rel_off) 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); @@ -1029,15 +1058,15 @@ find_thumb_glue (info, name, input_bfd) 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); @@ -1211,7 +1240,8 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, && 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, @@ -1311,7 +1341,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, { /* 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; @@ -1353,10 +1383,10 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, --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. */ @@ -1365,7 +1395,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, if (info->base_file) arm_emit_base_file_entry (info, output_bfd, s, - my_offset + 8); + my_offset + 8); } @@ -1388,8 +1418,8 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, 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; } } @@ -1404,7 +1434,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, { /* 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; @@ -1452,22 +1482,22 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, 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. */ @@ -1475,14 +1505,15 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, 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 = @@ -1495,7 +1526,7 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, + 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); } @@ -1516,9 +1547,9 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, - 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; } @@ -1558,7 +1589,8 @@ coff_arm_relocate_section (output_bfd, info, input_bfd, input_section, { /* 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 */ @@ -1790,10 +1822,10 @@ bfd_arm_allocate_interworking_sections (info) 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; @@ -1809,10 +1841,10 @@ bfd_arm_allocate_interworking_sections (info) 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; @@ -1832,6 +1864,8 @@ record_arm_to_thumb_glue (info, h) 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); @@ -1843,8 +1877,8 @@ record_arm_to_thumb_glue (info, h) 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); @@ -1863,10 +1897,9 @@ record_arm_to_thumb_glue (info, h) 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); @@ -1886,6 +1919,8 @@ record_thumb_to_arm_glue (info, h) 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); @@ -1897,7 +1932,8 @@ record_thumb_to_arm_glue (info, h) 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); @@ -1912,10 +1948,10 @@ record_thumb_to_arm_glue (info, h) 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; @@ -1927,18 +1963,17 @@ record_thumb_to_arm_glue (info, h) #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); @@ -2474,7 +2509,7 @@ coff_arm_is_local_label_name (abfd, 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; diff --git a/bfd/coff-h8300.c b/bfd/coff-h8300.c index 1a4f166..7ce4208 100644 --- a/bfd/coff-h8300.c +++ b/bfd/coff-h8300.c @@ -184,11 +184,13 @@ h8300_coff_link_hash_table_create (abfd) 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; @@ -275,8 +277,8 @@ static reloc_howto_type howto_table[] = #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'; @@ -719,7 +721,7 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, /* 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; @@ -1055,8 +1057,8 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, /* 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; @@ -1097,7 +1099,7 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, 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 (); @@ -1107,8 +1109,8 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, 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 @@ -1147,7 +1149,7 @@ h8300_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, 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; } @@ -1180,6 +1182,7 @@ h8300_bfd_link_add_symbols (abfd, info) { 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) @@ -1201,8 +1204,8 @@ h8300_bfd_link_add_symbols (abfd, info) 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; @@ -1238,7 +1241,7 @@ h8300_bfd_link_add_symbols (abfd, info) 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; @@ -1269,13 +1272,15 @@ h8300_bfd_link_add_symbols (abfd, info) && 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 (); @@ -1286,15 +1291,14 @@ h8300_bfd_link_add_symbols (abfd, info) } /* 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); @@ -1318,15 +1322,15 @@ h8300_bfd_link_add_symbols (abfd, info) /* 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; diff --git a/bfd/coff-h8500.c b/bfd/coff-h8500.c index ecbb70f..05a8401 100644 --- a/bfd/coff-h8500.c +++ b/bfd/coff-h8500.c @@ -86,8 +86,8 @@ coff_h8500_select_reloc (howto) #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'; @@ -227,7 +227,7 @@ extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr) 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;; } @@ -235,7 +235,7 @@ extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr) 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;; } @@ -282,7 +282,7 @@ extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr) 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; diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c index 7d4ab5a..72c58a4 100644 --- a/bfd/coff-i386.c +++ b/bfd/coff-i386.c @@ -157,7 +157,7 @@ coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, { short x = bfd_get_16 (abfd, addr); DOIT (x); - bfd_put_16 (abfd, x, addr); + bfd_put_16 (abfd, (bfd_vma) x, addr); } break; @@ -165,7 +165,7 @@ coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, { long x = bfd_get_32 (abfd, addr); DOIT (x); - bfd_put_32 (abfd, x, addr); + bfd_put_32 (abfd, (bfd_vma) x, addr); } break; diff --git a/bfd/coff-i860.c b/bfd/coff-i860.c index 2bba55d..1355d49 100644 --- a/bfd/coff-i860.c +++ b/bfd/coff-i860.c @@ -114,7 +114,7 @@ coff_i860_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, { short x = bfd_get_16 (abfd, addr); DOIT (x); - bfd_put_16 (abfd, x, addr); + bfd_put_16 (abfd, (bfd_vma) x, addr); } break; @@ -122,7 +122,7 @@ coff_i860_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, { long x = bfd_get_32 (abfd, addr); DOIT (x); - bfd_put_32 (abfd, x, addr); + bfd_put_32 (abfd, (bfd_vma) x, addr); } break; diff --git a/bfd/coff-i960.c b/bfd/coff-i960.c index 53bb03a..d8948be 100644 --- a/bfd/coff-i960.c +++ b/bfd/coff-i960.c @@ -1,5 +1,5 @@ /* 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. @@ -48,8 +48,8 @@ static boolean coff_i960_adjust_symndx #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. */ @@ -156,7 +156,8 @@ optcall_callback (abfd, reloc_entry, symbol_in, data, 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; @@ -251,9 +252,8 @@ coff_i960_relocate (abfd, reloc_entry, symbol, data, input_section, 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; } @@ -350,7 +350,7 @@ coff_i960_start_final_link (abfd, info) 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; @@ -519,9 +519,8 @@ coff_i960_relocate_section (output_bfd, info, input_bfd, input_section, + (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; diff --git a/bfd/coff-ia64.c b/bfd/coff-ia64.c index 8452d96..76d1bf6 100644 --- a/bfd/coff-ia64.c +++ b/bfd/coff-ia64.c @@ -77,9 +77,9 @@ ia64coff_object_p (abfd) 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); @@ -96,23 +96,23 @@ ia64coff_object_p (abfd) 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); @@ -122,10 +122,7 @@ ia64coff_object_p (abfd) /* 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); diff --git a/bfd/coff-m68k.c b/bfd/coff-m68k.c index abab632..397d983 100644 --- a/bfd/coff-m68k.c +++ b/bfd/coff-m68k.c @@ -316,7 +316,7 @@ m68kcoff_common_addend_special_fn (abfd, reloc_entry, symbol, data, { short x = bfd_get_16 (abfd, addr); DOIT (x); - bfd_put_16 (abfd, x, addr); + bfd_put_16 (abfd, (bfd_vma) x, addr); } break; @@ -324,7 +324,7 @@ m68kcoff_common_addend_special_fn (abfd, reloc_entry, symbol, data, { long x = bfd_get_32 (abfd, addr); DOIT (x); - bfd_put_32 (abfd, x, addr); + bfd_put_32 (abfd, (bfd_vma) x, addr); } break; @@ -442,6 +442,7 @@ bfd_m68k_coff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg) bfd_size_type symesz; struct internal_reloc *irel, *irelend; bfd_byte *p; + bfd_size_type amt; BFD_ASSERT (! info->relocateable); @@ -457,7 +458,8 @@ bfd_m68k_coff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg) 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; diff --git a/bfd/coff-m88k.c b/bfd/coff-m88k.c index 8f92be2..05c47cc 100644 --- a/bfd/coff-m88k.c +++ b/bfd/coff-m88k.c @@ -1,5 +1,6 @@ /* 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. @@ -36,8 +37,8 @@ static void reloc_processing #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 '@'. */ @@ -115,7 +116,8 @@ m88k_special_reloc (abfd, reloc_entry, symbol, data, 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 @@ -251,8 +253,8 @@ rtype2howto (cache_ptr, dst) #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) diff --git a/bfd/coff-mcore.c b/bfd/coff-mcore.c index 0158eb2..8ddd06a 100644 --- a/bfd/coff-mcore.c +++ b/bfd/coff-mcore.c @@ -228,7 +228,7 @@ coff_mcore_link_hash_table_create (abfd) { 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; diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index 805824a..6e9cc6a 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -426,7 +426,7 @@ mips_ecoff_swap_reloc_in (abfd, ext_ptr, intern) { 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] @@ -503,7 +503,7 @@ mips_ecoff_swap_reloc_out (abfd, intern, dst) 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; @@ -691,7 +691,7 @@ mips_refhi_reloc (abfd, 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; @@ -758,8 +758,8 @@ mips_reflo_reloc (abfd, 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); @@ -854,7 +854,7 @@ mips_gprel_reloc (abfd, { 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) @@ -903,8 +903,8 @@ mips_gprel_reloc (abfd, || (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; @@ -982,7 +982,7 @@ mips_relhi_reloc (abfd, 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; @@ -1059,8 +1059,8 @@ mips_rello_reloc (abfd, 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); @@ -1223,7 +1223,7 @@ mips_relocate_hi (refhi, reflo, input_bfd, input_section, contents, adjust, 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); } @@ -1251,6 +1251,7 @@ mips_relocate_section (output_bfd, info, input_bfd, input_section, 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); @@ -1261,10 +1262,8 @@ mips_relocate_section (output_bfd, info, input_bfd, input_section, 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; @@ -1880,12 +1879,13 @@ mips_read_relocs (abfd, sec) 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; @@ -1897,20 +1897,14 @@ mips_read_relocs (abfd, sec) 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; } @@ -2009,6 +2003,7 @@ mips_relax_section (abfd, sec, info, again) 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. */ @@ -2085,7 +2080,7 @@ mips_relax_section (abfd, sec, info, 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, @@ -2118,13 +2113,13 @@ mips_relax_section (abfd, sec, info, again) 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; } @@ -2297,8 +2292,8 @@ mips_relax_section (abfd, sec, info, again) /* 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; @@ -2351,15 +2346,17 @@ mips_relax_pcrel16 (info, input_bfd, input_section, h, location, address) 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; } @@ -2386,6 +2383,7 @@ bfd_mips_ecoff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg) struct external_reloc *ext_rel; struct external_reloc *ext_rel_end; bfd_byte *p; + bfd_size_type amt; BFD_ASSERT (! info->relocateable); @@ -2399,7 +2397,8 @@ bfd_mips_ecoff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg) 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; diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c index 2bf296a..e77add6 100644 --- a/bfd/coff-ppc.c +++ b/bfd/coff-ppc.c @@ -202,9 +202,9 @@ ppc_coff_link_hash_table_create (abfd) 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, @@ -833,7 +833,7 @@ enum ref_category { priv, pub, - data + tocdata }; struct list_ele @@ -849,18 +849,19 @@ extern struct list_ele *head; 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; @@ -916,16 +917,16 @@ ppc_record_toc_entry(abfd, info, sec, sym, toc_kind) 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]); } } @@ -1199,7 +1200,7 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, 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); @@ -1246,13 +1247,10 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, 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]); @@ -1282,21 +1280,22 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, 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)) { @@ -1308,11 +1307,11 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, } 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); @@ -1331,8 +1330,8 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, 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; @@ -1341,23 +1340,20 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, } /* 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: @@ -1377,7 +1373,7 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, 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); } } } @@ -1432,7 +1428,6 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, case IMAGE_REL_PPC_ADDR32NB: { - struct coff_link_hash_entry *myh = 0; const char *name = 0; DUMP_RELOC2(howto->name, rel); @@ -1440,7 +1435,7 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, { /* 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); @@ -1480,7 +1475,7 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, if (target != 0) { - myh = 0; + struct coff_link_hash_entry *myh; myh = coff_link_hash_lookup (coff_hash_table (info), target, @@ -1654,7 +1649,7 @@ dump_toc (vfile) 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) @@ -1665,7 +1660,8 @@ dump_toc (vfile) { 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!"); } } @@ -1687,6 +1683,7 @@ ppc_allocate_toc_section (info) { 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? */ @@ -1705,8 +1702,9 @@ ppc_allocate_toc_section (info) 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; @@ -2321,11 +2319,11 @@ ppc_bfd_coff_final_link (abfd, info) 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; @@ -2333,6 +2331,7 @@ ppc_bfd_coff_final_link (abfd, info) bfd *sub; bfd_byte *external_relocs = NULL; char strbuf[STRING_SIZE_SIZE]; + bfd_size_type amt; symesz = bfd_coff_symesz (abfd); @@ -2433,10 +2432,9 @@ ppc_bfd_coff_final_link (abfd, info) /* 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++) @@ -2477,13 +2475,14 @@ ppc_bfd_coff_final_link (abfd, info) 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; @@ -2506,7 +2505,7 @@ ppc_bfd_coff_final_link (abfd, info) 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); @@ -2515,22 +2514,23 @@ ppc_bfd_coff_final_link (abfd, info) } /* 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) @@ -2649,14 +2649,14 @@ ppc_bfd_coff_final_link (abfd, info) 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; } @@ -2679,8 +2679,8 @@ ppc_bfd_coff_final_link (abfd, info) /* 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; @@ -2708,9 +2708,9 @@ ppc_bfd_coff_final_link (abfd, info) 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; } @@ -2744,21 +2744,22 @@ ppc_bfd_coff_final_link (abfd, info) /* 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)) diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index 3b02400..44ede25 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -76,10 +76,10 @@ void _bfd_xcoff_rtype2howto PARAMS ((arelent *, struct internal_reloc *)); #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 (); @@ -155,10 +155,9 @@ _bfd_xcoff_mkobject (abfd) 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); @@ -240,8 +239,6 @@ _bfd_xcoff_is_local_label_name (abfd, name) return false; } - - void _bfd_xcoff_swap_sym_in (abfd, ext1, in1) bfd *abfd; @@ -258,15 +255,14 @@ _bfd_xcoff_swap_sym_in (abfd, ext1, in1) 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 @@ -284,26 +280,18 @@ _bfd_xcoff_swap_sym_out (abfd, inp, extp) } 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; @@ -323,8 +311,8 @@ _bfd_xcoff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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 { @@ -346,18 +334,16 @@ _bfd_xcoff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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; @@ -367,12 +353,9 @@ _bfd_xcoff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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; @@ -384,38 +367,38 @@ _bfd_xcoff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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: ; @@ -445,10 +428,8 @@ _bfd_xcoff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) 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 { @@ -461,16 +442,16 @@ _bfd_xcoff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) 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; @@ -480,45 +461,44 @@ _bfd_xcoff_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) 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: @@ -913,7 +893,7 @@ _bfd_xcoff_rtype2howto (relent, internal) 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 @@ -1031,12 +1011,14 @@ _bfd_xcoff_slurp_armap (abfd) 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); @@ -1045,28 +1027,28 @@ _bfd_xcoff_slurp_armap (abfd) 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 { @@ -1084,13 +1066,14 @@ _bfd_xcoff_slurp_armap (abfd) 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 @@ -1102,28 +1085,28 @@ _bfd_xcoff_slurp_armap (abfd) 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. */ @@ -1153,8 +1136,9 @@ _bfd_xcoff_archive_p (abfd) 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); @@ -1171,9 +1155,8 @@ _bfd_xcoff_archive_p (abfd) /* 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; @@ -1192,8 +1175,9 @@ _bfd_xcoff_archive_p (abfd) 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); @@ -1203,7 +1187,8 @@ _bfd_xcoff_archive_p (abfd) 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; @@ -1218,8 +1203,9 @@ _bfd_xcoff_archive_p (abfd) 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); @@ -1232,7 +1218,8 @@ _bfd_xcoff_archive_p (abfd) 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; @@ -1255,10 +1242,11 @@ PTR _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; @@ -1267,22 +1255,23 @@ _bfd_xcoff_read_ar_hdr (abfd) 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; @@ -1298,7 +1287,7 @@ _bfd_xcoff_read_ar_hdr (abfd) 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); @@ -1306,16 +1295,15 @@ _bfd_xcoff_read_ar_hdr (abfd) } 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; @@ -1331,7 +1319,7 @@ _bfd_xcoff_read_ar_hdr (abfd) } /* 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; @@ -1486,12 +1474,14 @@ xcoff_write_armap_old (abfd, elength, map, orl_count, stridx) 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; @@ -1501,15 +1491,15 @@ xcoff_write_armap_old (abfd, elength, map, orl_count, stridx) { 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 @@ -1525,7 +1515,7 @@ xcoff_write_armap_old (abfd, elength, map, orl_count, stridx) 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; } @@ -1534,7 +1524,7 @@ xcoff_write_armap_old (abfd, elength, map, orl_count, stridx) char b; b = '\0'; - if (bfd_write (&b, 1, 1, abfd) != 1) + if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1) return false; } @@ -1579,7 +1569,7 @@ xcoff_write_one_armap_big (abfd, map, orl_count, orl_ccount, stridx, bits64, 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); @@ -1594,12 +1584,14 @@ xcoff_write_one_armap_big (abfd, map, orl_count, orl_ccount, stridx, bits64, 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; @@ -1609,20 +1601,20 @@ xcoff_write_one_armap_big (abfd, map, orl_count, orl_ccount, stridx, bits64, { 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 @@ -1636,7 +1628,7 @@ xcoff_write_one_armap_big (abfd, map, orl_count, orl_ccount, stridx, bits64, { 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); @@ -1645,7 +1637,7 @@ xcoff_write_one_armap_big (abfd, map, orl_count, orl_ccount, stridx, bits64, 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; } @@ -1654,7 +1646,7 @@ xcoff_write_one_armap_big (abfd, map, orl_count, orl_ccount, stridx, bits64, char b; b = '\0'; - if (bfd_write (&b, 1, 1, abfd) != 1) + if (bfd_bwrite (&b, (bfd_size_type) 1, abfd) != 1) return false; } @@ -1684,7 +1676,7 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) 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); @@ -1708,7 +1700,7 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) /* 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; @@ -1717,7 +1709,7 @@ xcoff_write_armap_big (abfd, elength, map, orl_count, stridx) xcoff_ardata_big (abfd)->symoff, xcoff_ardata_big (abfd)->symoff64)) return false; - + return true; } @@ -1743,14 +1735,14 @@ xcoff_write_archive_contents_old (abfd) 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; @@ -1772,7 +1764,7 @@ xcoff_write_archive_contents_old (abfd) 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); @@ -1782,7 +1774,7 @@ xcoff_write_archive_contents_old (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; @@ -1820,7 +1812,8 @@ xcoff_write_archive_contents_old (abfd) 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; } @@ -1833,7 +1826,7 @@ xcoff_write_archive_contents_old (abfd) /* 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 @@ -1855,9 +1848,10 @@ xcoff_write_archive_contents_old (abfd) 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; @@ -1871,8 +1865,8 @@ xcoff_write_archive_contents_old (abfd) 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; } @@ -1882,7 +1876,7 @@ xcoff_write_archive_contents_old (abfd) 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; } } @@ -1922,28 +1916,29 @@ xcoff_write_archive_contents_old (abfd) 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) @@ -1951,7 +1946,7 @@ xcoff_write_archive_contents_old (abfd) 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; } @@ -1976,8 +1971,8 @@ xcoff_write_archive_contents_old (abfd) *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; @@ -1988,14 +1983,14 @@ xcoff_write_archive_contents_big (abfd) 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; @@ -2017,7 +2012,7 @@ xcoff_write_archive_contents_big (abfd) 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); @@ -2027,7 +2022,7 @@ xcoff_write_archive_contents_big (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; @@ -2070,7 +2065,8 @@ xcoff_write_archive_contents_big (abfd) 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; } @@ -2086,7 +2082,7 @@ xcoff_write_archive_contents_big (abfd) /* 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 @@ -2108,10 +2104,10 @@ xcoff_write_archive_contents_big (abfd) 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; @@ -2125,8 +2121,8 @@ xcoff_write_archive_contents_big (abfd) 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; } @@ -2136,7 +2132,7 @@ xcoff_write_archive_contents_big (abfd) 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; } } @@ -2188,18 +2184,19 @@ xcoff_write_archive_contents_big (abfd) 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) @@ -2209,7 +2206,8 @@ xcoff_write_archive_contents_big (abfd) 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) @@ -2217,7 +2215,7 @@ xcoff_write_archive_contents_big (abfd) 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; } @@ -2244,8 +2242,8 @@ xcoff_write_archive_contents_big (abfd) *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; @@ -2315,7 +2313,7 @@ xcoff_swap_ldhdr_out (abfd, src, d) { 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); @@ -2363,11 +2361,12 @@ xcoff_swap_ldsym_out (abfd, src, d) 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); @@ -2402,8 +2401,8 @@ xcoff_swap_ldrel_out (abfd, src, d) 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); } @@ -2456,7 +2455,7 @@ xcoff_ppc_relocate_section (output_bfd, info, input_bfd, addend = 0; } else - { + { h = obj_xcoff_sym_hashes (input_bfd)[symndx]; sym = syms + symndx; addend = - sym->n_value; @@ -2715,12 +2714,16 @@ xcoff_ppc_relocate_section (output_bfd, info, input_bfd, 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); } } @@ -2785,7 +2788,7 @@ _bfd_xcoff_put_ldsymbol_name (abfd, ldinfo, ldsym, name) { if (ldinfo->string_size + len + 3 > ldinfo->string_alc) { - size_t newalc; + bfd_size_type newalc; bfd_byte *newstrings; newalc = ldinfo->string_alc * 2; @@ -2805,8 +2808,8 @@ _bfd_xcoff_put_ldsymbol_name (abfd, ldinfo, ldsym, name) 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; @@ -2817,7 +2820,7 @@ _bfd_xcoff_put_ldsymbol_name (abfd, ldinfo, ldsym, name) } 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) { @@ -2843,7 +2846,7 @@ _bfd_xcoff_put_symbol_name (bfd *abfd, struct bfd_strtab_hash *strtab, } 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; @@ -2856,13 +2859,13 @@ xcoff_create_csect_from_smclas (abfd, aux, 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 @@ -2876,7 +2879,7 @@ xcoff_create_csect_from_smclas (abfd, aux, symbol_name) return return_value; } -static boolean +static boolean xcoff_is_lineno_count_overflow (abfd, value) bfd *abfd ATTRIBUTE_UNUSED; bfd_vma value; @@ -2887,7 +2890,7 @@ xcoff_is_lineno_count_overflow (abfd, value) return false; } -static boolean +static boolean xcoff_is_reloc_count_overflow (abfd, value) bfd *abfd ATTRIBUTE_UNUSED; bfd_vma value; @@ -2911,29 +2914,29 @@ xcoff_loader_reloc_offset (abfd, ldhdr) 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] = @@ -2950,11 +2953,11 @@ 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 */ @@ -2993,10 +2996,10 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = 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 */ @@ -3005,7 +3008,7 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = 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 */ @@ -3070,7 +3073,7 @@ const bfd_target rs6000coff_vec = 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 */ @@ -3082,39 +3085,39 @@ const bfd_target rs6000coff_vec = 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), @@ -3127,12 +3130,12 @@ const bfd_target rs6000coff_vec = 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 */ @@ -3143,7 +3146,7 @@ const bfd_target rs6000coff_vec = _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 */ @@ -3179,37 +3182,37 @@ const bfd_target rs6000coff_vec = _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 */ @@ -3225,7 +3228,7 @@ static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data = 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 */ @@ -3240,7 +3243,7 @@ static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data = 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 */ @@ -3249,10 +3252,10 @@ static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data = 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 */ @@ -3298,7 +3301,7 @@ static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data = /* glink */ &xcoff_glink_code[0], (36), /* _xcoff_glink_size */ - + }; /* The transfer vector that leads the outside world to all of the above. */ @@ -3327,7 +3330,7 @@ const bfd_target pmac_xcoff_vec = 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 */ @@ -3339,39 +3342,39 @@ const bfd_target pmac_xcoff_vec = 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), @@ -3384,12 +3387,12 @@ const bfd_target pmac_xcoff_vec = 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 */ @@ -3400,7 +3403,7 @@ const bfd_target pmac_xcoff_vec = _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 */ @@ -3440,14 +3443,14 @@ const bfd_target pmac_xcoff_vec = /* 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, }; diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c index f3b74e9..eb1120b 100644 --- a/bfd/coff-sh.c +++ b/bfd/coff-sh.c @@ -379,8 +379,8 @@ static reloc_howto_type sh_coff_howtos[] = #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) \ @@ -589,14 +589,14 @@ sh_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, #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: @@ -610,7 +610,7 @@ sh_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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; @@ -784,7 +784,7 @@ sh_relax_section (abfd, sec, link_info, again) 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) @@ -886,8 +886,8 @@ sh_relax_section (abfd, sec, link_info, again) 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; } @@ -914,7 +914,7 @@ sh_relax_section (abfd, sec, link_info, again) 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 @@ -922,7 +922,8 @@ sh_relax_section (abfd, sec, link_info, again) /* 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 @@ -1023,8 +1024,8 @@ sh_relax_section (abfd, sec, link_info, again) { 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; } @@ -1056,8 +1057,8 @@ sh_relax_section (abfd, sec, link_info, again) /* 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; @@ -1117,7 +1118,8 @@ sh_relax_delete_bytes (abfd, sec, addr, 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)); if (irelalign == NULL) sec->_cooked_size -= count; else @@ -1128,7 +1130,7 @@ sh_relax_delete_bytes (abfd, sec, addr, count) 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. */ @@ -1314,14 +1316,14 @@ sh_relax_delete_bytes (abfd, sec, addr, count) 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: @@ -1335,26 +1337,26 @@ sh_relax_delete_bytes (abfd, sec, addr, count) } 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: @@ -1517,7 +1519,7 @@ sh_relax_delete_bytes (abfd, sec, addr, count) { /* Tail recursion. */ return sh_relax_delete_bytes (abfd, sec, alignaddr, - alignto - alignaddr); + (int) (alignto - alignaddr)); } } @@ -2643,13 +2645,15 @@ sh_align_loads (abfd, sec, internal_relocs, contents, pswapped) 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; @@ -2718,8 +2722,8 @@ sh_swap_insns (abfd, sec, relocs, contents, addr) /* 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; @@ -2787,7 +2791,7 @@ sh_swap_insns (abfd, sec, relocs, contents, addr) 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: @@ -2796,7 +2800,7 @@ sh_swap_insns (abfd, sec, relocs, contents, addr) 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: @@ -2813,7 +2817,7 @@ sh_swap_insns (abfd, sec, relocs, contents, addr) 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; @@ -3035,7 +3039,7 @@ sh_coff_get_relocated_section_contents (output_bfd, link_info, link_order, 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) @@ -3044,6 +3048,7 @@ sh_coff_get_relocated_section_contents (output_bfd, link_info, link_order, 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; @@ -3054,14 +3059,15 @@ sh_coff_get_relocated_section_contents (output_bfd, link_info, link_order, 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; diff --git a/bfd/coff-sparc.c b/bfd/coff-sparc.c index fb12fc1..35c23df 100644 --- a/bfd/coff-sparc.c +++ b/bfd/coff-sparc.c @@ -37,7 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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, @@ -57,7 +57,7 @@ enum reloc_type }; #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", @@ -134,7 +134,7 @@ struct coff_reloc_map { 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, }, @@ -188,8 +188,8 @@ rtype2howto (cache_ptr, dst) #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; diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c index bd9d00a..5d867ea 100644 --- a/bfd/coff-stgo32.c +++ b/bfd/coff-stgo32.c @@ -114,7 +114,7 @@ static boolean /* 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' */ @@ -149,7 +149,7 @@ adjust_filehdr_in_post (abfd, src, dst) 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_... @@ -312,7 +312,8 @@ create_go32_stub (abfd) 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"); @@ -354,7 +355,7 @@ create_go32_stub (abfd) 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; @@ -370,7 +371,8 @@ create_go32_stub (abfd) 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); @@ -390,7 +392,8 @@ stub_end: 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; diff --git a/bfd/coff-tic30.c b/bfd/coff-tic30.c index 67b2275..a3bbc4c 100644 --- a/bfd/coff-tic30.c +++ b/bfd/coff-tic30.c @@ -98,8 +98,8 @@ coff_tic30_select_reloc (howto) #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'; diff --git a/bfd/coff-tic54x.c b/bfd/coff-tic54x.c index ed34d95..e44e934 100644 --- a/bfd/coff-tic54x.c +++ b/bfd/coff-tic54x.c @@ -423,7 +423,7 @@ tic54x_reloc_processing (relent, reloc, symbols, abfd, section) } /* 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, @@ -464,7 +464,7 @@ static CONST bfd_coff_backend_data ticoff0_swap_table = }; /* 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, diff --git a/bfd/coff-tic80.c b/bfd/coff-tic80.c index cbaee25..373acab 100644 --- a/bfd/coff-tic80.c +++ b/bfd/coff-tic80.c @@ -35,8 +35,8 @@ Boston, MA 02111-1307, USA. */ #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)); diff --git a/bfd/coff-w65.c b/bfd/coff-w65.c index 8ce8ffe..774d270 100644 --- a/bfd/coff-w65.c +++ b/bfd/coff-w65.c @@ -57,8 +57,8 @@ static reloc_howto_type howto_table[] = #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'; @@ -274,7 +274,7 @@ w65_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, 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; } @@ -284,7 +284,7 @@ w65_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, 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; } @@ -294,7 +294,7 @@ w65_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, 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; } @@ -304,7 +304,7 @@ w65_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr, { 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; diff --git a/bfd/coff-z8k.c b/bfd/coff-z8k.c index 0eda8ee..c626cd7 100644 --- a/bfd/coff-z8k.c +++ b/bfd/coff-z8k.c @@ -87,8 +87,8 @@ coff_z8k_select_reloc (howto) #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'; @@ -314,7 +314,7 @@ extra_case (in_abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr) 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; diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c index fa246bd..e5485a7 100644 --- a/bfd/coff64-rs6000.c +++ b/bfd/coff64-rs6000.c @@ -27,179 +27,272 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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; @@ -212,19 +305,18 @@ _bfd_xcoff64_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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; @@ -232,9 +324,10 @@ _bfd_xcoff64_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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; @@ -246,284 +339,187 @@ _bfd_xcoff64_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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 @@ -556,7 +552,7 @@ xcoff64_swap_ldhdr_out (abfd, src, d) { 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); @@ -577,11 +573,9 @@ xcoff64_swap_ldsym_in (abfd, s, dst) 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); @@ -603,8 +597,8 @@ xcoff64_swap_ldsym_out (abfd, src, d) 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); @@ -638,8 +632,8 @@ xcoff64_swap_ldrel_out (abfd, src, d) 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); } @@ -657,25 +651,25 @@ xcoff64_write_object_contents (abfd) 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; @@ -685,31 +679,41 @@ xcoff64_write_object_contents (abfd) 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; @@ -717,55 +721,62 @@ xcoff64_write_object_contents (abfd) 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; @@ -792,10 +803,8 @@ xcoff64_write_object_contents (abfd) 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 : @@ -811,59 +820,63 @@ xcoff64_write_object_contents (abfd) 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; @@ -873,21 +886,27 @@ xcoff64_write_object_contents (abfd) 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) @@ -925,46 +944,45 @@ xcoff64_write_object_contents (abfd) } 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; } @@ -1009,15 +1027,18 @@ xcoff64_ppc_relocate_section (output_bfd, info, input_bfd, 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. */ @@ -1035,71 +1056,89 @@ xcoff64_ppc_relocate_section (output_bfd, info, input_bfd, 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 @@ -1107,133 +1146,132 @@ xcoff64_ppc_relocate_section (output_bfd, info, input_bfd, 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 @@ -1242,12 +1280,12 @@ xcoff64_ppc_relocate_section (output_bfd, info, input_bfd, 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; @@ -1256,22 +1294,24 @@ xcoff64_ppc_relocate_section (output_bfd, info, input_bfd, /* 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); } } @@ -1331,360 +1371,359 @@ xcoff64_ppc_relocate_section (output_bfd, info, input_bfd, 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 @@ -1707,7 +1746,7 @@ xcoff64_rtype2howto (relent, internal) 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 @@ -1751,36 +1790,41 @@ xcoff64_slurp_armap (abfd) { 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 @@ -1792,27 +1836,28 @@ xcoff64_slurp_armap (abfd) 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; @@ -1835,7 +1880,6 @@ xcoff64_slurp_armap (abfd) } - /* See if this is an NEW XCOFF archive. */ static const bfd_target * @@ -1845,23 +1889,26 @@ xcoff64_archive_p (abfd) 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; @@ -1875,12 +1922,14 @@ xcoff64_archive_p (abfd) 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 @@ -1888,18 +1937,19 @@ xcoff64_archive_p (abfd) 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; } @@ -1914,21 +1964,25 @@ xcoff64_openr_next_archived_file (archive, last_file) { 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. */ @@ -1936,10 +1990,11 @@ xcoff64_openr_next_archived_file (archive, last_file) || 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); } @@ -1955,86 +2010,86 @@ xcoff64_sizeof_headers (abfd, reloc) { 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); } @@ -2042,19 +2097,19 @@ xcoff64_loader_reloc_offset (abfd, ldhdr) /* 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] = { @@ -2070,11 +2125,11 @@ 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 */ @@ -2112,7 +2167,7 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = 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 */ @@ -2151,12 +2206,12 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = /* 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, @@ -2183,7 +2238,7 @@ const bfd_target rs6000coff64_vec = '/', /* 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 */ @@ -2192,9 +2247,9 @@ const bfd_target rs6000coff64_vec = 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 */ @@ -2204,43 +2259,43 @@ const bfd_target rs6000coff64_vec = 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 */ @@ -2248,16 +2303,16 @@ const bfd_target rs6000coff64_vec = /* 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 */ @@ -2265,8 +2320,8 @@ const bfd_target rs6000coff64_vec = 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 */ @@ -2293,7 +2348,7 @@ const bfd_target rs6000coff64_vec = /* 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 */ @@ -2304,15 +2359,15 @@ const bfd_target rs6000coff64_vec = 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, }; diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 3683fac..fc47d57 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -248,39 +248,37 @@ CODE_FRAGMENT . .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; . . @@ -288,17 +286,17 @@ CODE_FRAGMENT . .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; */ @@ -324,12 +322,12 @@ static boolean coff_write_relocs PARAMS ((bfd *, int)); 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 @@ -368,7 +366,7 @@ static flagword handle_COMDAT PARAMS ((bfd *, flagword, PTR, const char *, asect 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; @@ -508,7 +506,7 @@ sec_to_styp_flags (sec_name, sec_flags) 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) @@ -730,7 +728,7 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section) 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); @@ -917,21 +915,23 @@ handle_COMDAT (abfd, sec_flags, hdr, name, section) 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 (); @@ -981,7 +981,7 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr) { long flag = styp_flags & - styp_flags; char * unhandled = NULL; - + styp_flags &= ~ flag; /* We infer from the distinct read/write/execute bits the settings @@ -1006,7 +1006,7 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr) case STYP_NOLOAD: sec_flags |= SEC_NEVER_LOAD; break; -#endif +#endif case IMAGE_SCN_MEM_READ: /* Ignored, assume it always to be true. */ break; @@ -1063,7 +1063,7 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr) break; default: /* Silently ignore for now. */ - break; + break; } /* If the section flag was not handled, report it here. */ @@ -1089,7 +1089,7 @@ styp_to_sec_flags (abfd, hdr, name, section, flags_ptr) if (flags_ptr) * flags_ptr = sec_flags; - + return result; } @@ -1122,235 +1122,166 @@ CODE_FRAGMENT 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) @@ -1360,90 +1291,91 @@ dependent COFF routines: .#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)) . */ @@ -1545,6 +1477,7 @@ coff_new_section_hook (abfd, section) asection * section; { combined_entry_type *native; + bfd_size_type amt; section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; @@ -1562,8 +1495,8 @@ coff_new_section_hook (abfd, section) @@ 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; @@ -1645,6 +1578,7 @@ coff_set_alignment_hook (abfd, section, scnhdr) 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) @@ -1660,8 +1594,8 @@ coff_set_alignment_hook (abfd, section, scnhdr) 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. */ @@ -1670,8 +1604,8 @@ coff_set_alignment_hook (abfd, section, scnhdr) } 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. */ @@ -1688,16 +1622,15 @@ coff_set_alignment_hook (abfd, section, scnhdr) { 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 @@ -1725,7 +1658,7 @@ coff_set_alignment_hook (abfd, section, scnhdr) 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; @@ -1761,8 +1694,9 @@ coff_mkobject (abfd) 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); @@ -1870,7 +1804,7 @@ coff_set_arch_mach_hook (abfd, filehdr) bfd *abfd; PTR filehdr; { - long machine; + unsigned long machine; enum bfd_architecture arch; struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; @@ -2030,11 +1964,11 @@ coff_set_arch_mach_hook (abfd, 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; @@ -2325,7 +2259,7 @@ coff_print_aux (abfd, file, table_base, symbol, aux, indaux) 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); @@ -2413,12 +2347,18 @@ coff_write_relocs (abfd, first_undef) #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) @@ -2433,8 +2373,8 @@ coff_write_relocs (abfd, first_undef) /* 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 @@ -2457,15 +2397,15 @@ coff_write_relocs (abfd, first_undef) 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; } } @@ -2512,8 +2452,8 @@ coff_write_relocs (abfd, first_undef) 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; } @@ -2989,17 +2929,19 @@ coff_compute_section_file_positions (abfd) 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; @@ -3063,15 +3005,16 @@ coff_compute_section_file_positions (abfd) 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; } @@ -3176,7 +3119,7 @@ coff_compute_section_file_positions (abfd) 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; } @@ -3209,11 +3152,12 @@ coff_add_missing_symbols (abfd) 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 @@ -3245,7 +3189,9 @@ coff_add_missing_symbols (abfd) 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 *)); @@ -3365,12 +3311,12 @@ coff_write_object_contents (abfd) { 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 } @@ -3520,9 +3466,10 @@ coff_write_object_contents (abfd) #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; } @@ -3622,7 +3569,7 @@ coff_write_object_contents (abfd) } #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) @@ -3631,6 +3578,7 @@ coff_write_object_contents (abfd) { struct internal_scnhdr scnhdr; SCNHDR buff; + bfd_size_type amt; internal_f.f_nscns++; strncpy (&(scnhdr.s_name[0]), current->name, 8); @@ -3643,9 +3591,9 @@ coff_write_object_contents (abfd) 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; } } @@ -3672,12 +3620,12 @@ coff_write_object_contents (abfd) { 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 } @@ -3891,9 +3839,9 @@ coff_write_object_contents (abfd) 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 @@ -4017,14 +3965,14 @@ coff_write_object_contents (abfd) { 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); @@ -4037,14 +3985,14 @@ coff_write_object_contents (abfd) /* 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); @@ -4063,7 +4011,7 @@ coff_write_object_contents (abfd) 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 @@ -4130,14 +4078,13 @@ coff_set_section_contents (abfd, section, location, offset, count) 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 @@ -4167,17 +4114,16 @@ coff_close_and_cleanup (abfd) #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() */ @@ -4213,16 +4159,14 @@ coff_slurp_line_table (abfd, asect) { 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 @@ -4298,6 +4242,7 @@ coff_slurp_symbol_table (abfd) combined_entry_type *native_symbols; coff_symbol_type *cached_area; unsigned int *table_ptr; + bfd_size_type amt; unsigned int number_of_symbols = 0; @@ -4311,17 +4256,15 @@ coff_slurp_symbol_table (abfd) } /* 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; @@ -4819,8 +4762,8 @@ coff_slurp_reloc_table (abfd, asect, symbols) RELOC *native_relocs; arelent *reloc_cache; arelent *cache_ptr; - unsigned int idx; + bfd_size_type amt; if (asect->relocation) return true; @@ -4830,14 +4773,10 @@ coff_slurp_reloc_table (abfd, asect, symbols) 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; diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 45eda87..08c39f6 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -68,7 +68,7 @@ static void fixup_symbol_value 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) @@ -108,7 +108,7 @@ make_a_section_from_file (abfd, hdr, target_index) 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); @@ -118,7 +118,7 @@ make_a_section_from_file (abfd, hdr, target_index) 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)); @@ -148,7 +148,7 @@ make_a_section_from_file (abfd, hdr, target_index) 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 @@ -178,7 +178,7 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) 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; @@ -211,12 +211,12 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) 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 @@ -257,9 +257,9 @@ const bfd_target * 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; @@ -271,7 +271,7 @@ coff_object_p (abfd) 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); @@ -294,7 +294,7 @@ coff_object_p (abfd) 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; @@ -431,6 +431,7 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs, 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) @@ -444,24 +445,24 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs, 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; @@ -484,9 +485,8 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs, { 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; @@ -661,9 +661,10 @@ coff_renumber_symbols (bfd_ptr, first_undef) { 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; @@ -756,8 +757,8 @@ coff_mangle_symbols (bfd_ptr) 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; } @@ -876,7 +877,7 @@ coff_fix_symbol_name (abfd, symbol, native, string_size_p, } else { - long filepos; + file_ptr filepos; bfd_byte buf[4]; int prefix_len = bfd_coff_debug_string_prefix_length (abfd); @@ -889,9 +890,9 @@ coff_fix_symbol_name (abfd, symbol, native, string_size_p, *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, @@ -901,8 +902,8 @@ coff_fix_symbol_name (abfd, symbol, native, string_size_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) @@ -970,7 +971,7 @@ coff_write_symbol (abfd, symbol, native, written, string_size_p, 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); @@ -989,10 +990,10 @@ coff_write_symbol (abfd, symbol, native, written, string_size_p, &((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); @@ -1219,11 +1220,12 @@ coff_write_symbols (abfd) 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 @@ -1239,7 +1241,8 @@ coff_write_symbols (abfd) 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; } } @@ -1279,7 +1282,10 @@ coff_write_symbols (abfd) && 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 @@ -1287,8 +1293,8 @@ coff_write_symbols (abfd) 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; } } @@ -1302,11 +1308,11 @@ coff_write_symbols (abfd) 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; } @@ -1361,7 +1367,8 @@ coff_write_linenumbers (abfd) 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) @@ -1369,7 +1376,8 @@ coff_write_linenumbers (abfd) 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++; } @@ -1417,7 +1425,7 @@ coff_section_symbol (abfd, name) 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); @@ -1500,7 +1508,8 @@ build_debug_section (abfd) bfd *abfd; { char *debug_section; - long position; + file_ptr position; + bfd_size_type sec_size; asection *sect = bfd_get_section_by_name (abfd, ".debug"); @@ -1510,8 +1519,8 @@ build_debug_section (abfd) 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; @@ -1521,9 +1530,7 @@ build_debug_section (abfd) 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; @@ -1536,9 +1543,9 @@ static char * 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) @@ -1549,7 +1556,7 @@ copy_name (abfd, name, maxlen) } } - 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'; @@ -1563,7 +1570,7 @@ _bfd_coff_get_external_symbols (abfd) bfd *abfd; { bfd_size_type symesz; - size_t size; + bfd_size_type size; PTR syms; if (obj_coff_external_syms (abfd) != NULL) @@ -1578,7 +1585,7 @@ _bfd_coff_get_external_symbols (abfd) 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); @@ -1599,8 +1606,9 @@ _bfd_coff_read_string_table (abfd) 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); @@ -1611,13 +1619,13 @@ _bfd_coff_read_string_table (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; @@ -1628,9 +1636,9 @@ _bfd_coff_read_string_table (abfd) 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 } @@ -1647,8 +1655,7 @@ _bfd_coff_read_string_table (abfd) 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); @@ -1694,12 +1701,12 @@ coff_get_normalized_symtab (abfd) 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); @@ -1742,7 +1749,7 @@ coff_get_normalized_symtab (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); @@ -1797,7 +1804,7 @@ coff_get_normalized_symtab (abfd) ((long) copy_name (abfd, (internal_ptr + 1)->u.auxent.x_file.x_fname, - bfd_coff_filnmlen (abfd))); + (size_t) bfd_coff_filnmlen (abfd))); } } } @@ -1806,23 +1813,20 @@ coff_get_normalized_symtab (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; } @@ -1879,7 +1883,8 @@ asymbol * 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); @@ -1899,12 +1904,14 @@ coff_bfd_make_debug_symbol (abfd, ptr, sz) 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; @@ -1950,7 +1957,7 @@ bfd_coff_get_syment (abfd, symbol, psyment) *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. */ @@ -2185,8 +2192,8 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, 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; @@ -2198,6 +2205,7 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, 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. */ @@ -2372,9 +2380,8 @@ coff_find_nearest_line (abfd, section, symbols, offset, filename_ptr, /* 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) @@ -2431,8 +2438,9 @@ bfd_coff_set_symbol_class (abfd, symbol, class) 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; diff --git a/bfd/cofflink.c b/bfd/cofflink.c index 7e40bd9..e99c470 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -117,9 +117,9 @@ _bfd_coff_link_hash_table_create (abfd) 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, @@ -325,6 +325,7 @@ coff_link_add_symbols (abfd, info) 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. */ @@ -340,10 +341,8 @@ coff_link_add_symbols (abfd, info) /* 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; @@ -564,8 +563,8 @@ coff_link_add_symbols (abfd, info) 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; } } @@ -618,9 +617,8 @@ coff_link_add_symbols (abfd, info) 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); @@ -658,11 +656,11 @@ _bfd_coff_final_link (abfd, info) 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; @@ -670,6 +668,7 @@ _bfd_coff_final_link (abfd, info) bfd *sub; bfd_byte *external_relocs = NULL; char strbuf[STRING_SIZE_SIZE]; + bfd_size_type amt; symesz = bfd_coff_symesz (abfd); @@ -785,10 +784,9 @@ _bfd_coff_final_link (abfd, info) /* 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++) @@ -829,13 +827,14 @@ _bfd_coff_final_link (abfd, info) 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; @@ -867,22 +866,23 @@ _bfd_coff_final_link (abfd, info) } /* 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) @@ -987,14 +987,15 @@ _bfd_coff_final_link (abfd, info) 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; } @@ -1029,8 +1030,8 @@ _bfd_coff_final_link (abfd, info) /* 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; @@ -1059,8 +1060,9 @@ _bfd_coff_final_link (abfd, info) } 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; } @@ -1094,21 +1096,22 @@ _bfd_coff_final_link (abfd, info) /* 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)) @@ -1176,17 +1179,17 @@ dores_com (ptr, output_bfd, heap) { 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; @@ -1220,10 +1223,10 @@ process_embedded_commands (output_bfd, info, abfd) 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; @@ -1586,6 +1589,7 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) 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) @@ -1606,9 +1610,8 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) /* 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; @@ -1634,9 +1637,9 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) 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; @@ -1645,8 +1648,8 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) 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); @@ -1846,18 +1849,18 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) } 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; } } @@ -2079,6 +2082,8 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) } else { + file_ptr pos; + /* We have already written out the last .bf aux entry. We need to write it out again. We borrow *outsym @@ -2090,12 +2095,11 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) 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; } } @@ -2143,6 +2147,8 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) 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 @@ -2158,7 +2164,7 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) 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; @@ -2246,17 +2252,14 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) } } - 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; } } @@ -2277,12 +2280,13 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) /* 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) @@ -2454,14 +2458,11 @@ _bfd_coff_link_input_bfd (finfo, input_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 @@ -2494,6 +2495,7 @@ _bfd_coff_write_global_sym (h, data) struct internal_syment isym; bfd_size_type symesz; unsigned int i; + file_ptr pos; output_bfd = finfo->output_bfd; @@ -2602,11 +2604,10 @@ _bfd_coff_write_global_sym (h, data) 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; @@ -2674,9 +2675,9 @@ _bfd_coff_write_global_sym (h, data) } 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; @@ -2744,6 +2745,7 @@ _bfd_coff_reloc_link_order (output_bfd, finfo, output_section, link_order) 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); @@ -2751,7 +2753,8 @@ _bfd_coff_reloc_link_order (output_bfd, finfo, output_section, link_order) 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: @@ -2774,10 +2777,9 @@ _bfd_coff_reloc_link_order (output_bfd, finfo, output_section, link_order) } 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; diff --git a/bfd/coffswap.h b/bfd/coffswap.h index 2ff0a32..454e686 100644 --- a/bfd/coffswap.h +++ b/bfd/coffswap.h @@ -1,5 +1,6 @@ /* 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. @@ -27,174 +28,186 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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)); @@ -229,48 +242,44 @@ coff_swap_reloc_in (abfd, src, dst) 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); @@ -280,9 +289,9 @@ coff_swap_reloc_out (abfd, src, dst) 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; @@ -290,16 +299,15 @@ coff_swap_filehdr_in (abfd, src, 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 @@ -309,26 +317,25 @@ coff_swap_filehdr_in (abfd, src, dst) 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 @@ -341,34 +348,38 @@ coff_swap_filehdr_out (abfd, in, out) 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 @@ -376,35 +387,37 @@ coff_swap_sym_in (abfd, ext1, in1) 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 @@ -413,42 +426,45 @@ coff_swap_sym_out (abfd, inp, extp) 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: @@ -456,10 +472,11 @@ coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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. */ @@ -472,9 +489,9 @@ coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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)) @@ -485,29 +502,29 @@ coff_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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); @@ -516,87 +533,88 @@ end: ; 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 @@ -609,27 +627,26 @@ end: 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; @@ -639,128 +656,126 @@ coff_swap_lineno_out (abfd, inp, outp) 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 @@ -770,23 +785,23 @@ coff_swap_aouthdr_out (abfd, in, out) #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; @@ -794,9 +809,9 @@ coff_swap_aouthdr_out (abfd, in, out) 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; @@ -805,28 +820,18 @@ coff_swap_scnhdr_in (abfd, ext, 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); @@ -835,42 +840,32 @@ coff_swap_scnhdr_in (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]; @@ -881,11 +876,10 @@ coff_swap_scnhdr_out (abfd, in, out) (_("%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]; @@ -896,13 +890,13 @@ coff_swap_scnhdr_out (abfd, in, out) 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); diff --git a/bfd/configure b/bfd/configure index e39b1b2..fef25b3 100755 --- a/bfd/configure +++ b/bfd/configure @@ -1127,7 +1127,7 @@ fi 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; } @@ -5003,7 +5003,7 @@ if test "${target}" = "${host}"; then 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"' ;; @@ -5141,7 +5141,7 @@ if test "${target}" = "${host}"; then 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 ;; @@ -5896,76 +5896,55 @@ do 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" ;; @@ -5980,41 +5959,46 @@ do 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" ;; @@ -6027,83 +6011,76 @@ do 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" ;; @@ -6197,17 +6174,17 @@ for ac_hdr in unistd.h 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 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* @@ -6236,12 +6213,12 @@ done 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 <&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 @@ -6289,7 +6266,7 @@ fi 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 @@ -6297,7 +6274,7 @@ else ac_cv_func_mmap_fixed_mapped=no else cat > conftest.$ac_ext <&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 @@ -6462,12 +6439,12 @@ fi 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 <&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 @@ -6741,7 +6718,7 @@ cat >> $CONFIG_STATUS <<\EOF # 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. diff --git a/bfd/configure.in b/bfd/configure.in index ca5b184..46bc1ed 100644 --- a/bfd/configure.in +++ b/bfd/configure.in @@ -7,7 +7,7 @@ AC_INIT(libbfd.c) 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. @@ -151,7 +151,7 @@ if test "${target}" = "${host}"; then 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"' ;; @@ -315,7 +315,7 @@ changequote([,])dnl 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 ;; @@ -469,76 +469,55 @@ do 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" ;; @@ -553,41 +532,46 @@ do 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" ;; @@ -600,83 +584,76 @@ do 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" ;; diff --git a/bfd/corefile.c b/bfd/corefile.c index 3ce0785..609c4e6 100644 --- a/bfd/corefile.c +++ b/bfd/corefile.c @@ -1,5 +1,5 @@ /* 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. @@ -36,7 +36,7 @@ FUNCTION 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 diff --git a/bfd/cpu-arc.c b/bfd/cpu-arc.c index 2904ae3..204eb48 100644 --- a/bfd/cpu-arc.c +++ b/bfd/cpu-arc.c @@ -55,6 +55,8 @@ const bfd_arch_info_type bfd_arc_arch = /* 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; diff --git a/bfd/cpu-h8300.c b/bfd/cpu-h8300.c index 7d6b5d2..929ebd1 100644 --- a/bfd/cpu-h8300.c +++ b/bfd/cpu-h8300.c @@ -23,8 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 diff --git a/bfd/cpu-h8500.c b/bfd/cpu-h8500.c index 7b526ef..6a1fae0 100644 --- a/bfd/cpu-h8500.c +++ b/bfd/cpu-h8500.c @@ -1,5 +1,5 @@ /* 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. @@ -22,8 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 @@ -147,8 +148,6 @@ local_bfd_reloc_type_lookup (arch, code) } #endif -int bfd_default_scan_num_mach(); - static boolean scan_mach (info, string) const struct bfd_arch_info *info ATTRIBUTE_UNUSED; diff --git a/bfd/cpu-i960.c b/bfd/cpu-i960.c index 2b7c122..a7c4500 100644 --- a/bfd/cpu-i960.c +++ b/bfd/cpu-i960.c @@ -1,5 +1,5 @@ /* 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. @@ -23,6 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 */ @@ -136,7 +141,7 @@ compatible (a,b) #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 }, @@ -159,7 +164,6 @@ compatible (a,b) } } -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,} diff --git a/bfd/cpu-ia64-opc.c b/bfd/cpu-ia64-opc.c index 8c22942..a228b1c 100644 --- a/bfd/cpu-ia64-opc.c +++ b/bfd/cpu-ia64-opc.c @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* 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. diff --git a/bfd/cpu-ns32k.c b/bfd/cpu-ns32k.c index c01599e..2cfa26f 100644 --- a/bfd/cpu-ns32k.c +++ b/bfd/cpu-ns32k.c @@ -1,5 +1,5 @@ /* 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. @@ -36,40 +36,36 @@ static const bfd_arch_info_type arch_info_struct[] = 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; @@ -78,37 +74,38 @@ _bfd_ns32k_get_displacement(buffer, offset, size) } 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; @@ -116,19 +113,21 @@ _bfd_ns32k_put_displacement(value, buffer, offset, size) 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); @@ -139,18 +138,21 @@ _bfd_ns32k_get_immediate (buffer, offset, size) } 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; @@ -175,8 +177,8 @@ do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, 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; @@ -185,6 +187,7 @@ do_ns32k_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, 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) @@ -433,7 +436,8 @@ space consuming. For each target: 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 @@ -444,7 +448,8 @@ space consuming. For each target: 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 @@ -528,38 +533,39 @@ space consuming. For each target: #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; @@ -571,9 +577,9 @@ space consuming. For each target: #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 (); @@ -591,14 +597,14 @@ space consuming. For each target: /* 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; @@ -622,7 +628,7 @@ _bfd_do_ns32k_reloc_contents ( howto, input_bfd, relocation, location, #ifdef BFD64 case 8: #endif - x = get_data (location, 0, size); + x = get_data (location, size); break; } @@ -729,7 +735,7 @@ _bfd_do_ns32k_reloc_contents ( howto, input_bfd, relocation, location, if ((check & ~reloc_bits) != 0 && (((bfd_vma) signed_check & ~reloc_bits) - != (-1 & ~reloc_bits))) + != (-(bfd_vma) 1 & ~reloc_bits))) overflow = true; } break; @@ -758,7 +764,7 @@ _bfd_do_ns32k_reloc_contents ( howto, input_bfd, relocation, location, #ifdef BFD64 case 8: #endif - put_data(x, location, 0, size); + put_data (x, location, size); break; } diff --git a/bfd/cpu-pdp11.c b/bfd/cpu-pdp11.c index 2e24ad9..13e0e90 100644 --- a/bfd/cpu-pdp11.c +++ b/bfd/cpu-pdp11.c @@ -32,7 +32,7 @@ const bfd_arch_info_type bfd_pdp11_arch = "pdp11", 1, /* aligment = 16 bit */ true, /* the one and only */ - bfd_default_compatible, + bfd_default_compatible, bfd_default_scan , 0, }; diff --git a/bfd/cpu-pj.c b/bfd/cpu-pj.c index 0687e4a..aeb7e58 100644 --- a/bfd/cpu-pj.c +++ b/bfd/cpu-pj.c @@ -1,5 +1,5 @@ /* 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. @@ -22,6 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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; diff --git a/bfd/cpu-sh.c b/bfd/cpu-sh.c index 134b4e4..054eb16 100644 --- a/bfd/cpu-sh.c +++ b/bfd/cpu-sh.c @@ -1,5 +1,6 @@ /* 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. @@ -22,6 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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; diff --git a/bfd/cpu-w65.c b/bfd/cpu-w65.c index b549563..a73444d 100644 --- a/bfd/cpu-w65.c +++ b/bfd/cpu-w65.c @@ -1,5 +1,5 @@ /* 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. @@ -22,7 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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) diff --git a/bfd/cpu-z8k.c b/bfd/cpu-z8k.c index 643932a..0afdfc7 100644 --- a/bfd/cpu-z8k.c +++ b/bfd/cpu-z8k.c @@ -1,5 +1,5 @@ /* 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. @@ -22,6 +22,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 @@ -148,8 +153,6 @@ local_bfd_reloc_type_lookup (arch, code) } #endif -int bfd_default_scan_num_mach (); - static boolean scan_mach (info, string) const struct bfd_arch_info *info; diff --git a/bfd/dwarf1.c b/bfd/dwarf1.c index 0ed206d..6531986 100644 --- a/bfd/dwarf1.c +++ b/bfd/dwarf1.c @@ -145,9 +145,9 @@ static struct dwarf1_unit* 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; @@ -162,9 +162,9 @@ alloc_dwarf1_func (stash, aUnit) 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; @@ -277,7 +277,7 @@ parse_line_table (stash, aUnit) 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) @@ -289,7 +289,8 @@ parse_line_table (stash, aUnit) 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; @@ -302,9 +303,9 @@ parse_line_table (stash, aUnit) 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; @@ -319,9 +320,9 @@ parse_line_table (stash, aUnit) 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++) { @@ -482,10 +483,10 @@ _bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset, 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; @@ -505,7 +506,8 @@ _bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset, 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; diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index 4be6acf..7126360 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -463,6 +463,7 @@ read_abbrevs (abfd, offset, stash) 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) { @@ -477,13 +478,12 @@ read_abbrevs (abfd, offset, stash) } 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; } @@ -495,7 +495,8 @@ read_abbrevs (abfd, offset, stash) 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); @@ -504,7 +505,8 @@ read_abbrevs (abfd, offset, stash) /* 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; @@ -523,10 +525,10 @@ read_abbrevs (abfd, offset, stash) { 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; } @@ -574,6 +576,7 @@ read_attribute (attr, abbrev, unit, info_ptr) bfd *abfd = unit->abfd; unsigned int bytes_read; struct dwarf_block *blk; + bfd_size_type amt; attr->name = abbrev->name; attr->form = abbrev->form; @@ -586,7 +589,8 @@ read_attribute (attr, abbrev, unit, info_ptr) 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); @@ -594,7 +598,8 @@ read_attribute (attr, abbrev, unit, info_ptr) 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); @@ -618,7 +623,8 @@ read_attribute (attr, abbrev, unit, info_ptr) 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); @@ -626,7 +632,8 @@ read_attribute (attr, abbrev, unit, info_ptr) 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); @@ -722,8 +729,8 @@ add_line_info (table, address, filename, line, column, end_sequence) 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; @@ -799,7 +806,7 @@ arange_add (unit, low_pc, high_pc) } /* 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; @@ -822,6 +829,7 @@ decode_line_info (unit, stash) 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) { @@ -836,13 +844,12 @@ decode_line_info (unit, stash) } 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 @@ -860,8 +867,8 @@ decode_line_info (unit, stash) 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; @@ -894,8 +901,8 @@ decode_line_info (unit, stash) 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; @@ -912,9 +919,9 @@ decode_line_info (unit, stash) 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; } @@ -931,10 +938,9 @@ decode_line_info (unit, stash) 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; } @@ -1001,10 +1007,10 @@ decode_line_info (unit, stash) 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; } @@ -1208,7 +1214,8 @@ scan_unit_for_functions (unit) 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; } @@ -1295,7 +1302,7 @@ find_rela_addend (abfd, sec, offset, syms) 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; @@ -1318,7 +1325,7 @@ find_rela_addend (abfd, sec, offset, syms) free (relocs); return addend; } - + free (relocs); return 0; } @@ -1353,6 +1360,8 @@ parse_comp_unit (abfd, stash, unit_length, abbrev_length) 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; @@ -1367,9 +1376,8 @@ parse_comp_unit (abfd, stash, unit_length, abbrev_length) .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; @@ -1421,7 +1429,8 @@ parse_comp_unit (abfd, stash, unit_length, abbrev_length) 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; @@ -1645,11 +1654,11 @@ _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, 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; @@ -1680,8 +1689,8 @@ _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, 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) @@ -1689,7 +1698,8 @@ _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, 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; @@ -1732,7 +1742,6 @@ _bfd_dwarf2_find_nearest_line (abfd, section, symbols, offset, /* 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; diff --git a/bfd/ecoff.c b/bfd/ecoff.c index 86a1222..359c254 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -65,7 +65,7 @@ static boolean ecoff_compute_section_file_positions PARAMS ((bfd *abfd)); 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)); @@ -78,7 +78,7 @@ static asection bfd_debug_section = "*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, @@ -104,8 +104,8 @@ boolean _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; @@ -474,13 +474,12 @@ ecoff_slurp_symbolic_header (abfd) } /* 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); @@ -525,6 +524,8 @@ _bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug) 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); @@ -583,11 +584,11 @@ _bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug) 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; @@ -624,9 +625,9 @@ _bfd_ecoff_slurp_symbolic_info (abfd, ignore, debug) 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; @@ -658,8 +659,9 @@ _bfd_ecoff_make_empty_symbol (abfd) 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); @@ -858,6 +860,7 @@ ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, weak) 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 @@ -877,7 +880,8 @@ ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, weak) { 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); @@ -885,8 +889,8 @@ ecoff_set_symbol_info (abfd, ecoff_sym, asym, ext, weak) } /* 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 = @@ -958,7 +962,8 @@ _bfd_ecoff_slurp_symbol_table (abfd) 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; @@ -1663,7 +1668,7 @@ ecoff_slurp_reloc_table (abfd, section, symbols) 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; @@ -1676,19 +1681,19 @@ ecoff_slurp_reloc_table (abfd, section, symbols) 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++) @@ -1717,7 +1722,7 @@ ecoff_slurp_reloc_table (abfd, section, symbols) } else { - CONST char *sec_name; + const char *sec_name; asection *sec; /* r_symndx is a section key. */ @@ -1814,8 +1819,8 @@ _bfd_ecoff_find_nearest_line (abfd, section, ignore_symbols, offset, 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 @@ -1830,9 +1835,9 @@ _bfd_ecoff_find_nearest_line (abfd, section, ignore_symbols, offset, 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; } @@ -2057,13 +2062,15 @@ ecoff_compute_section_file_positions (abfd) 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; @@ -2257,6 +2264,8 @@ _bfd_ecoff_set_section_contents (abfd, section, location, offset, count) 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) @@ -2285,8 +2294,9 @@ _bfd_ecoff_set_section_contents (abfd, section, location, offset, count) 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; @@ -2513,7 +2523,7 @@ _bfd_ecoff_write_object_contents (abfd) 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; } @@ -2573,7 +2583,7 @@ _bfd_ecoff_write_object_contents (abfd) 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 @@ -2724,11 +2734,11 @@ _bfd_ecoff_write_object_contents (abfd) 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 @@ -2756,12 +2766,13 @@ _bfd_ecoff_write_object_contents (abfd) 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; @@ -2792,7 +2803,7 @@ _bfd_ecoff_write_object_contents (abfd) } else { - CONST char *name; + const char *name; name = bfd_get_section_name (abfd, bfd_get_section (sym)); if (strcmp (name, ".text") == 0) @@ -2837,9 +2848,8 @@ _bfd_ecoff_write_object_contents (abfd) 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; @@ -2869,12 +2879,12 @@ _bfd_ecoff_write_object_contents (abfd) 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; } @@ -2942,7 +2952,7 @@ _bfd_ecoff_write_object_contents (abfd) 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; @@ -2975,9 +2985,10 @@ _bfd_ecoff_slurp_armap (abfd) 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) @@ -3032,7 +3043,7 @@ _bfd_ecoff_slurp_armap (abfd) 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); @@ -3042,7 +3053,7 @@ _bfd_ecoff_slurp_armap (abfd) 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; @@ -3069,8 +3080,8 @@ _bfd_ecoff_slurp_armap (abfd) 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, @@ -3082,8 +3093,7 @@ _bfd_ecoff_slurp_armap (abfd) 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); } } @@ -3092,12 +3102,12 @@ _bfd_ecoff_slurp_armap (abfd) 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; @@ -3108,10 +3118,10 @@ _bfd_ecoff_slurp_armap (abfd) { 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; @@ -3137,7 +3147,7 @@ _bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx) int stridx; { unsigned int hashsize, hashlog; - unsigned int symdefsize; + bfd_size_type symdefsize; int padit; unsigned int stringsize; unsigned int mapsize; @@ -3210,12 +3220,12 @@ _bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx) 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); @@ -3230,7 +3240,7 @@ _bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx) /* 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 { @@ -3238,13 +3248,13 @@ _bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx) 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; @@ -3252,7 +3262,7 @@ _bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx) 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); @@ -3260,27 +3270,25 @@ _bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx) 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; } @@ -3288,7 +3296,7 @@ _bfd_ecoff_write_armap (abfd, elength, map, orl_count, stridx) 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; } @@ -3304,10 +3312,11 @@ _bfd_ecoff_archive_p (abfd) { 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); @@ -3323,8 +3332,8 @@ _bfd_ecoff_archive_p (abfd) /* 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) { @@ -3441,9 +3450,9 @@ _bfd_ecoff_bfd_link_hash_table_create (abfd) 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, @@ -3533,7 +3542,7 @@ ecoff_link_add_archive_symbols (abfd, info) 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) @@ -3586,7 +3595,7 @@ ecoff_link_add_archive_symbols (abfd, info) 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. */ @@ -3594,7 +3603,7 @@ ecoff_link_add_archive_symbols (abfd, info) 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) { @@ -3607,10 +3616,10 @@ ecoff_link_add_archive_symbols (abfd, info) 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) { @@ -3628,7 +3637,7 @@ ecoff_link_add_archive_symbols (abfd, info) 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; @@ -3664,7 +3673,7 @@ ecoff_link_check_archive_element (abfd, info, pneeded) 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; @@ -3687,17 +3696,17 @@ ecoff_link_check_archive_element (abfd, info, pneeded) 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 @@ -3787,7 +3796,7 @@ ecoff_link_add_object_symbols (abfd, info) HDRR *symhdr; bfd_size_type external_ext_size; PTR external_ext = NULL; - size_t esize; + bfd_size_type esize; char *ssext = NULL; boolean result; @@ -3807,16 +3816,16 @@ ecoff_link_add_object_symbols (abfd, info) 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; @@ -3857,12 +3866,13 @@ ecoff_link_add_externals (abfd, info, external_ext, ssext) 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; @@ -3999,7 +4009,7 @@ ecoff_link_add_externals (abfd, info, external_ext, ssext) 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; @@ -4288,25 +4298,24 @@ ecoff_final_link_debug_accumulate (output_bfd, input_bfd, info, handle) 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 @@ -4528,6 +4537,7 @@ ecoff_indirect_link_order (output_bfd, info, output_section, link_order) 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); @@ -4549,10 +4559,9 @@ ecoff_indirect_link_order (output_bfd, info, output_section, link_order) /* 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 @@ -4579,12 +4588,12 @@ ecoff_indirect_link_order (output_bfd, info, output_section, link_order) 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; } @@ -4599,7 +4608,7 @@ ecoff_indirect_link_order (output_bfd, info, output_section, link_order) 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; @@ -4609,11 +4618,10 @@ ecoff_indirect_link_order (output_bfd, info, output_section, link_order) 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; @@ -4653,6 +4661,7 @@ ecoff_reloc_link_order (output_bfd, info, output_section, link_order) bfd_size_type external_reloc_size; bfd_byte *rbuf; boolean ok; + file_ptr pos; type = link_order->type; section = NULL; @@ -4712,13 +4721,13 @@ ecoff_reloc_link_order (output_bfd, info, output_section, link_order) 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: @@ -4777,7 +4786,7 @@ ecoff_reloc_link_order (output_bfd, info, output_section, link_order) } else { - CONST char *name; + const char *name; name = bfd_get_section_name (output_bfd, section); if (strcmp (name, ".text") == 0) @@ -4820,17 +4829,16 @@ ecoff_reloc_link_order (output_bfd, info, output_section, link_order) /* 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) diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c index 37b3538..633a9e6 100644 --- a/bfd/ecofflink.c +++ b/bfd/ecofflink.c @@ -1,5 +1,5 @@ /* 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, . @@ -272,7 +272,7 @@ ecoff_add_bytes (buf, bufend, need) 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; @@ -497,8 +497,9 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info) 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, @@ -621,6 +622,7 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap, 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. */ @@ -661,9 +663,9 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap, } 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); @@ -712,7 +714,7 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap, 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); @@ -937,10 +939,9 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap, 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; @@ -949,10 +950,10 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap, } 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; @@ -970,10 +971,9 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap, } 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; @@ -989,21 +989,21 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap, 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; } } @@ -1210,7 +1210,7 @@ bfd_ecoff_debug_accumulate_other (handle, output_bfd, output_debug, 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); @@ -1254,7 +1254,8 @@ bfd_ecoff_debug_accumulate_other (handle, output_bfd, output_debug, } (*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; } @@ -1274,7 +1275,8 @@ bfd_ecoff_debug_accumulate_other (handle, output_bfd, output_debug, } (*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; @@ -1386,7 +1388,7 @@ bfd_ecoff_debug_one_external (abfd, debug, swap, name, esym) { 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; } @@ -1546,12 +1548,12 @@ ecoff_write_symhdr (abfd, debug, swap, where) 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; @@ -1585,7 +1587,7 @@ bfd_ecoff_write_debug (abfd, debug, swap, where) #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; @@ -1594,7 +1596,8 @@ bfd_ecoff_write_debug (abfd, debug, swap, where) 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); @@ -1626,14 +1629,16 @@ ecoff_write_shuffle (abfd, swap, shuffle, space) { 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; @@ -1645,12 +1650,12 @@ ecoff_write_shuffle (abfd, swap, shuffle, space) 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; @@ -1675,11 +1680,13 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where) { 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; @@ -1706,7 +1713,7 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where) 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); @@ -1717,7 +1724,8 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where) 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; } @@ -1728,11 +1736,11 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where) 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; @@ -1743,8 +1751,8 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where) /* 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) { @@ -1753,11 +1761,11 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where) 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; @@ -1773,9 +1781,8 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where) || (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) @@ -1829,6 +1836,7 @@ mk_fdrtab (abfd, debug_info, debug_swap, line_info) 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; @@ -1843,9 +1851,8 @@ mk_fdrtab (abfd, debug_info, debug_swap, line_info) /* 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; @@ -1902,7 +1909,7 @@ mk_fdrtab (abfd, debug_info, debug_swap, line_info) 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; @@ -2004,7 +2011,7 @@ lookup_line (abfd, debug_info, debug_swap, line_info) 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; @@ -2330,7 +2337,7 @@ lookup_line (abfd, debug_info, debug_swap, line_info) { 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; @@ -2429,7 +2436,8 @@ ecoff_collect_shuffle (l, buff) 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; diff --git a/bfd/ecoffswap.h b/bfd/ecoffswap.h index dd6fa6f..24627d0 100644 --- a/bfd/ecoffswap.h +++ b/bfd/ecoffswap.h @@ -45,20 +45,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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 @@ -104,31 +104,31 @@ ecoff_swap_hdr_in (abfd, ext_copy, intern) *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) @@ -149,34 +149,34 @@ ecoff_swap_hdr_out (abfd, intern_copy, ext_ptr) *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 } @@ -193,55 +193,58 @@ ecoff_swap_fdr_in (abfd, ext_copy, intern) *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) @@ -262,54 +265,57 @@ ecoff_swap_fdr_out (abfd, intern_copy, ext_ptr) *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) @@ -333,26 +339,23 @@ ecoff_swap_pdr_in (abfd, ext_copy, intern) 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); @@ -373,7 +376,7 @@ ecoff_swap_pdr_in (abfd, ext_copy, intern) | ((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 @@ -395,23 +398,24 @@ ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr) *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) @@ -434,7 +438,7 @@ ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr) 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 @@ -458,23 +462,20 @@ ecoff_swap_pdr_in (abfd, ext_copy, intern) *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) @@ -495,20 +496,20 @@ ecoff_swap_pdr_out (abfd, intern_copy, ext_ptr) *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) @@ -529,8 +530,8 @@ ecoff_swap_sym_in (abfd, ext_copy, intern) *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)) { @@ -579,8 +580,8 @@ ecoff_swap_sym_out (abfd, intern_copy, ext_ptr) *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)) { @@ -640,10 +641,10 @@ ecoff_swap_ext_in (abfd, ext_copy, intern) 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); @@ -689,10 +690,10 @@ ecoff_swap_ext_out (abfd, intern_copy, ext_ptr) } #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); @@ -713,7 +714,7 @@ ecoff_swap_rfd_in (abfd, ext_ptr, intern) { 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) @@ -731,7 +732,7 @@ ecoff_swap_rfd_out (abfd, intern, ext_ptr) { 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) @@ -772,7 +773,7 @@ ecoff_swap_opt_in (abfd, ext_copy, intern) _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) @@ -811,7 +812,7 @@ ecoff_swap_opt_out (abfd, intern_copy, ext_ptr) _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) @@ -831,8 +832,8 @@ ecoff_swap_dnr_in (abfd, ext_copy, intern) *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) @@ -853,8 +854,8 @@ ecoff_swap_dnr_out (abfd, intern_copy, ext_ptr) *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) diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 93e8e6d..eaf37fe 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -293,15 +293,22 @@ struct elf_size_info { 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 @@ -355,20 +362,21 @@ struct elf_backend_data /* 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. */ @@ -379,52 +387,52 @@ struct elf_backend_data 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 @@ -578,11 +586,13 @@ struct elf_backend_data /* 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 @@ -616,8 +626,7 @@ struct elf_backend_data 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. */ @@ -641,18 +650,23 @@ struct elf_backend_data /* 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. */ @@ -810,7 +824,7 @@ typedef struct elf_linker_section_pointers { 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; @@ -1005,41 +1019,48 @@ extern void _bfd_elf_swap_versym_in 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 @@ -1053,7 +1074,8 @@ extern boolean _bfd_elf_link_hash_table_init 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 *)); @@ -1062,135 +1084,133 @@ extern boolean _bfd_elf_copy_private_symbol_data 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 *)); @@ -1219,9 +1239,10 @@ extern void bfd_elf32_swap_dyn_out 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 @@ -1233,12 +1254,16 @@ extern boolean bfd_elf32_link_create_dynamic_sections 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 @@ -1266,9 +1291,10 @@ extern void bfd_elf64_swap_dyn_out 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 @@ -1285,41 +1311,43 @@ extern Elf_Internal_Rela *_bfd_elf64_link_read_relocs #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 @@ -1328,10 +1356,12 @@ extern boolean _bfd_mips_elf_section_from_bfd_section 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 @@ -1342,9 +1372,12 @@ extern bfd_reloc_status_type _bfd_mips_elf_got16_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 *)); @@ -1384,14 +1417,17 @@ extern boolean _bfd_mips_elf_link_output_symbol_hook 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_ */ diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h index 006a2c4..2b1d38e 100644 --- a/bfd/elf-hppa.h +++ b/bfd/elf-hppa.h @@ -92,8 +92,8 @@ static bfd_reloc_status_type elf_hppa_final_link_relocate 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. */ @@ -619,16 +619,16 @@ _bfd_elf_hppa_gen_reloc_type (abfd, base_type, format, field, ignore, sym) { 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; @@ -1484,9 +1484,9 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, 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; @@ -1538,7 +1538,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, 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; } @@ -1570,7 +1570,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, 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; } @@ -1672,7 +1672,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, 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; } @@ -1709,7 +1709,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, 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; } @@ -1746,7 +1746,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, value >>= 2; } - insn = elf_hppa_relocate_insn (insn, value, r_type); + insn = elf_hppa_relocate_insn (insn, (int) value, r_type); break; } @@ -1781,7 +1781,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, 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; } @@ -1991,7 +1991,7 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, } /* 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; } @@ -2001,10 +2001,10 @@ elf_hppa_final_link_relocate (rel, input_bfd, output_bfd, 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) @@ -2013,11 +2013,11 @@ elf_hppa_relocate_insn (insn, sym_value, 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. */ @@ -2026,7 +2026,7 @@ elf_hppa_relocate_insn (insn, sym_value, r_type) 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: @@ -2037,7 +2037,7 @@ elf_hppa_relocate_insn (insn, sym_value, r_type) 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: @@ -2062,7 +2062,7 @@ elf_hppa_relocate_insn (insn, sym_value, r_type) 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: @@ -2080,8 +2080,8 @@ elf_hppa_relocate_insn (insn, sym_value, r_type) 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: @@ -2099,8 +2099,8 @@ elf_hppa_relocate_insn (insn, sym_value, r_type) 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; diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c index cde5641..9caf1bb 100644 --- a/bfd/elf-m10200.c +++ b/bfd/elf-m10200.c @@ -605,14 +605,13 @@ mn10200_elf_relax_section (abfd, sec, link_info, again) 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; } } @@ -1279,7 +1278,8 @@ mn10200_elf_relax_delete_bytes (abfd, sec, addr, count) 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. */ @@ -1411,7 +1411,7 @@ mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order, 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) @@ -1419,20 +1419,19 @@ mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order, 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; } @@ -1442,15 +1441,16 @@ mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order, 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; diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index bf8bb63..01211ba 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -36,7 +36,7 @@ static boolean mn10300_elf_relax_section 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 *)); @@ -840,15 +840,14 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) 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; } @@ -925,6 +924,8 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) { /* 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); @@ -953,7 +954,8 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) /* 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; @@ -961,10 +963,10 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) 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 @@ -1016,6 +1018,9 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) 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 @@ -1028,13 +1033,14 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) 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; @@ -1042,10 +1048,10 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) 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); @@ -1138,15 +1144,14 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) 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; } @@ -1206,6 +1211,8 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) 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); @@ -1230,16 +1237,17 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) /* 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) @@ -1455,15 +1463,14 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) 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; } } @@ -1501,7 +1508,7 @@ mn10300_elf_relax_section (abfd, sec, link_info, again) /* 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); @@ -2583,7 +2590,8 @@ mn10300_elf_relax_delete_bytes (abfd, sec, addr, count) 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. */ @@ -2716,7 +2724,7 @@ mn10300_elf_get_relocated_section_contents (output_bfd, link_info, link_order, 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) @@ -2724,20 +2732,19 @@ mn10300_elf_get_relocated_section_contents (output_bfd, link_info, link_order, 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; } @@ -2747,15 +2754,16 @@ mn10300_elf_get_relocated_section_contents (output_bfd, link_info, link_order, 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; @@ -2866,9 +2874,9 @@ elf32_mn10300_link_hash_table_create (abfd) 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; @@ -2880,9 +2888,9 @@ elf32_mn10300_link_hash_table_create (abfd) } 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); @@ -2899,7 +2907,7 @@ elf32_mn10300_link_hash_table_create (abfd) return &ret->root.root; } -static int +static unsigned long elf_mn10300_mach (flags) flagword flags; { diff --git a/bfd/elf.c b/bfd/elf.c index 2fb73c5..89828f4 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -50,13 +50,13 @@ static boolean assign_file_positions_except_relocs PARAMS ((bfd *)); 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 **)); @@ -80,13 +80,13 @@ _bfd_elf_swap_verdef_in (abfd, src, dst) 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. */ @@ -97,13 +97,13 @@ _bfd_elf_swap_verdef_out (abfd, src, dst) 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. */ @@ -114,8 +114,8 @@ _bfd_elf_swap_verdaux_in (abfd, src, dst) 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. */ @@ -126,8 +126,8 @@ _bfd_elf_swap_verdaux_out (abfd, src, dst) 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. */ @@ -138,11 +138,11 @@ _bfd_elf_swap_verneed_in (abfd, src, dst) 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. */ @@ -153,11 +153,11 @@ _bfd_elf_swap_verneed_out (abfd, src, dst) 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. */ @@ -168,11 +168,11 @@ _bfd_elf_swap_vernaux_in (abfd, src, dst) 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. */ @@ -183,11 +183,11 @@ _bfd_elf_swap_vernaux_out (abfd, src, dst) 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. */ @@ -198,7 +198,7 @@ _bfd_elf_swap_versym_in (abfd, src, dst) 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. */ @@ -209,7 +209,7 @@ _bfd_elf_swap_versym_out (abfd, src, dst) 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 @@ -245,16 +245,16 @@ bfd_elf_hash (namearg) 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); @@ -269,8 +269,8 @@ bfd_elf_mkobject (abfd) { /* 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 @@ -294,8 +294,8 @@ bfd_elf_get_str_section (abfd, shindex) { 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) @@ -374,7 +374,7 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name) 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; @@ -599,21 +599,21 @@ _bfd_elf_print_private_bfd_data (abfd, farg) 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); @@ -628,8 +628,8 @@ _bfd_elf_print_private_bfd_data (abfd, farg) (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"); } } @@ -638,7 +638,7 @@ _bfd_elf_print_private_bfd_data (abfd, farg) 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 *)); @@ -655,7 +655,7 @@ _bfd_elf_print_private_bfd_data (abfd, farg) 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; @@ -747,9 +747,9 @@ _bfd_elf_print_private_bfd_data (abfd, farg) 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); @@ -1076,9 +1076,9 @@ _bfd_elf_link_hash_table_create (abfd) 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; @@ -1167,7 +1167,7 @@ bfd_elf_get_bfd_needed_list (abfd, pneeded) 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 *)); @@ -1194,7 +1194,7 @@ bfd_elf_get_bfd_needed_list (abfd, pneeded) 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; @@ -1214,13 +1214,15 @@ bfd_elf_get_bfd_needed_list (abfd, pneeded) { 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; @@ -1456,8 +1458,10 @@ bfd_section_from_shdr (abfd, shindex) 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; @@ -1529,8 +1533,9 @@ _bfd_elf_new_section_hook (abfd, sec) 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; @@ -1580,7 +1585,7 @@ _bfd_elf_make_section_from_phdr (abfd, hdr, index, typename) && (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); @@ -1611,7 +1616,7 @@ _bfd_elf_make_section_from_phdr (abfd, hdr, index, typename) 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); @@ -1659,7 +1664,7 @@ bfd_section_from_phdr (abfd, hdr, index) 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; @@ -1692,10 +1697,10 @@ _bfd_elf_init_reloc_shdr (abfd, rel_hdr, asect, use_rela_p) 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); @@ -1879,6 +1884,7 @@ assign_section_numbers (abfd) asection *sec; unsigned int section_number; Elf_Internal_Shdr **i_shdrp; + bfd_size_type amt; section_number = 1; @@ -1912,13 +1918,13 @@ assign_section_numbers (abfd) /* 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); @@ -2000,7 +2006,7 @@ assign_section_numbers (abfd) 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); @@ -2066,19 +2072,19 @@ static boolean 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"); @@ -2094,7 +2100,8 @@ elf_map_symbols (abfd) } 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; @@ -2102,7 +2109,7 @@ elf_map_symbols (abfd) for (idx = 0; idx < symcount; idx++) { - sym = syms[idx]; + asymbol *sym = syms[idx]; if ((sym->flags & BSF_SECTION_SYM) != 0 && sym->value == 0) @@ -2141,6 +2148,8 @@ elf_map_symbols (abfd) for (asect = abfd->sections; asect; asect = asect->next) { + asymbol *sym; + if (sect_syms[asect->index] != NULL) continue; @@ -2185,16 +2194,16 @@ elf_map_symbols (abfd) } /* 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++; @@ -2209,7 +2218,7 @@ elf_map_symbols (abfd) && 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)) @@ -2367,11 +2376,11 @@ make_mapping (abfd, sections, from, to, phdr) 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; @@ -2410,6 +2419,7 @@ map_sections_to_segments (abfd) boolean phdr_in_segment = true; boolean writable; asection *dynsec; + bfd_size_type amt; if (elf_tdata (abfd)->segment_map != NULL) return true; @@ -2419,8 +2429,8 @@ map_sections_to_segments (abfd) /* 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; @@ -2449,8 +2459,8 @@ map_sections_to_segments (abfd) 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; @@ -2463,8 +2473,8 @@ map_sections_to_segments (abfd) *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; @@ -2611,8 +2621,8 @@ map_sections_to_segments (abfd) /* 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; @@ -2634,8 +2644,8 @@ map_sections_to_segments (abfd) 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; @@ -2733,6 +2743,7 @@ assign_file_positions_for_segments (abfd) 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) { @@ -2773,8 +2784,8 @@ assign_file_positions_for_segments (abfd) 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; @@ -3102,7 +3113,7 @@ assign_file_positions_for_segments (abfd) 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; @@ -3470,10 +3481,10 @@ _bfd_elf_write_object_contents (abfd) (*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; } } @@ -3779,6 +3790,7 @@ copy_private_bfd_data (ibfd, obfd) bfd_vma matching_lma; bfd_vma suggested_lma; unsigned int j; + bfd_size_type amt; if (segment->p_type == PT_NULL) continue; @@ -3791,10 +3803,9 @@ copy_private_bfd_data (ibfd, obfd) /* 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; @@ -3871,8 +3882,8 @@ copy_private_bfd_data (ibfd, obfd) 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; @@ -4064,11 +4075,9 @@ copy_private_bfd_data (ibfd, obfd) /* 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; @@ -4283,6 +4292,7 @@ swap_out_syms (abfd, sttp, relocatable_p) Elf_Internal_Shdr *symstrtab_hdr; char *outbound_syms; int idx; + bfd_size_type amt; stt = _bfd_elf_stringtab_init (); if (stt == NULL) @@ -4298,8 +4308,8 @@ swap_out_syms (abfd, sttp, relocatable_p) 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; @@ -4673,6 +4683,7 @@ _bfd_elf_slurp_version_tables (abfd) bfd *abfd; { bfd_byte *contents = NULL; + bfd_size_type amt; if (elf_dynverdef (abfd) != 0) { @@ -4690,7 +4701,7 @@ _bfd_elf_slurp_version_tables (abfd) 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 @@ -4709,9 +4720,8 @@ _bfd_elf_slurp_version_tables (abfd) ((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; @@ -4732,10 +4742,8 @@ _bfd_elf_slurp_version_tables (abfd) 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; @@ -4785,9 +4793,9 @@ _bfd_elf_slurp_version_tables (abfd) 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; @@ -4797,7 +4805,7 @@ _bfd_elf_slurp_version_tables (abfd) 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; @@ -4818,10 +4826,9 @@ _bfd_elf_slurp_version_tables (abfd) 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)); @@ -4871,8 +4878,9 @@ _bfd_elf_make_empty_symbol (abfd) 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 @@ -5090,6 +5098,7 @@ _bfd_elf_set_section_contents (abfd, section, location, offset, count) bfd_size_type count; { Elf_Internal_Shdr *hdr; + bfd_signed_vma pos; if (! abfd->output_has_begun && ! _bfd_elf_compute_section_file_positions @@ -5097,10 +5106,9 @@ _bfd_elf_set_section_contents (abfd, section, location, offset, count) 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; @@ -5312,8 +5320,8 @@ boolean _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; @@ -5322,7 +5330,7 @@ _bfd_elfcore_make_pseudosection (abfd, name, size, filepos) /* 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); @@ -5352,7 +5360,7 @@ elfcore_grok_prstatus (abfd, note) bfd *abfd; Elf_Internal_Note *note; { - int raw_size; + size_t raw_size; int offset; if (note->descsz == sizeof (prstatus_t)) @@ -5470,25 +5478,25 @@ char * _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) @@ -5617,7 +5625,7 @@ elfcore_grok_lwpstatus (abfd, note) /* 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); @@ -5646,7 +5654,7 @@ elfcore_grok_lwpstatus (abfd, note) /* 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); @@ -5701,7 +5709,7 @@ elfcore_grok_win32pstatus (abfd, note) /* 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; @@ -5726,7 +5734,7 @@ elfcore_grok_win32pstatus (abfd, note) /* 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; @@ -5814,8 +5822,8 @@ elfcore_grok_note (abfd, note) 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; @@ -5823,14 +5831,14 @@ elfcore_read_notes (abfd, offset, size) 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); @@ -5844,12 +5852,12 @@ elfcore_read_notes (abfd, offset, size) 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); diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index 87d7a97..4f7d1c1 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -155,7 +155,7 @@ static boolean 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) { diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h index 2b627ec..5eca779 100644 --- a/bfd/elf32-arm.h +++ b/bfd/elf32-arm.h @@ -35,7 +35,7 @@ static struct bfd_link_hash_table *elf32_arm_link_hash_table_create 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 @@ -117,7 +117,7 @@ static enum elf_reloc_type_class elf32_arm_reloc_type_class 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] */ @@ -127,7 +127,7 @@ static const unsigned long elf32_arm_plt0_entry [PLT_ENTRY_SIZE / 4] = /* 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 */ @@ -184,10 +184,10 @@ struct elf32_arm_link_hash_table 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; @@ -234,9 +234,9 @@ elf32_arm_link_hash_table_create (abfd) 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; @@ -270,8 +270,8 @@ find_thumb_glue (link_info, name, input_bfd) /* 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); @@ -305,8 +305,8 @@ find_arm_glue (link_info, name, input_bfd) /* 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); @@ -383,13 +383,13 @@ bfd_elf32_arm_allocate_interworking_sections (info) { 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; @@ -404,8 +404,8 @@ bfd_elf32_arm_allocate_interworking_sections (info) 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; @@ -424,6 +424,7 @@ record_arm_to_thumb_glue (link_info, h) 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); @@ -435,8 +436,8 @@ record_arm_to_thumb_glue (link_info, h) 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); @@ -455,9 +456,9 @@ record_arm_to_thumb_glue (link_info, h) /* 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); @@ -479,6 +480,7 @@ record_thumb_to_arm_glue (link_info, h) 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); @@ -490,7 +492,8 @@ record_thumb_to_arm_glue (link_info, h) 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); @@ -506,8 +509,9 @@ record_thumb_to_arm_glue (link_info, h) 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); @@ -521,7 +525,8 @@ record_thumb_to_arm_glue (link_info, h) #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); @@ -529,8 +534,9 @@ record_thumb_to_arm_glue (link_info, h) 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); @@ -655,7 +661,7 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info, no_pipeline_knowledge) /* 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); @@ -691,7 +697,7 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info, no_pipeline_knowledge) 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; } } @@ -713,7 +719,7 @@ bfd_elf32_arm_process_before_allocation (abfd, link_info, no_pipeline_knowledge) 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; } @@ -846,7 +852,7 @@ elf32_thumb_to_arm_stub (info, name, input_bfd, output_bfd, input_section, 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; @@ -889,10 +895,10 @@ elf32_thumb_to_arm_stub (info, name, input_bfd, output_bfd, input_section, --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 = @@ -911,7 +917,7 @@ elf32_thumb_to_arm_stub (info, name, input_bfd, output_bfd, input_section, + 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); } @@ -919,18 +925,17 @@ elf32_thumb_to_arm_stub (info, name, input_bfd, output_bfd, input_section, /* 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; @@ -953,7 +958,7 @@ elf32_arm_to_thumb_stub (info, name, input_bfd, output_bfd, input_section, 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; @@ -992,10 +997,10 @@ elf32_arm_to_thumb_stub (info, name, input_bfd, output_bfd, input_section, --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. */ @@ -1009,18 +1014,17 @@ elf32_arm_to_thumb_stub (info, name, input_bfd, output_bfd, input_section, 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; } @@ -1041,7 +1045,7 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd, 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; @@ -1722,8 +1726,8 @@ arm_add_to_rel (abfd, address, howto, increment) 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 { @@ -1751,7 +1755,7 @@ arm_add_to_rel (abfd, address, howto, increment) case R_ARM_PC24: addend <<= howto->size; - addend += increment; + addend += increment; /* Should we check for overflow here ? */ @@ -1810,7 +1814,12 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, || 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) @@ -1827,7 +1836,9 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, 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 @@ -2540,10 +2551,11 @@ elf32_arm_check_relocs (abfd, info, sec, relocs) 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; @@ -2667,8 +2679,7 @@ elf32_arm_check_relocs (abfd, info, sec, relocs) 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; @@ -3091,37 +3102,40 @@ elf32_arm_size_dynamic_sections (output_bfd, info) 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; } @@ -3254,7 +3268,7 @@ elf32_arm_finish_dynamic_symbol (output_bfd, info, h, sym) 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 @@ -3466,14 +3480,14 @@ elf32_arm_reloc_type_class (type) #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 diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c index 55ea2c6..1081b51 100644 --- a/bfd/elf32-avr.c +++ b/bfd/elf32-avr.c @@ -1,5 +1,5 @@ /* 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 This file is part of BFD, the Binary File Descriptor library. @@ -699,7 +699,7 @@ avr_final_link_relocate (howto, input_bfd, input_section, 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: @@ -913,7 +913,7 @@ static boolean 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) { diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index a4b5e09..eb9a6f4 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -637,9 +637,9 @@ elf_cris_link_hash_table_create (abfd) 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; @@ -758,7 +758,7 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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); @@ -803,9 +803,10 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, + 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 { @@ -815,7 +816,7 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, || 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) @@ -881,14 +882,14 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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; @@ -904,7 +905,7 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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))))) @@ -951,7 +952,7 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, (_("%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 @@ -1078,7 +1079,7 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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); @@ -1095,7 +1096,7 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, (_("%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; @@ -1327,13 +1328,13 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, { 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; @@ -1356,7 +1357,7 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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; @@ -1505,6 +1506,7 @@ elf_cris_finish_dynamic_symbol (output_bfd, info, h, sym) asection *sgot; asection *srela; Elf_Internal_Rela rela; + bfd_byte *where; /* This symbol has an entry in the global offset table. Set it up. */ @@ -1514,27 +1516,25 @@ elf_cris_finish_dynamic_symbol (output_bfd, info, h, sym) 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; } @@ -2317,17 +2317,17 @@ cris_elf_check_relocs (abfd, info, sec, relocs) 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; @@ -2605,7 +2605,7 @@ cris_elf_check_relocs (abfd, info, sec, relocs) 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; @@ -2790,37 +2790,40 @@ elf_cris_size_dynamic_sections (output_bfd, info) 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; } diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c index 345d512..320a3c1 100644 --- a/bfd/elf32-fr30.c +++ b/bfd/elf32-fr30.c @@ -33,13 +33,20 @@ static reloc_howto_type * fr30_reloc_type_lookup 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 [] = { @@ -279,7 +286,7 @@ fr30_elf_i20_reloc (abfd, reloc_entry, symbol, data, 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; } diff --git a/bfd/elf32-gen.c b/bfd/elf32-gen.c index bbef97a..7832d11 100644 --- a/bfd/elf32-gen.c +++ b/bfd/elf32-gen.c @@ -65,7 +65,7 @@ elf_generic_info_to_howto_rel (abfd, bfd_reloc, elf_reloc) bfd_reloc->howto = &dummy; } -static boolean +static boolean elf32_generic_link_add_symbols (abfd, info) bfd *abfd; struct bfd_link_info *info; diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c index 54167b5..397f595 100644 --- a/bfd/elf32-h8300.c +++ b/bfd/elf32-h8300.c @@ -1,5 +1,5 @@ /* 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. @@ -29,8 +29,23 @@ static void elf32_h8_info_to_howto 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, @@ -39,7 +54,7 @@ static boolean elf32_h8_relocate_section 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 @@ -420,7 +435,7 @@ elf32_h8_relocate_section (output_bfd, info, input_bfd, input_section, 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; @@ -503,7 +518,7 @@ elf32_h8_relocate_section (output_bfd, info, input_bfd, input_section, elf32_h8_info_to_howto (input_bfd, &bfd_reloc, rel); howto = bfd_reloc.howto; - + if (h != NULL) name = h->root.root.string; else @@ -564,7 +579,7 @@ elf32_h8_relocate_section (output_bfd, info, input_bfd, input_section, 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; { @@ -586,7 +601,7 @@ elf32_h8_mach (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; @@ -616,7 +631,7 @@ elf32_h8_final_write_processing (abfd, linker) /* 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; { @@ -629,7 +644,7 @@ elf32_h8_object_p (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; @@ -665,7 +680,7 @@ elf32_h8_merge_private_bfd_data (ibfd, obfd) mov.b:24/32 -> mov.b:8 4 bytes mov.[bwl]:24/32 -> mov.[bwl]:16 2 bytes - + */ @@ -766,7 +781,7 @@ elf32_h8_relax_section (abfd, sec, link_info, again) 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; } @@ -837,7 +852,7 @@ elf32_h8_relax_section (abfd, sec, link_info, again) /* 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; @@ -859,8 +874,8 @@ elf32_h8_relax_section (abfd, sec, link_info, again) 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) @@ -871,7 +886,7 @@ elf32_h8_relax_section (abfd, sec, link_info, again) /* 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); @@ -958,7 +973,7 @@ elf32_h8_relax_section (abfd, sec, link_info, again) 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 @@ -1268,7 +1283,8 @@ elf32_h8_relax_delete_bytes (abfd, sec, addr, count) 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. */ @@ -1400,7 +1416,7 @@ elf32_h8_get_relocated_section_contents (output_bfd, link_info, link_order, 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) @@ -1413,15 +1429,15 @@ elf32_h8_get_relocated_section_contents (output_bfd, link_info, link_order, 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; } @@ -1432,12 +1448,12 @@ elf32_h8_get_relocated_section_contents (output_bfd, link_info, link_order, 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; diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 4c3dadb..68a956c 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -506,8 +506,9 @@ elf32_hppa_link_hash_table_create (abfd) 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; @@ -551,7 +552,7 @@ hppa_stub_name (input_section, sym_sec, hash, rel) const Elf_Internal_Rela *rel; { char *stub_name; - size_t len; + bfd_size_type len; if (hash) { @@ -659,7 +660,7 @@ hppa_add_stub (stub_name, section, hplink) 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); @@ -1452,19 +1453,20 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs) /* 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; @@ -1507,17 +1509,18 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs) 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); @@ -1615,7 +1618,7 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs) 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) @@ -1687,7 +1690,7 @@ elf32_hppa_check_relocs (abfd, info, sec, relocs) 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; @@ -2432,7 +2435,10 @@ elf32_hppa_size_dynamic_sections (output_bfd, info) 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 @@ -2440,36 +2446,36 @@ elf32_hppa_size_dynamic_sections (output_bfd, info) 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; } @@ -2504,6 +2510,7 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size, boolean stubs_always_before_branch; boolean stub_changed = 0; boolean ret = 0; + bfd_size_type amt; hplink = hppa_link_hash_table (info); @@ -2542,8 +2549,8 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size, } } - 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; @@ -2561,8 +2568,8 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size, 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; @@ -2679,9 +2686,8 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size, /* 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; @@ -2695,6 +2701,7 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size, 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; @@ -2703,25 +2710,24 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size, /* 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; @@ -2746,7 +2752,7 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size, 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) @@ -2867,19 +2873,18 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size, 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); @@ -2889,7 +2894,7 @@ elf32_hppa_size_stubs (output_bfd, stub_bfd, info, multi_subspace, group_size, /* 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) { @@ -3205,7 +3210,7 @@ elf32_hppa_build_stubs (info) 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; @@ -3255,7 +3260,7 @@ elf32_hppa_final_link (abfd, info) 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; @@ -3805,7 +3810,7 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section, { /* 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 @@ -3957,8 +3962,6 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section, 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, diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c index 4a43496..61d4d88 100644 --- a/bfd/elf32-i370.c +++ b/bfd/elf32-i370.c @@ -921,37 +921,40 @@ i370_elf_size_dynamic_sections (output_bfd, info) 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 @@ -1174,7 +1177,7 @@ i370_elf_finish_dynamic_sections (output_bfd, info) 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); @@ -1704,7 +1707,9 @@ i370_elf_post_process_headers (abfd, link_info) #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; } diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index ffa810c..93dfa5e 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -455,9 +455,9 @@ elf_i386_link_hash_table_create (abfd) 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; @@ -633,15 +633,16 @@ elf_i386_check_relocs (abfd, info, sec, relocs) /* 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; @@ -801,7 +802,7 @@ elf_i386_check_relocs (abfd, info, sec, relocs) 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; @@ -1388,36 +1389,39 @@ elf_i386_size_dynamic_sections (output_bfd, info) 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; } @@ -1764,8 +1768,6 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, 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, @@ -1983,7 +1985,7 @@ elf_i386_finish_dynamic_symbol (output_bfd, info, h, sym) 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 @@ -2226,7 +2228,7 @@ elf_i386_grok_prstatus (abfd, note) Elf_Internal_Note *note; { int offset; - int raw_size; + size_t raw_size; switch (note->descsz) { diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c index e72b90c..142d138 100644 --- a/bfd/elf32-i860.c +++ b/bfd/elf32-i860.c @@ -695,7 +695,8 @@ elf32_i860_info_to_howto_rela (abfd, bfd_reloc, elf_reloc) 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)); } /* Specialized relocation handler for R_860_SPLITn. These relocations @@ -709,7 +710,7 @@ elf32_i860_relocate_splitn (input_bfd, rello, contents, value) { 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. */ @@ -736,7 +737,7 @@ elf32_i860_relocate_pc16 (input_bfd, input_section, rello, contents, value) { 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. */ @@ -768,7 +769,7 @@ elf32_i860_relocate_pc26 (input_bfd, input_section, rello, contents, value) { 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. */ @@ -924,10 +925,10 @@ elf32_i860_relocate_section (output_bfd, info, input_bfd, input_section, } /* 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) { diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index fd3d227..bd6e80a 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -369,7 +369,7 @@ m32r_elf_do_10_pcrel_reloc (abfd, howto, input_section, data, offset, + 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; @@ -380,7 +380,7 @@ m32r_elf_do_10_pcrel_reloc (abfd, howto, input_section, data, offset, 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; } @@ -457,7 +457,7 @@ m32r_elf_hi16_reloc (abfd, reloc_entry, symbol, data, 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; @@ -556,8 +556,8 @@ m32r_elf_lo16_reloc (input_bfd, reloc_entry, symbol, data, 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); @@ -647,14 +647,14 @@ m32r_elf_generic_reloc (input_bfd, reloc_entry, symbol, data, { 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: @@ -855,8 +855,8 @@ m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 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) @@ -874,7 +874,7 @@ m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) "_SDA_BASE_", BSF_GLOBAL, s, - 32768, + (bfd_vma) 32768, (const char *) NULL, false, get_elf_backend_data (abfd)->collect, @@ -1410,15 +1410,14 @@ m32r_elf_relax_section (abfd, sec, link_info, again) 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; } } @@ -1782,6 +1781,7 @@ m32r_elf_get_relocated_section_contents (output_bfd, link_info, link_order, 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. */ @@ -1808,15 +1808,13 @@ m32r_elf_get_relocated_section_contents (output_bfd, link_info, link_order, 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; } @@ -1826,14 +1824,15 @@ m32r_elf_get_relocated_section_contents (output_bfd, link_info, link_order, 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; diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 6dc5f58..33de899 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -340,9 +340,9 @@ elf_m68k_link_hash_table_create (abfd) 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; @@ -558,15 +558,16 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) /* 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) { @@ -750,7 +751,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) 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; @@ -1264,36 +1265,39 @@ elf_m68k_size_dynamic_sections (output_bfd, info) 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; } @@ -1961,7 +1965,7 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym) 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 @@ -1975,12 +1979,12 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym) 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; } @@ -2186,6 +2190,7 @@ bfd_m68k_elf32_create_embedded_relocs (abfd, info, datasec, relsec, errmsg) Elf_Internal_Rela *free_relocs = NULL; Elf_Internal_Rela *irel, *irelend; bfd_byte *p; + bfd_size_type amt; BFD_ASSERT (! info->relocateable); @@ -2203,17 +2208,15 @@ bfd_m68k_elf32_create_embedded_relocs (abfd, info, datasec, relsec, errmsg) { /* 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) @@ -2229,7 +2232,8 @@ bfd_m68k_elf32_create_embedded_relocs (abfd, info, datasec, relsec, errmsg) 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; diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c index a9fec6f..8cf9822 100644 --- a/bfd/elf32-mcore.c +++ b/bfd/elf32-mcore.c @@ -550,7 +550,7 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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; } @@ -565,7 +565,7 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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; } diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 935f4fb..1554cce 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -132,7 +132,7 @@ static boolean mips_elf_create_procedure_table 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 *)); @@ -316,15 +316,15 @@ static bfd *reldyn_sorting_bfd; /* 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. */ @@ -1195,7 +1195,7 @@ _bfd_mips_elf_hi16_reloc (abfd, 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; @@ -1263,8 +1263,8 @@ _bfd_mips_elf_lo16_reloc (abfd, 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) { @@ -1387,7 +1387,7 @@ mips_elf_assign_gp (output_bfd, pgp) { 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) @@ -1555,8 +1555,8 @@ gprel16_with_gp (abfd, symbol, reloc_entry, input_section, relocateable, data, || (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; @@ -1671,7 +1671,7 @@ gprel32_with_gp (abfd, symbol, reloc_entry, input_section, relocateable, data, || (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; @@ -1721,7 +1721,7 @@ mips32_64bit_reloc (abfd, reloc_entry, symbol, data, input_section, 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; } @@ -1815,9 +1815,9 @@ mips16_gprel_reloc (abfd, reloc_entry, symbol, data, input_section, /* 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, @@ -1825,13 +1825,13 @@ mips16_gprel_reloc (abfd, reloc_entry, symbol, data, 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; @@ -1865,7 +1865,7 @@ elf_mips_isa (flags) /* Return the MACH for a MIPS e_flags value. */ -static INLINE int +static INLINE unsigned long elf_mips_mach (flags) flagword flags; { @@ -1964,7 +1964,7 @@ struct elf_reloc_map { 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 }, @@ -2133,12 +2133,12 @@ bfd_mips_elf32_swap_reginfo_in (abfd, ex, in) 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 @@ -2147,18 +2147,12 @@ bfd_mips_elf32_swap_reginfo_out (abfd, in, ex) 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 @@ -2173,13 +2167,13 @@ bfd_mips_elf64_swap_reginfo_in (abfd, ex, in) 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 @@ -2188,20 +2182,13 @@ bfd_mips_elf64_swap_reginfo_out (abfd, in, ex) 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 @@ -2213,8 +2200,8 @@ bfd_mips_elf32_swap_gptab_in (abfd, ex, in) 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 @@ -2223,10 +2210,8 @@ bfd_mips_elf32_swap_gptab_out (abfd, in, ex) 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 @@ -2235,12 +2220,12 @@ bfd_elf32_swap_compact_rel_out (abfd, in, ex) 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 @@ -2255,9 +2240,9 @@ bfd_elf32_swap_crinfo_out (abfd, in, ex) | ((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. */ @@ -2268,10 +2253,10 @@ bfd_mips_elf_swap_options_in (abfd, ex, in) 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. */ @@ -2282,10 +2267,10 @@ bfd_mips_elf_swap_options_out (abfd, in, ex) 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. */ @@ -2296,8 +2281,8 @@ bfd_mips_elf_swap_msym_in (abfd, ex, in) 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. */ @@ -2308,8 +2293,8 @@ bfd_mips_elf_swap_msym_out (abfd, in, ex) 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); } /* Determine whether a symbol is global for the purposes of splitting @@ -2879,7 +2864,8 @@ _bfd_mips_elf_section_from_shdr (abfd, hdr, name) 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; @@ -3060,11 +3046,11 @@ _bfd_mips_elf_fake_sections (abfd, hdr, sec) 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, @@ -3118,8 +3104,8 @@ _bfd_mips_elf_set_section_contents (abfd, section, location, offset, count) 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; } @@ -3138,7 +3124,7 @@ _bfd_mips_elf_set_section_contents (abfd, section, location, offset, count) 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, @@ -3165,10 +3151,10 @@ _bfd_mips_elf_section_processing (abfd, hdr) 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; } @@ -3204,10 +3190,10 @@ _bfd_mips_elf_section_processing (abfd, hdr) + (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) @@ -3219,10 +3205,10 @@ _bfd_mips_elf_section_processing (abfd, hdr) + (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; @@ -3401,6 +3387,7 @@ _bfd_mips_elf_modify_segment_map (abfd) { 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. */ @@ -3412,7 +3399,8 @@ _bfd_mips_elf_modify_segment_map (abfd) 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; @@ -3438,8 +3426,6 @@ _bfd_mips_elf_modify_segment_map (abfd) 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; @@ -3458,8 +3444,8 @@ _bfd_mips_elf_modify_segment_map (abfd) 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; @@ -3484,7 +3470,8 @@ _bfd_mips_elf_modify_segment_map (abfd) 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; @@ -3574,8 +3561,8 @@ _bfd_mips_elf_modify_segment_map (abfd) 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; @@ -3632,20 +3619,20 @@ ecoff_swap_rpdr_out (abfd, in, ex) 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 } @@ -3665,7 +3652,7 @@ _bfd_mips_elf_read_ecoff_info (abfd, section, debug) 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; @@ -3684,12 +3671,12 @@ _bfd_mips_elf_read_ecoff_info (abfd, section, debug) 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; \ } @@ -3785,7 +3772,7 @@ _bfd_mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr, 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; @@ -3811,9 +3798,9 @@ _bfd_mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr, 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; @@ -3827,10 +3814,8 @@ _bfd_mips_elf_find_nearest_line (abfd, section, symbols, offset, filename_ptr, } /* 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; @@ -4031,9 +4016,9 @@ _bfd_mips_elf_link_hash_table_create (abfd) 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; @@ -4101,12 +4086,14 @@ _bfd_mips_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) { 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; @@ -4140,12 +4127,14 @@ _bfd_mips_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) { 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; @@ -4431,7 +4420,8 @@ mips_elf_create_procedure_table (handle, abfd, info, s, debug) 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; @@ -4464,7 +4454,8 @@ mips_elf_create_procedure_table (handle, abfd, info, s, debug) 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; @@ -4485,7 +4476,7 @@ mips_elf_create_procedure_table (handle, abfd, info, s, debug) 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); @@ -4526,7 +4517,7 @@ mips_elf_create_procedure_table (handle, abfd, info, s, debug) 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; @@ -4598,9 +4589,10 @@ _bfd_mips_elf_final_link (abfd, info) 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" @@ -4749,7 +4741,7 @@ _bfd_mips_elf_final_link (abfd, info) 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); @@ -4782,6 +4774,7 @@ _bfd_mips_elf_final_link (abfd, info) 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 @@ -4830,10 +4823,10 @@ _bfd_mips_elf_final_link (abfd, info) 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; @@ -4842,7 +4835,7 @@ _bfd_mips_elf_final_link (abfd, info) else esym.asym.value = last; if (!bfd_ecoff_debug_one_external (abfd, &debug, swap, - name[i], &esym)) + secname[i], &esym)) return false; } @@ -4999,7 +4992,7 @@ _bfd_mips_elf_final_link (abfd, info) 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 @@ -5007,8 +5000,6 @@ _bfd_mips_elf_final_link (abfd, info) 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) @@ -5077,7 +5068,8 @@ _bfd_mips_elf_final_link (abfd, info) /* 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); @@ -5122,7 +5114,8 @@ _bfd_mips_elf_final_link (abfd, info) 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; @@ -5149,9 +5142,8 @@ _bfd_mips_elf_final_link (abfd, info) 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); @@ -5193,16 +5185,16 @@ _bfd_mips_elf_final_link (abfd, info) 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); @@ -5236,7 +5228,7 @@ _bfd_mips_elf_final_link (abfd, info) 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; } @@ -6804,7 +6796,7 @@ _bfd_mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, /* 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. */ @@ -6864,7 +6856,7 @@ _bfd_mips_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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 @@ -7234,7 +7226,7 @@ _bfd_mips_elf_create_dynamic_sections (abfd, info) { 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; @@ -7397,6 +7389,7 @@ mips_elf_create_got_section (abfd, info) 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)) @@ -7432,8 +7425,8 @@ mips_elf_create_got_section (abfd, info) /* 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; @@ -7441,8 +7434,8 @@ mips_elf_create_got_section (abfd, info) 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; } @@ -7605,13 +7598,14 @@ _bfd_mips_elf_check_relocs (abfd, info, sec, relocs) { 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; @@ -7714,7 +7708,7 @@ _bfd_mips_elf_check_relocs (abfd, info, sec, relocs) 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); @@ -7849,12 +7843,12 @@ _bfd_mips_elf_check_relocs (abfd, info, sec, relocs) { 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 @@ -8133,7 +8127,7 @@ _bfd_mips_elf_adjust_dynamic_symbol (info, h) 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, @@ -8220,7 +8214,8 @@ _bfd_mips_elf_always_size_sections (output_bfd, info) /* 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) @@ -8397,7 +8392,8 @@ _bfd_mips_elf_size_dynamic_sections (output_bfd, info) { 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; @@ -8697,18 +8693,18 @@ _bfd_mips_elf_finish_dynamic_symbol (output_bfd, info, h, sym) /* 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); @@ -8982,7 +8978,7 @@ _bfd_mips_elf_finish_dynamic_sections (output_bfd, info) 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: @@ -9158,7 +9154,7 @@ _bfd_elf32_mips_grok_prstatus (abfd, note) Elf_Internal_Note *note; { int offset; - int raw_size; + unsigned int raw_size; switch (note->descsz) { @@ -9240,7 +9236,7 @@ elf32_mips_get_relocated_section_contents (abfd, link_info, link_order, data, 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; @@ -9248,7 +9244,7 @@ elf32_mips_get_relocated_section_contents (abfd, link_info, link_order, data, if (!bfd_get_section_contents (input_bfd, input_section, (PTR) data, - 0, + (file_ptr) 0, input_section->_raw_size)) goto error_return; diff --git a/bfd/elf32-openrisc.c b/bfd/elf32-openrisc.c index 8199bf3..20358e0 100644 --- a/bfd/elf32-openrisc.c +++ b/bfd/elf32-openrisc.c @@ -1,5 +1,5 @@ /* 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. @@ -35,10 +35,10 @@ static boolean openrisc_elf_relocate_section 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 *, diff --git a/bfd/elf32-pj.c b/bfd/elf32-pj.c index 5502616..5620b5b 100644 --- a/bfd/elf32-pj.c +++ b/bfd/elf32-pj.c @@ -1,5 +1,5 @@ /* 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. @@ -224,7 +224,7 @@ pj_elf_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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 @@ -233,7 +233,7 @@ pj_elf_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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: @@ -241,18 +241,18 @@ pj_elf_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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: diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index a25bcde..392d4fd 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -1059,6 +1059,7 @@ ppc_elf_relax_section (abfd, isec, link_info, again) if (isec->reloc_count) { unsigned n; + bfd_size_type amt; /* Get a copy of the native relocations. */ internal_relocs = _bfd_elf32_link_read_relocs ( @@ -1070,8 +1071,9 @@ ppc_elf_relax_section (abfd, isec, link_info, again) 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) @@ -1200,7 +1202,7 @@ ppc_elf_relax_section (abfd, isec, link_info, again) #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; } } @@ -2014,37 +2016,40 @@ ppc_elf_size_dynamic_sections (output_bfd, info) 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; } @@ -2200,15 +2205,16 @@ ppc_elf_check_relocs (abfd, info, sec, relocs) /* 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) { @@ -2579,21 +2585,24 @@ ppc_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 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; @@ -2697,7 +2706,7 @@ ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym) 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 @@ -2842,7 +2851,7 @@ ppc_elf_finish_dynamic_sections (output_bfd, info) 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); @@ -3320,7 +3329,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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 */ @@ -3331,7 +3340,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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 */ @@ -3568,7 +3577,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, { /* 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; @@ -3731,7 +3740,7 @@ ppc_elf_grok_prstatus (abfd, note) Elf_Internal_Note *note; { int offset; - int raw_size; + unsigned int raw_size; switch (note->descsz) { diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index fad7a8a..873f8b6 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -104,7 +104,7 @@ static reloc_howto_type elf_howto_table[] = 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) @@ -157,7 +157,7 @@ elf_s390_reloc_type_lookup (abfd, code) case BFD_RELOC_VTABLE_ENTRY: return &elf32_s390_vtentry_howto; default: - break; + break; } return 0; } @@ -184,7 +184,7 @@ elf_s390_info_to_howto (abfd, cache_ptr, dst) 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 @@ -213,7 +213,7 @@ elf_s390_is_local_label_name (abfd, name) /* 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 @@ -227,7 +227,7 @@ elf_s390_is_local_label_name (abfd, name) 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. @@ -241,7 +241,7 @@ elf_s390_is_local_label_name (abfd, name) 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. @@ -334,7 +334,7 @@ RET1: BASR 1,0 # 2 bytes Return from GOT 1st time 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 @@ -456,9 +456,9 @@ elf_s390_link_hash_table_create (abfd) 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; @@ -517,7 +517,7 @@ elf_s390_check_relocs (abfd, info, sec, relocs) 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) @@ -598,15 +598,16 @@ elf_s390_check_relocs (abfd, info, sec, relocs) /* 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) { @@ -744,7 +745,7 @@ elf_s390_check_relocs (abfd, info, sec, relocs) 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; @@ -772,7 +773,7 @@ elf_s390_check_relocs (abfd, info, sec, relocs) if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend)) return false; break; - + default: break; } @@ -1220,37 +1221,40 @@ elf_s390_size_dynamic_sections (output_bfd, info) 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; } @@ -1546,7 +1550,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, break; - + case R_390_GOTOFF: /* Relocation is relative to the start of the global offset table. */ @@ -1798,7 +1802,7 @@ elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym) 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; @@ -1807,81 +1811,82 @@ elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym) 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); @@ -1932,7 +1937,7 @@ elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym) 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 @@ -2069,31 +2074,31 @@ elf_s390_finish_dynamic_sections (output_bfd, info) 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); diff --git a/bfd/elf32-sh-lin.c b/bfd/elf32-sh-lin.c index 84413f5..e0b434d 100644 --- a/bfd/elf32-sh-lin.c +++ b/bfd/elf32-sh-lin.c @@ -1,5 +1,5 @@ /* 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. @@ -43,7 +43,7 @@ elf32_shlin_grok_prstatus (abfd, note) Elf_Internal_Note *note; { int offset; - int raw_size; + unsigned int raw_size; switch (note->descsz) { diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 6cf4974..e835156 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -767,10 +767,10 @@ sh_elf_reloc_loop (r_type, input_bfd, input_section, contents, addr, 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)) @@ -825,7 +825,7 @@ sh_elf_reloc_loop (r_type, input_bfd, input_section, contents, addr, 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; } @@ -880,7 +880,7 @@ sh_elf_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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); @@ -893,7 +893,7 @@ sh_elf_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, 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; @@ -1120,7 +1120,7 @@ sh_elf_relax_section (abfd, sec, link_info, again) 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) @@ -1151,13 +1151,12 @@ sh_elf_relax_section (abfd, sec, link_info, again) 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; } @@ -1251,7 +1250,7 @@ sh_elf_relax_section (abfd, sec, link_info, again) 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 @@ -1259,7 +1258,7 @@ sh_elf_relax_section (abfd, sec, link_info, again) /* 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 @@ -1460,7 +1459,8 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, 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)); if (irelalign == NULL) sec->_cooked_size -= count; else @@ -1471,7 +1471,7 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count) 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. */ @@ -1649,14 +1649,14 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count) 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: @@ -1670,7 +1670,7 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count) } 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: @@ -1684,12 +1684,12 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count) 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: @@ -1780,12 +1780,12 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count) 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); } @@ -1886,7 +1886,7 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count) { /* Tail recursion. */ return sh_elf_relax_delete_bytes (abfd, sec, alignaddr, - alignto - alignaddr); + (int) (alignto - alignaddr)); } } @@ -1907,13 +1907,16 @@ sh_elf_align_loads (abfd, sec, internal_relocs, contents, pswapped) 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; @@ -1982,8 +1985,8 @@ sh_elf_swap_insns (abfd, sec, relocs, contents, addr) /* 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; @@ -2052,7 +2055,7 @@ sh_elf_swap_insns (abfd, sec, relocs, contents, addr) 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: @@ -2061,7 +2064,7 @@ sh_elf_swap_insns (abfd, sec, relocs, contents, addr) 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: @@ -2078,7 +2081,7 @@ sh_elf_swap_insns (abfd, sec, relocs, contents, addr) 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; @@ -2431,9 +2434,9 @@ sh_elf_link_hash_table_create (abfd) 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; @@ -2535,7 +2538,7 @@ sh_elf_create_dynamic_sections (abfd, info) || ((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); @@ -2891,36 +2894,39 @@ sh_elf_size_dynamic_sections (output_bfd, info) 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; } @@ -3531,7 +3537,7 @@ sh_elf_get_relocated_section_contents (output_bfd, link_info, link_order, 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) @@ -3539,20 +3545,19 @@ sh_elf_get_relocated_section_contents (output_bfd, link_info, link_order, 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; } @@ -3562,14 +3567,15 @@ sh_elf_get_relocated_section_contents (output_bfd, link_info, link_order, 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; @@ -3828,10 +3834,11 @@ sh_elf_check_relocs (abfd, info, sec, relocs) 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; @@ -3967,7 +3974,7 @@ sh_elf_check_relocs (abfd, info, sec, relocs) 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; @@ -4220,7 +4227,7 @@ sh_elf_finish_dynamic_symbol (output_bfd, info, h, sym) 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 diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c index 1fe328e..1707830 100644 --- a/bfd/elf32-sparc.c +++ b/bfd/elf32-sparc.c @@ -142,7 +142,7 @@ struct elf_reloc_map { 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, }, @@ -455,10 +455,11 @@ elf32_sparc_check_relocs (abfd, info, sec, relocs) 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; @@ -1032,33 +1033,36 @@ elf32_sparc_size_dynamic_sections (output_bfd, info) 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; } @@ -1670,7 +1674,7 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section, || 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); } @@ -1757,7 +1761,7 @@ elf32_sparc_finish_dynamic_symbol (output_bfd, info, h, sym) (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. */ @@ -1800,7 +1804,7 @@ elf32_sparc_finish_dynamic_symbol (output_bfd, info, h, sym) 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 @@ -1926,7 +1930,7 @@ elf32_sparc_finish_dynamic_sections (output_bfd, info) 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); } diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index 7696c00..0e9fbae 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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)); @@ -46,7 +46,7 @@ static boolean v850_elf_relocate_section 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 @@ -524,7 +524,7 @@ v850_elf_reloc_type_lookup (abfd, code) 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; @@ -699,7 +699,8 @@ v850_elf_check_relocs (abfd, info, sec, relocs) 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; @@ -764,10 +765,11 @@ remember_hi16s_reloc (abfd, addend, address) 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; @@ -837,10 +839,10 @@ find_remembered_hi16s_reloc (addend, already_found) 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; @@ -865,7 +867,7 @@ v850_elf_perform_relocation (abfd, r_type, addend, address) 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: @@ -1064,7 +1066,7 @@ v850_elf_perform_relocation (abfd, r_type, addend, address) { 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 @@ -1130,7 +1132,7 @@ v850_elf_perform_relocation (abfd, r_type, addend, address) 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: @@ -1219,9 +1221,9 @@ v850_elf_perform_relocation (abfd, r_type, addend, address) 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: @@ -1246,7 +1248,7 @@ v850_elf_perform_relocation (abfd, r_type, addend, address) } - bfd_put_16 (abfd, insn, address); + bfd_put_16 (abfd, (bfd_vma) insn, address); return bfd_reloc_ok; } @@ -1315,7 +1317,7 @@ v850_elf_reloc (abfd, reloc, symbol, data, isection, obfd, err) .text .globl _start nop - _start: + _start: jr foo .section ".foo","ax" @@ -1363,7 +1365,7 @@ v850_elf_final_link_relocate (howto, input_bfd, output_bfd, 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. */ @@ -1535,7 +1537,8 @@ v850_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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; } diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index 2836fd5..79cebc1 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -163,7 +163,7 @@ struct alpha_elf_link_hash_entry 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; @@ -321,9 +321,9 @@ elf64_alpha_bfd_link_hash_table_create (abfd) 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; @@ -375,7 +375,8 @@ static boolean 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; @@ -387,7 +388,8 @@ elf64_alpha_object_p (abfd) { /* 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; @@ -803,8 +805,8 @@ elf64_alpha_do_reloc_gpdisp (abfd, gpdisp, p_ldah, p_lda) | (((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; } @@ -1065,7 +1067,8 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) 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; } @@ -1077,7 +1080,7 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) 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; @@ -1097,13 +1100,15 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) /* 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; @@ -1136,7 +1141,8 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) 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 @@ -1172,8 +1178,8 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) 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; @@ -1204,7 +1210,8 @@ elf64_alpha_relax_with_lituse (info, symval, irel, irelend) 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; } } @@ -1317,7 +1324,7 @@ elf64_alpha_relax_without_lituse (info, symval, irel) `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); @@ -1444,13 +1451,12 @@ elf64_alpha_relax_section (abfd, sec, link_info, again) 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; } @@ -1586,10 +1592,10 @@ elf64_alpha_relax_section (abfd, sec, link_info, again) /* 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 */ @@ -1857,7 +1863,7 @@ elf64_alpha_read_ecoff_info (abfd, section, debug) 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; @@ -1876,12 +1882,12 @@ elf64_alpha_read_ecoff_info (abfd, section, debug) 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; \ } @@ -1994,9 +2000,9 @@ elf64_alpha_find_nearest_line (abfd, section, symbols, offset, filename_ptr, 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; @@ -2010,10 +2016,8 @@ elf64_alpha_find_nearest_line (abfd, section, symbols, offset, filename_ptr, } /* 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; @@ -2225,6 +2229,7 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) 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; @@ -2278,9 +2283,9 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) 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; @@ -2303,16 +2308,16 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) /* 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; } @@ -2323,9 +2328,9 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) 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; @@ -2433,17 +2438,15 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) 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; } @@ -2465,9 +2468,8 @@ elf64_alpha_check_relocs (abfd, info, sec, relocs) 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; @@ -3162,7 +3164,7 @@ elf64_alpha_size_dynamic_sections (output_bfd, info) 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; } @@ -3175,35 +3177,38 @@ elf64_alpha_size_dynamic_sections (output_bfd, info) 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; } @@ -3265,7 +3270,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, 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); @@ -3408,7 +3413,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, /* 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 @@ -3424,7 +3429,7 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, + 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 *) @@ -3654,7 +3659,7 @@ elf64_alpha_finish_dynamic_symbol (output_bfd, info, h, sym) /* 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; @@ -3840,8 +3845,8 @@ elf64_alpha_finish_dynamic_sections (output_bfd, info) 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; @@ -4103,7 +4108,8 @@ elf64_alpha_final_link (abfd, info) 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; } diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index 12a1641..d09a93f 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -62,7 +62,7 @@ struct elf64_hppa_dyn_hash_entry /* 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 @@ -317,7 +317,7 @@ elf64_hppa_hash_table_create (abfd) { 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, @@ -557,7 +557,7 @@ count_dyn_reloc (abfd, dyn_h, type, sec, sec_symndx, offset, addend) 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; @@ -614,6 +614,7 @@ elf64_hppa_check_relocs (abfd, info, sec, relocs) 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. @@ -624,15 +625,15 @@ elf64_hppa_check_relocs (abfd, info, sec, relocs) 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); @@ -641,10 +642,7 @@ elf64_hppa_check_relocs (abfd, info, sec, relocs) /* 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); @@ -669,8 +667,9 @@ elf64_hppa_check_relocs (abfd, info, sec, relocs) /* 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. */ @@ -1047,8 +1046,8 @@ allocate_global_data_dlt (dyn_h, data) 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; } } @@ -1801,8 +1800,11 @@ elf64_hppa_size_dynamic_sections (output_bfd, info) /* 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 @@ -1812,36 +1814,36 @@ elf64_hppa_size_dynamic_sections (output_bfd, info) 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; } @@ -2026,13 +2028,13 @@ elf64_hppa_finish_dynamic_symbol (output_bfd, info, h, sym) /* 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) @@ -2043,7 +2045,7 @@ elf64_hppa_finish_dynamic_symbol (output_bfd, info, h, sym) 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. */ @@ -2052,14 +2054,14 @@ elf64_hppa_finish_dynamic_symbol (output_bfd, info, h, sym) 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); } @@ -2571,7 +2573,8 @@ elf64_hppa_modify_segment_map (abfd) 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; diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c index f68e587..0b8638f 100644 --- a/bfd/elf64-mips.c +++ b/bfd/elf64-mips.c @@ -1154,12 +1154,12 @@ mips_elf64_swap_reloc_in (abfd, src, dst) 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. */ @@ -1170,13 +1170,13 @@ mips_elf64_swap_reloca_in (abfd, src, dst) 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. */ @@ -1187,12 +1187,12 @@ mips_elf64_swap_reloc_out (abfd, src, dst) 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. */ @@ -1203,13 +1203,13 @@ mips_elf64_swap_reloca_out (abfd, src, dst) 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. */ @@ -1310,7 +1310,7 @@ struct elf_reloc_map 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 }, @@ -1391,10 +1391,10 @@ mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, rel_hdr) 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; @@ -1583,6 +1583,7 @@ mips_elf64_slurp_reloc_table (abfd, asect, symbols, dynamic) asymbol **symbols; boolean dynamic; { + bfd_size_type amt; struct bfd_elf_section_data * const d = elf_section_data (asect); if (dynamic) @@ -1597,9 +1598,9 @@ mips_elf64_slurp_reloc_table (abfd, asect, symbols, 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; @@ -1785,18 +1786,19 @@ mips_elf64_slurp_armap (abfd) 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. */ @@ -1815,7 +1817,7 @@ mips_elf64_slurp_armap (abfd) 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); @@ -1828,7 +1830,8 @@ mips_elf64_slurp_armap (abfd) 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; @@ -1838,8 +1841,8 @@ mips_elf64_slurp_armap (abfd) 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); @@ -1919,12 +1922,12 @@ mips_elf64_write_armap (arch, elength, map, symbol_count, stridx) /* 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 - @@ -1940,10 +1943,10 @@ mips_elf64_write_armap (arch, elength, map, symbol_count, stridx) /* 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++; } @@ -1960,7 +1963,7 @@ mips_elf64_write_armap (arch, elength, map, symbol_count, stridx) { 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; } @@ -1968,7 +1971,7 @@ mips_elf64_write_armap (arch, elength, map, symbol_count, stridx) 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; } diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 3a98bc1..d5a340d 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -1724,15 +1724,16 @@ ppc64_elf_check_relocs (abfd, info, sec, relocs) /* 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) { @@ -2455,36 +2456,39 @@ ppc64_elf_size_dynamic_sections (output_bfd, info) 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 @@ -2663,7 +2667,6 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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", @@ -2707,6 +2710,7 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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; @@ -2910,16 +2914,17 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, <= 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); @@ -3118,7 +3123,7 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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. */ @@ -3129,7 +3134,7 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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; @@ -3461,7 +3466,7 @@ ppc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym) + (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"); @@ -3535,7 +3540,7 @@ ppc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym) 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 diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 0e80c43..65041a6 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -289,14 +289,14 @@ elf_s390_is_local_label_name (abfd, name) 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 @@ -313,14 +313,14 @@ elf_s390_is_local_label_name (abfd, name) 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 @@ -415,9 +415,9 @@ elf_s390_link_hash_table_create (abfd) 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; @@ -562,15 +562,15 @@ elf_s390_check_relocs (abfd, info, sec, relocs) /* 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) { @@ -718,7 +718,7 @@ elf_s390_check_relocs (abfd, info, sec, relocs) 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; @@ -1200,37 +1200,40 @@ elf_s390_size_dynamic_sections (output_bfd, info) 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; } @@ -1886,7 +1889,7 @@ elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym) 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 diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index e121126..0742e22 100644 --- a/bfd/elf64-sparc.c +++ b/bfd/elf64-sparc.c @@ -47,9 +47,9 @@ static void sparc64_elf_info_to_howto 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, @@ -177,7 +177,7 @@ struct elf_reloc_map { 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, }, @@ -294,13 +294,12 @@ sparc64_elf_slurp_one_reloc_table (abfd, asect, rel_hdr, symbols, dynamic) 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; @@ -385,6 +384,7 @@ sparc64_elf_slurp_reloc_table (abfd, asect, symbols, dynamic) 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; @@ -415,9 +415,9 @@ sparc64_elf_slurp_reloc_table (abfd, asect, symbols, dynamic) 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; @@ -653,9 +653,9 @@ sparc64_elf_bfd_link_hash_table_create (abfd) 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; @@ -773,8 +773,8 @@ sparc_elf_wdisp16_reloc (abfd, reloc_entry, symbol, data, input_section, 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 @@ -812,7 +812,7 @@ sparc_elf_hix22_reloc (abfd, 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) @@ -848,7 +848,7 @@ sparc_elf_lox10_reloc (abfd, 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; @@ -879,7 +879,7 @@ sparc64_elf_build_plt (output_bfd, contents, nentries) 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. */ @@ -895,14 +895,14 @@ sparc64_elf_build_plt (output_bfd, contents, nentries) /* 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 @@ -923,14 +923,20 @@ sparc64_elf_build_plt (output_bfd, contents, nentries) /* 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); } } } @@ -939,9 +945,9 @@ sparc64_elf_build_plt (output_bfd, contents, nentries) 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; @@ -951,22 +957,21 @@ sparc64_elf_plt_entry_offset (index) 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; @@ -1087,10 +1092,11 @@ sparc64_elf_check_relocs (abfd, info, sec, relocs) 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; @@ -1768,35 +1774,37 @@ sparc64_elf_size_dynamic_sections (output_bfd, info) 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; } @@ -1810,7 +1818,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info) { 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 *) @@ -1847,6 +1855,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info) eht->dynsymcount++; } } +#undef add_dynamic_entry return true; } @@ -2365,7 +2374,8 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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. */ @@ -2431,7 +2441,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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, @@ -2452,8 +2462,9 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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, @@ -2471,7 +2482,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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, @@ -2489,7 +2500,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, 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; @@ -2578,7 +2589,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, || 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; @@ -2683,7 +2694,7 @@ sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym) } 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); @@ -2729,7 +2740,7 @@ sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym) 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 @@ -2871,8 +2882,8 @@ sparc64_elf_finish_dynamic_sections (output_bfd, info) /* 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 = diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 1605b56..24eb9f7 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -98,7 +98,7 @@ struct elf_reloc_map 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, }, @@ -327,9 +327,9 @@ elf64_x86_64_link_hash_table_create (abfd) 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; @@ -463,15 +463,16 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs) /* 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) { @@ -606,7 +607,7 @@ elf64_x86_64_check_relocs (abfd, info, sec, relocs) 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; @@ -1077,36 +1078,39 @@ elf64_x86_64_size_dynamic_sections (output_bfd, info) 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; } @@ -1521,7 +1525,7 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section, } else { - long indx; + long sindx; if (h == NULL) sec = local_sections[r_symndx]; @@ -1533,7 +1537,7 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section, 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); @@ -1544,12 +1548,12 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section, 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; } @@ -1730,7 +1734,7 @@ elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym) 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 diff --git a/bfd/elfarm-nabi.c b/bfd/elfarm-nabi.c index 8b3fc16..7ced680 100644 --- a/bfd/elfarm-nabi.c +++ b/bfd/elfarm-nabi.c @@ -688,7 +688,7 @@ elf32_arm_nabi_grok_prstatus (abfd, note) Elf_Internal_Note *note; { int offset; - int raw_size; + size_t raw_size; switch (note->descsz) { diff --git a/bfd/elfcode.h b/bfd/elfcode.h index d9f3e05..6e3c2c9 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -185,16 +185,16 @@ static char *elf_symbol_flags PARAMS ((flagword)); /* 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 @@ -208,15 +208,15 @@ elf_swap_symbol_in (abfd, src, dst) { 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 @@ -229,12 +229,12 @@ elf_swap_symbol_out (abfd, src, cdst) 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 @@ -248,22 +248,22 @@ elf_swap_ehdr_in (abfd, src, dst) { 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 @@ -278,22 +278,22 @@ elf_swap_ehdr_out (abfd, src, dst) 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 @@ -307,19 +307,19 @@ elf_swap_shdr_in (abfd, src, dst) { 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; } @@ -334,16 +334,16 @@ elf_swap_shdr_out (abfd, src, dst) 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 @@ -357,22 +357,22 @@ elf_swap_phdr_in (abfd, src, dst) { 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 @@ -382,14 +382,14 @@ elf_swap_phdr_out (abfd, src, dst) 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. */ @@ -399,8 +399,8 @@ elf_swap_reloc_in (abfd, src, dst) 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 @@ -409,9 +409,9 @@ elf_swap_reloca_in (abfd, src, dst) 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. */ @@ -421,8 +421,8 @@ elf_swap_reloc_out (abfd, src, dst) 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 @@ -431,9 +431,9 @@ elf_swap_reloca_out (abfd, src, dst) 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 @@ -444,8 +444,8 @@ elf_swap_dyn_in (abfd, p, dst) { 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 @@ -456,8 +456,8 @@ elf_swap_dyn_out (abfd, src, p) { 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); } /* ELF .o/exec file reading */ @@ -503,6 +503,7 @@ elf_object_p (abfd) 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. */ @@ -511,7 +512,8 @@ elf_object_p (abfd) /* 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; @@ -549,8 +551,8 @@ elf_object_p (abfd) /* 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; @@ -632,18 +634,18 @@ elf_object_p (abfd) /* 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; @@ -671,20 +673,18 @@ elf_object_p (abfd) 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); @@ -936,14 +936,14 @@ int 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++; } @@ -961,6 +961,7 @@ elf_write_shdrs_and_ehdr (abfd) 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); @@ -971,14 +972,14 @@ elf_write_shdrs_and_ehdr (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; @@ -989,9 +990,10 @@ elf_write_shdrs_and_ehdr (abfd) #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... */ @@ -1013,6 +1015,7 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) 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 @@ -1046,7 +1049,7 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) } } - 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); @@ -1057,22 +1060,26 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) { 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; @@ -1101,7 +1108,7 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic) 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; } @@ -1271,12 +1278,12 @@ elf_slurp_reloc_table_from_section (abfd, asect, rel_hdr, reloc_count, 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; @@ -1362,6 +1369,7 @@ elf_slurp_reloc_table (abfd, asect, symbols, dynamic) bfd_size_type reloc_count; bfd_size_type reloc_count2; arelent *relents; + bfd_size_type amt; if (asect->relocation != NULL) return true; @@ -1397,9 +1405,8 @@ elf_slurp_reloc_table (abfd, asect, symbols, dynamic) 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; diff --git a/bfd/elfcore.h b/bfd/elfcore.h index df3af0c..3155e52 100644 --- a/bfd/elfcore.h +++ b/bfd/elfcore.h @@ -86,9 +86,11 @@ elf_core_file_p (abfd) 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); @@ -121,8 +123,8 @@ elf_core_file_p (abfd) } /* 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; @@ -181,12 +183,12 @@ elf_core_file_p (abfd) 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; @@ -196,7 +198,7 @@ elf_core_file_p (abfd) 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; @@ -206,7 +208,7 @@ elf_core_file_p (abfd) /* 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; } diff --git a/bfd/elflink.c b/bfd/elflink.c index f06a49b..a96e175 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -278,10 +278,10 @@ _bfd_elf_link_record_dynamic_symbol (info, h) } 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; @@ -397,9 +397,9 @@ _bfd_elf_create_linker_section (abfd, info, which, defaults) 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; @@ -506,7 +506,7 @@ _bfd_elf_create_linker_section (abfd, info, which, defaults) 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) diff --git a/bfd/elflink.h b/bfd/elflink.h index e7ea66a..123bc8d 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -145,10 +145,12 @@ elf_link_is_defined_archive_symbol (abfd, symdef) 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) @@ -185,18 +187,16 @@ elf_link_is_defined_archive_symbol (abfd, symdef) 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; @@ -264,6 +264,7 @@ elf_link_add_archive_symbols (abfd, info) boolean *included = NULL; carsym *symdefs; boolean loop; + bfd_size_type amt; if (! bfd_has_map (abfd)) { @@ -280,12 +281,14 @@ elf_link_add_archive_symbols (abfd, info) 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; @@ -333,10 +336,10 @@ elf_link_add_archive_symbols (abfd, info) 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, @@ -902,9 +905,9 @@ elf_link_add_object_symbols (abfd, info) 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; @@ -917,6 +920,8 @@ elf_link_add_object_symbols (abfd, info) 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); @@ -1041,9 +1046,9 @@ elf_link_add_object_symbols (abfd, 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; } } @@ -1064,16 +1069,15 @@ elf_link_add_object_symbols (abfd, info) 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; @@ -1132,11 +1136,11 @@ elf_link_add_object_symbols (abfd, info) 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; @@ -1147,22 +1151,22 @@ elf_link_add_object_symbols (abfd, info) 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; } } @@ -1177,8 +1181,8 @@ elf_link_add_object_symbols (abfd, info) 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; } @@ -1186,14 +1190,14 @@ elf_link_add_object_symbols (abfd, info) { 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); @@ -1210,6 +1214,7 @@ elf_link_add_object_symbols (abfd, info) { 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 @@ -1218,13 +1223,12 @@ elf_link_add_object_symbols (abfd, info) 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); @@ -1244,14 +1248,14 @@ elf_link_add_object_symbols (abfd, info) { 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); @@ -1329,7 +1333,7 @@ elf_link_add_object_symbols (abfd, info) } } - if (! elf_add_dynamic_entry (info, DT_NEEDED, strindex)) + if (! elf_add_dynamic_entry (info, (bfd_vma) DT_NEEDED, strindex)) goto error_return; } @@ -1340,11 +1344,10 @@ elf_link_add_object_symbols (abfd, info) 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; @@ -1472,7 +1475,8 @@ elf_link_add_object_symbols (abfd, info) || (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) @@ -1744,10 +1748,10 @@ elf_link_add_object_symbols (abfd, info) 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 @@ -1869,7 +1873,7 @@ elf_link_add_object_symbols (abfd, info) 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. */ @@ -2010,7 +2014,7 @@ elf_link_add_object_symbols (abfd, info) } } - if (! elf_add_dynamic_entry (info, DT_NEEDED, strindex)) + if (! elf_add_dynamic_entry (info, (bfd_vma) DT_NEEDED, strindex)) goto error_return; } } @@ -2349,7 +2353,7 @@ elf_add_dynamic_entry (info, tag, val) Elf_Internal_Dyn dyn; bfd *dynobj; asection *s; - size_t newsize; + bfd_size_type newsize; bfd_byte *newcontents; if (! is_elf_hash_table (info)) @@ -2390,6 +2394,8 @@ elf_link_record_local_dynamic_symbol (info, input_bfd, input_indx) 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; @@ -2400,17 +2406,15 @@ elf_link_record_local_dynamic_symbol (info, input_bfd, input_indx) 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); @@ -2467,6 +2471,7 @@ elf_link_read_relocs_from_section (abfd, shdr, external_relocs, 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) @@ -2477,8 +2482,7 @@ elf_link_read_relocs_from_section (abfd, shdr, external_relocs, 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); @@ -2494,8 +2498,8 @@ elf_link_read_relocs_from_section (abfd, shdr, external_relocs, 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; @@ -2570,10 +2574,10 @@ NAME(_bfd_elf,link_read_relocs) (abfd, o, external_relocs, internal_relocs, 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 @@ -2584,10 +2588,10 @@ NAME(_bfd_elf,link_read_relocs) (abfd, o, external_relocs, internal_relocs, 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; @@ -2753,12 +2757,14 @@ compute_bucket_count (info) 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; @@ -2789,8 +2795,9 @@ compute_bucket_count (info) /* 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); @@ -2941,13 +2948,15 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; } @@ -2959,9 +2968,10 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; } @@ -2972,7 +2982,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; } @@ -2987,7 +2997,8 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; } } @@ -3041,7 +3052,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, && (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 @@ -3053,7 +3064,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, && (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; } @@ -3067,12 +3078,12 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; } } @@ -3085,7 +3096,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; @@ -3250,8 +3261,9 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, } } - 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; @@ -3259,7 +3271,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; } @@ -3269,7 +3281,8 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; } @@ -3316,7 +3329,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, } 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; @@ -3376,8 +3389,10 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, } } - 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; @@ -3409,7 +3424,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; } @@ -3454,8 +3469,9 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; @@ -3465,7 +3481,7 @@ NAME(bfd_elf,size_dynamic_sections) (output_bfd, soname, rpath, 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; } @@ -3789,6 +3805,7 @@ elf_link_find_version_dependencies (h, data) 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. */ @@ -3815,7 +3832,8 @@ elf_link_find_version_dependencies (h, data) 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; @@ -3827,7 +3845,8 @@ elf_link_find_version_dependencies (h, data) 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 @@ -3858,12 +3877,15 @@ elf_link_assign_sym_version (h, data) 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; @@ -3911,12 +3933,12 @@ elf_link_assign_sym_version (h, data) { 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); @@ -3976,8 +3998,9 @@ elf_link_assign_sym_version (h, data) 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; @@ -4169,8 +4192,8 @@ elf_link_size_reloc_section (abfd, rel_hdr, o) 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) @@ -4181,7 +4204,7 @@ elf_link_size_reloc_section (abfd, rel_hdr, o) 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; @@ -4228,17 +4251,17 @@ elf_link_adjust_relocs (abfd, rel_hdr, count, rel_hash) 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")); @@ -4402,7 +4425,8 @@ elf_link_sort_relocs (abfd, info, psec) 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; } @@ -4426,9 +4450,9 @@ elf_link_sort_relocs (abfd, info, psec) 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 { @@ -4441,13 +4465,14 @@ elf_link_sort_relocs (abfd, info, psec) 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))); + } } } @@ -4461,7 +4486,7 @@ elf_link_sort_relocs (abfd, info, psec) 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) @@ -4478,7 +4503,8 @@ elf_link_sort_relocs (abfd, info, psec) 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); } @@ -4494,10 +4520,11 @@ elf_link_sort_relocs (abfd, info, psec) 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); - } + } } } @@ -4520,10 +4547,10 @@ elf_bfd_final_link (abfd, info) 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; @@ -4534,6 +4561,7 @@ elf_bfd_final_link (abfd, info) boolean merged; size_t relativecount = 0; asection *reldyn = 0; + bfd_size_type amt; if (! is_elf_hash_table (info)) return false; @@ -4797,8 +4825,9 @@ elf_bfd_final_link (abfd, info) 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; @@ -5048,11 +5077,12 @@ elf_bfd_final_link (abfd, info) 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; } @@ -5263,14 +5293,13 @@ elf_bfd_final_link (abfd, info) || 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; @@ -5407,14 +5436,14 @@ elf_link_flush_output_syms (finfo) 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); @@ -5498,7 +5527,7 @@ elf_link_output_extsym (h, data) { 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; @@ -5677,13 +5706,11 @@ elf_link_output_extsym (h, data) 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; @@ -5692,7 +5719,8 @@ elf_link_output_extsym (h, data) 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)); @@ -5700,6 +5728,7 @@ elf_link_output_extsym (h, data) 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) { @@ -5719,10 +5748,9 @@ elf_link_output_extsym (h, data) 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); } } @@ -5760,6 +5788,7 @@ elf_link_output_relocs (output_bfd, input_section, input_rel_hdr, 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; @@ -5789,9 +5818,9 @@ elf_link_output_relocs (output_bfd, input_section, input_rel_hdr, { 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")); @@ -5802,7 +5831,7 @@ elf_link_output_relocs (output_bfd, input_section, input_rel_hdr, 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; @@ -5898,11 +5927,10 @@ elf_link_input_bfd (finfo, input_bfd) 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; } @@ -6163,22 +6191,20 @@ elf_link_input_bfd (finfo, input_bfd) 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) @@ -6261,7 +6287,7 @@ elf_link_input_bfd (finfo, input_bfd) { if (finfo->indices[r_symndx] == -1) { - unsigned long link; + unsigned long shlink; const char *name; asection *osec; @@ -6275,9 +6301,9 @@ elf_link_input_bfd (finfo, input_bfd) /* 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; @@ -6320,8 +6346,8 @@ elf_link_input_bfd (finfo, input_bfd) 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); } @@ -6344,12 +6370,14 @@ elf_link_input_bfd (finfo, input_bfd) } 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; } } @@ -6446,28 +6474,31 @@ elf_reloc_link_order (output_bfd, info, output_section, link_order) 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; @@ -6492,15 +6523,16 @@ elf_reloc_link_order (output_bfd, info, output_section, link_order) 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); @@ -6517,12 +6549,13 @@ elf_reloc_link_order (output_bfd, info, output_section, link_order) } 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; @@ -6557,7 +6590,8 @@ elf_create_pointer_linker_section (abfd, info, lsect, h, rel) { 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); @@ -6592,9 +6626,9 @@ elf_create_pointer_linker_section (abfd, info, lsect, h, rel) 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; @@ -6625,8 +6659,8 @@ elf_create_pointer_linker_section (abfd, info, lsect, h, rel) /* 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; @@ -6754,12 +6788,13 @@ elf_finish_pointer_linker_section (output_bfd, input_bfd, info, lsect, h, { 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")); @@ -6783,13 +6818,11 @@ elf_finish_pointer_linker_section (output_bfd, input_bfd, info, lsect, h, + 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); } } @@ -6885,13 +6918,11 @@ elf_gc_mark (info, sec, gc_mark_hook) 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; @@ -7174,7 +7205,7 @@ elf_gc_sections (abfd, info) 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 @@ -7262,7 +7293,7 @@ elf_gc_record_vtinherit (abfd, sec, h, offset) bfd_set_error (bfd_error_invalid_operation); return false; -win: + win: if (!h) { /* This *should* only be the absolute section. It could potentially @@ -7316,7 +7347,7 @@ elf_gc_record_vtentry (abfd, sec, h, addend) if (ptr) { - ptr = bfd_realloc (ptr - 1, bytes); + ptr = bfd_realloc (ptr - 1, (bfd_size_type) bytes); if (ptr != NULL) { @@ -7328,7 +7359,7 @@ elf_gc_record_vtentry (abfd, sec, h, addend) } } else - ptr = bfd_zmalloc (bytes); + ptr = bfd_zmalloc ((bfd_size_type) bytes); if (ptr == NULL) return false; @@ -7460,8 +7491,8 @@ elf_collect_hash_codes (h, data) 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; } diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index 0273610..4ba4665 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -172,7 +172,7 @@ static boolean elfNN_ia64_add_symbol_hook 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, @@ -240,7 +240,7 @@ static boolean elfNN_ia64_check_relocs 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)); @@ -548,7 +548,8 @@ elfNN_ia64_info_to_howto (abfd, bfd_reloc, elf_reloc) 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)); } #define PLT_HEADER_SIZE (3 * 16) @@ -714,7 +715,7 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) 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; } @@ -725,6 +726,7 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) 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; @@ -792,7 +794,7 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) 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 @@ -816,7 +818,7 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) 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); @@ -830,11 +832,12 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) } /* 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) { @@ -862,7 +865,7 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) } /* 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; @@ -878,7 +881,7 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again) /* 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; @@ -1163,7 +1166,7 @@ elfNN_ia64_aix_vec (const bfd_target *vec) 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); } @@ -1188,24 +1191,24 @@ elfNN_ia64_aix_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 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; } @@ -1215,15 +1218,15 @@ elfNN_ia64_aix_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 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; @@ -1233,14 +1236,14 @@ elfNN_ia64_aix_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) 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); } } @@ -1302,7 +1305,8 @@ elfNN_ia64_modify_segment_map (abfd) 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; @@ -1337,7 +1341,8 @@ elfNN_ia64_modify_segment_map (abfd) 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; @@ -1574,7 +1579,7 @@ elfNN_ia64_hash_table_create (abfd) { 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, @@ -1756,8 +1761,8 @@ get_dyn_sym_info (ia64_info, h, abfd, rel, create) 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; } @@ -1940,8 +1945,8 @@ count_dyn_reloc (abfd, dyn_i, srel, type) 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; @@ -2071,7 +2076,7 @@ elfNN_ia64_check_relocs (abfd, info, sec, relocs) { (*info->callbacks->warning) (info, _("@pltoff reloc against local symbol"), 0, - abfd, 0, 0); + abfd, 0, (bfd_vma) 0); } break; @@ -2129,7 +2134,7 @@ elfNN_ia64_check_relocs (abfd, info, sec, relocs) { (*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); @@ -2165,7 +2170,7 @@ elfNN_ia64_check_relocs (abfd, info, sec, relocs) || 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; } @@ -2270,7 +2275,7 @@ allocate_local_got (dyn_i, data) /* 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; { @@ -2594,7 +2599,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info) } /* 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) @@ -2711,7 +2716,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info) 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; } @@ -2727,32 +2732,34 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info) { /* 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; } @@ -3352,11 +3359,13 @@ elfNN_ia64_final_link (abfd, info) 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; } @@ -3538,7 +3547,7 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, 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) { @@ -3674,7 +3683,7 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, 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, @@ -3718,7 +3727,7 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, } else dynindx = (_bfd_elf_link_lookup_local_dynindx - (info, input_bfd, r_symndx)); + (info, input_bfd, (long) r_symndx)); value = 0; } @@ -3972,7 +3981,8 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, 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)) diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 2c7f095..15d6052 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -87,7 +87,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 \ @@ -393,7 +394,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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 */ diff --git a/bfd/format.c b/bfd/format.c index eb97be1..f60f0ca 100644 --- a/bfd/format.c +++ b/bfd/format.c @@ -142,10 +142,11 @@ bfd_check_format_matches (abfd, format, matching) 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; } @@ -159,7 +160,7 @@ bfd_check_format_matches (abfd, format, matching) /* 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)); @@ -210,7 +211,7 @@ bfd_check_format_matches (abfd, format, matching) 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 diff --git a/bfd/hash.c b/bfd/hash.c index 11d54fd..9766eaf 100644 --- a/bfd/hash.c +++ b/bfd/hash.c @@ -582,9 +582,9 @@ struct bfd_strtab_hash * _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; @@ -711,8 +711,8 @@ _bfd_stringtab_emit (abfd, tab) 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; @@ -722,12 +722,12 @@ _bfd_stringtab_emit (abfd, tab) 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; } diff --git a/bfd/hp300hpux.c b/bfd/hp300hpux.c index faed74e..17d5d4e 100644 --- a/bfd/hp300hpux.c +++ b/bfd/hp300hpux.c @@ -301,10 +301,10 @@ MY (write_object_contents) (abfd) /* 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; @@ -314,7 +314,7 @@ MY (write_object_contents) (abfd) 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; } @@ -324,11 +324,11 @@ MY (write_object_contents) (abfd) 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; @@ -449,7 +449,7 @@ NAME (aout,swap_exec_header_in) (abfd, raw_bytes, execp) 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); @@ -468,14 +468,16 @@ NAME (aout,swap_exec_header_in) (abfd, raw_bytes, execp) { 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; @@ -483,7 +485,8 @@ NAME (aout,swap_exec_header_in) (abfd, raw_bytes, execp) 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; @@ -527,19 +530,20 @@ MY (slurp_symbol_table) (abfd) 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; @@ -558,10 +562,10 @@ MY (slurp_symbol_table) (abfd) /* 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 @@ -635,8 +639,8 @@ MY (swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount) 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]) { @@ -706,7 +710,7 @@ MY (slurp_reloc_table) (abfd, asect, symbols) sec_ptr asect; asymbol **symbols; { - unsigned int count; + bfd_size_type count; bfd_size_type reloc_size; PTR relocs; arelent *reloc_cache; @@ -743,8 +747,7 @@ doit: 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; @@ -755,7 +758,7 @@ doit: 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); @@ -769,7 +772,7 @@ doit: 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); diff --git a/bfd/hppabsd-core.c b/bfd/hppabsd-core.c index ff738a3..dd0ffda 100644 --- a/bfd/hppabsd-core.c +++ b/bfd/hppabsd-core.c @@ -48,7 +48,7 @@ #include /* After a.out.h */ #include -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 *)); @@ -80,7 +80,7 @@ struct hppabsd_core_struct 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; @@ -104,7 +104,9 @@ static asymbol * 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; @@ -121,7 +123,7 @@ hppabsd_core_core_file_p (abfd) /* 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) @@ -168,7 +170,7 @@ hppabsd_core_core_file_p (abfd) /* 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; diff --git a/bfd/hpux-core.c b/bfd/hpux-core.c index 199a6a1..e39df79 100644 --- a/bfd/hpux-core.c +++ b/bfd/hpux-core.c @@ -100,12 +100,21 @@ struct hpux_core_struct #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; @@ -114,7 +123,7 @@ make_bfd_asection (abfd, name, flags, _raw_size, vma, alignment_power) 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; @@ -137,7 +146,9 @@ static asymbol * 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; @@ -160,7 +171,7 @@ hpux_core_core_file_p (abfd) 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; @@ -169,21 +180,23 @@ hpux_core_core_file_p (abfd) 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++; @@ -197,13 +210,13 @@ hpux_core_core_file_p (abfd) /* 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) @@ -258,7 +271,7 @@ hpux_core_core_file_p (abfd) 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++; } @@ -275,7 +288,7 @@ hpux_core_core_file_p (abfd) 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; @@ -327,7 +340,8 @@ hpux_core_core_file_failing_signal (abfd) /* 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 */ } @@ -346,7 +360,7 @@ hpux_core_core_file_matches_executable_p (core_bfd, exec_bfd) /* 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 */ } diff --git a/bfd/i386aout.c b/bfd/i386aout.c index 63ba13a..19b45d5 100644 --- a/bfd/i386aout.c +++ b/bfd/i386aout.c @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software 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 @@ -75,7 +75,7 @@ i386aout_write_object_contents (abfd) #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 */ diff --git a/bfd/i386dynix.c b/bfd/i386dynix.c index ae7cc68..bafaf34 100644 --- a/bfd/i386dynix.c +++ b/bfd/i386dynix.c @@ -1,5 +1,5 @@ /* 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. @@ -65,7 +65,7 @@ i386dynix_32_swap_exec_header_in (abfd, raw_bytes, execp) 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); diff --git a/bfd/i386linux.c b/bfd/i386linux.c index 5fee098..783951f 100644 --- a/bfd/i386linux.c +++ b/bfd/i386linux.c @@ -1,5 +1,5 @@ /* 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. @@ -223,9 +223,9 @@ linux_link_hash_table_create (abfd) 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, @@ -405,7 +405,8 @@ linux_add_one_symbol (info, abfd, name, flags, section, value, string, 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; } @@ -444,7 +445,7 @@ linux_tally_symbols (h, data) 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"), @@ -476,7 +477,7 @@ linux_tally_symbols (h, data) + 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); @@ -587,7 +588,8 @@ bfd_i386linux_size_dynamic_sections (output_bfd, info) ".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; @@ -624,13 +626,14 @@ linux_finish_dynamic_link (output_bfd, info) 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. */ @@ -660,15 +663,15 @@ linux_finish_dynamic_link (output_bfd, info) 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; @@ -679,9 +682,9 @@ linux_finish_dynamic_link (output_bfd, info) 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) @@ -707,7 +710,7 @@ linux_finish_dynamic_link (output_bfd, info) 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; @@ -720,15 +723,15 @@ linux_finish_dynamic_link (output_bfd, info) (*_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); @@ -744,16 +747,16 @@ linux_finish_dynamic_link (output_bfd, info) 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; diff --git a/bfd/i386lynx.c b/bfd/i386lynx.c index f5dd7f2..13c0f74 100644 --- a/bfd/i386lynx.c +++ b/bfd/i386lynx.c @@ -50,31 +50,31 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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; \ } \ } @@ -366,7 +366,7 @@ NAME(lynx,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols, symcount) 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)); @@ -391,7 +391,7 @@ NAME(lynx,slurp_reloc_table) (abfd, asect, symbols) sec_ptr asect; asymbol **symbols; { - unsigned int count; + bfd_size_type count; bfd_size_type reloc_size; PTR relocs; arelent *reloc_cache; @@ -429,7 +429,7 @@ doit: 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) @@ -438,7 +438,7 @@ doit: 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); @@ -454,7 +454,7 @@ doit: 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 @@ -466,7 +466,7 @@ doit: 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)); } } @@ -491,13 +491,14 @@ NAME(lynx,squirt_out_relocs) (abfd, section) 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; @@ -519,7 +520,7 @@ NAME(lynx,squirt_out_relocs) (abfd, section) 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; diff --git a/bfd/i386mach3.c b/bfd/i386mach3.c index f0bddce..1cd2edd 100644 --- a/bfd/i386mach3.c +++ b/bfd/i386mach3.c @@ -48,7 +48,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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 */ diff --git a/bfd/i386msdos.c b/bfd/i386msdos.c index 38ca603..f192b22 100644 --- a/bfd/i386msdos.c +++ b/bfd/i386msdos.c @@ -107,27 +107,26 @@ msdos_write_object_contents (abfd) } /* 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; @@ -149,8 +148,8 @@ msdos_set_section_contents (abfd, section, location, offset, count) 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; } @@ -244,7 +243,7 @@ const bfd_target i386msdos_vec = BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, - + (PTR) 0 }; diff --git a/bfd/i386os9k.c b/bfd/i386os9k.c index 34dabc3..626fc77 100644 --- a/bfd/i386os9k.c +++ b/bfd/i386os9k.c @@ -44,28 +44,28 @@ os9k_swap_exec_header_in (abfd, raw_bytes, execp) 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; @@ -77,10 +77,9 @@ os9k_swap_exec_header_in (abfd, raw_bytes, execp) /* 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; @@ -90,16 +89,16 @@ os9k_swap_exec_header_out (abfd, execp, raw_bytes) 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; @@ -115,7 +114,7 @@ os9k_object_p (abfd) 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) @@ -123,7 +122,7 @@ os9k_object_p (abfd) 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); @@ -199,8 +198,9 @@ os9k_mkobject (abfd) 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; @@ -245,8 +245,8 @@ os9k_write_object_contents (abfd) 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. */ @@ -299,7 +299,7 @@ os9k_set_section_contents (abfd, section, location, offset, count) 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; } @@ -368,7 +368,7 @@ const bfd_target i386os9k_vec = BFD_JUMP_TABLE_WRITE (aout_32), BFD_JUMP_TABLE_LINK (os9k), BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), - + NULL, (PTR) 0, diff --git a/bfd/ieee.c b/bfd/ieee.c index f49ee53..cb7dca5 100644 --- a/bfd/ieee.c +++ b/bfd/ieee.c @@ -61,7 +61,7 @@ static void parse_expression 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 *)); @@ -135,7 +135,7 @@ ieee_write_byte (abfd, barg) 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; } @@ -149,7 +149,7 @@ ieee_write_2bytes (abfd, bytes) 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; } @@ -239,7 +239,7 @@ ieee_write_id (abfd, id) 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; } @@ -298,7 +298,7 @@ read_id (ieee) 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); @@ -384,7 +384,7 @@ ieee_write_expression (abfd, value, symbol, pcrel, index) /* 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; } @@ -423,7 +423,7 @@ ieee_write_int5_out (abfd, value) 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; } @@ -775,14 +775,16 @@ get_symbol (abfd, ieee, last_symbol, symbol_count, pptr, max_index, this_type) 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; @@ -1161,6 +1163,7 @@ get_section_entry (abfd, ieee, index) { unsigned int c, i; asection **n; + bfd_size_type amt; c = ieee->section_table_size; if (c == 0) @@ -1168,8 +1171,9 @@ get_section_entry (abfd, ieee, index) 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; @@ -1182,7 +1186,7 @@ get_section_entry (abfd, ieee, index) 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) @@ -1203,7 +1207,6 @@ ieee_slurp_sections (abfd) { ieee_data_type *ieee = IEEE_DATA (abfd); file_ptr offset = ieee->w.r.section_part; - asection *section = (asection *) NULL; char *name; if (offset != 0) @@ -1216,6 +1219,7 @@ ieee_slurp_sections (abfd) { case ieee_section_type_enum: { + asection *section; unsigned int section_index; next_byte (&(ieee->h)); section_index = must_parse_int (&(ieee->h)); @@ -1315,8 +1319,10 @@ ieee_slurp_sections (abfd) 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: @@ -1403,18 +1409,18 @@ ieee_archive_p (abfd) 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; @@ -1481,21 +1487,20 @@ ieee_archive_p (abfd) 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; @@ -1505,15 +1510,15 @@ ieee_archive_p (abfd) 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; @@ -1546,6 +1551,7 @@ ieee_object_p (abfd) 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); @@ -1554,8 +1560,8 @@ ieee_object_p (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) @@ -1700,16 +1706,17 @@ ieee_object_p (abfd) 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); @@ -1721,7 +1728,7 @@ ieee_object_p (abfd) if (! ieee_slurp_section_data (abfd)) goto fail; - + return abfd->xvec; got_wrong_format: bfd_set_error (bfd_error_wrong_format); @@ -1832,9 +1839,10 @@ do_one (ieee, current_map, location_ptr, s, iterations) 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; @@ -1891,21 +1899,20 @@ do_one (ieee, current_map, location_ptr, s, iterations) 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; @@ -1914,19 +1921,22 @@ do_one (ieee, current_map, location_ptr, s, iterations) 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; @@ -2103,7 +2113,7 @@ ieee_slurp_section_data (abfd) { ieee->h.input_p = start; if (!do_one (ieee, current_map, location_ptr, s, - iterations)) + (int) iterations)) return false; iterations--; } @@ -2126,7 +2136,7 @@ ieee_new_section_hook (abfd, newsect) 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; @@ -2282,7 +2292,7 @@ ieee_write_section_part (abfd) || ! 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 */ @@ -2344,7 +2354,7 @@ do_with_relocs (abfd, s) } 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; } @@ -2370,10 +2380,7 @@ do_with_relocs (abfd, s) /* 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; @@ -2421,10 +2428,7 @@ do_with_relocs (abfd, s) /* 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; @@ -2486,7 +2490,7 @@ do_with_relocs (abfd, s) if (! ieee_write_expression (abfd, r->addend + ov, *(r->sym_ptr_ptr), r->howto->pc_relative, - s->index)) + (unsigned) s->index)) return false; } else @@ -2494,15 +2498,15 @@ do_with_relocs (abfd, s) 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, @@ -2549,7 +2553,7 @@ do_as_repeat (abfd, s) } 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; } @@ -2610,6 +2614,8 @@ static boolean ieee_mkobject (abfd) bfd *abfd; { + bfd_size_type amt; + output_ptr_start = NULL; output_ptr = NULL; output_ptr_end = NULL; @@ -2619,25 +2625,26 @@ ieee_mkobject (abfd) 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++; @@ -2712,7 +2719,7 @@ copy_expression () { int stack[10]; int *tos = stack; - int value = 0; + int value; while (1) { switch (THIS ()) @@ -2766,16 +2773,13 @@ copy_expression () } *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'): { @@ -2788,17 +2792,11 @@ copy_expression () 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: @@ -2807,11 +2805,9 @@ copy_expression () write_int (*(--tos)); OUT (0x90); return; - } } } - } /* Drop the int in the buffer, and copy a null into the gap, which we @@ -3279,7 +3275,7 @@ relocate_debug (output, input) 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 (); } @@ -3292,13 +3288,13 @@ ieee_write_debug_part (abfd) { 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) @@ -3315,7 +3311,7 @@ ieee_write_debug_part (abfd) } 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 @@ -3327,8 +3323,7 @@ ieee_write_debug_part (abfd) 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); } @@ -3395,7 +3390,8 @@ init_for_output (abfd) 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; } @@ -3420,14 +3416,14 @@ ieee_set_section_contents (abfd, section, location, offset, count) { 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; } @@ -3468,7 +3464,7 @@ ieee_write_external_part (abfd) { /* 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; @@ -3479,11 +3475,11 @@ ieee_write_external_part (abfd) { /* 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; @@ -3495,10 +3491,10 @@ ieee_write_external_part (abfd) /* 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 */ @@ -3506,7 +3502,7 @@ ieee_write_external_part (abfd) /* 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)) { @@ -3722,7 +3718,8 @@ ieee_write_object_contents (abfd) 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) { @@ -3736,7 +3733,8 @@ ieee_write_object_contents (abfd) } 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. */ @@ -3750,12 +3748,12 @@ ieee_write_object_contents (abfd) || ! 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; } @@ -3797,7 +3795,7 @@ ieee_write_object_contents (abfd) { 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; } @@ -3814,8 +3812,8 @@ static asymbol * 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; @@ -3957,7 +3955,8 @@ ieee_bfd_debug_info_accumulate (abfd, section) /* 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; @@ -4094,6 +4093,6 @@ const bfd_target ieee_vec = BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, - + (PTR) 0 }; diff --git a/bfd/ihex.c b/bfd/ihex.c index 700dfa9..83808ee 100644 --- a/bfd/ihex.c +++ b/bfd/ihex.c @@ -1,5 +1,6 @@ /* 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 . This file is part of BFD, the Binary File Descriptor library. @@ -137,7 +138,7 @@ static boolean ihex_get_section_contents 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 @@ -197,9 +198,9 @@ ihex_mkobject (abfd) 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; @@ -220,7 +221,7 @@ ihex_get_byte (abfd, errorptr) { 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; @@ -272,7 +273,7 @@ ihex_scan (abfd) bfd_vma segbase; bfd_vma extbase; asection *sec; - int lineno; + unsigned int lineno; boolean error; bfd_byte *buf = NULL; size_t bufsize; @@ -320,7 +321,7 @@ ihex_scan (abfd) /* 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++) @@ -341,13 +342,13 @@ ihex_scan (abfd) 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++) @@ -366,7 +367,7 @@ ihex_scan (abfd) 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); @@ -388,9 +389,11 @@ ihex_scan (abfd) { 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); @@ -418,7 +421,7 @@ ihex_scan (abfd) 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; @@ -435,7 +438,7 @@ ihex_scan (abfd) 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; @@ -452,7 +455,7 @@ ihex_scan (abfd) 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; @@ -469,7 +472,7 @@ ihex_scan (abfd) 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; @@ -486,7 +489,7 @@ ihex_scan (abfd) 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; @@ -522,7 +525,7 @@ ihex_object_p (abfd) 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); @@ -595,7 +598,7 @@ ihex_read_section (abfd, section, contents) 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); @@ -614,13 +617,13 @@ ihex_read_section (abfd, section, contents) 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++) @@ -634,7 +637,7 @@ ihex_read_section (abfd, section, contents) } /* Skip the checksum. */ - if (bfd_read (buf, 1, 2, abfd) != 2) + if (bfd_bread (buf, (bfd_size_type) 2, abfd) != 2) goto error_return; } @@ -696,14 +699,15 @@ ihex_set_section_contents (abfd, section, location, offset, count) 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; @@ -748,8 +752,8 @@ ihex_set_section_contents (abfd, section, location, offset, count) 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; { @@ -758,6 +762,7 @@ ihex_write_record (abfd, count, addr, type, 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]) @@ -780,7 +785,8 @@ ihex_write_record (abfd, count, addr, type, data) 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; @@ -809,10 +815,11 @@ ihex_write_object_contents (abfd) 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) @@ -867,8 +874,8 @@ ihex_write_object_contents (abfd) } } - 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; @@ -919,7 +926,7 @@ ihex_make_empty_symbol (abfd) { 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; @@ -1039,6 +1046,6 @@ const bfd_target ihex_vec = BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, - + (PTR) 0 }; diff --git a/bfd/irix-core.c b/bfd/irix-core.c index 2de76f1..3ee3695 100644 --- a/bfd/irix-core.c +++ b/bfd/irix-core.c @@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include -struct sgi_core_struct +struct sgi_core_struct { int sig; char cmd[CORE_NAMESIZE]; @@ -41,11 +41,11 @@ struct sgi_core_struct #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)); @@ -53,7 +53,7 @@ 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; @@ -83,8 +83,9 @@ irix_core_core_file_p (abfd) 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) @@ -99,7 +100,8 @@ irix_core_core_file_p (abfd) || 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; @@ -113,7 +115,7 @@ irix_core_core_file_p (abfd) { 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; @@ -165,7 +167,7 @@ irix_core_core_file_p (abfd) 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); @@ -197,7 +199,8 @@ static asymbol * 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; @@ -260,7 +263,7 @@ const bfd_target irix_core_vec = 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), @@ -272,7 +275,7 @@ const bfd_target irix_core_vec = BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, - + (PTR) 0 /* backend_data */ }; diff --git a/bfd/libaout.h b/bfd/libaout.h index 60424bc..c6eb5c2 100644 --- a/bfd/libaout.h +++ b/bfd/libaout.h @@ -29,14 +29,61 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 @@ -44,22 +91,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 @@ -143,7 +190,8 @@ struct aout_backend_data /* 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 @@ -152,44 +200,43 @@ struct aout_backend_data /* 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. @@ -216,7 +263,7 @@ struct internal_exec char a_relaxable; /* Enough info for linker relax */ }; -/* Magic number is written +/* Magic number is written < MSB > 3130292827262524232221201918171615141312111009080706050403020100 < FLAGS >< MACHINE TYPE >< MAGIC NUMBER > @@ -325,7 +372,7 @@ typedef struct aout_symbol { 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; @@ -440,148 +487,126 @@ struct aout_section_data_struct /* 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... */ @@ -615,31 +640,32 @@ NAME(aout,bfd_free_cached_info) PARAMS ((bfd *)); 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) */ diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index 14a4c1b..db24ec2 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -29,9 +29,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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 @@ -87,20 +87,20 @@ struct areltdata { #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)); @@ -162,8 +162,7 @@ int bfd_generic_stat_arch_elt PARAMS ((bfd *, struct stat *)); #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)); @@ -440,7 +439,7 @@ extern unsigned int _bfd_count_link_order_relocs /* 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 diff --git a/bfd/libbfd.c b/bfd/libbfd.c index 695df8d..64a7614 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 @@ -153,13 +153,20 @@ _bfd_dummy_target (ignore_abfd) 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; } @@ -168,16 +175,22 @@ bfd_malloc (size) 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; @@ -187,18 +200,24 @@ bfd_realloc (ptr, size) 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; @@ -213,8 +232,8 @@ bfd_zmalloc (size) 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; @@ -242,17 +261,15 @@ real_read (where, a,b, file) #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) { @@ -260,7 +277,7 @@ bfd_read (ptr, size, nitems, abfd) 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) @@ -269,13 +286,13 @@ bfd_read (ptr, size, nitems, abfd) 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. @@ -285,7 +302,7 @@ bfd_read (ptr, size, nitems, abfd) 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); @@ -386,7 +403,7 @@ bfd_get_file_window (abfd, offset, size, windowp, writable) { 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)", @@ -402,7 +419,9 @@ bfd_get_file_window (abfd, offset, size, windowp, writable) 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; @@ -497,12 +516,11 @@ bfd_get_file_window (abfd, offset, size, windowp, writable) { 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; @@ -523,24 +541,25 @@ bfd_get_file_window (abfd, offset, size, windowp, writable) #endif /* USE_MMAP */ 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); @@ -551,16 +570,15 @@ bfd_write (ptr, size, nitems, abfd) } } } - 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) @@ -576,7 +594,7 @@ INTERNAL_FUNCTION 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 @@ -587,15 +605,15 @@ DESCRIPTION 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; { @@ -604,7 +622,7 @@ bfd_tell (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; @@ -657,7 +675,7 @@ bfd_seek (abfd, position, direction) { 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. */ @@ -678,22 +696,22 @@ bfd_seek (abfd, position, direction) 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; } } @@ -724,7 +742,7 @@ bfd_seek (abfd, position, direction) 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 @@ -819,9 +837,9 @@ DESCRIPTION .#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))) @@ -873,7 +891,7 @@ FUNCTION DESCRIPTION These macros have the same function as their <> - 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. @@ -881,42 +899,89 @@ DESCRIPTION .{* 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) @@ -1240,14 +1305,14 @@ _bfd_generic_get_section_contents (abfd, section, location, offset, count) 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; @@ -1272,10 +1337,11 @@ _bfd_generic_get_section_contents_in_window (abfd, section, w, offset, count) /* @@ 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); @@ -1288,7 +1354,7 @@ _bfd_generic_get_section_contents_in_window (abfd, section, w, offset, count) 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; @@ -1313,8 +1379,8 @@ _bfd_generic_set_section_contents (abfd, section, location, offset, count) 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; @@ -1325,11 +1391,11 @@ INTERNAL_FUNCTION 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 @@ -1380,3 +1446,26 @@ _bfd_generic_verify_endian_match (ibfd, obfd) 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; + } +} diff --git a/bfd/libbfd.h b/bfd/libbfd.h index a0c6836..b132596 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -29,9 +29,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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 @@ -87,20 +87,20 @@ struct areltdata { #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)); @@ -162,8 +162,7 @@ int bfd_generic_stat_arch_elt PARAMS ((bfd *, struct stat *)); #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)); @@ -440,7 +439,7 @@ extern unsigned int _bfd_count_link_order_relocs /* 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 @@ -578,7 +577,7 @@ extern boolean _bfd_sh_align_load_span /* 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)); @@ -816,7 +815,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "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", diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index 8368cc8..1a7599d 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -302,50 +302,64 @@ struct coff_link_hash_table #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. */ @@ -559,10 +573,12 @@ extern boolean _bfd_coff_reloc_link_order /* 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 @@ -578,7 +594,8 @@ extern boolean _bfd_ppc_xcoff_relocate_section /* 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 *)); diff --git a/bfd/libcoff.h b/bfd/libcoff.h index 76a5d24..eb90045 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -302,50 +302,64 @@ struct coff_link_hash_table #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. */ @@ -559,10 +573,12 @@ extern boolean _bfd_coff_reloc_link_order /* 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 @@ -578,7 +594,8 @@ extern boolean _bfd_ppc_xcoff_relocate_section /* 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 *)); @@ -586,39 +603,37 @@ extern boolean ppc_process_before_allocation 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; @@ -626,17 +641,17 @@ union { 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. */ @@ -656,228 +671,166 @@ enum coff_symbol_classification 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) @@ -887,88 +840,89 @@ typedef struct #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)) diff --git a/bfd/libecoff.h b/bfd/libecoff.h index a3e6245..957ff1b 100644 --- a/bfd/libecoff.h +++ b/bfd/libecoff.h @@ -1,5 +1,6 @@ /* 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. @@ -320,7 +321,7 @@ extern long _bfd_ecoff_canonicalize_reloc /* 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)); diff --git a/bfd/libieee.h b/bfd/libieee.h index 3d919f9..c48566c 100644 --- a/bfd/libieee.h +++ b/bfd/libieee.h @@ -29,7 +29,7 @@ typedef struct ct { struct ct *next; } bfd_chain_type; -typedef struct ieee_symbol +typedef struct ieee_symbol { asymbol symbol; struct ieee_symbol *next; @@ -61,7 +61,7 @@ typedef struct ieee_per_section } 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; @@ -73,7 +73,7 @@ typedef struct ieee_data_struct { 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; @@ -81,31 +81,31 @@ typedef struct ieee_data_struct 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; @@ -119,11 +119,11 @@ typedef struct { 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; diff --git a/bfd/libnlm.h b/bfd/libnlm.h index 00c8905..4773d55 100644 --- a/bfd/libnlm.h +++ b/bfd/libnlm.h @@ -1,5 +1,5 @@ /* 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. @@ -161,7 +161,7 @@ struct nlm_backend_data /* 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. */ @@ -169,7 +169,7 @@ struct nlm_backend_data /* 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 diff --git a/bfd/libpei.h b/bfd/libpei.h index 5b9cc04..6b232b4 100644 --- a/bfd/libpei.h +++ b/bfd/libpei.h @@ -58,153 +58,167 @@ PE/PEI rearrangement (and code added): Donn Terry #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 @@ -227,16 +241,16 @@ PE/PEI rearrangement (and code added): Donn Terry #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 diff --git a/bfd/libxcoff.h b/bfd/libxcoff.h index cbc0bfc..3c2532a 100644 --- a/bfd/libxcoff.h +++ b/bfd/libxcoff.h @@ -28,14 +28,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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; @@ -50,7 +50,7 @@ struct xcoff_backend_data_rec 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; @@ -60,9 +60,9 @@ struct xcoff_backend_data_rec /* size of the small aout file header */ unsigned int _xcoff_small_aout_header_size; - /* - * version - * loader version + /* + * version + * loader version * 1 : xcoff32 * 2 : xcoff64 */ @@ -72,7 +72,7 @@ struct xcoff_backend_data_rec 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 *); @@ -80,34 +80,34 @@ struct xcoff_backend_data_rec 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; @@ -218,19 +218,19 @@ extern boolean _bfd_xcoff_bfd_link_add_symbols 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 *, @@ -259,7 +259,7 @@ extern boolean bfd_xcoff_size_dynamic_sections 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 */ diff --git a/bfd/linker.c b/bfd/linker.c index df7ee4b..233ea48 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -528,6 +528,8 @@ bfd_wrapped_link_hash_lookup (abfd, info, string, create, copy, follow) boolean copy; boolean follow; { + bfd_size_type amt; + if (info->wrap_hash != NULL) { const char *l; @@ -547,7 +549,8 @@ bfd_wrapped_link_hash_lookup (abfd, info, string, create, copy, follow) /* 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; @@ -578,7 +581,8 @@ bfd_wrapped_link_hash_lookup (abfd, info, string, create, copy, follow) 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; @@ -671,9 +675,9 @@ _bfd_generic_link_hash_table_create (abfd) 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, @@ -704,7 +708,8 @@ generic_link_read_symbols (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)); @@ -781,12 +786,14 @@ generic_link_add_object_symbols (abfd, info, collect) 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); } /* We build a hash table of all symbols defined in an archive. */ @@ -797,7 +804,7 @@ generic_link_add_object_symbols (abfd, info, collect) struct archive_list { struct archive_list *next; - int indx; + unsigned int indx; }; /* An entry in an archive hash table. */ @@ -926,7 +933,7 @@ _bfd_generic_link_add_archive_symbols (abfd, info, checkfn) 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)) @@ -1005,11 +1012,12 @@ _bfd_generic_link_add_archive_symbols (abfd, info, checkfn) 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; @@ -1840,7 +1848,7 @@ _bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, && 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; @@ -2039,7 +2047,7 @@ _bfd_generic_final_link (abfd, info) 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); @@ -2057,10 +2065,11 @@ _bfd_generic_final_link (abfd, info) } 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; @@ -2113,13 +2122,15 @@ generic_add_output_symbol (output_bfd, psymalloc, sym) 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; @@ -2499,7 +2510,7 @@ _bfd_generic_reloc_link_order (abfd, info, sec, link_order) 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; @@ -2545,13 +2556,15 @@ _bfd_generic_reloc_link_order (abfd, info, sec, link_order) 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: @@ -2573,10 +2586,9 @@ _bfd_generic_reloc_link_order (abfd, info, sec, link_order) } 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; @@ -2597,10 +2609,8 @@ bfd_new_link_order (abfd, section) 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; @@ -2629,6 +2639,8 @@ _bfd_default_link_order (abfd, info, sec, link_order) asection *sec; struct bfd_link_order *link_order; { + file_ptr loc; + switch (link_order->type) { case bfd_undefined_link_order: @@ -2642,12 +2654,10 @@ _bfd_default_link_order (abfd, info, sec, 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); } } @@ -2660,7 +2670,7 @@ default_fill_link_order (abfd, info, sec, link_order) asection *sec; struct bfd_link_order *link_order; { - size_t size; + bfd_size_type size; unsigned char *space; size_t i; unsigned int fill; @@ -2669,7 +2679,7 @@ default_fill_link_order (abfd, info, sec, link_order) BFD_ASSERT ((sec->flags & SEC_HAS_CONTENTS) != 0); - size = (size_t) link_order->size; + size = link_order->size; if (size == 0) return true; @@ -2687,8 +2697,8 @@ default_fill_link_order (abfd, info, sec, link_order) 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; @@ -2709,6 +2719,8 @@ default_indirect_link_order (output_bfd, info, output_section, link_order, 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); @@ -2792,9 +2804,9 @@ default_indirect_link_order (output_bfd, info, output_section, link_order, } /* 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, @@ -2803,12 +2815,9 @@ default_indirect_link_order (output_bfd, info, output_section, link_order, 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) diff --git a/bfd/lynx-core.c b/bfd/lynx-core.c index ee070cb..1d4a763 100644 --- a/bfd/lynx-core.c +++ b/bfd/lynx-core.c @@ -55,7 +55,7 @@ struct lynx_core_struct 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; @@ -64,7 +64,7 @@ make_bfd_asection (abfd, name, flags, _raw_size, vma, filepos) 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; @@ -87,13 +87,13 @@ const bfd_target * 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 @@ -101,11 +101,11 @@ lynx_core_file_p (abfd) /* 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) @@ -113,8 +113,8 @@ lynx_core_file_p (abfd) 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; @@ -127,18 +127,16 @@ lynx_core_file_p (abfd) /* 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) diff --git a/bfd/m68klinux.c b/bfd/m68klinux.c index 86c5aaf..3e14781 100644 --- a/bfd/m68klinux.c +++ b/bfd/m68klinux.c @@ -1,5 +1,5 @@ /* 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. @@ -224,9 +224,9 @@ linux_link_hash_table_create (abfd) 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); @@ -409,7 +409,8 @@ linux_add_one_symbol (info, abfd, name, flags, section, value, string, 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; } @@ -448,7 +449,7 @@ linux_tally_symbols (h, data) 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"), @@ -591,7 +592,8 @@ bfd_m68klinux_size_dynamic_sections (output_bfd, info) ".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) { @@ -637,7 +639,8 @@ linux_finish_dynamic_link (output_bfd, info) #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. */ @@ -666,14 +669,14 @@ linux_finish_dynamic_link (output_bfd, info) 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; @@ -684,9 +687,9 @@ linux_finish_dynamic_link (output_bfd, info) 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) @@ -712,7 +715,7 @@ linux_finish_dynamic_link (output_bfd, info) 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; @@ -725,9 +728,9 @@ linux_finish_dynamic_link (output_bfd, info) (*_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; } @@ -749,16 +752,16 @@ linux_finish_dynamic_link (output_bfd, info) 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; diff --git a/bfd/merge.c b/bfd/merge.c index 49074ec..150e936 100644 --- a/bfd/merge.c +++ b/bfd/merge.c @@ -202,7 +202,7 @@ sec_merge_hash_lookup (table, string, alignment, create) } hash ^= hash >> 2; len += table->entsize; - } + } else { for (i = 0; i < table->entsize; ++i) @@ -262,9 +262,9 @@ sec_merge_init (entsize, strings) 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; @@ -325,7 +325,7 @@ sec_merge_emit (abfd, entry) 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) { @@ -336,7 +336,7 @@ sec_merge_emit (abfd, entry) 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; } @@ -344,7 +344,7 @@ sec_merge_emit (abfd, entry) 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; @@ -369,6 +369,7 @@ _bfd_merge_section (abfd, psinfo, sec, psecinfo) 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) @@ -417,7 +418,7 @@ _bfd_merge_section (abfd, psinfo, sec, psecinfo) { /* 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; @@ -431,8 +432,8 @@ _bfd_merge_section (abfd, psinfo, sec, psecinfo) /* 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; @@ -450,8 +451,8 @@ _bfd_merge_section (abfd, psinfo, sec, psecinfo) 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; @@ -470,7 +471,7 @@ cmplengthentry (a, b) { 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) @@ -556,16 +557,16 @@ record_section (sinfo, secinfo) 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; @@ -576,8 +577,8 @@ record_section (sinfo, secinfo) 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; } @@ -596,8 +597,8 @@ record_section (sinfo, secinfo) 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; } @@ -633,12 +634,12 @@ merge_strings (sinfo) 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; @@ -648,11 +649,11 @@ merge_strings (sinfo) 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; @@ -850,15 +851,15 @@ _bfd_write_merged_section (output_bfd, sec, psecinfo) 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)) diff --git a/bfd/mipsbsd.c b/bfd/mipsbsd.c index bbdb379..442b40d 100644 --- a/bfd/mipsbsd.c +++ b/bfd/mipsbsd.c @@ -46,7 +46,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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) @@ -67,18 +67,21 @@ static boolean MY(write_object_contents) PARAMS ((bfd *abfd)); #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) @@ -194,13 +197,15 @@ MY (write_object_contents) (abfd) 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; @@ -378,7 +383,7 @@ MY(canonicalize_reloc) (abfd, section, relptr, symbols) 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 */ diff --git a/bfd/netbsd-core.c b/bfd/netbsd-core.c index c93d6a4..1c1a99e 100644 --- a/bfd/netbsd-core.c +++ b/bfd/netbsd-core.c @@ -1,5 +1,5 @@ /* 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 @@ -39,12 +39,12 @@ struct netbsd_core_struct { /* 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. */ @@ -54,117 +54,132 @@ netbsd_core_file_p (abfd) 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* @@ -187,7 +202,8 @@ netbsd_core_file_failing_signal (abfd) /* 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 */ } diff --git a/bfd/nlm.c b/bfd/nlm.c index 965ca26..1c1498b 100644 --- a/bfd/nlm.c +++ b/bfd/nlm.c @@ -1,5 +1,5 @@ /* 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. @@ -29,8 +29,8 @@ boolean 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); diff --git a/bfd/nlm32-alpha.c b/bfd/nlm32-alpha.c index 2684ffb..0d3919e 100644 --- a/bfd/nlm32-alpha.c +++ b/bfd/nlm32-alpha.c @@ -61,18 +61,18 @@ nlm_alpha_backend_object_p (abfd) 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; @@ -88,10 +88,10 @@ nlm_alpha_write_prefix (abfd) 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; } @@ -421,12 +421,12 @@ nlm_alpha_read_reloc (abfd, sym, secp, rel) 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)); @@ -624,26 +624,28 @@ nlm_alpha_read_import (abfd, sym) 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; @@ -750,8 +752,8 @@ nlm_alpha_write_import (abfd, sec, rel) } /* 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)); @@ -765,7 +767,7 @@ nlm_alpha_write_import (abfd, sec, rel) & 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; @@ -828,12 +830,13 @@ nlm_alpha_write_external (abfd, count, sym, relocs) 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 diff --git a/bfd/nlm32-i386.c b/bfd/nlm32-i386.c index 9318304..a330134 100644 --- a/bfd/nlm32-i386.c +++ b/bfd/nlm32-i386.c @@ -1,5 +1,5 @@ /* 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. @@ -86,7 +86,7 @@ nlm_i386_read_reloc (abfd, sym, secp, rel) 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); @@ -228,7 +228,7 @@ nlm_i386_write_import (abfd, sec, rel) } 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; @@ -350,23 +350,24 @@ nlm_i386_read_import (abfd, sym) 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) @@ -402,12 +403,13 @@ nlm_i386_write_external (abfd, count, sym, 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++) diff --git a/bfd/nlm32-ppc.c b/bfd/nlm32-ppc.c index 0401d1e..98410a8 100644 --- a/bfd/nlm32-ppc.c +++ b/bfd/nlm32-ppc.c @@ -1,5 +1,5 @@ /* 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. @@ -76,11 +76,11 @@ nlm_powerpc_backend_object_p (abfd) { 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; @@ -96,12 +96,12 @@ nlm_powerpc_write_prefix (abfd) 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; @@ -141,7 +141,7 @@ nlm_powerpc_read_reloc (abfd, sym, secp, rel) 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); @@ -561,14 +561,14 @@ nlm_powerpc_read_reloc (abfd, sym, secp, rel) 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); @@ -661,23 +661,24 @@ nlm_powerpc_read_import (abfd, sym) 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) @@ -762,7 +763,7 @@ nlm_powerpc_write_import (abfd, sec, rel) } 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; @@ -818,7 +819,7 @@ nlm_powerpc_write_reloc (abfd, sec, rel, indx) } } - 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; @@ -849,7 +850,7 @@ nlm_powerpc_write_reloc (abfd, sec, rel, indx) 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; @@ -866,10 +867,10 @@ nlm_powerpc_write_reloc (abfd, sec, rel, indx) 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; @@ -907,12 +908,13 @@ nlm_powerpc_write_external (abfd, count, sym, relocs) #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++) diff --git a/bfd/nlm32-sparc.c b/bfd/nlm32-sparc.c index 6048cb5..0246dd2 100644 --- a/bfd/nlm32-sparc.c +++ b/bfd/nlm32-sparc.c @@ -62,7 +62,7 @@ enum reloc_type }; #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", @@ -131,7 +131,7 @@ nlm_sparc_read_reloc (abfd, sym, secp, rel) 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); @@ -224,7 +224,7 @@ nlm_sparc_write_reloc (abfd, sec, rel) 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; @@ -259,24 +259,24 @@ nlm_sparc_read_import (abfd, sym) /* 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; @@ -337,10 +337,10 @@ nlm_sparc_write_import (abfd, sec, rel) __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; @@ -361,12 +361,13 @@ nlm_sparc_write_external (abfd, count, sym, relocs) 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++) @@ -395,9 +396,9 @@ nlm_sparc_write_export (abfd, sym, value) 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; diff --git a/bfd/nlmcode.h b/bfd/nlmcode.h index 0dce943..d4501d0 100644 --- a/bfd/nlmcode.h +++ b/bfd/nlmcode.h @@ -1,5 +1,6 @@ /* 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. @@ -82,12 +83,12 @@ static int nlm_external_reloc_compare /* 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 * @@ -101,6 +102,7 @@ nlm_object_p (abfd) 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. */ @@ -113,12 +115,12 @@ nlm_object_p (abfd) /* 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; @@ -129,8 +131,8 @@ nlm_object_p (abfd) /* 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; @@ -238,14 +240,14 @@ add_bfd_section (abfd, name, offset, size, flags) 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 @@ -256,66 +258,62 @@ nlm_swap_variable_header_in (abfd) 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 @@ -326,68 +324,64 @@ nlm_swap_variable_header_out (abfd) 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 @@ -404,21 +398,24 @@ nlm_swap_auxiliary_headers_in (abfd) 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 = @@ -437,8 +434,10 @@ nlm_swap_auxiliary_headers_in (abfd) 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 = @@ -502,22 +501,19 @@ nlm_swap_auxiliary_headers_in (abfd) } 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) { @@ -529,12 +525,12 @@ nlm_swap_auxiliary_headers_in (abfd) 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. */ @@ -542,9 +538,8 @@ nlm_swap_auxiliary_headers_in (abfd) 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); } @@ -552,9 +547,8 @@ nlm_swap_auxiliary_headers_in (abfd) 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); } @@ -562,8 +556,8 @@ nlm_swap_auxiliary_headers_in (abfd) 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; } @@ -579,7 +573,7 @@ nlm_swap_auxiliary_headers_in (abfd) 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; } @@ -600,7 +594,7 @@ nlm_swap_auxiliary_headers_in (abfd) 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; @@ -638,11 +632,11 @@ nlm_swap_auxiliary_headers_in (abfd) 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); @@ -673,7 +667,7 @@ nlm_swap_auxiliary_headers_in (abfd) break; } } - return (true); + return true; } /* Return whether there is a non-zero byte in a memory block. */ @@ -699,6 +693,8 @@ static boolean 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))) @@ -718,7 +714,8 @@ nlm_swap_auxiliary_headers_out (abfd) (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; } @@ -816,7 +813,8 @@ nlm_swap_auxiliary_headers_out (abfd) 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; } @@ -827,19 +825,18 @@ nlm_swap_auxiliary_headers_out (abfd) 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; } @@ -864,20 +861,19 @@ nlm_swap_auxiliary_headers_out (abfd) 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; } } @@ -896,7 +892,8 @@ nlm_swap_auxiliary_headers_out (abfd) 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; } @@ -958,9 +955,9 @@ asymbol * 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; @@ -1037,9 +1034,10 @@ nlm_slurp_symbol_table (abfd) 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. @@ -1056,14 +1054,14 @@ nlm_slurp_symbol_table (abfd) + 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); @@ -1076,20 +1074,21 @@ nlm_slurp_symbol_table (abfd) 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) @@ -1123,25 +1122,28 @@ nlm_slurp_symbol_table (abfd) 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; @@ -1173,9 +1175,8 @@ nlm_slurp_symbol_table (abfd) 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) @@ -1187,7 +1188,7 @@ nlm_slurp_symbol_table (abfd) } } - return (true); + return true; } /* Get the relocs for an NLM file. There are two types of relocs. @@ -1209,7 +1210,7 @@ nlm_slurp_reloc_fixups (abfd) { boolean (*read_func) PARAMS ((bfd *, nlm_symbol_type *, asection **, arelent *)); - bfd_size_type count; + bfd_size_type count, amt; arelent *rels; asection **secs; @@ -1224,8 +1225,10 @@ nlm_slurp_reloc_fixups (abfd) 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; @@ -1609,8 +1612,8 @@ nlm_set_section_contents (abfd, section, location, offset, count) } } - 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; @@ -1679,9 +1682,11 @@ nlm_write_object_contents (abfd) 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; @@ -1690,9 +1695,8 @@ nlm_write_object_contents (abfd) 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) @@ -1703,7 +1707,7 @@ nlm_write_object_contents (abfd) /* 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; @@ -1769,10 +1773,8 @@ nlm_write_object_contents (abfd) 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; @@ -1906,13 +1908,14 @@ nlm_write_object_contents (abfd) 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; } } @@ -1971,18 +1974,19 @@ nlm_write_object_contents (abfd) 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; @@ -2026,7 +2030,7 @@ nlm_write_object_contents (abfd) 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); @@ -2040,7 +2044,7 @@ nlm_write_object_contents (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; diff --git a/bfd/nlmswap.h b/bfd/nlmswap.h index 47efd9d..2fbb102b 100644 --- a/bfd/nlmswap.h +++ b/bfd/nlmswap.h @@ -1,5 +1,5 @@ /* 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. @@ -48,51 +48,51 @@ nlm_swap_fixed_header_in (abfd, realsrc, dst) 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 @@ -108,50 +108,50 @@ nlm_swap_fixed_header_out (abfd, src, realdst) 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); } diff --git a/bfd/ns32k.h b/bfd/ns32k.h index d63ba09..818ae0b 100644 --- a/bfd/ns32k.h +++ b/bfd/ns32k.h @@ -1,5 +1,5 @@ /* 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. @@ -23,17 +23,17 @@ extern bfd_reloc_status_type _bfd_ns32k_relocate_contents 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 **)); diff --git a/bfd/oasys.c b/bfd/oasys.c index ab836a5..dcb2b73 100644 --- a/bfd/oasys.c +++ b/bfd/oasys.c @@ -27,13 +27,11 @@ #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 *)); @@ -45,7 +43,8 @@ static const bfd_target *oasys_archive_p 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 @@ -57,34 +56,35 @@ static boolean oasys_set_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; @@ -111,7 +111,7 @@ moving in, and the defined symbols at the end of the table moving back. 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); @@ -119,22 +119,24 @@ oasys_slurp_symbol_table (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; @@ -191,7 +193,7 @@ oasys_slurp_symbol_table (abfd) } 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: @@ -210,7 +212,7 @@ oasys_slurp_symbol_table (abfd) 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] != '_') @@ -235,7 +237,7 @@ oasys_slurp_symbol_table (abfd) static long oasys_get_symtab_upper_bound (abfd) - bfd *CONST abfd; + bfd *const abfd; { if (! oasys_slurp_symbol_table (abfd)) return -1; @@ -277,24 +279,25 @@ oasys_archive_p (abfd) 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 @@ -313,14 +316,17 @@ oasys_archive_p (abfd) 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; @@ -339,18 +345,19 @@ oasys_archive_p (abfd) 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; @@ -364,39 +371,36 @@ oasys_archive_p (abfd) 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; } @@ -405,8 +409,8 @@ static boolean 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; } @@ -463,7 +467,7 @@ oasys_object_p (abfd) { 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; @@ -480,8 +484,8 @@ oasys_object_p (abfd) 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; } @@ -555,8 +559,8 @@ oasys_print_symbol (abfd, afile, symbol, how) 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); @@ -583,15 +587,14 @@ static reloc_howto_type howto_table[] = /* 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) @@ -634,14 +637,15 @@ oasys_slurp_section_data (abfd) 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 */ @@ -695,10 +699,11 @@ oasys_slurp_section_data (abfd) 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; @@ -739,10 +744,11 @@ oasys_slurp_section_data (abfd) 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; @@ -808,7 +814,7 @@ oasys_new_section_hook (abfd, newsect) 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; @@ -846,11 +852,11 @@ oasys_get_section_contents (abfd, section, location, offset, count) 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; } @@ -913,7 +919,7 @@ oasys_write_record (abfd, type, record, size) 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; } @@ -931,28 +937,28 @@ oasys_write_syms (abfd) { 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++; } @@ -974,7 +980,7 @@ oasys_write_syms (abfd) { 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] == '_') @@ -986,7 +992,7 @@ oasys_write_syms (abfd) l++; } - bfd_h_put_32 (abfd, g->value, symbol.value); + H_PUT_32 (abfd, g->value, symbol.value); if (g->flags & BSF_LOCAL) @@ -1033,8 +1039,8 @@ oasys_write_sections (abfd) 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, @@ -1083,23 +1089,23 @@ oasys_write_end (abfd) 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); @@ -1148,8 +1154,8 @@ oasys_write_data (abfd) *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 @@ -1221,16 +1227,16 @@ oasys_write_data (abfd) 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 @@ -1242,8 +1248,8 @@ oasys_write_data (abfd) 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++; } @@ -1283,11 +1289,10 @@ oasys_write_data (abfd) --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; } } @@ -1357,9 +1362,8 @@ static asymbol * 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; @@ -1410,19 +1414,14 @@ oasys_openr_next_archived_file (arch, prev) } 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; @@ -1547,6 +1546,6 @@ const bfd_target oasys_vec = BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, - + (PTR) 0 }; diff --git a/bfd/opncls.c b/bfd/opncls.c index 0c3d2c9..0cf6723 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -49,7 +49,7 @@ _bfd_new_bfd () { bfd *nbfd; - nbfd = (bfd *) bfd_zmalloc (sizeof (bfd)); + nbfd = (bfd *) bfd_zmalloc ((bfd_size_type) sizeof (bfd)); if (nbfd == NULL) return NULL; @@ -68,7 +68,7 @@ _bfd_new_bfd () 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; @@ -107,7 +107,7 @@ FUNCTION 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 <>) with the target @@ -122,8 +122,8 @@ DESCRIPTION bfd * bfd_openr (filename, target) - CONST char *filename; - CONST char *target; + const char *filename; + const char *target; { bfd *nbfd; const bfd_target *target_vec; @@ -169,7 +169,7 @@ FUNCTION 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 <> is to <> much like <> is to <>. @@ -192,8 +192,8 @@ DESCRIPTION bfd * bfd_fdopenr (filename, target, fd) - CONST char *filename; - CONST char *target; + const char *filename; + const char *target; int fd; { bfd *nbfd; @@ -307,7 +307,7 @@ bfd_openstreamr (filename, target, streamarg) nbfd->iostream = (PTR) stream; nbfd->filename = filename; nbfd->direction = read_direction; - + if (! bfd_cache_init (nbfd)) { objalloc_free ((struct objalloc *) nbfd->memory); @@ -328,7 +328,7 @@ FUNCTION 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 @@ -340,8 +340,8 @@ DESCRIPTION bfd * bfd_openw (filename, target) - CONST char *filename; - CONST char *target; + const char *filename; + const char *target; { bfd *nbfd; const bfd_target *target_vec; @@ -429,7 +429,7 @@ bfd_close (abfd) if (stat (abfd->filename, &buf) == 0) { - int mask = umask (0); + unsigned int mask = umask (0); umask (mask); chmod (abfd->filename, (0777 @@ -484,7 +484,7 @@ bfd_close_all_done (abfd) if (stat (abfd->filename, &buf) == 0) { - int mask = umask (0); + unsigned int mask = umask (0); umask (mask); chmod (abfd->filename, (0777 @@ -503,7 +503,7 @@ FUNCTION 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 @@ -515,7 +515,7 @@ DESCRIPTION bfd * bfd_create (filename, templ) - CONST char *filename; + const char *filename; bfd *templ; { bfd *nbfd; @@ -560,9 +560,10 @@ bfd_make_writable(abfd) 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; @@ -613,7 +614,7 @@ bfd_make_readable(abfd) 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; @@ -650,10 +651,16 @@ DESCRIPTION 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); @@ -663,13 +670,13 @@ bfd_alloc (abfd, size) 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; } diff --git a/bfd/osf-core.c b/bfd/osf-core.c index c458ecf..bafc728 100644 --- a/bfd/osf-core.c +++ b/bfd/osf-core.c @@ -1,5 +1,6 @@ /* 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. @@ -30,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* 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 *)); @@ -47,7 +48,7 @@ swap_abort PARAMS ((void)); /* These are stored in the bfd's tdata */ -struct osf_core_struct +struct osf_core_struct { int sig; char cmd[MAXCOMLEN + 1]; @@ -60,7 +61,7 @@ struct osf_core_struct 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; @@ -85,7 +86,9 @@ static asymbol * 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; @@ -99,8 +102,10 @@ osf_core_core_file_p (abfd) 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; @@ -108,7 +113,7 @@ osf_core_core_file_p (abfd) 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; @@ -120,7 +125,8 @@ osf_core_core_file_p (abfd) 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; @@ -178,7 +184,8 @@ osf_core_core_file_failing_signal (abfd) /* 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 */ } @@ -239,7 +246,7 @@ const bfd_target osf_core_vec = 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), @@ -251,6 +258,6 @@ const bfd_target osf_core_vec = BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), NULL, - + (PTR) 0 /* backend_data */ }; diff --git a/bfd/pc532-mach.c b/bfd/pc532-mach.c index 9b7fc6f..9161c7b 100644 --- a/bfd/pc532-mach.c +++ b/bfd/pc532-mach.c @@ -63,8 +63,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 ... */ @@ -75,19 +73,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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); diff --git a/bfd/pdp11.c b/bfd/pdp11.c index 7c95b87..de12563 100644 --- a/bfd/pdp11.c +++ b/bfd/pdp11.c @@ -27,7 +27,7 @@ * 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 @@ -176,7 +176,7 @@ const bfd_target MY(vec) = /* Alternative_target */ NULL, - + (PTR) MY_backend_data, }; @@ -449,7 +449,7 @@ pdp11_aout_write_headers (abfd, execp) 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; @@ -458,28 +458,29 @@ pdp11_aout_write_headers (abfd, execp) 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 @@ -658,8 +659,9 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p) { 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; @@ -874,11 +876,12 @@ NAME(aout,mkobject) (abfd) 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; @@ -997,7 +1000,7 @@ NAME(aout,machine_type) (arch, machine, unknown) case bfd_arch_vax: *unknown = false; break; - + default: arch_flags = M_UNKNOWN; } @@ -1123,9 +1126,9 @@ adjust_z_magic (abfd, execp) { 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. */ @@ -1194,7 +1197,7 @@ adjust_z_magic (abfd, execp) } 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))) @@ -1239,7 +1242,7 @@ adjust_n_magic (abfd, execp) 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) @@ -1254,7 +1257,7 @@ adjust_n_magic (abfd, execp) 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; @@ -1451,7 +1454,7 @@ NAME(aout,set_section_contents) (abfd, section, location, offset, count) 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; } @@ -1481,13 +1484,12 @@ aout_get_external_symbols (abfd) /* 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); @@ -1498,7 +1500,7 @@ aout_get_external_symbols (abfd) 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) { @@ -1508,10 +1510,10 @@ aout_get_external_symbols (abfd) /* 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, @@ -1519,13 +1521,13 @@ aout_get_external_symbols (abfd) 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; @@ -1665,7 +1667,7 @@ translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer) 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; @@ -1752,8 +1754,8 @@ asymbol * 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; @@ -1799,7 +1801,7 @@ NAME(aout,translate_symbol_table) (abfd, in, ext, count, str, strsize, dynamic) /* 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)) @@ -1822,7 +1824,7 @@ NAME(aout,slurp_symbol_table) (abfd) { 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) @@ -1833,13 +1835,13 @@ NAME(aout,slurp_symbol_table) (abfd) 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) @@ -1935,8 +1937,9 @@ emit_stringtab (abfd, tab) 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); @@ -1960,24 +1963,24 @@ NAME(aout,write_syms) (abfd) 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; @@ -2135,7 +2138,7 @@ pdp11_aout_swap_reloc_out (abfd, g, natptr) cache_ptr->addend = ad; \ break; \ } \ - } + } void pdp11_aout_swap_reloc_in (abfd, bytes, cache_ptr, offset, @@ -2189,7 +2192,7 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols) 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; @@ -2220,11 +2223,11 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols) 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; @@ -2248,10 +2251,10 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols) 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; @@ -2264,14 +2267,15 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols) { 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 @@ -2296,7 +2300,7 @@ NAME(aout,squirt_out_relocs) (abfd, section) 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 @@ -2311,7 +2315,7 @@ NAME(aout,squirt_out_relocs) (abfd, section) if (!native) return false; - memset ((PTR)native, 0, natsize); + memset ((PTR)native, 0, (size_t) natsize); generic = section->orelocation; if (generic != NULL) @@ -2328,14 +2332,13 @@ NAME(aout,squirt_out_relocs) (abfd, section) } } - 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; } @@ -2393,7 +2396,7 @@ NAME(aout,get_reloc_upper_bound) (abfd, asect) return -1; } - if (asect->flags & SEC_CONSTRUCTOR) + if (asect->flags & SEC_CONSTRUCTOR) return (sizeof (arelent *) * (asect->reloc_count+1)); if (asect == obj_datasec (abfd)) @@ -2487,7 +2490,7 @@ NAME(aout,print_symbol) (abfd, afile, symbol, how) 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); @@ -2588,16 +2591,16 @@ NAME(aout,find_nearest_line) 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; @@ -2730,7 +2733,7 @@ NAME(aout,find_nearest_line) 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; @@ -2751,7 +2754,7 @@ NAME(aout,find_nearest_line) 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 @@ -2765,9 +2768,9 @@ NAME(aout,find_nearest_line) } /* Have to remove : stuff. */ - p = strchr (buf, ':'); - if (p != NULL) - *p = '\0'; + colon = strchr (buf, ':'); + if (colon != NULL) + *colon = '\0'; *functionname_ptr = buf; } @@ -2876,9 +2879,9 @@ NAME(aout,link_hash_table_create) (abfd) 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, @@ -3014,7 +3017,7 @@ aout_link_check_ar_symbols (abfd, info, pneeded) 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; @@ -3168,8 +3171,7 @@ aout_link_add_symbols (abfd, info) 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; @@ -3191,7 +3193,7 @@ aout_link_add_symbols (abfd, info) *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. */ @@ -3407,9 +3409,9 @@ NAME(aout,final_link) (abfd, info, callback) 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; @@ -3713,11 +3715,11 @@ NAME(aout,final_link) (abfd, info, callback) 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; } @@ -3838,7 +3840,7 @@ aout_link_write_symbols (finfo, input_bfd) 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) @@ -3859,7 +3861,7 @@ aout_link_write_symbols (finfo, input_bfd) 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; @@ -3882,7 +3884,7 @@ aout_link_write_symbols (finfo, input_bfd) 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; @@ -4153,7 +4155,7 @@ aout_link_write_symbols (finfo, input_bfd) { 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) @@ -4222,7 +4224,7 @@ aout_link_write_symbols (finfo, input_bfd) { 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) @@ -4243,7 +4245,7 @@ aout_link_write_symbols (finfo, input_bfd) /* 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) { @@ -4269,17 +4271,15 @@ aout_link_write_symbols (finfo, input_bfd) /* 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; @@ -4299,6 +4299,7 @@ aout_link_write_other_symbol (h, data) bfd_vma val; struct external_nlist outsym; bfd_size_type indx; + bfd_size_type amt; output_bfd = finfo->output_bfd; @@ -4375,7 +4376,7 @@ aout_link_write_other_symbol (h, data) 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) @@ -4386,15 +4387,15 @@ aout_link_write_other_symbol (h, data) 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); @@ -4432,7 +4433,7 @@ aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr, 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; } } @@ -4447,7 +4448,7 @@ aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr, 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; @@ -4457,8 +4458,7 @@ aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr, { 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; @@ -4818,6 +4818,7 @@ aout_link_reloc_link_order (finfo, o, p) file_ptr *reloff_ptr; struct reloc_std_external srel; PTR rel_ptr; + bfd_size_type rel_size; pr = p->u.reloc.p; @@ -4979,14 +4980,12 @@ aout_link_reloc_link_order (finfo, o, 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. */ diff --git a/bfd/pe-mips.c b/bfd/pe-mips.c index 318d0bd..82b1a05 100644 --- a/bfd/pe-mips.c +++ b/bfd/pe-mips.c @@ -153,7 +153,7 @@ coff_mips_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, { short x = bfd_get_16 (abfd, addr); DOIT (x); - bfd_put_16 (abfd, x, addr); + bfd_put_16 (abfd, (bfd_vma) x, addr); } break; @@ -161,7 +161,7 @@ coff_mips_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, { long x = bfd_get_32 (abfd, addr); DOIT (x); - bfd_put_32 (abfd, x, addr); + bfd_put_32 (abfd, (bfd_vma) x, addr); } break; @@ -567,10 +567,9 @@ mips_swap_reloc_in (abfd, src, dst) 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; @@ -614,23 +613,18 @@ mips_swap_reloc_out (abfd, src, dst) 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; } diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index 957a934..cc2a5ef 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -111,22 +111,21 @@ _bfd_XXi_swap_sym_in (abfd, ext1, 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); + 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. */ @@ -184,7 +183,7 @@ _bfd_XXi_swap_sym_in (abfd, ext1, in1) 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); @@ -232,22 +231,22 @@ _bfd_XXi_swap_sym_out (abfd, inp, 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); + 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; } @@ -271,8 +270,7 @@ _bfd_XXi_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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); @@ -286,19 +284,16 @@ _bfd_XXi_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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)) { @@ -308,19 +303,18 @@ _bfd_XXi_swap_aux_in (abfd, ext1, type, class, indx, numaux, in1) 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 { @@ -348,10 +342,8 @@ _bfd_XXi_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) 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); @@ -366,19 +358,16 @@ _bfd_XXi_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) 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)) { @@ -387,19 +376,18 @@ _bfd_XXi_swap_aux_out (abfd, inp, type, class, indx, numaux, extp) } 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); @@ -418,7 +406,7 @@ _bfd_XXi_swap_lineno_in (abfd, ext1, 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_addr.l_symndx = H_GET_32 (abfd, ext->l_addr.l_symndx); in->l_lnno = GET_LINENO_LNNO (abfd, ext); } @@ -430,8 +418,7 @@ _bfd_XXi_swap_lineno_out (abfd, inp, outp) { 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; @@ -448,48 +435,48 @@ _bfd_XXi_swap_aouthdr_in (abfd, aouthdr_ext1, 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_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; @@ -498,12 +485,12 @@ _bfd_XXi_swap_aouthdr_in (abfd, aouthdr_ext1, aouthdr_int1) { /* 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; } @@ -687,80 +674,67 @@ _bfd_XXi_swap_aouthdr_out (abfd, in, out) } 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]); } } @@ -829,58 +803,51 @@ _bfd_XXi_only_swap_filehdr_out (abfd, in, out) 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; } @@ -894,14 +861,13 @@ _bfd_XX_only_swap_filehdr_out (abfd, in, out) 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; } @@ -924,7 +890,7 @@ _bfd_XXi_swap_scnhdr_out (abfd, in, out) ((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, @@ -941,17 +907,17 @@ _bfd_XXi_swap_scnhdr_out (abfd, in, out) } 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 @@ -970,7 +936,7 @@ _bfd_XXi_swap_scnhdr_out (abfd, in, out) { 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 @@ -986,42 +952,37 @@ _bfd_XXi_swap_scnhdr_out (abfd, in, out) 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 } @@ -1074,6 +1035,7 @@ pe_print_idata (abfd, vfile) 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); @@ -1135,15 +1097,13 @@ pe_print_idata (abfd, vfile) 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; @@ -1173,13 +1133,13 @@ pe_print_idata (abfd, vfile) 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; @@ -1397,8 +1357,8 @@ pe_print_edata (abfd, vfile) 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. */ @@ -1585,18 +1545,16 @@ pe_print_pdata (abfd, vfile) _(" \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; @@ -1699,7 +1657,7 @@ pe_print_reloc (abfd, vfile) 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; @@ -1712,15 +1670,13 @@ pe_print_reloc (abfd, vfile) 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; @@ -1935,16 +1891,16 @@ _bfd_XX_bfd_copy_private_section_data (ibfd, isec, obfd, osec) { 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; } diff --git a/bfd/peicode.h b/bfd/peicode.h index 20fe01c..0430059 100644 --- a/bfd/peicode.h +++ b/bfd/peicode.h @@ -139,7 +139,7 @@ static void pe_ILF_make_a_reloc PARAMS ((pe_ILF_vars *, bfd_vm 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 */ @@ -156,14 +156,13 @@ coff_swap_reloc_in (abfd, src, dst) 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 } @@ -175,19 +174,16 @@ coff_swap_reloc_out (abfd, src, dst) { 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; } @@ -201,13 +197,13 @@ coff_swap_filehdr_in (abfd, src, dst) { 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. */ @@ -217,8 +213,7 @@ coff_swap_filehdr_in (abfd, src, dst) 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 @@ -237,33 +232,24 @@ coff_swap_scnhdr_in (abfd, ext, in) 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) @@ -292,8 +278,9 @@ pe_mkobject (abfd) 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; @@ -541,7 +528,7 @@ pe_ILF_save_relocs (pe_ILF_vars * vars, 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. */ @@ -587,8 +574,9 @@ pe_ILF_make_a_symbol (pe_ILF_vars * vars, 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 @@ -666,7 +654,7 @@ pe_ILF_make_a_section (pe_ILF_vars * vars, /* 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 ++; @@ -767,7 +755,7 @@ static jump_table jtab[] = /* 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, @@ -825,7 +813,7 @@ pe_ILF_build_a_bfd (bfd * abfd, 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; @@ -933,11 +921,11 @@ pe_ILF_build_a_bfd (bfd * abfd, 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. */ @@ -976,16 +964,19 @@ pe_ILF_build_a_bfd (bfd * abfd, #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; @@ -1006,7 +997,7 @@ pe_ILF_build_a_bfd (bfd * abfd, 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; @@ -1031,8 +1022,6 @@ pe_ILF_build_a_bfd (bfd * abfd, /* 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); @@ -1087,23 +1076,23 @@ pe_ILF_object_p (bfd * abfd) 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. */ @@ -1190,10 +1179,10 @@ _("%s: Recognised but unhandled machine type (0x%x) in Import Library Format arc } /* 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) @@ -1206,10 +1195,10 @@ _("%s: Recognised but unhandled machine type (0x%x) in Import Library Format arc 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. */ @@ -1217,7 +1206,7 @@ _("%s: Recognised but unhandled machine type (0x%x) in Import Library Format arc 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; @@ -1251,19 +1240,19 @@ pe_bfd_object_p (bfd * abfd) 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) @@ -1281,24 +1270,23 @@ pe_bfd_object_p (bfd * abfd) 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; @@ -1307,10 +1295,7 @@ pe_bfd_object_p (bfd * abfd) /* 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); diff --git a/bfd/ppcboot.c b/bfd/ppcboot.c index eccbe79..478d55a 100644 --- a/bfd/ppcboot.c +++ b/bfd/ppcboot.c @@ -114,7 +114,10 @@ ppcboot_mkobject (abfd) 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; } @@ -172,7 +175,8 @@ ppcboot_object_p (abfd) 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); @@ -216,7 +220,7 @@ ppcboot_object_p (abfd) 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; } @@ -235,8 +239,8 @@ ppcboot_get_section_contents (abfd, section, location, offset, count) 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; } @@ -259,7 +263,7 @@ mangle_name (abfd, suffix) bfd *abfd; char *suffix; { - int size; + bfd_size_type size; char *buf; char *p; @@ -292,8 +296,9 @@ ppcboot_get_symtab (abfd, alocation) 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; @@ -335,7 +340,7 @@ static asymbol * ppcboot_make_empty_symbol (abfd) bfd *abfd; { - return (asymbol *) bfd_alloc (abfd, sizeof (asymbol)); + return (asymbol *) bfd_alloc (abfd, (bfd_size_type) sizeof (asymbol)); } diff --git a/bfd/ptrace-core.c b/bfd/ptrace-core.c index 704391a..998b1b4 100644 --- a/bfd/ptrace-core.c +++ b/bfd/ptrace-core.c @@ -64,8 +64,9 @@ ptrace_unix_core_file_p (abfd) 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) { @@ -78,8 +79,8 @@ ptrace_unix_core_file_p (abfd) /* 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; @@ -91,13 +92,14 @@ ptrace_unix_core_file_p (abfd) /* 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; diff --git a/bfd/reloc.c b/bfd/reloc.c index ef98042..3ab02f9 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -65,31 +65,31 @@ CODE_FRAGMENT . .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; @@ -97,16 +97,16 @@ CODE_FRAGMENT . .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; @@ -250,19 +250,19 @@ CODE_FRAGMENT . .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 .}; @@ -280,97 +280,91 @@ CODE_FRAGMENT . .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; -. .}; */ @@ -382,37 +376,43 @@ FUNCTION 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; \ +. } \ +. } \ +. } */ @@ -453,9 +453,10 @@ DESCRIPTION How relocs are tied together in an <>: -.typedef struct relent_chain { +.typedef struct relent_chain +.{ . arelent relent; -. struct relent_chain *next; +. struct relent_chain *next; .} arelent_chain; */ @@ -903,14 +904,14 @@ space consuming. For each target: { 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: @@ -918,7 +919,7 @@ space consuming. For each target: 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; @@ -927,7 +928,7 @@ space consuming. For each target: 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; @@ -1292,14 +1293,14 @@ space consuming. For each target: { 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: @@ -1307,7 +1308,7 @@ space consuming. For each target: 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; @@ -1955,8 +1956,8 @@ ENUM 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 @@ -2224,7 +2225,7 @@ ENUMX ENUMX BFD_RELOC_PPC64_TOC ENUMX - BFD_RELOC_PPC64_PLTGOT16 + BFD_RELOC_PPC64_PLTGOT16 ENUMX BFD_RELOC_PPC64_PLTGOT16_LO ENUMX @@ -2874,7 +2875,7 @@ ENUM BFD_RELOC_390_GOTENT ENUMDOC 32 bit rel. offset to GOT entry. - + ENUM BFD_RELOC_VTABLE_INHERIT ENUMX @@ -3394,7 +3395,7 @@ bfd_generic_get_relocated_section_contents (abfd, link_info, link_order, data, 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; @@ -3402,7 +3403,7 @@ bfd_generic_get_relocated_section_contents (abfd, link_info, link_order, data, if (!bfd_get_section_contents (input_bfd, input_section, (PTR) data, - 0, + (bfd_vma) 0, input_section->_raw_size)) goto error_return; diff --git a/bfd/reloc16.c b/bfd/reloc16.c index 7de8d95..1d69a7f 100644 --- a/bfd/reloc16.c +++ b/bfd/reloc16.c @@ -1,5 +1,5 @@ /* 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. @@ -137,17 +137,16 @@ bfd_perform_slip (abfd, slip, input_section, value) } 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; @@ -159,7 +158,7 @@ bfd_coff_reloc16_relax_section (abfd, i, link_info, again) 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; @@ -191,11 +190,14 @@ bfd_coff_reloc16_relax_section (abfd, i, link_info, again) 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 { @@ -268,11 +270,11 @@ bfd_coff_reloc16_get_relocated_section_contents(in_abfd, 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; diff --git a/bfd/riscix.c b/bfd/riscix.c index 956ba47..bc560f2 100644 --- a/bfd/riscix.c +++ b/bfd/riscix.c @@ -55,19 +55,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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) @@ -90,47 +94,47 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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" @@ -240,12 +244,12 @@ riscix_fix_pcrel_26 (abfd, reloc_entry, symbol, data, input_section, 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. */ @@ -399,12 +403,13 @@ riscix_squirt_out_relocs (abfd, section) 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; @@ -417,9 +422,9 @@ riscix_squirt_out_relocs (abfd, section) 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; } @@ -488,9 +493,9 @@ riscix_some_aout_object_p (abfd, execp, callback_to_real_object_p) { 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; @@ -632,14 +637,15 @@ MY(object_p) (abfd) 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 diff --git a/bfd/rs6000-core.c b/bfd/rs6000-core.c index 08b17ee..e6405f9 100644 --- a/bfd/rs6000-core.c +++ b/bfd/rs6000-core.c @@ -258,24 +258,28 @@ read_hdr (bfd *abfd, CoreHdr *core) { 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; @@ -424,7 +428,7 @@ rs6000coff_core_p (abfd) /* 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; @@ -545,7 +549,7 @@ rs6000coff_core_p (abfd) { 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) @@ -590,7 +594,7 @@ rs6000coff_core_p (abfd) 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)) @@ -652,14 +656,14 @@ rs6000coff_core_file_matches_executable_p (core_bfd, exec_bfd) 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; @@ -672,7 +676,7 @@ rs6000coff_core_file_matches_executable_p (core_bfd, exec_bfd) char *n; alloc *= 2; - n = bfd_realloc (path, alloc); + n = bfd_realloc (path, (bfd_size_type) alloc); if (n == NULL) { free (path); diff --git a/bfd/sco5-core.c b/bfd/sco5-core.c index 62f9c98..a84ef45 100644 --- a/bfd/sco5-core.c +++ b/bfd/sco5-core.c @@ -1,5 +1,5 @@ /* 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 This file is part of BFD, the Binary File Descriptor library. @@ -79,7 +79,9 @@ static asymbol * 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; @@ -92,17 +94,17 @@ read_uarea(abfd, filepos) { 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; @@ -150,9 +152,10 @@ sco5_core_file_p (abfd) 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; @@ -160,8 +163,8 @@ sco5_core_file_p (abfd) /* 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))) { @@ -207,13 +210,15 @@ sco5_core_file_p (abfd) 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)) { @@ -227,8 +232,9 @@ sco5_core_file_p (abfd) 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; @@ -351,7 +357,8 @@ sco5_core_file_failing_signal (ignore_abfd) /* 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 */ } diff --git a/bfd/section.c b/bfd/section.c index 78ab0cb..dc875bb 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -689,7 +689,7 @@ bfd_get_unique_section_name (abfd, templat, count) 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); @@ -788,7 +788,7 @@ bfd_make_section_anyway (abfd, name) 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; @@ -1013,12 +1013,9 @@ FUNCTION 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 @@ -1059,17 +1056,15 @@ bfd_set_section_contents (abfd, section, location, offset, count) 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) { @@ -1092,7 +1087,7 @@ bfd_set_section_contents (abfd, section, location, offset, count) /* 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))) @@ -1109,9 +1104,9 @@ FUNCTION 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} @@ -1138,21 +1133,21 @@ bfd_get_section_contents (abfd, section, location, offset, count) 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. */ @@ -1160,7 +1155,7 @@ bfd_get_section_contents (abfd, section, location, offset, count) if ((section->flags & SEC_HAS_CONTENTS) == 0) { - memset (location, 0, (unsigned) count); + memset (location, 0, (size_t) count); return true; } @@ -1179,7 +1174,8 @@ FUNCTION 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 diff --git a/bfd/som.c b/bfd/som.c index 1b877d5..0ea1353 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -102,7 +102,7 @@ /* 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 @@ -190,8 +190,8 @@ static boolean som_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, 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 *, @@ -214,7 +214,8 @@ static unsigned char * try_prev_fixup PARAMS ((bfd *, int *, unsigned char *, 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 *, @@ -383,315 +384,315 @@ struct fixup_format { 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= 0x1000000) { @@ -1234,7 +1235,7 @@ som_reloc_skip (abfd, skip, p, subspace_reloc_sizep, queue) 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); } } @@ -1243,7 +1244,7 @@ som_reloc_skip (abfd, skip, p, subspace_reloc_sizep, 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; @@ -1257,24 +1258,24 @@ som_reloc_skip (abfd, skip, p, subspace_reloc_sizep, queue) 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); @@ -1395,7 +1396,7 @@ som_reloc_call (abfd, p, subspace_reloc_sizep, bfd_reloc, sym_num, queue) 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); } } @@ -1453,8 +1454,8 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym) { 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; @@ -1478,7 +1479,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym) 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) @@ -1494,7 +1495,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym) 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; @@ -1505,7 +1506,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym) 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; @@ -1516,7 +1517,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym) 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; @@ -1527,7 +1528,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym) 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; @@ -1537,7 +1538,7 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym) 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; @@ -1548,11 +1549,11 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym) 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) @@ -1571,10 +1572,11 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym) /* 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) @@ -1651,10 +1653,11 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym) /* 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) @@ -1688,7 +1691,8 @@ hppa_som_gen_reloc_type (abfd, base_type, format, field, sym_diff, sym) /* 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) @@ -1773,7 +1777,7 @@ som_object_setup (abfd, file_hdrp, aux_hdrp, current_offset) /* 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; @@ -1846,18 +1850,19 @@ setup_sections (abfd, file_hdr, current_offset) 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. */ @@ -1873,16 +1878,18 @@ setup_sections (abfd, file_hdr, current_offset) 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); @@ -1908,15 +1915,16 @@ setup_sections (abfd, file_hdr, current_offset) 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 @@ -1924,7 +1932,7 @@ setup_sections (abfd, file_hdr, current_offset) 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 @@ -1938,14 +1946,15 @@ setup_sections (abfd, file_hdr, current_offset) 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); @@ -2036,7 +2045,7 @@ setup_sections (abfd, file_hdr, current_offset) = 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. */ @@ -2049,7 +2058,7 @@ setup_sections (abfd, file_hdr, current_offset) 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; } @@ -2074,8 +2083,9 @@ setup_sections (abfd, file_hdr, current_offset) } /* 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; @@ -2123,9 +2133,11 @@ som_object_p (abfd) 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); @@ -2159,14 +2171,15 @@ som_object_p (abfd) 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); @@ -2175,14 +2188,15 @@ som_object_p (abfd) /* 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); @@ -2191,7 +2205,7 @@ som_object_p (abfd) /* 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); @@ -2201,8 +2215,8 @@ som_object_p (abfd) 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); @@ -2230,7 +2244,8 @@ som_object_p (abfd) 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); @@ -2257,7 +2272,7 @@ som_mkobject (abfd) { /* 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; @@ -2273,9 +2288,10 @@ som_prep_headers (abfd) { 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; @@ -2284,8 +2300,9 @@ som_prep_headers (abfd) { /* 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; @@ -2330,9 +2347,9 @@ som_prep_headers (abfd) 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 @@ -2353,9 +2370,9 @@ som_prep_headers (abfd) 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; @@ -2546,9 +2563,10 @@ som_prep_for_fixups (abfd, syms, num_syms) 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 @@ -2574,16 +2592,16 @@ som_prep_for_fixups (abfd, syms, num_syms) 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 @@ -2620,7 +2638,9 @@ som_prep_for_fixups (abfd, syms, num_syms) /* 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; @@ -2653,6 +2673,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) 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; @@ -2677,7 +2698,8 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) 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 @@ -2705,7 +2727,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) 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 @@ -2743,8 +2765,8 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) 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; @@ -2827,7 +2849,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) { 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); } @@ -2856,7 +2878,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) { 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); } @@ -2866,7 +2888,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) case R_ENTRY: { - int tmp; + unsigned int tmp; arelent *tmp_reloc = NULL; bfd_put_8 (abfd, R_ENTRY, p); @@ -2978,7 +3000,7 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) 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; @@ -3011,8 +3033,8 @@ som_write_fixups (abfd, current_offset, total_reloc_sizep) 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; @@ -3041,10 +3063,11 @@ som_write_space_strings (abfd, current_offset, string_sizep) 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) @@ -3068,8 +3091,8 @@ som_write_space_strings (abfd, current_offset, string_sizep) 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. */ @@ -3093,7 +3116,7 @@ som_write_space_strings (abfd, current_offset, string_sizep) /* 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; @@ -3119,7 +3142,8 @@ som_write_space_strings (abfd, current_offset, string_sizep) /* 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; @@ -3131,7 +3155,7 @@ static boolean 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; @@ -3147,6 +3171,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, 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 @@ -3164,7 +3189,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep, /* 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) @@ -3179,8 +3204,8 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep, 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. */ @@ -3200,7 +3225,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep, 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; @@ -3248,8 +3273,8 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep, 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. */ @@ -3268,7 +3293,7 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep, 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; @@ -3289,7 +3314,8 @@ som_write_symbol_strings (abfd, current_offset, syms, num_syms, string_sizep, } /* 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; @@ -3343,47 +3369,47 @@ som_begin_writing (abfd) } 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; } @@ -3628,9 +3654,9 @@ som_begin_writing (abfd) 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 @@ -3660,6 +3686,7 @@ som_finish_writing (abfd) 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. @@ -3735,7 +3762,7 @@ som_finish_writing (abfd) /* 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; @@ -3783,9 +3810,9 @@ som_finish_writing (abfd) 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. */ @@ -3839,9 +3866,9 @@ som_finish_writing (abfd) 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. */ @@ -3854,7 +3881,7 @@ som_finish_writing (abfd) 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; @@ -3865,9 +3892,9 @@ som_finish_writing (abfd) 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. */ @@ -3878,11 +3905,11 @@ som_finish_writing (abfd) 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; } @@ -3903,11 +3930,10 @@ som_finish_writing (abfd) /* 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. */ @@ -3941,11 +3967,11 @@ som_finish_writing (abfd) } 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; @@ -4100,15 +4126,17 @@ som_build_and_write_symbol_table (abfd) 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++) @@ -4138,7 +4166,7 @@ som_build_and_write_symbol_table (abfd) 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) @@ -4177,6 +4205,7 @@ som_slurp_string_table (abfd) bfd *abfd; { char *stringtab; + bfd_size_type amt; /* Use the saved version if its available. */ if (obj_som_stringtab (abfd) != NULL) @@ -4192,16 +4221,16 @@ som_slurp_string_table (abfd) } /* 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. */ @@ -4282,6 +4311,7 @@ som_slurp_symbol_table (abfd) 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) @@ -4296,20 +4326,22 @@ som_slurp_symbol_table (abfd) 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. */ @@ -4487,8 +4519,8 @@ static asymbol * 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; @@ -4518,7 +4550,7 @@ som_print_symbol (abfd, afile, symbol, how) 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); @@ -4849,13 +4881,13 @@ som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count) 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) @@ -4903,6 +4935,7 @@ som_slurp_reloc_table (abfd, section, symbols, just_count) 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. */ @@ -4911,9 +4944,10 @@ som_slurp_reloc_table (abfd, section, symbols, just_count) /* 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. */ @@ -4922,8 +4956,7 @@ som_slurp_reloc_table (abfd, section, symbols, just_count) 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. @@ -4946,8 +4979,9 @@ som_slurp_reloc_table (abfd, section, symbols, just_count) 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; @@ -5019,8 +5053,8 @@ som_new_section_hook (abfd, newsect) 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; @@ -5065,15 +5099,17 @@ som_bfd_copy_private_section_data (ibfd, isection, obfd, osection) 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; @@ -5103,7 +5139,7 @@ som_bfd_copy_private_bfd_data (ibfd, obfd) /* 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; @@ -5128,10 +5164,10 @@ bfd_som_set_section_attributes (section, defined, private, sort_key, spnum) /* 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; } @@ -5158,10 +5194,10 @@ bfd_som_set_subsection_attributes (section, container, access, /* 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; } @@ -5195,16 +5231,18 @@ bfd_som_attach_aux_hdr (abfd, type, string) 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; @@ -5220,9 +5258,9 @@ bfd_som_attach_aux_hdr (abfd, type, string) 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; @@ -5246,14 +5284,14 @@ bfd_som_attach_compilation_unit (abfd, name, language_name, product_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); \ @@ -5282,8 +5320,8 @@ som_get_section_contents (abfd, section, location, offset, count) 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); } @@ -5316,10 +5354,10 @@ som_set_section_contents (abfd, section, location, offset, count) /* 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; } @@ -5341,8 +5379,8 @@ som_find_nearest_line (abfd, section, symbols, offset, filename_ptr, 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); @@ -5431,11 +5469,12 @@ som_bfd_count_ar_symbols (abfd, lst_header, count) { 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; @@ -5444,8 +5483,7 @@ som_bfd_count_ar_symbols (abfd, lst_header, count) /* 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 @@ -5459,12 +5497,12 @@ som_bfd_count_ar_symbols (abfd, lst_header, count) 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)++; @@ -5475,12 +5513,12 @@ som_bfd_count_ar_symbols (abfd, lst_header, 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)++; @@ -5509,34 +5547,32 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms) 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. */ @@ -5549,11 +5585,11 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms) 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 @@ -5564,17 +5600,17 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms) 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; @@ -5591,27 +5627,28 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms) 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; @@ -5651,7 +5688,8 @@ som_slurp_armap (abfd) 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) @@ -5659,7 +5697,7 @@ som_slurp_armap (abfd) 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. */ @@ -5670,8 +5708,8 @@ som_slurp_armap (abfd) } /* 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)) @@ -5694,8 +5732,8 @@ som_slurp_armap (abfd) /* 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. */ @@ -5711,15 +5749,15 @@ som_slurp_armap (abfd) 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; @@ -5730,7 +5768,7 @@ som_slurp_armap (abfd) /* 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. */ @@ -5849,20 +5887,23 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength) 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; @@ -5900,10 +5941,12 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength) 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; @@ -6037,29 +6080,29 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst, elength) /* 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) @@ -6107,6 +6150,7 @@ som_write_armap (abfd, elength, map, orl_count, stridx) 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) @@ -6199,18 +6243,17 @@ som_write_armap (abfd, elength, map, orl_count, stridx) (((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. */ @@ -6236,7 +6279,7 @@ som_bfd_free_cached_info (abfd) 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); diff --git a/bfd/sparclinux.c b/bfd/sparclinux.c index b877018..14e5351 100644 --- a/bfd/sparclinux.c +++ b/bfd/sparclinux.c @@ -1,5 +1,5 @@ /* 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. @@ -225,9 +225,9 @@ linux_link_hash_table_create (abfd) 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, @@ -407,7 +407,8 @@ linux_add_one_symbol (info, abfd, name, flags, section, value, string, 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; } @@ -446,7 +447,7 @@ linux_tally_symbols (h, data) 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"), @@ -590,7 +591,8 @@ bfd_sparclinux_size_dynamic_sections (output_bfd, info) ".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; @@ -633,7 +635,8 @@ linux_finish_dynamic_link (output_bfd, info) #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. */ @@ -664,14 +667,14 @@ linux_finish_dynamic_link (output_bfd, info) { /* 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; @@ -682,9 +685,9 @@ linux_finish_dynamic_link (output_bfd, info) 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) @@ -710,7 +713,7 @@ linux_finish_dynamic_link (output_bfd, info) 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; @@ -723,9 +726,9 @@ linux_finish_dynamic_link (output_bfd, info) (*_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; } @@ -747,15 +750,16 @@ linux_finish_dynamic_link (output_bfd, info) 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; diff --git a/bfd/sparclynx.c b/bfd/sparclynx.c index 3d98ff3..e59b57c 100644 --- a/bfd/sparclynx.c +++ b/bfd/sparclynx.c @@ -43,7 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #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 *)); @@ -78,11 +78,11 @@ 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) { @@ -228,7 +228,7 @@ sparclynx_set_sizes (abfd) } } -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 */ diff --git a/bfd/srec.c b/bfd/srec.c index 5c6ef82..0987051 100644 --- a/bfd/srec.c +++ b/bfd/srec.c @@ -1,6 +1,6 @@ /* 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 . @@ -122,7 +122,7 @@ static const bfd_target *srec_object_p PARAMS ((bfd *)); 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 *)); @@ -144,7 +144,7 @@ static long srec_get_symtab PARAMS ((bfd *, asymbol **)); /* 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])) @@ -235,7 +235,8 @@ srec_mkobject (abfd) 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; @@ -260,7 +261,7 @@ srec_get_byte (abfd, errorptr) { 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; @@ -313,8 +314,9 @@ srec_new_symbol (abfd, name, val) 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; @@ -389,7 +391,7 @@ srec_scan (abfd) case ' ': do { - unsigned int alc; + bfd_size_type alc; char *p, *symname; bfd_vma symval; @@ -418,7 +420,7 @@ srec_scan (abfd) 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; @@ -440,7 +442,7 @@ srec_scan (abfd) } *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); @@ -503,7 +505,7 @@ srec_scan (abfd) 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])) @@ -521,13 +523,13 @@ srec_scan (abfd) { 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. */ @@ -572,9 +574,11 @@ srec_scan (abfd) { 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) @@ -642,7 +646,7 @@ srec_object_p (abfd) 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])) @@ -672,7 +676,7 @@ symbolsrec_object_p (abfd) 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] != '$') @@ -722,7 +726,7 @@ srec_read_section (abfd, section, contents) 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])); @@ -733,13 +737,13 @@ srec_read_section (abfd, section, contents) { 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; @@ -821,8 +825,7 @@ srec_get_section_contents (abfd, section, location, offset, count) 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)) @@ -865,7 +868,7 @@ srec_set_section_contents (abfd, section, location, offset, bytes_to_do) 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; @@ -873,7 +876,9 @@ srec_set_section_contents (abfd, section, location, offset, bytes_to_do) && (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); @@ -927,14 +932,14 @@ srec_set_section_contents (abfd, section, location, offset, 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; @@ -981,7 +986,7 @@ srec_write_record (abfd, type, address, data, end) *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; } @@ -998,7 +1003,7 @@ srec_write_header (abfd) 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 @@ -1056,12 +1061,12 @@ srec_write_symbols (abfd) 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++) @@ -1071,7 +1076,6 @@ srec_write_symbols (abfd) && (s->flags & BSF_DEBUGGING) == 0) { /* Just dump out non debug symbols. */ - bfd_size_type l; char buf2[40], *p; sprintf_vma (buf2, @@ -1081,14 +1085,14 @@ srec_write_symbols (abfd) 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; } @@ -1150,7 +1154,9 @@ static asymbol * 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; @@ -1172,7 +1178,7 @@ srec_get_symtab (abfd, alocation) bfd *abfd; asymbol **alocation; { - unsigned int symcount = bfd_get_symcount (abfd); + bfd_size_type symcount = bfd_get_symcount (abfd); asymbol *csymbols; unsigned int i; diff --git a/bfd/stabs.c b/bfd/stabs.c index 15b1af5..ea7e486 100644 --- a/bfd/stabs.c +++ b/bfd/stabs.c @@ -1,5 +1,6 @@ /* 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. @@ -178,7 +179,7 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo) { 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; @@ -223,7 +224,8 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo) { /* 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; @@ -247,16 +249,16 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo) 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. */ @@ -265,9 +267,9 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo) 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; @@ -383,7 +385,8 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo) /* 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; @@ -471,8 +474,8 @@ _bfd_link_section_stabs (abfd, psinfo, stabsec, stabstrsec, psecinfo) 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; @@ -522,7 +525,8 @@ _bfd_write_section_stabs (output_bfd, psinfo, stabsec, psecinfo, contents) 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. */ @@ -571,7 +575,7 @@ _bfd_write_section_stabs (output_bfd, psinfo, stabsec, psecinfo, contents) 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); } @@ -600,8 +604,8 @@ _bfd_write_stab_strings (output_bfd, psinfo) <= 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; diff --git a/bfd/sunos.c b/bfd/sunos.c index f4ada70..db9d08a 100644 --- a/bfd/sunos.c +++ b/bfd/sunos.c @@ -1,5 +1,5 @@ /* 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. @@ -142,6 +142,7 @@ sunos_read_dynamic_info (abfd) 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; @@ -152,8 +153,8 @@ sunos_read_dynamic_info (abfd) 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; @@ -174,7 +175,8 @@ sunos_read_dynamic_info (abfd) 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); @@ -195,7 +197,8 @@ sunos_read_dynamic_info (abfd) /* 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; @@ -277,6 +280,7 @@ sunos_slurp_dynamic_symtab (abfd) bfd *abfd; { struct sunos_dynamic_info *info; + bfd_size_type amt; /* Get the general dynamic information. */ if (obj_aout_dynamic_info (abfd) == NULL) @@ -295,16 +299,12 @@ sunos_slurp_dynamic_symtab (abfd) /* 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) { @@ -318,13 +318,12 @@ sunos_slurp_dynamic_symtab (abfd) /* 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) { @@ -367,8 +366,8 @@ sunos_canonicalize_dynamic_symtab (abfd, storage) 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++) { @@ -398,18 +397,18 @@ sunos_canonicalize_dynamic_symtab (abfd, storage) 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) { @@ -459,6 +458,7 @@ sunos_canonicalize_dynamic_reloc (abfd, storage, syms) { 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) @@ -477,15 +477,12 @@ sunos_canonicalize_dynamic_reloc (abfd, storage, syms) /* 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) { @@ -502,10 +499,8 @@ sunos_canonicalize_dynamic_reloc (abfd, storage, syms) { 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; @@ -520,7 +515,7 @@ sunos_canonicalize_dynamic_reloc (abfd, storage, syms) 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 { @@ -531,7 +526,7 @@ sunos_canonicalize_dynamic_reloc (abfd, storage, syms) 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); } } @@ -564,21 +559,21 @@ static const bfd_byte sparc_plt_first_entry[SPARC_PLT_ENTRY_SIZE] = }; /* 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
, %g1 */ -#define SPARC_PLT_PIC_WORD0 0x03000000 +#define SPARC_PLT_PIC_WORD0 ((bfd_vma) 0x03000000) /* jmp %g1 +
*/ -#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 @@ -598,7 +593,7 @@ static const bfd_byte m68k_plt_first_entry[M68K_PLT_ENTRY_SIZE] = }; /* 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. */ @@ -715,9 +710,9 @@ sunos_link_hash_table_create (abfd) 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, @@ -875,7 +870,6 @@ sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp) bfd_size_type *sym_countp; char **stringsp; { - asection *s; bfd *dynobj; struct sunos_dynamic_info *dinfo; unsigned long need; @@ -938,7 +932,7 @@ sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp) /* 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 @@ -955,7 +949,7 @@ sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp) /* 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 @@ -985,12 +979,12 @@ sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp) 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 @@ -998,12 +992,12 @@ sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp) 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; @@ -1020,7 +1014,7 @@ sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp) *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; @@ -1028,13 +1022,13 @@ sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp) 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; @@ -1085,7 +1079,7 @@ sunos_add_dynamic_symbols (abfd, info, symsp, sym_countp, stringsp) 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); @@ -1322,11 +1316,11 @@ bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr, 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; @@ -1442,7 +1436,7 @@ bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr, 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; @@ -1470,7 +1464,7 @@ bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr, 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); @@ -1544,19 +1538,19 @@ sunos_scan_relocs (info, abfd, sec, rel_size) 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; } } @@ -1564,7 +1558,7 @@ sunos_scan_relocs (info, abfd, sec, rel_size) 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) @@ -1777,6 +1771,7 @@ sunos_scan_ext_relocs (info, abfd, sec, relocs, rel_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) @@ -1868,10 +1863,10 @@ sunos_scan_ext_relocs (info, abfd, sec, relocs, rel_size) 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; } @@ -2201,7 +2196,6 @@ sunos_write_dynamic_symbol (output_bfd, info, harg) bfd *dynobj; asection *splt; bfd_byte *p; - asection *s; bfd_vma r_address; dynobj = sunos_hash_table (info)->dynobj; @@ -2230,8 +2224,6 @@ sunos_write_dynamic_symbol (output_bfd, info, harg) } 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); @@ -2250,7 +2242,7 @@ sunos_write_dynamic_symbol (output_bfd, info, harg) 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; @@ -2399,13 +2391,13 @@ sunos_write_dynamic_symbol (output_bfd, info, harg) 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); @@ -2668,7 +2660,7 @@ sunos_check_dynamic_reloc (info, input_bfd, input_section, harg, reloc, } *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. */ @@ -2845,7 +2837,8 @@ sunos_finish_dynamic_link (abfd, info) 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; } @@ -2855,6 +2848,7 @@ sunos_finish_dynamic_link (abfd, info) { 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); @@ -2869,7 +2863,8 @@ sunos_finish_dynamic_link (abfd, info) 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); @@ -2934,11 +2929,10 @@ sunos_finish_dynamic_link (abfd, info) 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; diff --git a/bfd/syms.c b/bfd/syms.c index 5d885a4..9c8922b 100644 --- a/bfd/syms.c +++ b/bfd/syms.c @@ -197,7 +197,7 @@ CODE_FRAGMENT . . {* 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 @@ -508,14 +508,14 @@ DESCRIPTION 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'}, @@ -547,7 +547,7 @@ static char 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))) @@ -722,7 +722,7 @@ _bfd_generic_read_minisymbols (abfd, dynamic, minisymsp, sizep) 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; @@ -852,7 +852,8 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, 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; @@ -898,11 +899,10 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, 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; @@ -929,10 +929,10 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, 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 @@ -942,7 +942,7 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, 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, @@ -983,7 +983,7 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, 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); } } @@ -1033,10 +1033,9 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, 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; @@ -1154,7 +1153,8 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, ++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; } @@ -1276,9 +1276,8 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, { 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); diff --git a/bfd/targets.c b/bfd/targets.c index 5201ee9..0972d7f 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -208,27 +208,27 @@ Entries for byte swapping for data. These are different from the other 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. @@ -239,11 +239,11 @@ Check the format of a file being read. Return a <> or zero. 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 <>. -. 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. @@ -258,17 +258,16 @@ 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)\ @@ -280,23 +279,23 @@ BFD_JUMP_TABLE macros. .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)\ @@ -322,15 +321,12 @@ BFD_JUMP_TABLE macros. . 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 *)); @@ -349,37 +345,34 @@ BFD_JUMP_TABLE macros. .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, @@ -390,22 +383,21 @@ BFD_JUMP_TABLE macros. .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)\ @@ -418,34 +410,33 @@ BFD_JUMP_TABLE macros. .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)\ @@ -454,14 +445,14 @@ BFD_JUMP_TABLE macros. .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 **)); . @@ -570,12 +561,12 @@ extern const bfd_target bfd_elf64_ia64_big_vec; 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; @@ -657,7 +648,6 @@ extern const bfd_target sparclynx_aout_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; @@ -675,28 +665,25 @@ extern const bfd_target w65_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[] = { @@ -717,134 +704,144 @@ 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. */ @@ -861,20 +858,14 @@ static const bfd_target * const _bfd_target_vector[] = { &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 @@ -892,13 +883,15 @@ static const bfd_target * const _bfd_target_vector[] = { &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... @@ -908,41 +901,45 @@ static const bfd_target * const _bfd_target_vector[] = { &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, @@ -950,12 +947,9 @@ static const bfd_target * const _bfd_target_vector[] = { &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. */ @@ -973,12 +967,19 @@ static const bfd_target * const _bfd_target_vector[] = { #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 @@ -988,17 +989,16 @@ static const bfd_target * const _bfd_target_vector[] = { #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; @@ -1105,7 +1105,7 @@ FUNCTION 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 @@ -1171,19 +1171,20 @@ const char ** 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; diff --git a/bfd/tekhex.c b/bfd/tekhex.c index 943992b..f5d5160 100644 --- a/bfd/tekhex.c +++ b/bfd/tekhex.c @@ -1,5 +1,5 @@ /* 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 . @@ -107,7 +107,7 @@ static asymbol *tekhex_make_empty_symbol PARAMS ((bfd *)); 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)); @@ -354,11 +354,11 @@ find_chunk (abfd, vma) } 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; @@ -394,7 +394,7 @@ first_phase (abfd, type, src) 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) @@ -419,7 +419,7 @@ first_phase (abfd, type, src) 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 */ @@ -445,10 +445,10 @@ first_phase (abfd, type, src) 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 */ @@ -459,12 +459,12 @@ first_phase (abfd, type, src) 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; @@ -496,17 +496,17 @@ pass_over (abfd, func) 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]; @@ -516,7 +516,7 @@ pass_over (abfd, func) 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 */ @@ -555,8 +555,9 @@ static boolean 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; @@ -580,7 +581,7 @@ tekhex_object_p (abfd) 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])) @@ -597,7 +598,7 @@ move_section_contents (abfd, section, locationp, offset, count, get) bfd *abfd; asection *section; PTR locationp; - file_ptr offset ATTRIBUTE_UNUSED; + file_ptr offset; bfd_size_type count; boolean get; { @@ -606,10 +607,11 @@ move_section_contents (abfd, section, locationp, offset, count, 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) @@ -689,7 +691,7 @@ tekhex_set_section_contents (abfd, section, locationp, offset, bytes_to_do) { 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); @@ -699,7 +701,8 @@ tekhex_set_section_contents (abfd, section, locationp, offset, bytes_to_do) } 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 @@ -740,7 +743,7 @@ writevalue (dst, value) static void writesym (dst, sym) char **dst; - CONST char *sym; + const char *sym; { char *p = *dst; int len = (sym ? strlen (sym) : 0); @@ -797,11 +800,11 @@ out (abfd, type, start, end) 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 (); } @@ -826,7 +829,7 @@ tekhex_write_object_contents (abfd) { int low; - CONST int span = 32; + const int span = 32; int addr; /* Write it in blocks of 32 bytes */ @@ -876,10 +879,10 @@ tekhex_write_object_contents (abfd) 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) { @@ -911,15 +914,15 @@ tekhex_write_object_contents (abfd) 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; } @@ -937,8 +940,8 @@ static asymbol * 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; @@ -975,7 +978,7 @@ tekhex_print_symbol (abfd, filep, symbol, how) 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); diff --git a/bfd/trad-core.c b/bfd/trad-core.c index 872ad54..829be0c 100644 --- a/bfd/trad-core.c +++ b/bfd/trad-core.c @@ -1,6 +1,6 @@ /* 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. @@ -80,14 +80,15 @@ trad_unix_core_file_p (abfd) 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 */ @@ -149,8 +150,8 @@ trad_unix_core_file_p (abfd) /* 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; @@ -161,13 +162,16 @@ trad_unix_core_file_p (abfd) /* 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; diff --git a/bfd/versados.c b/bfd/versados.c index 19eed1a..276a101 100644 --- a/bfd/versados.c +++ b/bfd/versados.c @@ -47,7 +47,7 @@ static boolean versados_mkobject PARAMS ((bfd *)); 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 @@ -58,6 +58,14 @@ static int versados_sizeof_headers PARAMS ((bfd *, boolean)); 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' @@ -170,7 +178,8 @@ versados_mkobject (abfd) { 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; @@ -208,8 +217,9 @@ get_record (abfd, ptr) 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; } @@ -243,7 +253,7 @@ get_10 (pp, name) static char * new_symbol_string (abfd, name) bfd *abfd; - char *name; + const char *name; { char *n = VDATA (abfd)->strings; strcpy (VDATA (abfd)->strings, name); @@ -294,8 +304,8 @@ process_esd (abfd, esd, pass) 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; } @@ -318,7 +328,7 @@ process_esd (abfd, esd, pass) 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) @@ -330,7 +340,8 @@ process_esd (abfd, esd, pass) { 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; } } @@ -399,7 +410,7 @@ process_otr (abfd, otr, pass) 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) { @@ -472,8 +483,10 @@ process_otr (abfd, otr, pass) 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 @@ -484,6 +497,7 @@ versados_scan (abfd) int i; int j; int nsecs = 0; + bfd_size_type amt; VDATA (abfd)->stringlen = 0; VDATA (abfd)->nrefs = 0; @@ -527,8 +541,8 @@ versados_scan (abfd) 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; @@ -549,10 +563,12 @@ versados_scan (abfd) 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)) @@ -600,14 +616,14 @@ versados_object_p (abfd) 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); @@ -642,7 +658,7 @@ versados_pass_2 (abfd) 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; @@ -711,7 +727,9 @@ static asymbol * 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; @@ -751,7 +769,7 @@ versados_get_symtab (abfd, alocation) return symcount; } -void +static void versados_get_symbol_info (ignore_abfd, symbol, ret) bfd *ignore_abfd ATTRIBUTE_UNUSED; asymbol *symbol; @@ -760,7 +778,7 @@ versados_get_symbol_info (ignore_abfd, symbol, ret) bfd_symbol_info (symbol, ret); } -void +static void versados_print_symbol (abfd, afile, symbol, how) bfd *abfd; PTR afile; @@ -782,7 +800,7 @@ versados_print_symbol (abfd, afile, symbol, how) } } -long +static long versados_get_reloc_upper_bound (abfd, asect) bfd *abfd ATTRIBUTE_UNUSED; sec_ptr asect; @@ -790,7 +808,7 @@ versados_get_reloc_upper_bound (abfd, asect) return (asect->reloc_count + 1) * sizeof (arelent *); } -long +static long versados_canonicalize_reloc (abfd, section, relptr, symbols) bfd *abfd; sec_ptr section; diff --git a/bfd/vms-gsd.c b/bfd/vms-gsd.c index 5365853..2ee015f 100644 --- a/bfd/vms-gsd.c +++ b/bfd/vms-gsd.c @@ -145,11 +145,11 @@ static flagword vms_esecflag_by_name PARAMS ((struct sec_flags_struct *, char *, /* 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; @@ -159,14 +159,14 @@ vms_secflag_by_name (abfd, section_flags, name, size) 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; } @@ -174,10 +174,10 @@ vms_secflag_by_name (abfd, section_flags, name, size) /* 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; @@ -185,14 +185,14 @@ vms_esecflag_by_name (section_flags, name, size) { 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; } @@ -290,16 +290,16 @@ _bfd_vms_slurp_gsd (abfd, objtype) 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 */ @@ -359,8 +359,9 @@ _bfd_vms_slurp_gsd (abfd, objtype) 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) @@ -414,7 +415,8 @@ _bfd_vms_slurp_gsd (abfd, objtype) 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); @@ -425,13 +427,13 @@ _bfd_vms_slurp_gsd (abfd, objtype) 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 @@ -456,7 +458,7 @@ _bfd_vms_slurp_gsd (abfd, objtype) 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) @@ -473,30 +475,30 @@ _bfd_vms_slurp_gsd (abfd, objtype) 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 */ @@ -604,7 +606,8 @@ _bfd_vms_slurp_gsd (abfd, objtype) 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)) @@ -821,10 +824,11 @@ _bfd_vms_write_gsd (abfd, objtype) } 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); @@ -842,6 +846,7 @@ _bfd_vms_write_gsd (abfd, objtype) for (symnum = 0; symnum < abfd->symcount; symnum++) { + char *hash; symbol = abfd->outsymbols[symnum]; if (*(symbol->name) == '_') @@ -893,27 +898,26 @@ _bfd_vms_write_gsd (abfd, objtype) } _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); diff --git a/bfd/vms-hdr.c b/bfd/vms-hdr.c index f98577d..c6278c1 100644 --- a/bfd/vms-hdr.c +++ b/bfd/vms-hdr.c @@ -347,7 +347,8 @@ _bfd_vms_write_hdr (abfd, objtype) 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; diff --git a/bfd/vms-misc.c b/bfd/vms-misc.c index f0ba285..0c8236f 100644 --- a/bfd/vms-misc.c +++ b/bfd/vms-misc.c @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 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 */ @@ -334,7 +334,7 @@ _bfd_vms_get_record (abfd) 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; @@ -344,7 +344,7 @@ _bfd_vms_get_record (abfd) /* 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); @@ -370,7 +370,8 @@ _bfd_vms_get_record (abfd) 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); @@ -403,7 +404,8 @@ _bfd_vms_get_record (abfd) 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) { @@ -418,9 +420,9 @@ _bfd_vms_get_record (abfd) 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); @@ -430,7 +432,7 @@ _bfd_vms_get_record (abfd) } #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); @@ -491,11 +493,11 @@ _bfd_vms_save_sized_string (str, size) 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; @@ -591,11 +593,11 @@ add_new_contents (abfd, section) 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; @@ -665,7 +667,7 @@ _bfd_vms_output_begin (abfd, rectype, rechead) 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 */ @@ -677,10 +679,10 @@ _bfd_vms_output_begin (abfd, rectype, rechead) 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; } @@ -780,15 +782,16 @@ _bfd_vms_output_flush (abfd) /* 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; } @@ -859,7 +862,8 @@ _bfd_vms_output_short (abfd, value) 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; } @@ -875,7 +879,7 @@ _bfd_vms_output_long (abfd, value) 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; } @@ -920,7 +924,7 @@ int len; (*_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); } @@ -939,7 +943,7 @@ _bfd_vms_output_dump (abfd, data, length) 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; @@ -959,7 +963,7 @@ _bfd_vms_output_fill (abfd, value, count) 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; @@ -1031,7 +1035,7 @@ _bfd_vms_length_hash_symbol (abfd, in, maxlen) i = maxlen; } - strncpy (out, in, i); + strncpy (out, in, (size_t) i); in += i; out += i; diff --git a/bfd/vms-tir.c b/bfd/vms-tir.c index 7ffe605..fc9d23d 100644 --- a/bfd/vms-tir.c +++ b/bfd/vms-tir.c @@ -68,19 +68,20 @@ check_section (abfd, size) 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; @@ -98,11 +99,11 @@ image_set_ptr (abfd, psect, offset) { #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; } @@ -117,7 +118,7 @@ image_inc_ptr (abfd, offset) _bfd_vms_debug (4, "image_inc_ptr (%d)\n", offset); #endif - PRIV(image_ptr) += offset; + PRIV (image_ptr) += offset; return; } @@ -132,15 +133,16 @@ image_dump (abfd, ptr, size, offset) 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; } @@ -152,13 +154,13 @@ image_write_b (abfd, value) 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; } @@ -170,14 +172,14 @@ image_write_w (abfd, value) 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; } @@ -193,11 +195,11 @@ image_write_l (abfd, value) _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; } @@ -213,11 +215,11 @@ image_write_q (abfd, value) _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; } @@ -243,7 +245,7 @@ etir_sta (abfd, cmd, ptr) #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) @@ -251,87 +253,87 @@ etir_sta (abfd, cmd, ptr) /* 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 @@ -361,7 +363,7 @@ etir_sto (abfd, cmd, ptr) #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) @@ -376,7 +378,8 @@ etir_sto (abfd, cmd, ptr) 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 @@ -388,7 +391,8 @@ etir_sto (abfd, cmd, ptr) 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 @@ -396,8 +400,9 @@ etir_sto (abfd, cmd, ptr) 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 @@ -405,7 +410,7 @@ etir_sto (abfd, cmd, ptr) 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; @@ -415,11 +420,11 @@ etir_sto (abfd, cmd, ptr) 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; @@ -433,8 +438,9 @@ etir_sto (abfd, cmd, ptr) 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); @@ -454,8 +460,9 @@ etir_sto (abfd, cmd, ptr) 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); @@ -473,16 +480,16 @@ etir_sto (abfd, cmd, ptr) (*_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; @@ -500,8 +507,9 @@ etir_sto (abfd, cmd, ptr) } 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 */ @@ -512,13 +520,14 @@ etir_sto (abfd, cmd, ptr) 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 */ @@ -531,13 +540,13 @@ etir_sto (abfd, cmd, ptr) (*_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")); @@ -568,7 +577,7 @@ etir_opr (abfd, cmd, ptr) #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) @@ -583,34 +592,34 @@ etir_opr (abfd, cmd, ptr) /* 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; @@ -618,58 +627,58 @@ etir_opr (abfd, cmd, ptr) /* 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 */ @@ -687,13 +696,13 @@ etir_opr (abfd, cmd, ptr) /* 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; @@ -732,7 +741,7 @@ etir_ctl (abfd, cmd, ptr) #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) @@ -797,7 +806,7 @@ etir_stc (abfd, cmd, ptr) #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) @@ -816,7 +825,7 @@ etir_stc (abfd, cmd, ptr) 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 @@ -893,7 +902,10 @@ etir_stc (abfd, cmd, ptr) 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: @@ -919,12 +931,12 @@ new_section (abfd, idx) #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 @@ -948,21 +960,25 @@ alloc_section (abfd, idx) 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; @@ -990,302 +1006,304 @@ tir_sta (bfd *abfd, unsigned char *ptr) 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; } @@ -1314,149 +1332,149 @@ tir_sto (bfd *abfd, unsigned char *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 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 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; } @@ -1481,175 +1499,175 @@ tir_opr (bfd *abfd, unsigned char *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; } @@ -1673,54 +1691,54 @@ tir_ctl (bfd *abfd, unsigned char *ptr) 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; } @@ -1731,22 +1749,25 @@ tir_ctl (bfd *abfd, unsigned char *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 */ @@ -1760,7 +1781,7 @@ tir_cmd (bfd *abfd, unsigned char *ptr) 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; @@ -1785,11 +1806,14 @@ etir_cmd (abfd, cmd, ptr) 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 }, @@ -1802,13 +1826,13 @@ etir_cmd (abfd, cmd, ptr) #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; @@ -1903,19 +1927,19 @@ _bfd_vms_slurp_tir (abfd, objtype) 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; @@ -1998,7 +2022,7 @@ sto_imm (abfd, sptr, vaddr, index) #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; @@ -2025,7 +2049,7 @@ sto_imm (abfd, sptr, vaddr, index) #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; @@ -2054,8 +2078,8 @@ start_etir_record (abfd, index, offset, justoffset) } _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 () */ @@ -2091,7 +2115,7 @@ _bfd_vms_write_tir (abfd, objtype) _bfd_vms_output_alignment (abfd, 4); nextoffset = 0; - PRIV(vms_linkage_index) = 1; + PRIV (vms_linkage_index) = 1; /* dump all other sections */ @@ -2101,7 +2125,9 @@ _bfd_vms_write_tir (abfd, objtype) { #if VMS_DEBUG - _bfd_vms_debug (4, "writing %d. section '%s' (%d bytes)\n", section->index, section->name, (int) (section->_raw_size)); + _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) @@ -2122,12 +2148,12 @@ _bfd_vms_write_tir (abfd, objtype) 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++; } } @@ -2135,7 +2161,7 @@ _bfd_vms_write_tir (abfd, objtype) } if ((section->flags & SEC_HAS_CONTENTS) - && (! bfd_is_com_section (section))) + && (! bfd_is_com_section (section))) { bfd_vma vaddr; /* virtual addr in section */ @@ -2151,10 +2177,10 @@ _bfd_vms_write_tir (abfd, objtype) 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; @@ -2162,10 +2188,10 @@ _bfd_vms_write_tir (abfd, objtype) { 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; @@ -2182,7 +2208,7 @@ _bfd_vms_write_tir (abfd, objtype) 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; @@ -2196,9 +2222,10 @@ _bfd_vms_write_tir (abfd, objtype) { 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, @@ -2206,10 +2233,11 @@ _bfd_vms_write_tir (abfd, objtype) 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)) @@ -2222,14 +2250,14 @@ _bfd_vms_write_tir (abfd, objtype) 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 @@ -2242,17 +2270,17 @@ _bfd_vms_write_tir (abfd, objtype) 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); } } @@ -2262,9 +2290,9 @@ _bfd_vms_write_tir (abfd, objtype) { 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, @@ -2272,10 +2300,11 @@ _bfd_vms_write_tir (abfd, objtype) 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)) @@ -2288,14 +2317,14 @@ _bfd_vms_write_tir (abfd, objtype) 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 @@ -2308,17 +2337,17 @@ _bfd_vms_write_tir (abfd, objtype) 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); } } @@ -2327,23 +2356,31 @@ _bfd_vms_write_tir (abfd, objtype) 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); @@ -2351,13 +2388,14 @@ _bfd_vms_write_tir (abfd, objtype) 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); } @@ -2365,9 +2403,9 @@ _bfd_vms_write_tir (abfd, objtype) 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, @@ -2375,10 +2413,11 @@ _bfd_vms_write_tir (abfd, objtype) 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; @@ -2404,24 +2443,25 @@ _bfd_vms_write_tir (abfd, objtype) 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; @@ -2438,7 +2478,7 @@ _bfd_vms_write_tir (abfd, objtype) section = section->next; } - _bfd_vms_output_alignment(abfd, 2); + _bfd_vms_output_alignment (abfd, 2); return 0; } diff --git a/bfd/vms.c b/bfd/vms.c index 78c31c2..94fa84e 100644 --- a/bfd/vms.c +++ b/bfd/vms.c @@ -63,7 +63,7 @@ static boolean vms_construct_extended_name_table 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)); @@ -71,7 +71,7 @@ static PTR vms_read_ar_hdr PARAMS ((bfd *abfd)); 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 @@ -232,14 +232,15 @@ vms_initialize (abfd) 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; @@ -255,8 +256,8 @@ vms_initialize (abfd) 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: @@ -266,8 +267,8 @@ vms_initialize (abfd) } 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: @@ -279,9 +280,8 @@ vms_initialize (abfd) 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: @@ -401,7 +401,7 @@ vms_object_p (abfd) 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; @@ -740,8 +740,9 @@ vms_new_section_hook (abfd, section) 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; @@ -978,7 +979,7 @@ vms_construct_extended_name_table (abfd, tabloc, tablen, name) 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 @@ -1051,14 +1052,14 @@ vms_get_elt_at_index (abfd, index) -> 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 */ @@ -1147,7 +1148,9 @@ asymbol * _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); @@ -1188,7 +1191,7 @@ vms_print_symbol (abfd, file, symbol, how) 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); @@ -1293,8 +1296,8 @@ vms_find_nearest_line (abfd, section, symbols, offset, file, func, line) 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 diff --git a/bfd/vms.h b/bfd/vms.h index 0b1f7fa..5963a8c 100644 --- a/bfd/vms.h +++ b/bfd/vms.h @@ -1,6 +1,7 @@ #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) diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index 6f70a32..3a49918 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -1,5 +1,5 @@ /* 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 , Cygnus Support. @@ -39,7 +39,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* 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. */ @@ -53,7 +54,8 @@ struct xcoff_import_file { /* 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 @@ -72,7 +74,8 @@ struct xcoff_link_section_info { /* 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. */ @@ -159,16 +162,16 @@ xcoff_get_section_contents (abfd, sec) 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; @@ -272,7 +275,7 @@ _bfd_xcoff_canonicalize_dynamic_symtab (abfd, psyms) { 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); @@ -374,8 +377,8 @@ _bfd_xcoff_canonicalize_dynamic_reloc (abfd, prelocs, syms) 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; @@ -477,9 +480,9 @@ _bfd_xcoff_bfd_link_hash_table_create (abfd) 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)) @@ -731,7 +734,7 @@ xcoff_link_check_ar_symbols (abfd, info, pneeded) 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)) { @@ -886,92 +889,103 @@ xcoff_find_reloc (relocs, count, address) } -/* - * 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: @@ -1018,26 +1032,30 @@ xcoff_link_add_symbols (abfd, info) 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) @@ -1055,79 +1073,78 @@ xcoff_link_add_symbols (abfd, info) 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. */ @@ -1142,56 +1159,57 @@ xcoff_link_add_symbols (abfd, info) 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 @@ -1199,80 +1217,89 @@ xcoff_link_add_symbols (abfd, info) 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); @@ -1322,13 +1349,11 @@ xcoff_link_add_symbols (abfd, info) 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) @@ -1346,123 +1371,122 @@ xcoff_link_add_symbols (abfd, info) 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 */ { @@ -1473,28 +1497,28 @@ xcoff_link_add_symbols (abfd, info) 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 @@ -1505,46 +1529,48 @@ xcoff_link_add_symbols (abfd, info) /* 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. */ @@ -1574,7 +1600,7 @@ xcoff_link_add_symbols (abfd, info) 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. */ { @@ -1621,16 +1647,17 @@ xcoff_link_add_symbols (abfd, info) / 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; @@ -1644,12 +1671,12 @@ xcoff_link_add_symbols (abfd, info) - (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; @@ -1669,31 +1696,36 @@ xcoff_link_add_symbols (abfd, info) } /* 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. */ @@ -1736,7 +1768,7 @@ xcoff_link_add_symbols (abfd, info) 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), @@ -1818,7 +1850,7 @@ xcoff_link_add_symbols (abfd, 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))) @@ -1858,11 +1890,11 @@ xcoff_link_add_symbols (abfd, info) 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; @@ -1922,7 +1954,7 @@ xcoff_link_add_symbols (abfd, info) /* 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) @@ -2014,7 +2046,7 @@ xcoff_link_add_symbols (abfd, info) 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; @@ -2045,15 +2077,15 @@ xcoff_link_add_dynamic_symbols (abfd, info) /* 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 @@ -2176,7 +2208,7 @@ xcoff_link_add_dynamic_symbols (abfd, info) { char *dsnm; - dsnm = bfd_malloc (strlen (name) + 2); + dsnm = bfd_malloc ((bfd_size_type) strlen (name) + 2); if (dsnm == NULL) return false; dsnm[0] = '.'; @@ -2227,7 +2259,7 @@ xcoff_link_add_dynamic_symbols (abfd, info) /* 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; @@ -2488,6 +2520,7 @@ bfd_xcoff_link_record_set (output_bfd, info, harg, size) { 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; @@ -2496,8 +2529,8 @@ bfd_xcoff_link_record_set (output_bfd, info, harg, size) 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; @@ -2611,9 +2644,9 @@ bfd_xcoff_import_symbol (output_bfd, info, harg, val, imppath, impfile, 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; @@ -2654,8 +2687,9 @@ bfd_xcoff_export_symbol (output_bfd, info, harg) { 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] = '.'; @@ -2799,13 +2833,15 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, 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; @@ -2823,77 +2859,77 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, 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. */ @@ -2931,22 +2967,24 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, } /* 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); @@ -2987,14 +3025,13 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, 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. */ @@ -3044,7 +3081,7 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry, 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. */ @@ -3190,15 +3227,16 @@ xcoff_build_ldsyms (h, p) 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 @@ -3305,36 +3343,38 @@ xcoff_build_ldsyms (h, p) || 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 @@ -3364,24 +3404,18 @@ xcoff_build_ldsyms (h, p) 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 { @@ -3438,9 +3472,8 @@ xcoff_build_ldsyms (h, p) /* 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; @@ -3450,19 +3483,18 @@ xcoff_build_ldsyms (h, p) 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; @@ -3480,11 +3512,11 @@ _bfd_xcoff_bfd_final_link (abfd, info) 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; @@ -3492,6 +3524,8 @@ _bfd_xcoff_bfd_final_link (abfd, info) 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; @@ -3511,11 +3545,12 @@ _bfd_xcoff_bfd_final_link (abfd, info) 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; @@ -3635,16 +3670,14 @@ _bfd_xcoff_bfd_final_link (abfd, 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) @@ -3679,10 +3712,9 @@ _bfd_xcoff_bfd_final_link (abfd, info) /* 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++) @@ -3728,13 +3760,16 @@ _bfd_xcoff_bfd_final_link (abfd, info) 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; @@ -3774,7 +3809,7 @@ _bfd_xcoff_bfd_final_link (abfd, info) 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); @@ -3783,17 +3818,24 @@ _bfd_xcoff_bfd_final_link (abfd, info) } /* 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 @@ -3842,49 +3884,54 @@ _bfd_xcoff_bfd_final_link (abfd, info) /* 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 @@ -3902,132 +3949,145 @@ _bfd_xcoff_bfd_final_link (abfd, info) /* 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; @@ -4036,42 +4096,44 @@ _bfd_xcoff_bfd_final_link (abfd, info) /* 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) @@ -4272,17 +4334,19 @@ xcoff_link_input_bfd (finfo, input_bfd) 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; @@ -4337,7 +4401,6 @@ xcoff_link_input_bfd (finfo, input_bfd) inp != NULL; inp = inp->link_next) { - asection *o; for (o = inp->sections; o != NULL; o = o->next) if (strcmp (o->name, ".tocbss") == 0) @@ -4375,7 +4438,7 @@ xcoff_link_input_bfd (finfo, input_bfd) xcoff_data (finfo->output_bfd)->sntoc = (*csectpp)->output_section->target_index; require = true; - + } } @@ -4520,14 +4583,16 @@ xcoff_link_input_bfd (finfo, input_bfd) /* 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; } @@ -4692,20 +4757,22 @@ xcoff_link_input_bfd (finfo, input_bfd) 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; + } } } } @@ -4777,12 +4844,11 @@ xcoff_link_input_bfd (finfo, input_bfd) 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; } @@ -4840,8 +4906,8 @@ xcoff_link_input_bfd (finfo, input_bfd) 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; @@ -4930,12 +4996,10 @@ xcoff_link_input_bfd (finfo, input_bfd) /* 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) @@ -4950,318 +5014,323 @@ xcoff_link_input_bfd (finfo, input_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) @@ -5280,16 +5349,18 @@ xcoff_link_input_bfd (finfo, input_bfd) 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; @@ -5300,149 +5371,165 @@ xcoff_write_global_symbol (h, p) 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. */ @@ -5465,43 +5552,46 @@ xcoff_write_global_symbol (h, p) + 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; @@ -5513,41 +5603,42 @@ xcoff_write_global_symbol (h, p) 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); @@ -5557,18 +5648,16 @@ xcoff_write_global_symbol (h, p) } } - /* - * 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 @@ -5585,15 +5674,20 @@ xcoff_write_global_symbol (h, p) 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; @@ -5637,33 +5731,33 @@ xcoff_write_global_symbol (h, p) 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); @@ -5709,9 +5803,8 @@ xcoff_write_global_symbol (h, p) 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; @@ -5728,11 +5821,12 @@ xcoff_write_global_symbol (h, p) 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) @@ -5820,13 +5914,11 @@ xcoff_write_global_symbol (h, p) 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); -- cgit v1.1