* libbfd.c (bfd_malloc, bfd_realloc): New functions.

(bfd_zmalloc): Return PTR, not char *.  Take size_t, not
	bfd_size_type.
	* libbfd-in.h (bfd_malloc, bfd_realloc): Declare.
	(bfd_zmalloc): Change declaration.
	* libbfd.h: Rebuild.
	* Many files: Use bfd_malloc and bfd_realloc rather than malloc
	and realloc.  Don't set bfd_error_no_memory if they fail.
This commit is contained in:
Ian Lance Taylor 1995-12-01 19:48:10 +00:00
parent 2eec871057
commit 58142f101d
22 changed files with 242 additions and 494 deletions

View file

@ -1,3 +1,14 @@
Fri Dec 1 14:46:51 1995 Ian Lance Taylor <ian@cygnus.com>
* libbfd.c (bfd_malloc, bfd_realloc): New functions.
(bfd_zmalloc): Return PTR, not char *. Take size_t, not
bfd_size_type.
* libbfd-in.h (bfd_malloc, bfd_realloc): Declare.
(bfd_zmalloc): Change declaration.
* libbfd.h: Rebuild.
* Many files: Use bfd_malloc and bfd_realloc rather than malloc
and realloc. Don't set bfd_error_no_memory if they fail.
Thu Nov 30 19:32:26 1995 Kim Knuttila <krk@cygnus.com> Thu Nov 30 19:32:26 1995 Kim Knuttila <krk@cygnus.com>
* coff-ppc.c: Added macros to tidy up toc cell treatment. Numerous * coff-ppc.c: Added macros to tidy up toc cell treatment. Numerous

View file

