diff options
author | Ian Lance Taylor <ian@airs.com> | 1995-11-29 22:05:37 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1995-11-29 22:05:37 +0000 |
commit | a9713b91a74c2cc05db65ec58573f388d2c41cc0 (patch) | |
tree | c786fa623034d37112d9290b9380d06ff0c36a5c /bfd/nlmcode.h | |
parent | 8f2bdc203241c910f5ddd969a5ebb5f7199f7edd (diff) | |
download | binutils-a9713b91a74c2cc05db65ec58573f388d2c41cc0.zip binutils-a9713b91a74c2cc05db65ec58573f388d2c41cc0.tar.gz binutils-a9713b91a74c2cc05db65ec58573f388d2c41cc0.tar.bz2 |
* opncls.c (bfd_alloc_by_size_t): Set bfd_error_no_memory if
obstack_alloc fails.
(bfd_alloc_finish): Set bfd_error_no_memory if obstack_finish
fails.
* libbfd.c (bfd_zmalloc): Set bfd_error_no_memory if malloc fails.
* Many files: don't set bfd_error_no_memory if one of the above
routines fails.
Diffstat (limited to 'bfd/nlmcode.h')
-rw-r--r-- | bfd/nlmcode.h | 80 |
1 files changed, 30 insertions, 50 deletions
diff --git a/bfd/nlmcode.h b/bfd/nlmcode.h index a53c67b..e1df043 100644 --- a/bfd/nlmcode.h +++ b/bfd/nlmcode.h @@ -18,7 +18,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <string.h> /* For strrchr and friends */ #include "bfd.h" @@ -114,7 +114,7 @@ nlm_object_p (abfd) /* Read in the fixed length portion of the NLM header in external format. */ - x_fxdhdr = (PTR) malloc (nlm_fixed_header_size (abfd)); + x_fxdhdr = (PTR) malloc ((size_t) nlm_fixed_header_size (abfd)); if (x_fxdhdr == NULL) { bfd_set_error (bfd_error_no_memory); @@ -136,10 +136,7 @@ nlm_object_p (abfd) new_tdata = ((struct nlm_obj_tdata *) bfd_zalloc (abfd, sizeof (struct nlm_obj_tdata))); if (new_tdata == NULL) - { - bfd_set_error (bfd_error_no_memory); - goto got_no_match; - } + goto got_no_match; nlm_tdata (abfd) = new_tdata; @@ -274,7 +271,7 @@ nlm_swap_variable_header_in (abfd) if (bfd_read ((PTR) nlm_variable_header (abfd)->descriptionText, nlm_variable_header (abfd)->descriptionLength + 1, 1, abfd) != - nlm_variable_header (abfd)->descriptionLength + 1) + (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1) return (false); /* Read and convert the stackSize field. */ @@ -307,7 +304,7 @@ nlm_swap_variable_header_in (abfd) if (bfd_read ((PTR) nlm_variable_header (abfd)->screenName, nlm_variable_header (abfd)->screenNameLength + 1, 1, abfd) != - nlm_variable_header (abfd)->screenNameLength + 1) + (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1) return (false); /* Read the thread name length and text members. */ @@ -320,7 +317,7 @@ nlm_swap_variable_header_in (abfd) if (bfd_read ((PTR) nlm_variable_header (abfd)->threadName, nlm_variable_header (abfd)->threadNameLength + 1, 1, abfd) != - nlm_variable_header (abfd)->threadNameLength + 1) + (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1) return (false); return (true); } @@ -344,7 +341,7 @@ nlm_swap_variable_header_out (abfd) if (bfd_write ((PTR) nlm_variable_header (abfd)->descriptionText, nlm_variable_header (abfd)->descriptionLength + 1, 1, abfd) != - nlm_variable_header (abfd)->descriptionLength + 1) + (bfd_size_type) nlm_variable_header (abfd)->descriptionLength + 1) return (false); /* Convert and write the stackSize field. */ @@ -379,7 +376,7 @@ nlm_swap_variable_header_out (abfd) if (bfd_write ((PTR) nlm_variable_header (abfd)->screenName, nlm_variable_header (abfd)->screenNameLength + 1, 1, abfd) != - nlm_variable_header (abfd)->screenNameLength + 1) + (bfd_size_type) nlm_variable_header (abfd)->screenNameLength + 1) return (false); /* Write the thread name length and text members. */ @@ -392,7 +389,7 @@ nlm_swap_variable_header_out (abfd) if (bfd_write ((PTR) nlm_variable_header (abfd)->threadName, nlm_variable_header (abfd)->threadNameLength + 1, 1, abfd) != - nlm_variable_header (abfd)->threadNameLength + 1) + (bfd_size_type) nlm_variable_header (abfd)->threadNameLength + 1) return (false); return (true); } @@ -522,7 +519,8 @@ nlm_swap_auxiliary_headers_in (abfd) if (bfd_read ((PTR) nlm_copyright_header (abfd)->copyrightMessage, nlm_copyright_header (abfd)->copyrightMessageLength + 1, 1, abfd) != - nlm_copyright_header (abfd)->copyrightMessageLength + 1) + ((bfd_size_type) + nlm_copyright_header (abfd)->copyrightMessageLength + 1)) return (false); } else if (strncmp (tempstr, "CuStHeAd", 8) == 0) @@ -584,10 +582,7 @@ nlm_swap_auxiliary_headers_in (abfd) hdrLength -= 2 * NLM_TARGET_LONG_SIZE + 8; hdr = bfd_alloc (abfd, hdrLength); if (hdr == NULL) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + return false; if (bfd_read (hdr, 1, hdrLength, abfd) != hdrLength) return false; } @@ -608,10 +603,7 @@ nlm_swap_auxiliary_headers_in (abfd) return false; contents = (bfd_byte *) bfd_alloc (abfd, dataLength); if (contents == NULL) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + return false; if (bfd_read (contents, 1, dataLength, abfd) != dataLength) return false; if (bfd_seek (abfd, pos, SEEK_SET) != 0) @@ -851,7 +843,8 @@ nlm_swap_auxiliary_headers_out (abfd) if (bfd_write ((PTR) nlm_copyright_header (abfd)->copyrightMessage, nlm_copyright_header (abfd)->copyrightMessageLength + 1, 1, abfd) != - nlm_copyright_header (abfd)->copyrightMessageLength + 1) + ((bfd_size_type) + nlm_copyright_header (abfd)->copyrightMessageLength + 1)) return false; } @@ -1077,10 +1070,7 @@ nlm_slurp_symbol_table (abfd) sym = ((nlm_symbol_type *) bfd_zalloc (abfd, totsymcount * sizeof (nlm_symbol_type))); if (!sym) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + return false; nlm_set_symbols (abfd, sym); /* We use the bfd's symcount directly as the control count, so that early @@ -1097,10 +1087,7 @@ nlm_slurp_symbol_table (abfd) sym->symbol.the_bfd = abfd; sym->symbol.name = bfd_alloc (abfd, symlength + 1); if (!sym->symbol.name) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + return false; if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd) != symlength) return (false); @@ -1156,10 +1143,7 @@ nlm_slurp_symbol_table (abfd) sym->symbol.the_bfd = abfd; sym->symbol.name = bfd_alloc (abfd, symlength + 1); if (!sym->symbol.name) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + return false; if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd) != symlength) return (false); @@ -1180,7 +1164,7 @@ nlm_slurp_symbol_table (abfd) } else { - sym->symbol.section = &bfd_abs_section; + sym->symbol.section = bfd_abs_section_ptr; } sym->rcnt = 0; abfd->symcount++; @@ -1248,10 +1232,7 @@ nlm_slurp_reloc_fixups (abfd) rels = (arelent *) bfd_alloc (abfd, count * sizeof (arelent)); secs = (asection **) bfd_alloc (abfd, count * sizeof (asection *)); if ((rels == NULL || secs == NULL) && count != 0) - { - bfd_set_error (bfd_error_no_memory); - return false; - } + return false; nlm_relocation_fixups (abfd) = rels; nlm_relocation_fixup_secs (abfd) = secs; @@ -1402,7 +1383,7 @@ nlm_compute_section_file_positions (abfd) asection *sec; bfd_vma text, data, bss; bfd_vma text_low, data_low; - int text_align, data_align, other_align; + unsigned int text_align, data_align, other_align; file_ptr text_ptr, data_ptr, other_ptr; asection *bss_sec; asymbol **sym_ptr_ptr; @@ -1704,7 +1685,8 @@ nlm_write_object_contents (abfd) boolean (*write_prefix_func) PARAMS ((bfd *)); unsigned char *fixed_header = NULL; - fixed_header = (unsigned char *) malloc (nlm_fixed_header_size (abfd)); + fixed_header = ((unsigned char *) + malloc ((size_t) nlm_fixed_header_size (abfd))); if (fixed_header == NULL) { bfd_set_error (bfd_error_no_memory); @@ -1779,7 +1761,7 @@ nlm_write_object_contents (abfd) rel = *rel_ptr_ptr; sym = *rel->sym_ptr_ptr; - if (bfd_get_section (sym) != &bfd_und_section) + if (! bfd_is_und_section (bfd_get_section (sym))) { ++internal_reloc_count; if ((*write_import_func) (abfd, sec, rel) == false) @@ -1800,10 +1782,7 @@ nlm_write_object_contents (abfd) (external_reloc_count * sizeof (struct reloc_and_sec))); if (external_relocs == (struct reloc_and_sec *) NULL) - { - bfd_set_error (bfd_error_no_memory); - goto error_return; - } + goto error_return; i = 0; for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next) { @@ -1822,7 +1801,7 @@ nlm_write_object_contents (abfd) rel = *rel_ptr_ptr; sym = *rel->sym_ptr_ptr; - if (bfd_get_section (sym) != &bfd_und_section) + if (! bfd_is_und_section (bfd_get_section (sym))) continue; external_relocs[i].rel = rel; @@ -1893,7 +1872,7 @@ nlm_write_object_contents (abfd) sym = *sym_ptr_ptr; if ((sym->flags & (BSF_EXPORT | BSF_GLOBAL)) == 0 - || bfd_get_section (sym) == &bfd_und_section) + || bfd_is_und_section (bfd_get_section (sym))) continue; ++c; @@ -1978,7 +1957,7 @@ nlm_write_object_contents (abfd) debugging symbol NLM does not understand at all. */ if ((sym->flags & (BSF_LOCAL | BSF_GLOBAL | BSF_EXPORT)) == 0 || (sym->flags & BSF_DEBUGGING) != 0 - || bfd_get_section (sym) == &bfd_und_section) + || bfd_is_und_section (bfd_get_section (sym))) continue; ++c; @@ -2065,7 +2044,8 @@ nlm_write_object_contents (abfd) goto error_return; } - BFD_ASSERT (bfd_tell (abfd) == nlm_optional_prefix_size (abfd)); + BFD_ASSERT ((bfd_size_type) bfd_tell (abfd) + == nlm_optional_prefix_size (abfd)); nlm_swap_fixed_header_out (abfd, nlm_fixed_header (abfd), fixed_header); if (bfd_write (fixed_header, nlm_fixed_header_size (abfd), 1, abfd) |