* 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>
* 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
possible to free them. */
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)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
|| (bfd_read (syms, 1, exec_hdr (abfd)->a_syms, abfd)
@ -1280,12 +1277,9 @@ aout_get_external_symbols (abfd)
return false;
strings = (char *) obj_aout_string_window (abfd).data;
#else
strings = (char *) malloc ((size_t) stringsize + 1);
strings = (char *) bfd_malloc ((size_t) stringsize + 1);
if (strings == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
/* Skip space for the string count in the buffer for convenience
when using indexes. */
@ -1736,12 +1730,9 @@ NAME(aout,slurp_symbol_table) (abfd)
cached_size = (obj_aout_external_sym_count (abfd)
* 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)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
if (cached_size != 0)
memset (cached, 0, cached_size);
@ -2294,19 +2285,15 @@ NAME(aout,slurp_reloc_table) (abfd, asect, symbols)
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)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
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)
{
free (reloc_cache);
bfd_set_error (bfd_error_no_memory);
return false;
}
@ -2732,12 +2719,10 @@ NAME(aout,find_nearest_line)
adata (abfd).line_buf = buf = NULL;
else
{
adata (abfd).line_buf = buf = (char *) malloc (filelen + funclen + 2);
if (adata (abfd).line_buf == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
buf = (char *) bfd_malloc (filelen + funclen + 2);
adata (abfd).line_buf = buf;
if (buf == NULL)
return false;
}
if (main_file_name != NULL)
@ -3568,20 +3553,17 @@ NAME(aout,final_link) (abfd, info, callback)
goto error_return;
/* Allocate buffers to hold section contents and relocs. */
aout_info.contents = (bfd_byte *) malloc (max_contents_size);
aout_info.relocs = (PTR) malloc (max_relocs_size);
aout_info.symbol_map = (int *) malloc (max_sym_count * sizeof (int *));
aout_info.contents = (bfd_byte *) bfd_malloc (max_contents_size);
aout_info.relocs = (PTR) bfd_malloc (max_relocs_size);
aout_info.symbol_map = (int *) bfd_malloc (max_sym_count * sizeof (int *));
aout_info.output_syms = ((struct external_nlist *)
malloc ((max_sym_count + 1)
* sizeof (struct external_nlist)));
bfd_malloc ((max_sym_count + 1)
* sizeof (struct external_nlist)));
if ((aout_info.contents == NULL && max_contents_size != 0)
|| (aout_info.relocs == NULL && max_relocs_size != 0)
|| (aout_info.symbol_map == NULL && max_sym_count != 0)
|| aout_info.output_syms == NULL)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
/* 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

View File

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

View File

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

View File

@ -1996,12 +1996,9 @@ mips_relax_section (abfd, sec, info, again)
if (info->keep_memory)
contents = (bfd_byte *) bfd_alloc (abfd, sec->_raw_size);
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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (! bfd_get_section_contents (abfd, sec, (PTR) contents,
(file_ptr) 0, sec->_raw_size))
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 */
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->offset = our_toc_offset;
t->name = name;

View File

@ -482,12 +482,9 @@ sh_relax_section (abfd, sec, link_info, again)
contents = coff_section_data (abfd, sec)->contents;
else
{
contents = (bfd_byte *) malloc (sec->_raw_size);
contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
if (contents == NULL)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
free_contents = 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
should free them, if we are permitted to,
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)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
if (! bfd_get_section_contents (abfd, o, ocontents,
(file_ptr) 0,
o->_raw_size))
@ -1383,21 +1377,15 @@ sh_coff_get_relocated_section_contents (output_bfd, link_info, link_order,
goto error_return;
internal_syms = ((struct internal_syment *)
malloc (obj_raw_syment_count (input_bfd)
* sizeof (struct internal_syment)));
bfd_malloc (obj_raw_syment_count (input_bfd)
* sizeof (struct internal_syment)));
if (internal_syms == NULL)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
sections = (asection **) malloc (obj_raw_syment_count (input_bfd)
* sizeof (asection *));
sections = (asection **) bfd_malloc (obj_raw_syment_count (input_bfd)
* sizeof (asection *));
if (sections == NULL)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
isymp = internal_syms;
secpp = sections;

