aboutsummaryrefslogtreecommitdiff
path: root/bfd/coffcode.h
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/coffcode.h')
-rw-r--r--bfd/coffcode.h697
1 files changed, 318 insertions, 379 deletions
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, &section, &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;