@ -1240,12 +1240,9 @@ aout_get_external_symbols (abfd)
later on. If we put them on the obstack it might not be later on. If we put them on the obstack it might not be
possible to free them. */ possible to free them. */
syms = ((struct external_nlist *) syms = ((struct external_nlist *)
malloc ((size_t) count * EXTERNAL_NLIST_SIZE)); bfd_malloc ((size_t) count * EXTERNAL_NLIST_SIZE));
if (syms == (struct external_nlist *) NULL && count != 0) if (syms == (struct external_nlist *) NULL && count != 0)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0 if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
|| (bfd_read (syms, 1, exec_hdr (abfd)->a_syms, abfd) || (bfd_read (syms, 1, exec_hdr (abfd)->a_syms, abfd)
@ -1280,12 +1277,9 @@ aout_get_external_symbols (abfd)
return false; return false;
strings = (char *) obj_aout_string_window (abfd).data; strings = (char *) obj_aout_string_window (abfd).data;
#else #else
strings = (char *) malloc ((size_t) stringsize + 1); strings = (char *) bfd_malloc ((size_t) stringsize + 1);
if (strings == NULL) if (strings == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
/* Skip space for the string count in the buffer for convenience /* Skip space for the string count in the buffer for convenience
when using indexes. */ when using indexes. */
@ -1736,12 +1730,9 @@ NAME(aout,slurp_symbol_table) (abfd)
cached_size = (obj_aout_external_sym_count (abfd) cached_size = (obj_aout_external_sym_count (abfd)
* sizeof (aout_symbol_type)); * sizeof (aout_symbol_type));
cached = (aout_symbol_type *) malloc (cached_size); cached = (aout_symbol_type *) bfd_malloc (cached_size);
if (cached == NULL && cached_size != 0) if (cached == NULL && cached_size != 0)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
if (cached_size != 0) if (cached_size != 0)
memset (cached, 0, cached_size); memset (cached, 0, cached_size);
@ -2294,19 +2285,15 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols)
count = reloc_size / each_size; count = reloc_size / each_size;
reloc_cache = (arelent *) malloc ((size_t) (count * sizeof (arelent))); reloc_cache = (arelent *) bfd_malloc ((size_t) (count * sizeof (arelent)));
if (reloc_cache == NULL && count != 0) if (reloc_cache == NULL && count != 0)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
memset (reloc_cache, 0, count * sizeof (arelent)); memset (reloc_cache, 0, count * sizeof (arelent));
relocs = malloc ((size_t) reloc_size); relocs = bfd_malloc ((size_t) reloc_size);
if (relocs == NULL && reloc_size != 0) if (relocs == NULL && reloc_size != 0)
{ {
free (reloc_cache); free (reloc_cache);
bfd_set_error (bfd_error_no_memory);
return false; return false;
} }
@ -2732,12 +2719,10 @@ NAME(aout,find_nearest_line)
adata (abfd).line_buf = buf = NULL; adata (abfd).line_buf = buf = NULL;
else else
{ {
adata (abfd).line_buf = buf = (char *) malloc (filelen + funclen + 2); buf = (char *) bfd_malloc (filelen + funclen + 2);
if (adata (abfd).line_buf == NULL) adata (abfd).line_buf = buf;
{ if (buf == NULL)
bfd_set_error (bfd_error_no_memory); return false;
return false;
}
} }
if (main_file_name != NULL) if (main_file_name != NULL)
@ -3568,20 +3553,17 @@ NAME(aout,final_link) (abfd, info, callback)
goto error_return; goto error_return;
/* Allocate buffers to hold section contents and relocs. */ /* Allocate buffers to hold section contents and relocs. */
aout_info.contents = (bfd_byte *) malloc (max_contents_size); aout_info.contents = (bfd_byte *) bfd_malloc (max_contents_size);
aout_info.relocs = (PTR) malloc (max_relocs_size); aout_info.relocs = (PTR) bfd_malloc (max_relocs_size);
aout_info.symbol_map = (int *) malloc (max_sym_count * sizeof (int *)); aout_info.symbol_map = (int *) bfd_malloc (max_sym_count * sizeof (int *));
aout_info.output_syms = ((struct external_nlist *) aout_info.output_syms = ((struct external_nlist *)
malloc ((max_sym_count + 1) bfd_malloc ((max_sym_count + 1)
* sizeof (struct external_nlist))); * sizeof (struct external_nlist)));
if ((aout_info.contents == NULL && max_contents_size != 0) if ((aout_info.contents == NULL && max_contents_size != 0)
|| (aout_info.relocs == NULL && max_relocs_size != 0) || (aout_info.relocs == NULL && max_relocs_size != 0)
|| (aout_info.symbol_map == NULL && max_sym_count != 0) || (aout_info.symbol_map == NULL && max_sym_count != 0)
|| aout_info.output_syms == NULL) || aout_info.output_syms == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
/* If we have a symbol named __DYNAMIC, force it out now. This is /* If we have a symbol named __DYNAMIC, force it out now. This is
required by SunOS. Doing this here rather than in sunos.c is a required by SunOS. Doing this here rather than in sunos.c is a

View file

@ -500,16 +500,13 @@ b_out_slurp_reloc_table (abfd, asect, symbols)
return false; return false;
count = reloc_size / sizeof (struct relocation_info); count = reloc_size / sizeof (struct relocation_info);
relocs = (struct relocation_info *) malloc (reloc_size); relocs = (struct relocation_info *) bfd_malloc (reloc_size);
if (!relocs && reloc_size != 0) { if (!relocs && reloc_size != 0)
bfd_set_error (bfd_error_no_memory);
return false; return false;
} reloc_cache = (arelent *) bfd_malloc ((count+1) * sizeof (arelent));
reloc_cache = (arelent *) malloc ((count+1) * sizeof (arelent));
if (!reloc_cache) { if (!reloc_cache) {
if (relocs != NULL) if (relocs != NULL)
free ((char*)relocs); free ((char*)relocs);
bfd_set_error (bfd_error_no_memory);
return false; return false;
} }
@ -698,11 +695,9 @@ b_out_squirt_out_relocs (abfd, section)
int extern_mask, pcrel_mask, len_2, callj_mask; int extern_mask, pcrel_mask, len_2, callj_mask;
if (count == 0) return true; if (count == 0) return true;
generic = section->orelocation; generic = section->orelocation;
native = ((struct relocation_info *) malloc (natsize)); native = ((struct relocation_info *) bfd_malloc (natsize));
if (!native && natsize != 0) { if (!native && natsize != 0)
bfd_set_error (bfd_error_no_memory);
return false; return false;
}
if (abfd->xvec->header_byteorder_big_p) if (abfd->xvec->header_byteorder_big_p)
{ {
@ -1154,12 +1149,9 @@ b_out_bfd_relax_section (abfd, i, link_info, again)
{ {
long reloc_count; long reloc_count;
reloc_vector = (arelent **) malloc (reloc_size); reloc_vector = (arelent **) bfd_malloc (reloc_size);
if (reloc_vector == NULL && reloc_size != 0) if (reloc_vector == NULL && reloc_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
/* Get the relocs and think about them */ /* Get the relocs and think about them */
reloc_count = reloc_count =
@ -1230,12 +1222,9 @@ b_out_bfd_get_relocated_section_contents (in_abfd, link_info, link_order,
data, relocateable, data, relocateable,
symbols); symbols);
reloc_vector = (arelent **) malloc (reloc_size); reloc_vector = (arelent **) bfd_malloc (reloc_size);
if (reloc_vector == NULL && reloc_size != 0) if (reloc_vector == NULL && reloc_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
input_section->reloc_done = 1; input_section->reloc_done = 1;

View file

@ -759,12 +759,9 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order,
if (reloc_size < 0) if (reloc_size < 0)
goto error_return; goto error_return;
reloc_vector = (arelent **) malloc (reloc_size); reloc_vector = (arelent **) bfd_malloc (reloc_size);
if (reloc_vector == NULL && reloc_size != 0) if (reloc_vector == NULL && reloc_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (! bfd_get_section_contents (input_bfd, input_section, data, if (! bfd_get_section_contents (input_bfd, input_section, data,
(file_ptr) 0, input_section->_raw_size)) (file_ptr) 0, input_section->_raw_size))

View file

@ -287,12 +287,9 @@ coff_i960_start_final_link (abfd, info)
if (! info->relocateable) if (! info->relocateable)
return true; return true;
esym = (bfd_byte *) malloc (symesz); esym = (bfd_byte *) bfd_malloc (symesz);
if (esym == NULL) if (esym == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
return false; return false;

View file

@ -1996,12 +1996,9 @@ mips_relax_section (abfd, sec, info, again)
if (info->keep_memory) if (info->keep_memory)
contents = (bfd_byte *) bfd_alloc (abfd, sec->_raw_size); contents = (bfd_byte *) bfd_alloc (abfd, sec->_raw_size);
else else
contents = (bfd_byte *) malloc ((size_t) sec->_raw_size); contents = (bfd_byte *) bfd_malloc ((size_t) sec->_raw_size);
if (contents == (bfd_byte *) NULL) if (contents == (bfd_byte *) NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (! bfd_get_section_contents (abfd, sec, (PTR) contents, if (! bfd_get_section_contents (abfd, sec, (PTR) contents,
(file_ptr) 0, sec->_raw_size)) (file_ptr) 0, sec->_raw_size))
goto error_return; goto error_return;

View file

@ -824,7 +824,9 @@ record_toc(toc_section, our_toc_offset, cat, name)
{ {
/* add this entry to our toc addr-offset-name list */ /* add this entry to our toc addr-offset-name list */
struct list_ele *t; struct list_ele *t;
t = malloc(sizeof(struct list_ele)); t = bfd_malloc (sizeof (struct list_ele));
if (t == NULL)
abort ();
t->next = 0; t->next = 0;
t->offset = our_toc_offset; t->offset = our_toc_offset;
t->name = name; t->name = name;

View file

@ -482,12 +482,9 @@ sh_relax_section (abfd, sec, link_info, again)
contents = coff_section_data (abfd, sec)->contents; contents = coff_section_data (abfd, sec)->contents;
else else
{ {
contents = (bfd_byte *) malloc (sec->_raw_size); contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
if (contents == NULL) if (contents == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
free_contents = contents; free_contents = contents;
if (! bfd_get_section_contents (abfd, sec, contents, if (! bfd_get_section_contents (abfd, sec, contents,
@ -1087,12 +1084,9 @@ sh_relax_delete_bytes (abfd, sec, addr, count)
Perhaps, if info->keep_memory is false, we Perhaps, if info->keep_memory is false, we
should free them, if we are permitted to, should free them, if we are permitted to,
when we leave sh_coff_relax_section. */ when we leave sh_coff_relax_section. */
ocontents = (bfd_byte *) malloc (o->_raw_size); ocontents = (bfd_byte *) bfd_malloc (o->_raw_size);
if (ocontents == NULL) if (ocontents == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
if (! bfd_get_section_contents (abfd, o, ocontents, if (! bfd_get_section_contents (abfd, o, ocontents,
(file_ptr) 0, (file_ptr) 0,
o->_raw_size)) o->_raw_size))
@ -1383,21 +1377,15 @@ sh_coff_get_relocated_section_contents (output_bfd, link_info, link_order,
goto error_return; goto error_return;
internal_syms = ((struct internal_syment *) internal_syms = ((struct internal_syment *)
malloc (obj_raw_syment_count (input_bfd) bfd_malloc (obj_raw_syment_count (input_bfd)
* sizeof (struct internal_syment))); * sizeof (struct internal_syment)));
if (internal_syms == NULL) if (internal_syms == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
sections = (asection **) malloc (obj_raw_syment_count (input_bfd) sections = (asection **) bfd_malloc (obj_raw_syment_count (input_bfd)
* sizeof (asection *)); * sizeof (asection *));
if (sections == NULL) if (sections == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
isymp = internal_syms; isymp = internal_syms;
secpp = sections; secpp = sections;

View file

@ -397,12 +397,9 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs,
if (external_relocs == NULL) if (external_relocs == NULL)
{ {
free_external = (bfd_byte *) malloc (sec->reloc_count * relsz); free_external = (bfd_byte *) bfd_malloc (sec->reloc_count * relsz);
if (free_external == NULL && sec->reloc_count > 0) if (free_external == NULL && sec->reloc_count > 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
external_relocs = free_external; external_relocs = free_external;
} }
@ -414,13 +411,10 @@ _bfd_coff_read_internal_relocs (abfd, sec, cache, external_relocs,
if (internal_relocs == NULL) if (internal_relocs == NULL)
{ {
free_internal = ((struct internal_reloc *) free_internal = ((struct internal_reloc *)
malloc (sec->reloc_count bfd_malloc (sec->reloc_count
* sizeof (struct internal_reloc))); * sizeof (struct internal_reloc)));
if (free_internal == NULL && sec->reloc_count > 0) if (free_internal == NULL && sec->reloc_count > 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
internal_relocs = free_internal; internal_relocs = free_internal;
} }
@ -1456,12 +1450,9 @@ _bfd_coff_get_external_symbols (abfd)
size = obj_raw_syment_count (abfd) * symesz; size = obj_raw_syment_count (abfd) * symesz;
syms = (PTR) malloc (size); syms = (PTR) bfd_malloc (size);
if (syms == NULL && size != 0) if (syms == NULL && size != 0)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0 if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
|| bfd_read (syms, size, 1, abfd) != size) || bfd_read (syms, size, 1, abfd) != size)
@ -1523,12 +1514,9 @@ _bfd_coff_read_string_table (abfd)
return NULL; return NULL;
} }
strings = (char *) malloc (strsize); strings = (char *) bfd_malloc (strsize);
if (strings == NULL) if (strings == NULL)
{ return NULL;
bfd_set_error (bfd_error_no_memory);
return NULL;
}
if (bfd_read (strings + STRING_SIZE_SIZE, if (bfd_read (strings + STRING_SIZE_SIZE,
strsize - STRING_SIZE_SIZE, 1, abfd) strsize - STRING_SIZE_SIZE, 1, abfd)

View file

@ -465,12 +465,9 @@ ecoff_slurp_symbolic_header (abfd)
} }
/* Read the symbolic information header. */ /* Read the symbolic information header. */
raw = (PTR) malloc ((size_t) external_hdr_size); raw = (PTR) bfd_malloc ((size_t) external_hdr_size);
if (raw == NULL) if (raw == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (bfd_seek (abfd, ecoff_data (abfd)->sym_filepos, SEEK_SET) == -1 if (bfd_seek (abfd, ecoff_data (abfd)->sym_filepos, SEEK_SET) == -1
|| (bfd_read (raw, external_hdr_size, 1, abfd) || (bfd_read (raw, external_hdr_size, 1, abfd)
@ -2063,13 +2060,10 @@ ecoff_compute_section_file_positions (abfd)
sofar = _bfd_ecoff_sizeof_headers (abfd, false); sofar = _bfd_ecoff_sizeof_headers (abfd, false);
/* Sort the sections by VMA. */ /* Sort the sections by VMA. */
sorted_hdrs = (asection **) malloc (abfd->section_count sorted_hdrs = (asection **) bfd_malloc (abfd->section_count
* sizeof (asection *)); * sizeof (asection *));
if (sorted_hdrs == NULL) if (sorted_hdrs == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
for (current = abfd->sections, i = 0; for (current = abfd->sections, i = 0;
current != NULL; current != NULL;
current = current->next, i++) current = current->next, i++)
@ -2479,12 +2473,9 @@ _bfd_ecoff_write_object_contents (abfd)
siz = filhsz; siz = filhsz;
if (siz < aoutsz) if (siz < aoutsz)
siz = aoutsz; siz = aoutsz;
buff = (PTR) malloc ((size_t) siz); buff = (PTR) bfd_malloc ((size_t) siz);
if (buff == NULL) if (buff == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
} }
internal_f.f_nscns = 0; internal_f.f_nscns = 0;
@ -3598,23 +3589,17 @@ ecoff_link_check_archive_element (abfd, info, pneeded)
/* Read in the external symbols and external strings. */ /* Read in the external symbols and external strings. */
external_ext_size = backend->debug_swap.external_ext_size; external_ext_size = backend->debug_swap.external_ext_size;
esize = symhdr->iextMax * external_ext_size; esize = symhdr->iextMax * external_ext_size;
external_ext = (PTR) malloc (esize); external_ext = (PTR) bfd_malloc (esize);
if (external_ext == NULL && esize != 0) if (external_ext == NULL && esize != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0 if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0
|| bfd_read (external_ext, 1, esize, abfd) != esize) || bfd_read (external_ext, 1, esize, abfd) != esize)
goto error_return; goto error_return;
ssext = (char *) malloc (symhdr->issExtMax); ssext = (char *) bfd_malloc (symhdr->issExtMax);
if (ssext == NULL && symhdr->issExtMax != 0) if (ssext == NULL && symhdr->issExtMax != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0 if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0
|| (bfd_read (ssext, 1, symhdr->issExtMax, abfd) != || (bfd_read (ssext, 1, symhdr->issExtMax, abfd) !=
@ -3724,23 +3709,17 @@ ecoff_link_add_object_symbols (abfd, info)
/* Read in the external symbols and external strings. */ /* Read in the external symbols and external strings. */
external_ext_size = ecoff_backend (abfd)->debug_swap.external_ext_size; external_ext_size = ecoff_backend (abfd)->debug_swap.external_ext_size;
esize = symhdr->iextMax * external_ext_size; esize = symhdr->iextMax * external_ext_size;
external_ext = (PTR) malloc (esize); external_ext = (PTR) bfd_malloc (esize);
if (external_ext == NULL && esize != 0) if (external_ext == NULL && esize != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0 if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0
|| bfd_read (external_ext, 1, esize, abfd) != esize) || bfd_read (external_ext, 1, esize, abfd) != esize)
goto error_return; goto error_return;
ssext = (char *) malloc (symhdr->issExtMax); ssext = (char *) bfd_malloc (symhdr->issExtMax);
if (ssext == NULL && symhdr->issExtMax != 0) if (ssext == NULL && symhdr->issExtMax != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0 if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0
|| (bfd_read (ssext, 1, symhdr->issExtMax, abfd) || (bfd_read (ssext, 1, symhdr->issExtMax, abfd)
@ -4209,10 +4188,9 @@ ecoff_final_link_debug_accumulate (output_bfd, input_bfd, info, handle)
debug->ptr = NULL; \ debug->ptr = NULL; \
else \ else \
{ \ { \
debug->ptr = (type) malloc ((size_t) (size * symhdr->count)); \ debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \
if (debug->ptr == NULL) \ if (debug->ptr == NULL) \
{ \ { \
bfd_set_error (bfd_error_no_memory); \
ret = false; \ ret = false; \
goto return_something; \ goto return_something; \
} \ } \
@ -4453,14 +4431,11 @@ ecoff_indirect_link_order (output_bfd, info, output_section, link_order)
/* Get the section contents. We allocate memory for the larger of /* Get the section contents. We allocate memory for the larger of
the size before relocating and the size after relocating. */ the size before relocating and the size after relocating. */
contents = (bfd_byte *) malloc (raw_size >= cooked_size contents = (bfd_byte *) bfd_malloc (raw_size >= cooked_size
? (size_t) raw_size ? (size_t) raw_size
: (size_t) cooked_size); : (size_t) cooked_size);
if (contents == NULL && raw_size != 0) if (contents == NULL && raw_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
/* If we are relaxing, the contents may have already been read into /* If we are relaxing, the contents may have already been read into
memory, in which case we copy them into our new buffer. We don't memory, in which case we copy them into our new buffer. We don't
@ -4486,12 +4461,9 @@ ecoff_indirect_link_order (output_bfd, info, output_section, link_order)
external_relocs = section_tdata->external_relocs; external_relocs = section_tdata->external_relocs;
else else
{ {
external_relocs = (PTR) malloc ((size_t) external_relocs_size); external_relocs = (PTR) bfd_malloc ((size_t) external_relocs_size);
if (external_relocs == NULL && external_relocs_size != 0) if (external_relocs == NULL && external_relocs_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0 if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
|| (bfd_read (external_relocs, 1, external_relocs_size, input_bfd) || (bfd_read (external_relocs, 1, external_relocs_size, input_bfd)
@ -4728,12 +4700,9 @@ ecoff_reloc_link_order (output_bfd, info, output_section, link_order)
/* Get some memory and swap out the reloc. */ /* Get some memory and swap out the reloc. */
external_reloc_size = ecoff_backend (output_bfd)->external_reloc_size; external_reloc_size = ecoff_backend (output_bfd)->external_reloc_size;
rbuf = (bfd_byte *) malloc ((size_t) external_reloc_size); rbuf = (bfd_byte *) bfd_malloc ((size_t) external_reloc_size);
if (rbuf == (bfd_byte *) NULL) if (rbuf == (bfd_byte *) NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
(*ecoff_backend (output_bfd)->swap_reloc_out) (output_bfd, &in, (PTR) rbuf); (*ecoff_backend (output_bfd)->swap_reloc_out) (output_bfd, &in, (PTR) rbuf);

View file

@ -270,15 +270,9 @@ ecoff_add_bytes (buf, bufend, need)
if (want < ALLOC_SIZE) if (want < ALLOC_SIZE)
want = ALLOC_SIZE; want = ALLOC_SIZE;
} }
if (*buf == NULL) newbuf = (char *) bfd_realloc (*buf, have + want);
newbuf = (char *) malloc (have + want);
else
newbuf = (char *) realloc (*buf, have + want);
if (newbuf == NULL) if (newbuf == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
*buf = newbuf; *buf = newbuf;
*bufend = *buf + have + want; *bufend = *buf + have + want;
return true; return true;
@ -503,12 +497,9 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info)
{ {
struct accumulate *ainfo; struct accumulate *ainfo;
ainfo = (struct accumulate *) malloc (sizeof (struct accumulate)); ainfo = (struct accumulate *) bfd_malloc (sizeof (struct accumulate));
if (!ainfo) if (!ainfo)
{ return NULL;
bfd_set_error (bfd_error_no_memory);
return NULL;
}
if (! bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc, if (! bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc,
1021)) 1021))
return NULL; return NULL;
@ -720,12 +711,9 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
information that should not be merged. */ information that should not be merged. */
name = input_debug->ss + fdr.issBase + fdr.rss; name = input_debug->ss + fdr.issBase + fdr.rss;
lookup = (char *) malloc (strlen (name) + 20); lookup = (char *) bfd_malloc (strlen (name) + 20);
if (lookup == NULL) if (lookup == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
sprintf (lookup, "%s %lx", name, fdr.csym); sprintf (lookup, "%s %lx", name, fdr.csym);
fh = string_hash_lookup (&ainfo->fdr_hash, lookup, true, true); fh = string_hash_lookup (&ainfo->fdr_hash, lookup, true, true);
@ -1558,12 +1546,9 @@ ecoff_write_symhdr (abfd, debug, swap, where)
SET (cbExtOffset, iextMax, swap->external_ext_size); SET (cbExtOffset, iextMax, swap->external_ext_size);
#undef SET #undef SET
buff = (PTR) malloc ((size_t) swap->external_hdr_size); buff = (PTR) bfd_malloc ((size_t) swap->external_hdr_size);
if (buff == NULL && swap->external_hdr_size != 0) if (buff == NULL && swap->external_hdr_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
(*swap->swap_hdr_out) (abfd, symhdr, buff); (*swap->swap_hdr_out) (abfd, symhdr, buff);
if (bfd_write (buff, 1, swap->external_hdr_size, abfd) if (bfd_write (buff, 1, swap->external_hdr_size, abfd)
@ -1660,12 +1645,9 @@ ecoff_write_shuffle (abfd, swap, shuffle, space)
bfd_byte *s; bfd_byte *s;
i = swap->debug_align - (total & (swap->debug_align - 1)); i = swap->debug_align - (total & (swap->debug_align - 1));
s = (bfd_byte *) malloc (i); s = (bfd_byte *) bfd_malloc (i);
if (s == NULL && i != 0) if (s == NULL && i != 0)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
memset ((PTR) s, 0, i); memset ((PTR) s, 0, i);
if (bfd_write ((PTR) s, 1, i, abfd) != i) if (bfd_write ((PTR) s, 1, i, abfd) != i)
@ -1697,12 +1679,9 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where)
if (! ecoff_write_symhdr (abfd, debug, swap, where)) if (! ecoff_write_symhdr (abfd, debug, swap, where))
goto error_return; goto error_return;
space = (PTR) malloc (ainfo->largest_file_shuffle); space = (PTR) bfd_malloc (ainfo->largest_file_shuffle);
if (space == NULL && ainfo->largest_file_shuffle != 0) if (space == NULL && ainfo->largest_file_shuffle != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (! ecoff_write_shuffle (abfd, swap, ainfo->line, space) if (! ecoff_write_shuffle (abfd, swap, ainfo->line, space)
|| ! ecoff_write_shuffle (abfd, swap, ainfo->pdr, space) || ! ecoff_write_shuffle (abfd, swap, ainfo->pdr, space)
@ -1749,12 +1728,9 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where)
bfd_byte *s; bfd_byte *s;
i = swap->debug_align - (total & (swap->debug_align - 1)); i = swap->debug_align - (total & (swap->debug_align - 1));
s = (bfd_byte *) malloc (i); s = (bfd_byte *) bfd_malloc (i);
if (s == NULL && i != 0) if (s == NULL && i != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
memset ((PTR) s, 0, i); memset ((PTR) s, 0, i);
if (bfd_write ((PTR) s, 1, i, abfd) != i) if (bfd_write ((PTR) s, 1, i, abfd) != i)
{ {
@ -1777,12 +1753,9 @@ bfd_ecoff_write_accumulated_debug (handle, abfd, debug, swap, info, where)
i = (swap->debug_align i = (swap->debug_align
- (debug->symbolic_header.issExtMax & (swap->debug_align - 1))); - (debug->symbolic_header.issExtMax & (swap->debug_align - 1)));
s = (bfd_byte *) malloc (i); s = (bfd_byte *) bfd_malloc (i);
if (s == NULL && i != 0) if (s == NULL && i != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
memset ((PTR) s, 0, i); memset ((PTR) s, 0, i);
if (bfd_write ((PTR) s, 1, i, abfd) != i) if (bfd_write ((PTR) s, 1, i, abfd) != i)
{ {
@ -2352,12 +2325,9 @@ _bfd_ecoff_locate_line (abfd, section, offset, debug_info, debug_swap,
{ {
if (line_info->find_buffer != NULL) if (line_info->find_buffer != NULL)
free (line_info->find_buffer); free (line_info->find_buffer);
buffer = (char *) malloc (len); buffer = (char *) bfd_malloc (len);
if (buffer == NULL) if (buffer == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
line_info->find_buffer = buffer; line_info->find_buffer = buffer;
} }

View file

@ -1158,12 +1158,9 @@ assign_section_numbers (abfd)
char *alc; char *alc;
len = strlen (sec->name); len = strlen (sec->name);
alc = (char *) malloc (len - 2); alc = (char *) bfd_malloc (len - 2);
if (alc == NULL) if (alc == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
strncpy (alc, sec->name, len - 3); strncpy (alc, sec->name, len - 3);
alc[len - 3] = '\0'; alc[len - 3] = '\0';
s = bfd_get_section_by_name (abfd, alc); s = bfd_get_section_by_name (abfd, alc);
@ -1548,13 +1545,10 @@ map_sections_to_segments (abfd)
/* Select the allocated sections, and sort them. */ /* Select the allocated sections, and sort them. */
sections = (asection **) malloc (bfd_count_sections (abfd) sections = (asection **) bfd_malloc (bfd_count_sections (abfd)
* sizeof (asection *)); * sizeof (asection *));
if (sections == NULL) if (sections == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
i = 0; i = 0;
for (s = abfd->sections; s != NULL; s = s->next) for (s = abfd->sections; s != NULL; s = s->next)

View file

@ -891,12 +891,9 @@ elf_slurp_symbol_table (abfd, symptrs, dynamic)
/* Temporarily allocate room for the raw ELF symbols. */ /* Temporarily allocate room for the raw ELF symbols. */
x_symp = ((Elf_External_Sym *) x_symp = ((Elf_External_Sym *)
malloc (symcount * sizeof (Elf_External_Sym))); bfd_malloc (symcount * sizeof (Elf_External_Sym)));
if (x_symp == NULL && symcount != 0) if (x_symp == NULL && symcount != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (bfd_read ((PTR) x_symp, sizeof (Elf_External_Sym), symcount, abfd) if (bfd_read ((PTR) x_symp, sizeof (Elf_External_Sym), symcount, abfd)
!= symcount * sizeof (Elf_External_Sym)) != symcount * sizeof (Elf_External_Sym))
@ -1053,12 +1050,9 @@ elf_slurp_reloc_table (abfd, asect, symbols)
&& (asect->reloc_count && (asect->reloc_count
== d->rel_hdr.sh_size / d->rel_hdr.sh_entsize)); == d->rel_hdr.sh_size / d->rel_hdr.sh_entsize));
allocated = (PTR) malloc ((size_t) d->rel_hdr.sh_size); allocated = (PTR) bfd_malloc ((size_t) d->rel_hdr.sh_size);
if (allocated == NULL) if (allocated == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0 if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0
|| (bfd_read (allocated, 1, d->rel_hdr.sh_size, abfd) || (bfd_read (allocated, 1, d->rel_hdr.sh_size, abfd)

View file

@ -238,7 +238,7 @@ elf_corefile_note (abfd, hdr)
asection *newsect; asection *newsect;
if (hdr->p_filesz > 0 if (hdr->p_filesz > 0
&& (buf = (char *) malloc ((size_t) hdr->p_filesz)) != NULL && (buf = (char *) bfd_malloc ((size_t) hdr->p_filesz)) != NULL
&& bfd_seek (abfd, hdr->p_offset, SEEK_SET) != -1 && bfd_seek (abfd, hdr->p_offset, SEEK_SET) != -1
&& bfd_read ((PTR) buf, hdr->p_filesz, 1, abfd) == hdr->p_filesz) && bfd_read ((PTR) buf, hdr->p_filesz, 1, abfd) == hdr->p_filesz)
{ {
@ -296,7 +296,6 @@ elf_corefile_note (abfd, hdr)
} }
else if (hdr->p_filesz > 0) else if (hdr->p_filesz > 0)
{ {
bfd_set_error (bfd_error_no_memory);
return false; return false;
} }
return true; return true;

View file

@ -110,13 +110,10 @@ elf_link_add_archive_symbols (abfd, info)
c = bfd_ardata (abfd)->symdef_count; c = bfd_ardata (abfd)->symdef_count;
if (c == 0) if (c == 0)
return true; return true;
defined = (boolean *) malloc (c * sizeof (boolean)); defined = (boolean *) bfd_malloc (c * sizeof (boolean));
included = (boolean *) malloc (c * sizeof (boolean)); included = (boolean *) bfd_malloc (c * sizeof (boolean));
if (defined == (boolean *) NULL || included == (boolean *) NULL) if (defined == (boolean *) NULL || included == (boolean *) NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
memset (defined, 0, c * sizeof (boolean)); memset (defined, 0, c * sizeof (boolean));
memset (included, 0, c * sizeof (boolean)); memset (included, 0, c * sizeof (boolean));
@ -328,12 +325,10 @@ elf_link_add_object_symbols (abfd, info)
extsymoff = hdr->sh_info; extsymoff = hdr->sh_info;
} }
buf = (Elf_External_Sym *) malloc (extsymcount * sizeof (Elf_External_Sym)); buf = ((Elf_External_Sym *)
bfd_malloc (extsymcount * sizeof (Elf_External_Sym)));
if (buf == NULL && extsymcount != 0) if (buf == NULL && extsymcount != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
/* We store a pointer to the hash table entry for each external /* We store a pointer to the hash table entry for each external
symbol. */ symbol. */
@ -404,12 +399,9 @@ elf_link_add_object_symbols (abfd, info)
int elfsec; int elfsec;
unsigned long link; unsigned long link;
dynbuf = (Elf_External_Dyn *) malloc ((size_t) s->_raw_size); dynbuf = (Elf_External_Dyn *) bfd_malloc ((size_t) s->_raw_size);
if (dynbuf == NULL) if (dynbuf == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (! bfd_get_section_contents (abfd, s, (PTR) dynbuf, if (! bfd_get_section_contents (abfd, s, (PTR) dynbuf,
(file_ptr) 0, s->_raw_size)) (file_ptr) 0, s->_raw_size))
@ -1090,15 +1082,9 @@ elf_add_dynamic_entry (info, tag, val)
BFD_ASSERT (s != NULL); BFD_ASSERT (s != NULL);
newsize = s->_raw_size + sizeof (Elf_External_Dyn); newsize = s->_raw_size + sizeof (Elf_External_Dyn);
if (s->contents == NULL) newcontents = (bfd_byte *) bfd_realloc (s->contents, newsize);
newcontents = (bfd_byte *) malloc (newsize);
else
newcontents = (bfd_byte *) realloc (s->contents, newsize);
if (newcontents == NULL) if (newcontents == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
dyn.d_tag = tag; dyn.d_tag = tag;
dyn.d_un.d_val = val; dyn.d_un.d_val = val;
@ -1146,22 +1132,16 @@ elf_link_read_relocs (abfd, o, external_relocs, internal_relocs, keep_memory)
if (keep_memory) if (keep_memory)
internal_relocs = (Elf_Internal_Rela *) bfd_alloc (abfd, size); internal_relocs = (Elf_Internal_Rela *) bfd_alloc (abfd, size);
else else
internal_relocs = alloc2 = (Elf_Internal_Rela *) malloc (size); internal_relocs = alloc2 = (Elf_Internal_Rela *) bfd_malloc (size);
if (internal_relocs == NULL) if (internal_relocs == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
} }
if (external_relocs == NULL) if (external_relocs == NULL)
{ {
alloc1 = (PTR) malloc ((size_t) rel_hdr->sh_size); alloc1 = (PTR) bfd_malloc ((size_t) rel_hdr->sh_size);
if (alloc1 == NULL) if (alloc1 == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
external_relocs = alloc1; external_relocs = alloc1;
} }
@ -1847,13 +1827,10 @@ elf_bfd_final_link (abfd, info)
goto error_return; goto error_return;
p = ((struct elf_link_hash_entry **) p = ((struct elf_link_hash_entry **)
malloc (o->reloc_count bfd_malloc (o->reloc_count
* sizeof (struct elf_link_hash_entry *))); * sizeof (struct elf_link_hash_entry *)));
if (p == NULL && o->reloc_count != 0) if (p == NULL && o->reloc_count != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
elf_section_data (o)->rel_hashes = p; elf_section_data (o)->rel_hashes = p;
pend = p + o->reloc_count; pend = p + o->reloc_count;
for (; p < pend; p++) for (; p < pend; p++)
@ -1898,12 +1875,9 @@ elf_bfd_final_link (abfd, info)
else else
finfo.symbuf_size = max_sym_count; finfo.symbuf_size = max_sym_count;
finfo.symbuf = ((Elf_External_Sym *) finfo.symbuf = ((Elf_External_Sym *)
malloc (finfo.symbuf_size * sizeof (Elf_External_Sym))); bfd_malloc (finfo.symbuf_size * sizeof (Elf_External_Sym)));
if (finfo.symbuf == NULL) if (finfo.symbuf == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
/* Start writing out the symbol table. The first symbol is always a /* Start writing out the symbol table. The first symbol is always a
dummy symbol. */ dummy symbol. */
@ -1954,17 +1928,20 @@ elf_bfd_final_link (abfd, info)
/* Allocate some memory to hold information read in from the input /* Allocate some memory to hold information read in from the input
files. */ files. */
finfo.contents = (bfd_byte *) malloc (max_contents_size); finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
finfo.external_relocs = (PTR) malloc (max_external_reloc_size); finfo.external_relocs = (PTR) bfd_malloc (max_external_reloc_size);
finfo.internal_relocs = ((Elf_Internal_Rela *) finfo.internal_relocs = ((Elf_Internal_Rela *)
malloc (max_internal_reloc_count bfd_malloc (max_internal_reloc_count
* sizeof (Elf_Internal_Rela))); * sizeof (Elf_Internal_Rela)));
finfo.external_syms = ((Elf_External_Sym *) finfo.external_syms = ((Elf_External_Sym *)
malloc (max_sym_count * sizeof (Elf_External_Sym))); bfd_malloc (max_sym_count
* sizeof (Elf_External_Sym)));
finfo.internal_syms = ((Elf_Internal_Sym *) finfo.internal_syms = ((Elf_Internal_Sym *)
malloc (max_sym_count * sizeof (Elf_Internal_Sym))); bfd_malloc (max_sym_count
finfo.indices = (long *) malloc (max_sym_count * sizeof (long)); * sizeof (Elf_Internal_Sym)));
finfo.sections = (asection **) malloc (max_sym_count * sizeof (asection *)); finfo.indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
finfo.sections = ((asection **)
bfd_malloc (max_sym_count * sizeof (asection *)));
if ((finfo.contents == NULL && max_contents_size != 0) if ((finfo.contents == NULL && max_contents_size != 0)
|| (finfo.external_relocs == NULL && max_external_reloc_size != 0) || (finfo.external_relocs == NULL && max_external_reloc_size != 0)
|| (finfo.internal_relocs == NULL && max_internal_reloc_count != 0) || (finfo.internal_relocs == NULL && max_internal_reloc_count != 0)
@ -1972,10 +1949,7 @@ elf_bfd_final_link (abfd, info)
|| (finfo.internal_syms == NULL && max_sym_count != 0) || (finfo.internal_syms == NULL && max_sym_count != 0)
|| (finfo.indices == NULL && max_sym_count != 0) || (finfo.indices == NULL && max_sym_count != 0)
|| (finfo.sections == NULL && max_sym_count != 0)) || (finfo.sections == NULL && max_sym_count != 0))
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
/* Since ELF permits relocations to be against local symbols, we /* Since ELF permits relocations to be against local symbols, we
must have the local symbols available when we do the relocations. must have the local symbols available when we do the relocations.

View file

@ -418,12 +418,9 @@ doit:
count = reloc_size / each_size; count = reloc_size / each_size;
reloc_cache = (arelent *) malloc (count * sizeof (arelent)); reloc_cache = (arelent *) bfd_malloc (count * sizeof (arelent));
if (!reloc_cache && count != 0) if (!reloc_cache && count != 0)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
memset (reloc_cache, 0, count * sizeof (arelent)); memset (reloc_cache, 0, count * sizeof (arelent));
relocs = (PTR) bfd_alloc (abfd, reloc_size); relocs = (PTR) bfd_alloc (abfd, reloc_size);

View file

@ -3158,10 +3158,7 @@ ieee_make_empty_symbol (abfd)
ieee_symbol_type *new = ieee_symbol_type *new =
(ieee_symbol_type *) bfd_zmalloc (sizeof (ieee_symbol_type)); (ieee_symbol_type *) bfd_zmalloc (sizeof (ieee_symbol_type));
if (!new) if (!new)
{ return NULL;
bfd_set_error (bfd_error_no_error);
return NULL;
}
new->symbol.the_bfd = abfd; new->symbol.the_bfd = abfd;
return &new->symbol; return &new->symbol;
} }

View file

@ -1160,13 +1160,10 @@ pe_print_idata(abfd, vfile)
bfd_byte *data = 0; bfd_byte *data = 0;
int offset; int offset;
data = (bfd_byte *) malloc ((size_t) bfd_section_size (abfd, data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd,
rel_section)); rel_section));
if (data == NULL && bfd_section_size (abfd, rel_section) != 0) if (data == NULL && bfd_section_size (abfd, rel_section) != 0)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
datasize = bfd_section_size (abfd, rel_section); datasize = bfd_section_size (abfd, rel_section);
bfd_get_section_contents (abfd, bfd_get_section_contents (abfd,
@ -1204,13 +1201,10 @@ pe_print_idata(abfd, vfile)
if (bfd_section_size (abfd, section) == 0) if (bfd_section_size (abfd, section) == 0)
return true; return true;
data = (bfd_byte *) malloc ((size_t) bfd_section_size (abfd, section)); data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
datasize = bfd_section_size (abfd, section); datasize = bfd_section_size (abfd, section);
if (data == NULL && datasize != 0) if (data == NULL && datasize != 0)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
bfd_get_section_contents (abfd, bfd_get_section_contents (abfd,
section, section,
@ -1363,13 +1357,10 @@ pe_print_pdata(abfd, vfile)
if (bfd_section_size (abfd, section) == 0) if (bfd_section_size (abfd, section) == 0)
return true; return true;
data = (bfd_byte *) malloc ((size_t) bfd_section_size (abfd, section)); data = (bfd_byte *) bfd_malloc ((size_t) bfd_section_size (abfd, section));
datasize = bfd_section_size (abfd, section); datasize = bfd_section_size (abfd, section);
if (data == NULL && datasize != 0) if (data == NULL && datasize != 0)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
bfd_get_section_contents (abfd, bfd_get_section_contents (abfd,
section, section,

112
bfd/som.c
View file

@ -1724,12 +1724,9 @@ setup_sections (abfd, file_hdr)
/* First, read in space names */ /* First, read in space names */
space_strings = malloc (file_hdr->space_strings_size); space_strings = bfd_malloc (file_hdr->space_strings_size);
if (!space_strings && file_hdr->space_strings_size != 0) if (!space_strings && file_hdr->space_strings_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (bfd_seek (abfd, file_hdr->space_strings_location, SEEK_SET) < 0) if (bfd_seek (abfd, file_hdr->space_strings_location, SEEK_SET) < 0)
goto error_return; goto error_return;
@ -1939,8 +1936,8 @@ setup_sections (abfd, file_hdr)
} }
/* Now that we've read in all the subspace records, we need to assign /* Now that we've read in all the subspace records, we need to assign
a target index to each subspace. */ a target index to each subspace. */
subspace_sections = (asection **) malloc (total_subspaces subspace_sections = (asection **) bfd_malloc (total_subspaces
* sizeof (asection *)); * sizeof (asection *));
if (subspace_sections == NULL) if (subspace_sections == NULL)
goto error_return; goto error_return;
@ -3708,12 +3705,9 @@ som_build_and_write_symbol_table (abfd)
/* Compute total symbol table size and allocate a chunk of memory /* Compute total symbol table size and allocate a chunk of memory
to hold the symbol table as we build it. */ to hold the symbol table as we build it. */
symtab_size = num_syms * sizeof (struct symbol_dictionary_record); symtab_size = num_syms * sizeof (struct symbol_dictionary_record);
som_symtab = (struct symbol_dictionary_record *) malloc (symtab_size); som_symtab = (struct symbol_dictionary_record *) bfd_malloc (symtab_size);
if (som_symtab == NULL && symtab_size != 0) if (som_symtab == NULL && symtab_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
memset (som_symtab, 0, symtab_size); memset (som_symtab, 0, symtab_size);
/* Walk over each symbol. */ /* Walk over each symbol. */
@ -3797,12 +3791,9 @@ som_slurp_string_table (abfd)
} }
/* Allocate and read in the string table. */ /* Allocate and read in the string table. */
stringtab = malloc (obj_som_stringtab_size (abfd)); stringtab = bfd_malloc (obj_som_stringtab_size (abfd));
if (stringtab == NULL) if (stringtab == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
memset (stringtab, 0, obj_som_stringtab_size (abfd)); 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)
@ -3904,22 +3895,16 @@ som_slurp_symbol_table (abfd)
stringtab = obj_som_stringtab (abfd); stringtab = obj_som_stringtab (abfd);
symbase = (som_symbol_type *) symbase = ((som_symbol_type *)
malloc (symbol_count * sizeof (som_symbol_type)); bfd_malloc (symbol_count * sizeof (som_symbol_type)));
if (symbase == NULL) if (symbase == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
memset (symbase, 0, symbol_count * sizeof (som_symbol_type)); memset (symbase, 0, symbol_count * sizeof (som_symbol_type));
/* Read in the external SOM representation. */ /* Read in the external SOM representation. */
buf = malloc (symbol_count * symsize); buf = bfd_malloc (symbol_count * symsize);
if (buf == NULL && symbol_count * symsize != 0) if (buf == NULL && symbol_count * symsize != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
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; goto error_return;
if (bfd_read (buf, symbol_count * symsize, 1, abfd) if (bfd_read (buf, symbol_count * symsize, 1, abfd)
@ -4453,7 +4438,7 @@ som_set_reloc_info (fixup, end, internal_relocs, section, symbols, just_count)
/* Got to read the damn contents first. We don't /* Got to read the damn contents first. We don't
bother saving the contents (yet). Add it one bother saving the contents (yet). Add it one
day if the need arises. */ day if the need arises. */
section->contents = malloc (section->_raw_size); section->contents = bfd_malloc (section->_raw_size);
if (section->contents == NULL) if (section->contents == NULL)
return -1; return -1;
@ -4519,12 +4504,9 @@ som_slurp_reloc_table (abfd, section, symbols, just_count)
parsed. We must do so now to know how many relocations exist. */ parsed. We must do so now to know how many relocations exist. */
if (section->reloc_count == -1) if (section->reloc_count == -1)
{ {
external_relocs = (char *) malloc (fixup_stream_size); external_relocs = (char *) bfd_malloc (fixup_stream_size);
if (external_relocs == (char *) NULL) if (external_relocs == (char *) NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
/* Read in the external forms. */ /* Read in the external forms. */
if (bfd_seek (abfd, if (bfd_seek (abfd,
obj_som_reloc_filepos (abfd) + section->rel_filepos, obj_som_reloc_filepos (abfd) + section->rel_filepos,
@ -5000,12 +4982,10 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header); file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
hash_table = hash_table =
(unsigned int *) malloc (lst_header->hash_size * sizeof (unsigned int)); (unsigned int *) bfd_malloc (lst_header->hash_size
* sizeof (unsigned int));
if (hash_table == NULL && lst_header->hash_size != 0) if (hash_table == NULL && lst_header->hash_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
/* Don't forget to initialize the counter! */ /* Don't forget to initialize the counter! */
*count = 0; *count = 0;
@ -5080,21 +5060,16 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header); file_ptr lst_filepos = bfd_tell (abfd) - sizeof (struct lst_header);
hash_table = hash_table =
(unsigned int *) malloc (lst_header->hash_size * sizeof (unsigned int)); (unsigned int *) bfd_malloc (lst_header->hash_size
* sizeof (unsigned int));
if (hash_table == NULL && lst_header->hash_size != 0) if (hash_table == NULL && lst_header->hash_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
som_dict = som_dict =
(struct som_entry *) malloc (lst_header->module_count (struct som_entry *) bfd_malloc (lst_header->module_count
* sizeof (struct som_entry)); * sizeof (struct som_entry));
if (som_dict == NULL && lst_header->module_count != 0) if (som_dict == NULL && lst_header->module_count != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
/* Read in the hash table. The has table is an array of 32bit file offsets /* Read in the hash table. The has table is an array of 32bit file offsets
which point to the hash chains. */ which point to the hash chains. */
@ -5435,29 +5410,20 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
unsigned int maxname = abfd->xvec->ar_max_namelen; unsigned int maxname = abfd->xvec->ar_max_namelen;
hash_table = hash_table =
(unsigned int *) malloc (lst.hash_size * sizeof (unsigned int)); (unsigned int *) bfd_malloc (lst.hash_size * sizeof (unsigned int));
if (hash_table == NULL && lst.hash_size != 0) if (hash_table == NULL && lst.hash_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
som_dict = som_dict =
(struct som_entry *) malloc (lst.module_count (struct som_entry *) bfd_malloc (lst.module_count
* sizeof (struct som_entry)); * sizeof (struct som_entry));
if (som_dict == NULL && lst.module_count != 0) if (som_dict == NULL && lst.module_count != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
last_hash_entry = last_hash_entry =
((struct lst_symbol_record **) ((struct lst_symbol_record **)
malloc (lst.hash_size * sizeof (struct lst_symbol_record *))); bfd_malloc (lst.hash_size * sizeof (struct lst_symbol_record *)));
if (last_hash_entry == NULL && lst.hash_size != 0) if (last_hash_entry == NULL && lst.hash_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
/* Lots of fields are file positions relative to the start /* Lots of fields are file positions relative to the start
of the lst record. So save its location. */ of the lst record. So save its location. */
@ -5504,18 +5470,12 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
curr_som_offset = (curr_som_offset + 0x1) & ~0x1; curr_som_offset = (curr_som_offset + 0x1) & ~0x1;
/* FIXME should be done with buffers just like everything else... */ /* FIXME should be done with buffers just like everything else... */
lst_syms = malloc (nsyms * sizeof (struct lst_symbol_record)); lst_syms = bfd_malloc (nsyms * sizeof (struct lst_symbol_record));
if (lst_syms == NULL && nsyms != 0) if (lst_syms == NULL && nsyms != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory); strings = bfd_malloc (string_size);
goto error_return;
}
strings = malloc (string_size);
if (strings == NULL && string_size != 0) if (strings == NULL && string_size != 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
p = strings; p = strings;
curr_lst_sym = lst_syms; curr_lst_sym = lst_syms;

View file

@ -461,12 +461,9 @@ srec_scan (abfd)
{ {
if (buf != NULL) if (buf != NULL)
free (buf); free (buf);
buf = (bfd_byte *) malloc (bytes * 2); buf = (bfd_byte *) bfd_malloc (bytes * 2);
if (buf == NULL) if (buf == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
bufsize = bytes * 2; bufsize = bytes * 2;
} }
@ -667,12 +664,9 @@ srec_read_section (abfd, section, contents)
{ {
if (buf != NULL) if (buf != NULL)
free (buf); free (buf);
buf = (bfd_byte *) malloc (bytes * 2); buf = (bfd_byte *) bfd_malloc (bytes * 2);
if (buf == NULL) if (buf == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
bufsize = bytes * 2; bufsize = bytes * 2;
} }

View file

@ -350,7 +350,7 @@ sunos_canonicalize_dynamic_symtab (abfd, storage)
if (info->dyninfo.ld_buckets > info->dynsym_count) if (info->dyninfo.ld_buckets > info->dynsym_count)
abort (); abort ();
table_size = info->dyninfo.ld_stab - info->dyninfo.ld_hash; table_size = info->dyninfo.ld_stab - info->dyninfo.ld_hash;
table = (bfd_byte *) malloc (table_size); table = (bfd_byte *) bfd_malloc (table_size);
if (table == NULL && table_size != 0) if (table == NULL && table_size != 0)
abort (); abort ();
if (bfd_seek (abfd, info->dyninfo.ld_hash, SEEK_SET) != 0 if (bfd_seek (abfd, info->dyninfo.ld_hash, SEEK_SET) != 0
@ -1311,13 +1311,10 @@ bfd_sunos_size_dynamic_sections (output_bfd, info, sdynptr, sneedptr,
bfd_byte *contents; bfd_byte *contents;
add = 8 - (s->_raw_size & 7); add = 8 - (s->_raw_size & 7);
contents = (bfd_byte *) realloc (s->contents, contents = (bfd_byte *) bfd_realloc (s->contents,
(size_t) (s->_raw_size + add)); (size_t) (s->_raw_size + add));
if (contents == NULL) if (contents == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
memset (contents + s->_raw_size, 0, (size_t) add); memset (contents + s->_raw_size, 0, (size_t) add);
s->contents = contents; s->contents = contents;
s->_raw_size += add; s->_raw_size += add;
@ -1389,7 +1386,7 @@ sunos_scan_relocs (info, abfd, sec, rel_size)
return true; return true;
if (! info->keep_memory) if (! info->keep_memory)
relocs = free_relocs = malloc ((size_t) rel_size); relocs = free_relocs = bfd_malloc ((size_t) rel_size);
else else
{ {
struct aout_section_data_struct *n; struct aout_section_data_struct *n;
@ -1401,15 +1398,12 @@ sunos_scan_relocs (info, abfd, sec, rel_size)
else else
{ {
set_aout_section_data (sec, n); set_aout_section_data (sec, n);
relocs = malloc ((size_t) rel_size); relocs = bfd_malloc ((size_t) rel_size);
aout_section_data (sec)->relocs = relocs; aout_section_data (sec)->relocs = relocs;
} }
} }
if (relocs == NULL) if (relocs == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0 if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
|| bfd_read (relocs, 1, rel_size, abfd) != rel_size) || bfd_read (relocs, 1, rel_size, abfd) != rel_size)
@ -1942,16 +1936,10 @@ sunos_scan_dynamic_symbol (h, data)
There are no debugging symbols in the dynamic symbols. */ There are no debugging symbols in the dynamic symbols. */
s = bfd_get_section_by_name (dynobj, ".dynstr"); s = bfd_get_section_by_name (dynobj, ".dynstr");
BFD_ASSERT (s != NULL); BFD_ASSERT (s != NULL);
if (s->contents == NULL) contents = (bfd_byte *) bfd_realloc (s->contents,
contents = (bfd_byte *) malloc (len + 1); s->_raw_size + len + 1);
else
contents = (bfd_byte *) realloc (s->contents,
(size_t) (s->_raw_size + len + 1));
if (contents == NULL) if (contents == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
s->contents = contents; s->contents = contents;
h->dynstr_index = s->_raw_size; h->dynstr_index = s->_raw_size;

View file

@ -1058,13 +1058,10 @@ xcoff_link_add_symbols (abfd, info)
scanning along the relocs as we process the csects. We index scanning along the relocs as we process the csects. We index
into reloc_info using the section target_index. */ into reloc_info using the section target_index. */
reloc_info = ((struct reloc_info_struct *) reloc_info = ((struct reloc_info_struct *)
malloc ((abfd->section_count + 1) bfd_malloc ((abfd->section_count + 1)
* sizeof (struct reloc_info_struct))); * sizeof (struct reloc_info_struct)));
if (reloc_info == NULL) if (reloc_info == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
memset ((PTR) reloc_info, 0, memset ((PTR) reloc_info, 0,
(abfd->section_count + 1) * sizeof (struct reloc_info_struct)); (abfd->section_count + 1) * sizeof (struct reloc_info_struct));
@ -1080,12 +1077,9 @@ xcoff_link_add_symbols (abfd, info)
xcoff_read_internal_relocs (abfd, o, true, (bfd_byte *) NULL, xcoff_read_internal_relocs (abfd, o, true, (bfd_byte *) NULL,
false, (struct internal_reloc *) NULL); false, (struct internal_reloc *) NULL);
reloc_info[o->target_index].csects = reloc_info[o->target_index].csects =
(asection **) malloc (o->reloc_count * sizeof (asection *)); (asection **) bfd_malloc (o->reloc_count * sizeof (asection *));
if (reloc_info[o->target_index].csects == NULL) if (reloc_info[o->target_index].csects == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
memset (reloc_info[o->target_index].csects, 0, memset (reloc_info[o->target_index].csects, 0,
o->reloc_count * sizeof (asection *)); o->reloc_count * sizeof (asection *));
} }
@ -1095,12 +1089,9 @@ xcoff_link_add_symbols (abfd, info)
{ {
bfd_byte *linenos; bfd_byte *linenos;
linenos = (bfd_byte *) malloc (o->lineno_count * linesz); linenos = (bfd_byte *) bfd_malloc (o->lineno_count * linesz);
if (linenos == NULL) if (linenos == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
reloc_info[o->target_index].linenos = linenos; reloc_info[o->target_index].linenos = linenos;
if (bfd_seek (abfd, o->line_filepos, SEEK_SET) != 0 if (bfd_seek (abfd, o->line_filepos, SEEK_SET) != 0
|| (bfd_read (linenos, linesz, o->lineno_count, abfd) || (bfd_read (linenos, linesz, o->lineno_count, abfd)
@ -1943,12 +1934,9 @@ xcoff_link_add_dynamic_symbols (abfd, info)
goto error_return; goto error_return;
} }
buf = (bfd_byte *) malloc (lsec->_raw_size); buf = (bfd_byte *) bfd_malloc (lsec->_raw_size);
if (buf == NULL && lsec->_raw_size > 0) if (buf == NULL && lsec->_raw_size > 0)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (! bfd_get_section_contents (abfd, lsec, (PTR) buf, (file_ptr) 0, if (! bfd_get_section_contents (abfd, lsec, (PTR) buf, (file_ptr) 0,
lsec->_raw_size)) lsec->_raw_size))
@ -2441,12 +2429,9 @@ bfd_xcoff_export_symbol (output_bfd, info, harg, syscall)
char *fnname; char *fnname;
struct xcoff_link_hash_entry *hfn; struct xcoff_link_hash_entry *hfn;
fnname = (char *) malloc (strlen (h->root.root.string) + 2); fnname = (char *) bfd_malloc (strlen (h->root.root.string) + 2);
if (fnname == NULL) if (fnname == NULL)
{ return false;
bfd_set_error (bfd_error_no_memory);
return false;
}
fnname[0] = '.'; fnname[0] = '.';
strcpy (fnname + 1, h->root.root.string); strcpy (fnname + 1, h->root.root.string);
hfn = xcoff_link_hash_lookup (xcoff_hash_table (info), hfn = xcoff_link_hash_lookup (xcoff_hash_table (info),
@ -2838,12 +2823,9 @@ bfd_xcoff_size_dynamic_sections (output_bfd, info, libpath, entry,
bfd_alloc, because I expect that, when linking many files bfd_alloc, because I expect that, when linking many files
together, many of the strings will be the same. Storing the together, many of the strings will be the same. Storing the
strings in the hash table should save space in this case. */ strings in the hash table should save space in this case. */
debug_contents = (bfd_byte *) malloc (subdeb->_raw_size); debug_contents = (bfd_byte *) bfd_malloc (subdeb->_raw_size);
if (debug_contents == NULL) if (debug_contents == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (! bfd_get_section_contents (sub, subdeb, (PTR) debug_contents, if (! bfd_get_section_contents (sub, subdeb, (PTR) debug_contents,
(file_ptr) 0, subdeb->_raw_size)) (file_ptr) 0, subdeb->_raw_size))
goto error_return; goto error_return;
@ -3106,15 +3088,11 @@ xcoff_build_ldsyms (h, p)
while (ldinfo->string_size + len + 3 > newalc) while (ldinfo->string_size + len + 3 > newalc)
newalc *= 2; newalc *= 2;
if (ldinfo->strings == NULL) newstrings = ((bfd_byte *)
newstrings = (bfd_byte *) malloc (newalc); bfd_realloc ((PTR) ldinfo->strings, newalc));
else
newstrings = ((bfd_byte *)
realloc ((PTR) ldinfo->strings, newalc));
if (newstrings == NULL) if (newstrings == NULL)
{ {
ldinfo->failed = true; ldinfo->failed = true;
bfd_set_error (bfd_error_no_memory);
return false; return false;
} }
ldinfo->string_alc = newalc; ldinfo->string_alc = newalc;
@ -3334,14 +3312,12 @@ _bfd_xcoff_bfd_final_link (abfd, info)
/* We use section_count + 1, rather than section_count, because /* We use section_count + 1, rather than section_count, because
the target_index fields are 1 based. */ the target_index fields are 1 based. */
finfo.section_info = ((struct xcoff_link_section_info *) finfo.section_info =
malloc ((abfd->section_count + 1) ((struct xcoff_link_section_info *)
* sizeof (struct xcoff_link_section_info))); bfd_malloc ((abfd->section_count + 1)
* sizeof (struct xcoff_link_section_info)));
if (finfo.section_info == NULL) if (finfo.section_info == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
for (i = 0; i <= abfd->section_count; i++) for (i = 0; i <= abfd->section_count; i++)
{ {
finfo.section_info[i].relocs = NULL; finfo.section_info[i].relocs = NULL;
@ -3379,17 +3355,14 @@ _bfd_xcoff_bfd_final_link (abfd, info)
would be slow. */ would be slow. */
finfo.section_info[o->target_index].relocs = finfo.section_info[o->target_index].relocs =
((struct internal_reloc *) ((struct internal_reloc *)
malloc (o->reloc_count * sizeof (struct internal_reloc))); bfd_malloc (o->reloc_count * sizeof (struct internal_reloc)));
finfo.section_info[o->target_index].rel_hashes = finfo.section_info[o->target_index].rel_hashes =
((struct xcoff_link_hash_entry **) ((struct xcoff_link_hash_entry **)
malloc (o->reloc_count bfd_malloc (o->reloc_count
* sizeof (struct xcoff_link_hash_entry *))); * sizeof (struct xcoff_link_hash_entry *)));
if (finfo.section_info[o->target_index].relocs == NULL if (finfo.section_info[o->target_index].relocs == NULL
|| finfo.section_info[o->target_index].rel_hashes == NULL) || finfo.section_info[o->target_index].rel_hashes == NULL)
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
if (o->reloc_count > max_output_reloc_count) if (o->reloc_count > max_output_reloc_count)
max_output_reloc_count = o->reloc_count; max_output_reloc_count = o->reloc_count;
@ -3436,25 +3409,22 @@ _bfd_xcoff_bfd_final_link (abfd, info)
/* Allocate some buffers used while linking. */ /* Allocate some buffers used while linking. */
finfo.internal_syms = ((struct internal_syment *) finfo.internal_syms = ((struct internal_syment *)
malloc (max_sym_count bfd_malloc (max_sym_count
* sizeof (struct internal_syment))); * sizeof (struct internal_syment)));
finfo.sym_indices = (long *) malloc (max_sym_count * sizeof (long)); finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
finfo.outsyms = ((bfd_byte *) finfo.outsyms = ((bfd_byte *)
malloc ((size_t) ((max_sym_count + 1) * symesz))); bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
finfo.linenos = (bfd_byte *) malloc (max_lineno_count finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
* bfd_coff_linesz (abfd)); * bfd_coff_linesz (abfd));
finfo.contents = (bfd_byte *) malloc (max_contents_size); finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
finfo.external_relocs = (bfd_byte *) malloc (max_reloc_count * relsz); finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
if ((finfo.internal_syms == NULL && max_sym_count > 0) if ((finfo.internal_syms == NULL && max_sym_count > 0)
|| (finfo.sym_indices == NULL && max_sym_count > 0) || (finfo.sym_indices == NULL && max_sym_count > 0)
|| finfo.outsyms == NULL || finfo.outsyms == NULL
|| (finfo.linenos == NULL && max_lineno_count > 0) || (finfo.linenos == NULL && max_lineno_count > 0)
|| (finfo.contents == NULL && max_contents_size > 0) || (finfo.contents == NULL && max_contents_size > 0)
|| (finfo.external_relocs == NULL && max_reloc_count > 0)) || (finfo.external_relocs == NULL && max_reloc_count > 0))
{ goto error_return;
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
obj_raw_syment_count (abfd) = 0; obj_raw_syment_count (abfd) = 0;
xcoff_data (abfd)->toc = (bfd_vma) -1; xcoff_data (abfd)->toc = (bfd_vma) -1;