aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog10
-rw-r--r--bfd/aoutx.h242
-rw-r--r--bfd/som.c50
3 files changed, 159 insertions, 143 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f24cf54..009f815 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,13 @@
+Thu Mar 17 10:37:07 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * aoutx.h, elfcode.h, coff-alpha.c, bout.c, ecoff.c, ecofflink.c,
+ elf32-hppa.c, elf32-mips.c, linker.c, som.c, sunos.c: If malloc(0)
+ returns NULL, it is not an error. It's possible that some of
+ these checks are not necessary (because the size can never be
+ zero), but putting in the checks is the conservative thing to do
+ in light of the fact that some of these malloc calls replaced
+ unchecked alloca calls, in which a zero argument would work fine.
+
Thu Mar 17 11:44:45 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
* reloc.c (bfd_generic_get_relocated_section_contents): Don't fail
diff --git a/bfd/aoutx.h b/bfd/aoutx.h
index 029618c..674cf59 100644
--- a/bfd/aoutx.h
+++ b/bfd/aoutx.h
@@ -125,7 +125,6 @@ DESCRIPTION
#include <string.h> /* For strchr and friends */
#include "bfd.h"
#include <sysdep.h>
-#include <ansidecl.h>
#include "bfdlink.h"
#include "libaout.h"
@@ -208,9 +207,9 @@ HOWTO(10, 0, 2, 32, false, 0, complain_overflow_bitfield,0,"BASE32", f
#define TABLE_SIZE(TABLE) (sizeof(TABLE)/sizeof(TABLE[0]))
CONST struct reloc_howto_struct *
-DEFUN(NAME(aout,reloc_type_lookup),(abfd,code),
- bfd *abfd AND
- bfd_reloc_code_real_type code)
+NAME(aout,reloc_type_lookup) (abfd,code)
+ bfd *abfd;
+ bfd_reloc_code_real_type code;
{
#define EXT(i,j) case i: return &howto_table_ext[j]
#define STD(i,j) case i: return &howto_table_std[j]
@@ -276,10 +275,10 @@ DESCRIPTION
#ifndef NAME_swap_exec_header_in
void
-DEFUN(NAME(aout,swap_exec_header_in),(abfd, raw_bytes, execp),
- bfd *abfd AND
- struct external_exec *raw_bytes AND
- struct internal_exec *execp)
+NAME(aout,swap_exec_header_in) (abfd, raw_bytes, execp)
+ bfd *abfd;
+ struct external_exec *raw_bytes;
+ struct internal_exec *execp;
{
struct external_exec *bytes = (struct external_exec *)raw_bytes;
@@ -316,10 +315,10 @@ DESCRIPTION
@var{execp} into the buffer @var{raw_bytes} ready for writing to disk.
*/
void
-DEFUN(NAME(aout,swap_exec_header_out),(abfd, execp, raw_bytes),
- bfd *abfd AND
- struct internal_exec *execp AND
- struct external_exec *raw_bytes)
+NAME(aout,swap_exec_header_out) (abfd, execp, raw_bytes)
+ bfd *abfd;
+ struct internal_exec *execp;
+ struct external_exec *raw_bytes;
{
struct external_exec *bytes = (struct external_exec *)raw_bytes;
@@ -354,10 +353,10 @@ DESCRIPTION
*/
bfd_target *
-DEFUN(NAME(aout,some_aout_object_p),(abfd, execp, callback_to_real_object_p),
- bfd *abfd AND
- struct internal_exec *execp AND
- bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *)))
+NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p)
+ bfd *abfd;
+ struct internal_exec *execp;
+ bfd_target *(*callback_to_real_object_p) PARAMS ((bfd *));
{
struct aout_data_struct *rawptr, *oldrawptr;
bfd_target *result;
@@ -547,8 +546,8 @@ DESCRIPTION
*/
boolean
-DEFUN(NAME(aout,mkobject),(abfd),
- bfd *abfd)
+NAME(aout,mkobject) (abfd)
+ bfd *abfd;
{
struct aout_data_struct *rawptr;
@@ -601,9 +600,9 @@ DESCRIPTION
*/
enum machine_type
-DEFUN(NAME(aout,machine_type),(arch, machine),
- enum bfd_architecture arch AND
- unsigned long machine)
+NAME(aout,machine_type) (arch, machine)
+ enum bfd_architecture arch;
+ unsigned long machine;
{
enum machine_type arch_flags;
@@ -668,10 +667,10 @@ DESCRIPTION
*/
boolean
-DEFUN(NAME(aout,set_arch_mach),(abfd, arch, machine),
- bfd *abfd AND
- enum bfd_architecture arch AND
- unsigned long machine)
+NAME(aout,set_arch_mach) (abfd, arch, machine)
+ bfd *abfd;
+ enum bfd_architecture arch;
+ unsigned long machine;
{
if (! bfd_default_set_arch_mach (abfd, arch, machine))
return false;
@@ -871,8 +870,10 @@ adjust_n_magic (abfd, execp)
}
boolean
-DEFUN (NAME(aout,adjust_sizes_and_vmas), (abfd, text_size, text_end),
- bfd *abfd AND bfd_size_type *text_size AND file_ptr *text_end)
+NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end)
+ bfd *abfd;
+ bfd_size_type *text_size;
+ file_ptr *text_end;
{
struct internal_exec *execp = exec_hdr (abfd);
@@ -975,9 +976,9 @@ DESCRIPTION
request.
*/
boolean
-DEFUN(NAME(aout,new_section_hook),(abfd, newsect),
- bfd *abfd AND
- asection *newsect)
+NAME(aout,new_section_hook) (abfd, newsect)
+ bfd *abfd;
+ asection *newsect;
{
/* align to double at least */
newsect->alignment_power = bfd_get_arch_info(abfd)->section_align_power;
@@ -1010,12 +1011,12 @@ DEFUN(NAME(aout,new_section_hook),(abfd, newsect),
}
boolean
-DEFUN(NAME(aout,set_section_contents),(abfd, section, location, offset, count),
- bfd *abfd AND
- sec_ptr section AND
- PTR location AND
- file_ptr offset AND
- bfd_size_type count)
+NAME(aout,set_section_contents) (abfd, section, location, offset, count)
+ bfd *abfd;
+ sec_ptr section;
+ PTR location;
+ file_ptr offset;
+ bfd_size_type count;
{
file_ptr text_end;
bfd_size_type text_size;
@@ -1084,10 +1085,10 @@ DEFUN(NAME(aout,set_section_contents),(abfd, section, location, offset, count),
stabilised these should be inlined into their (single) caller */
static boolean
-DEFUN (translate_from_native_sym_flags, (sym_pointer, cache_ptr, abfd),
- struct external_nlist *sym_pointer AND
- aout_symbol_type * cache_ptr AND
- bfd * abfd)
+translate_from_native_sym_flags (sym_pointer, cache_ptr, abfd)
+ struct external_nlist *sym_pointer;
+ aout_symbol_type * cache_ptr;
+ bfd * abfd;
{
cache_ptr->symbol.section = 0;
switch (cache_ptr->type & N_TYPE)
@@ -1304,10 +1305,10 @@ DEFUN (translate_from_native_sym_flags, (sym_pointer, cache_ptr, abfd),
static boolean
-DEFUN(translate_to_native_sym_flags,(sym_pointer, cache_ptr, abfd),
- struct external_nlist *sym_pointer AND
- asymbol *cache_ptr AND
- bfd *abfd)
+translate_to_native_sym_flags (sym_pointer, cache_ptr, abfd)
+ struct external_nlist *sym_pointer;
+ asymbol *cache_ptr;
+ bfd *abfd;
{
bfd_vma value = cache_ptr->value;
@@ -1386,8 +1387,8 @@ DEFUN(translate_to_native_sym_flags,(sym_pointer, cache_ptr, abfd),
asymbol *
-DEFUN(NAME(aout,make_empty_symbol),(abfd),
- bfd *abfd)
+NAME(aout,make_empty_symbol) (abfd)
+ bfd *abfd;
{
aout_symbol_type *new =
(aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type));
@@ -1456,8 +1457,8 @@ translate_symbol_table (abfd, in, ext, count, str, strsize, dynamic)
hold them all plus all the cached symbol entries. */
boolean
-DEFUN(NAME(aout,slurp_symbol_table),(abfd),
- bfd *abfd)
+NAME(aout,slurp_symbol_table) (abfd)
+ bfd *abfd;
{
bfd_size_type symbol_size;
bfd_size_type string_size;
@@ -1941,8 +1942,8 @@ emit_strtab (abfd, tab)
}
boolean
-DEFUN(NAME(aout,write_syms),(abfd),
- bfd *abfd)
+NAME(aout,write_syms) (abfd)
+ bfd *abfd;
{
unsigned int count ;
asymbol **generic = bfd_get_outsymbols (abfd);
@@ -1993,9 +1994,9 @@ DEFUN(NAME(aout,write_syms),(abfd),
unsigned int
-DEFUN(NAME(aout,get_symtab),(abfd, location),
- bfd *abfd AND
- asymbol **location)
+NAME(aout,get_symtab) (abfd, location)
+ bfd *abfd;
+ asymbol **location;
{
unsigned int counter = 0;
aout_symbol_type *symbase;
@@ -2013,10 +2014,10 @@ DEFUN(NAME(aout,get_symtab),(abfd, location),
/* Output standard relocation information to a file in target byte order. */
void
-DEFUN(NAME(aout,swap_std_reloc_out),(abfd, g, natptr),
- bfd *abfd AND
- arelent *g AND
- struct reloc_std_external *natptr)
+NAME(aout,swap_std_reloc_out) (abfd, g, natptr)
+ bfd *abfd;
+ arelent *g;
+ struct reloc_std_external *natptr;
{
int r_index;
asymbol *sym = *(g->sym_ptr_ptr);
@@ -2109,10 +2110,10 @@ DEFUN(NAME(aout,swap_std_reloc_out),(abfd, g, natptr),
/* Output extended relocation information to a file in target byte order. */
void
-DEFUN(NAME(aout,swap_ext_reloc_out),(abfd, g, natptr),
- bfd *abfd AND
- arelent *g AND
- register struct reloc_ext_external *natptr)
+NAME(aout,swap_ext_reloc_out) (abfd, g, natptr)
+ bfd *abfd;
+ arelent *g;
+ register struct reloc_ext_external *natptr;
{
int r_index;
int r_extern;
@@ -2221,11 +2222,11 @@ DEFUN(NAME(aout,swap_ext_reloc_out),(abfd, g, natptr),
} \
void
-DEFUN(NAME(aout,swap_ext_reloc_in), (abfd, bytes, cache_ptr, symbols),
- bfd *abfd AND
- struct reloc_ext_external *bytes AND
- arelent *cache_ptr AND
- asymbol **symbols)
+NAME(aout,swap_ext_reloc_in) (abfd, bytes, cache_ptr, symbols)
+ bfd *abfd;
+ struct reloc_ext_external *bytes;
+ arelent *cache_ptr;
+ asymbol **symbols;
{
int r_index;
int r_extern;
@@ -2256,11 +2257,11 @@ DEFUN(NAME(aout,swap_ext_reloc_in), (abfd, bytes, cache_ptr, symbols),
}
void
-DEFUN(NAME(aout,swap_std_reloc_in), (abfd, bytes, cache_ptr, symbols),
- bfd *abfd AND
- struct reloc_std_external *bytes AND
- arelent *cache_ptr AND
- asymbol **symbols)
+NAME(aout,swap_std_reloc_in) (abfd, bytes, cache_ptr, symbols)
+ bfd *abfd;
+ struct reloc_std_external *bytes;
+ arelent *cache_ptr;
+ asymbol **symbols;
{
int r_index;
int r_extern;
@@ -2311,10 +2312,10 @@ DEFUN(NAME(aout,swap_std_reloc_in), (abfd, bytes, cache_ptr, symbols),
/* Reloc hackery */
boolean
-DEFUN(NAME(aout,slurp_reloc_table),(abfd, asect, symbols),
- bfd *abfd AND
- sec_ptr asect AND
- asymbol **symbols)
+NAME(aout,slurp_reloc_table) (abfd, asect, symbols)
+ bfd *abfd;
+ sec_ptr asect;
+ asymbol **symbols;
{
unsigned int count;
bfd_size_type reloc_size;
@@ -2450,9 +2451,9 @@ DEFUN(NAME(aout,slurp_reloc_table),(abfd, asect, symbols),
/* Write out a relocation section into an object file. */
boolean
-DEFUN(NAME(aout,squirt_out_relocs),(abfd, section),
- bfd *abfd AND
- asection *section)
+NAME(aout,squirt_out_relocs) (abfd, section)
+ bfd *abfd;
+ asection *section;
{
arelent **generic;
unsigned char *native, *natptr;
@@ -2499,11 +2500,11 @@ DEFUN(NAME(aout,squirt_out_relocs),(abfd, section),
/* This is stupid. This function should be a boolean predicate */
unsigned int
-DEFUN(NAME(aout,canonicalize_reloc),(abfd, section, relptr, symbols),
- bfd *abfd AND
- sec_ptr section AND
- arelent **relptr AND
- asymbol **symbols)
+NAME(aout,canonicalize_reloc) (abfd, section, relptr, symbols)
+ bfd *abfd;
+ sec_ptr section;
+ arelent **relptr;
+ asymbol **symbols;
{
arelent *tblptr = section->relocation;
unsigned int count;
@@ -2533,9 +2534,9 @@ DEFUN(NAME(aout,canonicalize_reloc),(abfd, section, relptr, symbols),
}
unsigned int
-DEFUN(NAME(aout,get_reloc_upper_bound),(abfd, asect),
- bfd *abfd AND
- sec_ptr asect)
+NAME(aout,get_reloc_upper_bound) (abfd, asect)
+ bfd *abfd;
+ sec_ptr asect;
{
bfd_size_type dynrel_count = 0;
@@ -2573,9 +2574,9 @@ DEFUN(NAME(aout,get_reloc_upper_bound),(abfd, asect),
}
- unsigned int
-DEFUN(NAME(aout,get_symtab_upper_bound),(abfd),
- bfd *abfd)
+unsigned int
+NAME(aout,get_symtab_upper_bound) (abfd)
+ bfd *abfd;
{
if (!NAME(aout,slurp_symbol_table)(abfd)) return 0;
@@ -2584,19 +2585,19 @@ DEFUN(NAME(aout,get_symtab_upper_bound),(abfd),
/*ARGSUSED*/
alent *
-DEFUN(NAME(aout,get_lineno),(ignore_abfd, ignore_symbol),
- bfd *ignore_abfd AND
- asymbol *ignore_symbol)
+NAME(aout,get_lineno) (ignore_abfd, ignore_symbol)
+ bfd *ignore_abfd;
+ asymbol *ignore_symbol;
{
return (alent *)NULL;
}
/*ARGSUSED*/
void
-DEFUN(NAME(aout,get_symbol_info),(ignore_abfd, symbol, ret),
- bfd *ignore_abfd AND
- asymbol *symbol AND
- symbol_info *ret)
+NAME(aout,get_symbol_info) (ignore_abfd, symbol, ret)
+ bfd *ignore_abfd;
+ asymbol *symbol;
+ symbol_info *ret;
{
bfd_symbol_info (symbol, ret);
@@ -2620,11 +2621,11 @@ DEFUN(NAME(aout,get_symbol_info),(ignore_abfd, symbol, ret),
/*ARGSUSED*/
void
-DEFUN(NAME(aout,print_symbol),(ignore_abfd, afile, symbol, how),
- bfd *ignore_abfd AND
- PTR afile AND
- asymbol *symbol AND
- bfd_print_symbol_type how)
+NAME(aout,print_symbol) (ignore_abfd, afile, symbol, how)
+ bfd *ignore_abfd;
+ PTR afile;
+ asymbol *symbol;
+ bfd_print_symbol_type how;
{
FILE *file = (FILE *)afile;
@@ -2664,20 +2665,15 @@ DEFUN(NAME(aout,print_symbol),(ignore_abfd, afile, symbol, how),
*/
boolean
-DEFUN(NAME(aout,find_nearest_line),(abfd,
- section,
- symbols,
- offset,
- filename_ptr,
- functionname_ptr,
- line_ptr),
- bfd *abfd AND
- asection *section AND
- asymbol **symbols AND
- bfd_vma offset AND
- CONST char **filename_ptr AND
- CONST char **functionname_ptr AND
- unsigned int *line_ptr)
+NAME(aout,find_nearest_line)
+ (abfd, section, symbols, offset, filename_ptr, functionname_ptr, line_ptr)
+ bfd *abfd;
+ asection *section;
+ asymbol **symbols;
+ bfd_vma offset;
+ CONST char **filename_ptr;
+ CONST char **functionname_ptr;
+ unsigned int *line_ptr;
{
/* Run down the file looking for the filename, function and linenumber */
asymbol **p;
@@ -2774,9 +2770,9 @@ DEFUN(NAME(aout,find_nearest_line),(abfd,
/*ARGSUSED*/
int
-DEFUN(NAME(aout,sizeof_headers),(abfd, execable),
- bfd *abfd AND
- boolean execable)
+NAME(aout,sizeof_headers) (abfd, execable)
+ bfd *abfd;
+ boolean execable;
{
return adata(abfd).exec_bytes_size;
}
@@ -2990,7 +2986,7 @@ aout_link_get_symbols (abfd)
to free them. */
syms = ((struct external_nlist *)
malloc ((size_t) count * EXTERNAL_NLIST_SIZE));
- if (syms == (struct external_nlist *) NULL)
+ if (syms == (struct external_nlist *) NULL && count != 0)
{
bfd_set_error (bfd_error_no_memory);
return false;
@@ -3008,7 +3004,7 @@ aout_link_get_symbols (abfd)
return false;
stringsize = GET_WORD (abfd, string_chars);
strings = (char *) malloc ((size_t) stringsize);
- if (strings == NULL)
+ if (strings == NULL && stringsize != 0)
{
bfd_set_error (bfd_error_no_memory);
return false;
@@ -3545,7 +3541,7 @@ aout_link_input_bfd (finfo, input_bfd)
sym_count = obj_aout_external_sym_count (input_bfd);
symbol_map = (int *) malloc ((size_t) sym_count * sizeof (int));
- if (symbol_map == NULL)
+ if (symbol_map == NULL && sym_count != 0)
{
bfd_set_error (bfd_error_no_memory);
return false;
@@ -4014,7 +4010,7 @@ aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr,
/* Get the section contents. */
input_size = bfd_section_size (input_bfd, input_section);
contents = (bfd_byte *) malloc (input_size);
- if (contents == NULL)
+ if (contents == NULL && input_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
@@ -4025,7 +4021,7 @@ aout_link_input_section (finfo, input_bfd, input_section, reloff_ptr,
/* Read in the relocs. */
relocs = (PTR) malloc (rel_size);
- if (relocs == NULL)
+ if (relocs == NULL && rel_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
diff --git a/bfd/som.c b/bfd/som.c
index c71b607..e18f76a 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -1609,7 +1609,7 @@ setup_sections (abfd, file_hdr)
/* First, read in space names */
space_strings = malloc (file_hdr->space_strings_size);
- if (!space_strings)
+ if (!space_strings && file_hdr->space_strings_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
@@ -2098,15 +2098,11 @@ som_prep_for_fixups (abfd, syms, num_syms)
{
/* Handle a section symbol; these have no pointers back to the
SOM symbol info. So we just use the pointer field (udata)
- to hold the relocation count.
-
- FIXME. While we're here set the name of any section symbol
- to something which will not screw GDB. How do other formats
- deal with this?!? */
- if (som_symbol_data (syms[i]) == NULL)
+ to hold the relocation count. */
+ if (som_symbol_data (syms[i]) == NULL
+ || syms[i]->flags & BSF_SECTION_SYM)
{
syms[i]->flags |= BSF_SECTION_SYM;
- syms[i]->name = "L$0\002";
syms[i]->udata = (PTR) 0;
}
else
@@ -2677,6 +2673,14 @@ som_begin_writing (abfd)
we support only the copyright and version headers. */
obj_som_file_hdr (abfd)->aux_header_location = current_offset;
obj_som_file_hdr (abfd)->aux_header_size = 0;
+ if (abfd->flags & EXEC_P)
+ {
+ /* Parts of the exec header will be filled in later, so
+ delay writing the header itself. Just leave space for
+ it. */
+ current_offset += sizeof (struct som_exec_auxhdr);
+ obj_som_file_hdr (abfd)->aux_header_size += sizeof (struct som_exec_auxhdr);
+ }
if (obj_som_version_hdr (abfd) != NULL)
{
unsigned int len;
@@ -3251,7 +3255,7 @@ som_build_and_write_symbol_table (abfd)
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);
- if (som_symtab == NULL)
+ if (som_symtab == NULL && symtab_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
@@ -3434,7 +3438,7 @@ som_slurp_symbol_table (abfd)
/* Read in the external SOM representation. */
buf = malloc (symbol_count * symsize);
- if (buf == NULL)
+ if (buf == NULL && symbol_count * symsize != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
@@ -3550,9 +3554,15 @@ som_slurp_symbol_table (abfd)
}
/* Mark section symbols and symbols used by the debugger. */
- if (!strcmp (sym->symbol.name, "L$0\002"))
+ if (sym->symbol.name[0] == '$'
+ && sym->symbol.name[strlen (sym->symbol.name) - 1] == '$')
sym->symbol.flags |= BSF_SECTION_SYM;
- else if (!strncmp (sym->symbol.name, "L$0", 3))
+ else if (!strncmp (sym->symbol.name, "L$0\002", 4))
+ {
+ sym->symbol.flags |= BSF_SECTION_SYM;
+ sym->symbol.name = sym->symbol.section->name;
+ }
+ else if (!strncmp (sym->symbol.name, "L$0\001", 4))
sym->symbol.flags |= BSF_DEBUGGING;
/* Note increment at bottom of loop, since we skip some symbols
@@ -4343,7 +4353,7 @@ som_bfd_count_ar_symbols (abfd, lst_header, count)
hash_table =
(unsigned int *) malloc (lst_header->hash_size * sizeof (unsigned int));
- if (hash_table == NULL)
+ if (hash_table == NULL && lst_header->hash_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
@@ -4436,7 +4446,7 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
hash_table =
(unsigned int *) malloc (lst_header->hash_size * sizeof (unsigned int));
- if (hash_table == NULL)
+ if (hash_table == NULL && lst_header->hash_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
@@ -4445,7 +4455,7 @@ som_bfd_fill_in_ar_symbols (abfd, lst_header, syms)
som_dict =
(struct som_entry *) malloc (lst_header->module_count
* sizeof (struct som_entry));
- if (som_dict == NULL)
+ if (som_dict == NULL && lst_header->module_count != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
@@ -4823,7 +4833,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
hash_table =
(unsigned int *) malloc (lst.hash_size * sizeof (unsigned int));
- if (hash_table == NULL)
+ if (hash_table == NULL && lst.hash_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
@@ -4831,7 +4841,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
som_dict =
(struct som_entry *) malloc (lst.module_count
* sizeof (struct som_entry));
- if (som_dict == NULL)
+ if (som_dict == NULL && lst.module_count != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
@@ -4840,7 +4850,7 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
last_hash_entry =
((struct lst_symbol_record **)
malloc (lst.hash_size * sizeof (struct lst_symbol_record *)));
- if (last_hash_entry == NULL)
+ if (last_hash_entry == NULL && lst.hash_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
@@ -4868,13 +4878,13 @@ som_bfd_ar_write_symbol_stuff (abfd, nsyms, string_size, lst)
/* FIXME should be done with buffers just like everything else... */
lst_syms = malloc (nsyms * sizeof (struct lst_symbol_record));
- if (lst_syms == NULL)
+ if (lst_syms == NULL && nsyms != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;
}
strings = malloc (string_size);
- if (strings == NULL)
+ if (strings == NULL && string_size != 0)
{
bfd_set_error (bfd_error_no_memory);
goto error_return;