diff options
Diffstat (limited to 'bfd/coff-rs6000.c')
-rw-r--r-- | bfd/coff-rs6000.c | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index 06d0fd8..7dd80a5 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -2193,8 +2193,12 @@ xcoff_write_armap_big (bfd *abfd, unsigned int elength ATTRIBUTE_UNUSED, } } - bfd_write (symbol_table, symbol_table_size, abfd); - + if (bfd_write (symbol_table, symbol_table_size, abfd) + != symbol_table_size) + { + free (symbol_table); + return false; + } free (symbol_table); prevoff = nextoff; @@ -2273,8 +2277,12 @@ xcoff_write_armap_big (bfd *abfd, unsigned int elength ATTRIBUTE_UNUSED, } } - bfd_write (symbol_table, symbol_table_size, abfd); - + if (bfd_write (symbol_table, symbol_table_size, abfd) + != symbol_table_size) + { + free (symbol_table); + return false; + } free (symbol_table); PRINT20 (fhdr->symoff64, nextoff); @@ -4204,7 +4212,10 @@ xcoff_generate_rtinit (bfd *abfd, const char *init, const char *fini, string_table_size += 4; string_table = (bfd_byte *) bfd_zmalloc (string_table_size); if (string_table == NULL) - return false; + { + free (data_buffer); + return false; + } val = string_table_size; bfd_h_put_32 (abfd, val, &string_table[0]); @@ -4354,18 +4365,21 @@ xcoff_generate_rtinit (bfd *abfd, const char *init, const char *fini, filehdr.f_symptr = scnhdr.s_relptr + scnhdr.s_nreloc * RELSZ; bfd_coff_swap_filehdr_out (abfd, &filehdr, filehdr_ext); - bfd_write (filehdr_ext, FILHSZ, abfd); bfd_coff_swap_scnhdr_out (abfd, &scnhdr, scnhdr_ext); - bfd_write (scnhdr_ext, SCNHSZ, abfd); - bfd_write (data_buffer, data_buffer_size, abfd); - bfd_write (reloc_ext, scnhdr.s_nreloc * RELSZ, abfd); - bfd_write (syment_ext, filehdr.f_nsyms * SYMESZ, abfd); - bfd_write (string_table, string_table_size, abfd); - + bool ret = true; + if (bfd_write (filehdr_ext, FILHSZ, abfd) != FILHSZ + || bfd_write (scnhdr_ext, SCNHSZ, abfd) != SCNHSZ + || bfd_write (data_buffer, data_buffer_size, abfd) != data_buffer_size + || (bfd_write (reloc_ext, scnhdr.s_nreloc * RELSZ, abfd) + != scnhdr.s_nreloc * RELSZ) + || (bfd_write (syment_ext, filehdr.f_nsyms * SYMESZ, abfd) + != (bfd_size_type) filehdr.f_nsyms * SYMESZ) + || bfd_write (string_table, string_table_size, abfd) != string_table_size) + ret = false; + + free (string_table); free (data_buffer); - data_buffer = NULL; - - return true; + return ret; } |