aboutsummaryrefslogtreecommitdiff
path: root/bfd/ecoff.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/ecoff.c')
-rw-r--r--bfd/ecoff.c69
1 files changed, 25 insertions, 44 deletions
diff --git a/bfd/ecoff.c b/bfd/ecoff.c
index 1d9e385..9e2efac 100644
--- a/bfd/ecoff.c
+++ b/bfd/ecoff.c
@@ -465,13 +465,12 @@ ecoff_slurp_symbolic_header (bfd *abfd)
}
/* Read the symbolic information header. */
- raw = bfd_malloc (external_hdr_size);
+ if (bfd_seek (abfd, ecoff_data (abfd)->sym_filepos, SEEK_SET) != 0)
+ goto error_return;
+ raw = _bfd_malloc_and_read (abfd, external_hdr_size, external_hdr_size);
if (raw == NULL)
goto error_return;
- 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);
@@ -571,18 +570,13 @@ _bfd_ecoff_slurp_symbolic_info (bfd *abfd,
ecoff_data (abfd)->sym_filepos = 0;
return TRUE;
}
- raw = bfd_alloc (abfd, raw_size);
- if (raw == NULL)
- return FALSE;
-
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;
- }
+ if (bfd_seek (abfd, pos, SEEK_SET) != 0)
+ return FALSE;
+ raw = _bfd_alloc_and_read (abfd, raw_size, raw_size);
+ if (raw == NULL)
+ return FALSE;
ecoff_data (abfd)->raw_syments = raw;
@@ -1611,7 +1605,7 @@ ecoff_slurp_reloc_table (bfd *abfd,
arelent *internal_relocs;
bfd_size_type external_reloc_size;
bfd_size_type amt;
- char *external_relocs;
+ bfd_byte *external_relocs;
arelent *rptr;
unsigned int i;
@@ -1625,12 +1619,10 @@ ecoff_slurp_reloc_table (bfd *abfd,
external_reloc_size = backend->external_reloc_size;
amt = external_reloc_size * section->reloc_count;
- external_relocs = (char *) bfd_alloc (abfd, amt);
- if (external_relocs == NULL)
- return FALSE;
if (bfd_seek (abfd, section->rel_filepos, SEEK_SET) != 0)
return FALSE;
- if (bfd_bread (external_relocs, amt, abfd) != amt)
+ external_relocs = _bfd_alloc_and_read (abfd, amt, amt);
+ if (external_relocs == NULL)
return FALSE;
amt = section->reloc_count;
@@ -2945,15 +2937,11 @@ _bfd_ecoff_slurp_armap (bfd *abfd)
parsed_size = mapdata->parsed_size;
free (mapdata);
- raw_armap = (char *) bfd_alloc (abfd, parsed_size);
+ raw_armap = (char *) _bfd_alloc_and_read (abfd, parsed_size, parsed_size);
if (raw_armap == NULL)
- return FALSE;
-
- if (bfd_bread ((void *) raw_armap, parsed_size, abfd) != parsed_size)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_malformed_archive);
- bfd_release (abfd, (void *) raw_armap);
return FALSE;
}
@@ -3503,25 +3491,21 @@ ecoff_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
symhdr = &ecoff_data (abfd)->debug_info.symbolic_header;
/* Read in the external symbols and external strings. */
+ if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0)
+ return FALSE;
external_ext_size = ecoff_backend (abfd)->debug_swap.external_ext_size;
esize = symhdr->iextMax * external_ext_size;
- external_ext = bfd_malloc (esize);
+ external_ext = _bfd_malloc_and_read (abfd, esize, esize);
if (external_ext == NULL && esize != 0)
goto error_return;
- if (bfd_seek (abfd, (file_ptr) symhdr->cbExtOffset, SEEK_SET) != 0
- || bfd_bread (external_ext, esize, abfd) != esize)
+ if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0)
goto error_return;
-
- ssext = (char *) bfd_malloc ((bfd_size_type) symhdr->issExtMax);
+ ssext = (char *) _bfd_malloc_and_read (abfd, symhdr->issExtMax,
+ symhdr->issExtMax);
if (ssext == NULL && symhdr->issExtMax != 0)
goto error_return;
- 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;
-
result = ecoff_link_add_externals (abfd, info, external_ext, ssext);
if (ssext != NULL)
@@ -3775,14 +3759,13 @@ ecoff_final_link_debug_accumulate (bfd *output_bfd,
ret = FALSE; \
goto return_something; \
} \
- debug->ptr = (type) bfd_malloc (amt); \
- if (debug->ptr == NULL) \
+ if (bfd_seek (input_bfd, symhdr->offset, SEEK_SET) != 0) \
{ \
ret = FALSE; \
goto return_something; \
} \
- if (bfd_seek (input_bfd, symhdr->offset, SEEK_SET) != 0 \
- || bfd_bread (debug->ptr, amt, input_bfd) != amt) \
+ debug->ptr = (type) _bfd_malloc_and_read (input_bfd, amt, amt); \
+ if (debug->ptr == NULL) \
{ \
ret = FALSE; \
goto return_something; \
@@ -3887,13 +3870,11 @@ ecoff_indirect_link_order (bfd *output_bfd,
external_reloc_size = ecoff_backend (input_bfd)->external_reloc_size;
external_relocs_size = external_reloc_size * input_section->reloc_count;
- external_relocs = bfd_malloc (external_relocs_size);
- if (external_relocs == NULL && external_relocs_size != 0)
+ if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0)
goto error_return;
-
- if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
- || (bfd_bread (external_relocs, external_relocs_size, input_bfd)
- != external_relocs_size))
+ external_relocs = _bfd_malloc_and_read (input_bfd, external_relocs_size,
+ external_relocs_size);
+ if (external_relocs == NULL && external_relocs_size != 0)
goto error_return;
/* Relocate the section contents. */