View File

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

View File

@ -465,12 +465,9 @@ ecoff_slurp_symbolic_header (abfd)
}
/* 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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (bfd_seek (abfd, ecoff_data (abfd)->sym_filepos, SEEK_SET) == -1
|| (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);
/* Sort the sections by VMA. */
sorted_hdrs = (asection **) malloc (abfd->section_count
* sizeof (asection *));
sorted_hdrs = (asection **) bfd_malloc (abfd->section_count
* sizeof (asection *));
if (sorted_hdrs == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
for (current = abfd->sections, i = 0;
current != NULL;
current = current->next, i++)
@ -2479,12 +2473,9 @@ _bfd_ecoff_write_object_contents (abfd)
siz = filhsz;
if (siz < aoutsz)
siz = aoutsz;
buff = (PTR) malloc ((size_t) siz);
buff = (PTR) bfd_malloc ((size_t) siz);
if (buff == NULL)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
}
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. */
external_ext_size = backend->debug_swap.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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0
|| bfd_read (external_ext, 1, esize, abfd) != esize)
goto error_return;
ssext = (char *) malloc (symhdr->issExtMax);
ssext = (char *) bfd_malloc (symhdr->issExtMax);
if (ssext == NULL && symhdr->issExtMax != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0
|| (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. */
external_ext_size = ecoff_backend (abfd)->debug_swap.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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (bfd_seek (abfd, symhdr->cbExtOffset, SEEK_SET) != 0
|| bfd_read (external_ext, 1, esize, abfd) != esize)
goto error_return;
ssext = (char *) malloc (symhdr->issExtMax);
ssext = (char *) bfd_malloc (symhdr->issExtMax);
if (ssext == NULL && symhdr->issExtMax != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (bfd_seek (abfd, symhdr->cbSsExtOffset, SEEK_SET) != 0
|| (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; \
else \
{ \
debug->ptr = (type) malloc ((size_t) (size * symhdr->count)); \
debug->ptr = (type) bfd_malloc ((size_t) (size * symhdr->count)); \
if (debug->ptr == NULL) \
{ \
bfd_set_error (bfd_error_no_memory); \
ret = false; \
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
the size before relocating and the size after relocating. */
contents = (bfd_byte *) malloc (raw_size >= cooked_size
? (size_t) raw_size
: (size_t) cooked_size);
contents = (bfd_byte *) bfd_malloc (raw_size >= cooked_size
? (size_t) raw_size
: (size_t) cooked_size);
if (contents == NULL && raw_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
/* 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
@ -4486,12 +4461,9 @@ ecoff_indirect_link_order (output_bfd, info, output_section, link_order)
external_relocs = section_tdata->external_relocs;
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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (bfd_seek (input_bfd, input_section->rel_filepos, SEEK_SET) != 0
|| (bfd_read (external_relocs, 1, external_relocs_size, input_bfd)
@ -4728,12 +4700,9 @@ ecoff_reloc_link_order (output_bfd, info, output_section, link_order)
/* Get some memory and swap out the reloc. */
external_reloc_size = ecoff_backend (output_bfd)->external_reloc_size;
rbuf = (bfd_byte *) malloc ((size_t) external_reloc_size);
rbuf = (bfd_byte *) bfd_malloc ((size_t) external_reloc_size);
if (rbuf == (bfd_byte *) NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
(*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)
want = ALLOC_SIZE;
}
if (*buf == NULL)
newbuf = (char *) malloc (have + want);
else
newbuf = (char *) realloc (*buf, have + want);
newbuf = (char *) bfd_realloc (*buf, have + want);
if (newbuf == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
*buf = newbuf;
*bufend = *buf + have + want;
return true;
@ -503,12 +497,9 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info)
{
struct accumulate *ainfo;
ainfo = (struct accumulate *) malloc (sizeof (struct accumulate));
ainfo = (struct accumulate *) bfd_malloc (sizeof (struct accumulate));
if (!ainfo)
{
bfd_set_error (bfd_error_no_memory);
return NULL;
}
return NULL;
if (! bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc,
1021))
return NULL;
@ -720,12 +711,9 @@ bfd_ecoff_debug_accumulate (handle, output_bfd, output_debug, output_swap,
information that should not be merged. */
name = input_debug->ss + fdr.issBase + fdr.rss;
lookup = (char *) malloc (strlen (name) + 20);
lookup = (char *) bfd_malloc (strlen (name) + 20);
if (lookup == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
sprintf (lookup, "%s %lx", name, fdr.csym);
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);
#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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
(*swap->swap_hdr_out) (abfd, symhdr, buff);
if (bfd_write (buff, 1, swap->external_hdr_size, abfd)
@ -1660,12 +1645,9 @@ ecoff_write_shuffle (abfd, swap, shuffle, space)
bfd_byte *s;
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)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
memset ((PTR) s, 0, 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))
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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (! ecoff_write_shuffle (abfd, swap, ainfo->line, 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;
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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
memset ((PTR) s, 0, 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
- (debug->symbolic_header.issExtMax & (swap->debug_align - 1)));
s = (bfd_byte *) malloc (i);
s = (bfd_byte *) bfd_malloc (i);
if (s == NULL && i != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
memset ((PTR) s, 0, 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)
free (line_info->find_buffer);
buffer = (char *) malloc (len);
buffer = (char *) bfd_malloc (len);
if (buffer == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
line_info->find_buffer = buffer;
}

View File

@ -1158,12 +1158,9 @@ assign_section_numbers (abfd)
char *alc;
len = strlen (sec->name);
alc = (char *) malloc (len - 2);
alc = (char *) bfd_malloc (len - 2);
if (alc == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
strncpy (alc, sec->name, len - 3);
alc[len - 3] = '\0';
s = bfd_get_section_by_name (abfd, alc);
@ -1548,13 +1545,10 @@ map_sections_to_segments (abfd)
/* Select the allocated sections, and sort them. */
sections = (asection **) malloc (bfd_count_sections (abfd)
* sizeof (asection *));
sections = (asection **) bfd_malloc (bfd_count_sections (abfd)
* sizeof (asection *));
if (sections == NULL)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
i = 0;
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. */
x_symp = ((Elf_External_Sym *)
malloc (symcount * sizeof (Elf_External_Sym)));
bfd_malloc (symcount * sizeof (Elf_External_Sym)));
if (x_symp == NULL && symcount != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (bfd_read ((PTR) x_symp, sizeof (Elf_External_Sym), symcount, abfd)
!= symcount * sizeof (Elf_External_Sym))
@ -1053,12 +1050,9 @@ elf_slurp_reloc_table (abfd, asect, symbols)
&& (asect->reloc_count
== 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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0
|| (bfd_read (allocated, 1, d->rel_hdr.sh_size, abfd)

View File

@ -238,7 +238,7 @@ elf_corefile_note (abfd, hdr)
asection *newsect;
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_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)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return true;

View File

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

View File

@ -418,12 +418,9 @@ doit:
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)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
memset (reloc_cache, 0, count * sizeof (arelent));
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 *) bfd_zmalloc (sizeof (ieee_symbol_type));
if (!new)
{
bfd_set_error (bfd_error_no_error);
return NULL;
}
return NULL;
new->symbol.the_bfd = abfd;
return &new->symbol;
}

View File

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

112
bfd/som.c
View File

@ -1724,12 +1724,9 @@ setup_sections (abfd, file_hdr)
/* 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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (bfd_seek (abfd, file_hdr->space_strings_location, SEEK_SET) < 0)
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
a target index to each subspace. */
subspace_sections = (asection **) malloc (total_subspaces
* sizeof (asection *));
subspace_sections = (asection **) bfd_malloc (total_subspaces
* sizeof (asection *));
if (subspace_sections == NULL)
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
to hold the symbol table as we build it. */
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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
memset (som_symtab, 0, symtab_size);
/* Walk over each symbol. */
@ -3797,12 +3791,9 @@ som_slurp_string_table (abfd)
}
/* 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)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
memset (stringtab, 0, obj_som_stringtab_size (abfd));
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);
symbase = (som_symbol_type *)
malloc (symbol_count * sizeof (som_symbol_type));
symbase = ((som_symbol_type *)
bfd_malloc (symbol_count * sizeof (som_symbol_type)));
if (symbase == NULL)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
memset (symbase, 0, symbol_count * sizeof (som_symbol_type));
/* Read in the external SOM representation. */
buf = malloc (symbol_count * symsize);
buf = bfd_malloc (symbol_count * symsize);
if (buf == NULL && symbol_count * symsize != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (bfd_seek (abfd, obj_som_sym_filepos (abfd), SEEK_SET) < 0)
goto error_return;
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
bother saving the contents (yet). Add it one
day if the need arises. */
section->contents = malloc (section->_raw_size);
section->contents = bfd_malloc (section->_raw_size);
if (section->contents == NULL)
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. */
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)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
/* Read in the external forms. */
if (bfd_seek (abfd,
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);
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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
/* Don't forget to initialize the counter! */
*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);
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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
som_dict =
(struct som_entry *) malloc (lst_header->module_count
* sizeof (struct som_entry));
(struct som_entry *) bfd_malloc (lst_header->module_count
* sizeof (struct som_entry));
if (som_dict == NULL && lst_header->module_count != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
/* Read in the hash table. The has table is an array of 32bit file offsets
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;
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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
som_dict =
(struct som_entry *) malloc (lst.module_count
* sizeof (struct som_entry));
(struct som_entry *) bfd_malloc (lst.module_count
* sizeof (struct som_entry));
if (som_dict == NULL && lst.module_count != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
last_hash_entry =
((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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
/* Lots of fields are file positions relative to the start
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;
/* 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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
strings = malloc (string_size);
goto error_return;
strings = bfd_malloc (string_size);
if (strings == NULL && string_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
p = strings;
curr_lst_sym = lst_syms;

View File

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

View File

@ -350,7 +350,7 @@ sunos_canonicalize_dynamic_symtab (abfd, storage)
if (info->dyninfo.ld_buckets > info->dynsym_count)
abort ();
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)
abort ();
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;
add = 8 - (s->_raw_size & 7);
contents = (bfd_byte *) realloc (s->contents,
(size_t) (s->_raw_size + add));
contents = (bfd_byte *) bfd_realloc (s->contents,
(size_t) (s->_raw_size + add));
if (contents == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
memset (contents + s->_raw_size, 0, (size_t) add);
s->contents = contents;
s->_raw_size += add;
@ -1389,7 +1386,7 @@ sunos_scan_relocs (info, abfd, sec, rel_size)
return true;
if (! info->keep_memory)
relocs = free_relocs = malloc ((size_t) rel_size);
relocs = free_relocs = bfd_malloc ((size_t) rel_size);
else
{
struct aout_section_data_struct *n;
@ -1401,15 +1398,12 @@ sunos_scan_relocs (info, abfd, sec, rel_size)
else
{
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;
}
}
if (relocs == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
if (bfd_seek (abfd, sec->rel_filepos, SEEK_SET) != 0
|| 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. */
s = bfd_get_section_by_name (dynobj, ".dynstr");
BFD_ASSERT (s != NULL);
if (s->contents == NULL)
contents = (bfd_byte *) malloc (len + 1);
else
contents = (bfd_byte *) realloc (s->contents,
(size_t) (s->_raw_size + len + 1));
contents = (bfd_byte *) bfd_realloc (s->contents,
s->_raw_size + len + 1);
if (contents == NULL)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
s->contents = contents;
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
into reloc_info using the section target_index. */
reloc_info = ((struct reloc_info_struct *)
malloc ((abfd->section_count + 1)
* sizeof (struct reloc_info_struct)));
bfd_malloc ((abfd->section_count + 1)
* sizeof (struct reloc_info_struct)));
if (reloc_info == NULL)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
memset ((PTR) reloc_info, 0,
(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,
false, (struct internal_reloc *) NULL);
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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
memset (reloc_info[o->target_index].csects, 0,
o->reloc_count * sizeof (asection *));
}
@ -1095,12 +1089,9 @@ xcoff_link_add_symbols (abfd, info)
{
bfd_byte *linenos;
linenos = (bfd_byte *) malloc (o->lineno_count * linesz);
linenos = (bfd_byte *) bfd_malloc (o->lineno_count * linesz);
if (linenos == NULL)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
reloc_info[o->target_index].linenos = linenos;
if (bfd_seek (abfd, o->line_filepos, SEEK_SET) != 0
|| (bfd_read (linenos, linesz, o->lineno_count, abfd)
@ -1943,12 +1934,9 @@ xcoff_link_add_dynamic_symbols (abfd, info)
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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (! bfd_get_section_contents (abfd, lsec, (PTR) buf, (file_ptr) 0,
lsec->_raw_size))
@ -2441,12 +2429,9 @@ bfd_xcoff_export_symbol (output_bfd, info, harg, syscall)
char *fnname;
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)
{
bfd_set_error (bfd_error_no_memory);
return false;
}
return false;
fnname[0] = '.';
strcpy (fnname + 1, h->root.root.string);
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
together, many of the strings will be the same. Storing the
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)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (! bfd_get_section_contents (sub, subdeb, (PTR) debug_contents,
(file_ptr) 0, subdeb->_raw_size))
goto error_return;
@ -3106,15 +3088,11 @@ xcoff_build_ldsyms (h, p)
while (ldinfo->string_size + len + 3 > newalc)
newalc *= 2;
if (ldinfo->strings == NULL)
newstrings = (bfd_byte *) malloc (newalc);
else
newstrings = ((bfd_byte *)
realloc ((PTR) ldinfo->strings, newalc));
newstrings = ((bfd_byte *)
bfd_realloc ((PTR) ldinfo->strings, newalc));
if (newstrings == NULL)
{
ldinfo->failed = true;
bfd_set_error (bfd_error_no_memory);
return false;
}
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
the target_index fields are 1 based. */
finfo.section_info = ((struct xcoff_link_section_info *)
malloc ((abfd->section_count + 1)
* sizeof (struct xcoff_link_section_info)));
finfo.section_info =
((struct xcoff_link_section_info *)
bfd_malloc ((abfd->section_count + 1)
* sizeof (struct xcoff_link_section_info)));
if (finfo.section_info == NULL)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
for (i = 0; i <= abfd->section_count; i++)
{
finfo.section_info[i].relocs = NULL;
@ -3379,17 +3355,14 @@ _bfd_xcoff_bfd_final_link (abfd, info)
would be slow. */
finfo.section_info[o->target_index].relocs =
((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 =
((struct xcoff_link_hash_entry **)
malloc (o->reloc_count
bfd_malloc (o->reloc_count
* sizeof (struct xcoff_link_hash_entry *)));
if (finfo.section_info[o->target_index].relocs == NULL
|| finfo.section_info[o->target_index].rel_hashes == NULL)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
if (o->reloc_count > max_output_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. */
finfo.internal_syms = ((struct internal_syment *)
malloc (max_sym_count
* sizeof (struct internal_syment)));
finfo.sym_indices = (long *) malloc (max_sym_count * sizeof (long));
bfd_malloc (max_sym_count
* sizeof (struct internal_syment)));
finfo.sym_indices = (long *) bfd_malloc (max_sym_count * sizeof (long));
finfo.outsyms = ((bfd_byte *)
malloc ((size_t) ((max_sym_count + 1) * symesz)));
finfo.linenos = (bfd_byte *) malloc (max_lineno_count
* bfd_coff_linesz (abfd));
finfo.contents = (bfd_byte *) malloc (max_contents_size);
finfo.external_relocs = (bfd_byte *) malloc (max_reloc_count * relsz);
bfd_malloc ((size_t) ((max_sym_count + 1) * symesz)));
finfo.linenos = (bfd_byte *) bfd_malloc (max_lineno_count
* bfd_coff_linesz (abfd));
finfo.contents = (bfd_byte *) bfd_malloc (max_contents_size);
finfo.external_relocs = (bfd_byte *) bfd_malloc (max_reloc_count * relsz);
if ((finfo.internal_syms == NULL && max_sym_count > 0)
|| (finfo.sym_indices == NULL && max_sym_count > 0)
|| finfo.outsyms == NULL
|| (finfo.linenos == NULL && max_lineno_count > 0)
|| (finfo.contents == NULL && max_contents_size > 0)
|| (finfo.external_relocs == NULL && max_reloc_count > 0))
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
goto error_return;
obj_raw_syment_count (abfd) = 0;
xcoff_data (abfd)->toc = (bfd_vma) -1;