Mon Apr 4 15:30:49 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+ Made sure that every call to bfd_read, bfd_write, and bfd_seek
+ checks the return value and handled bfd_error correctly. These
+ changes are not itemised. Also:
+ * aoutx.h (emit_strtab): Change return type to boolean, and return
+ errors.
+ (NAME(aout,write_syms)): Check emit_strtab return value.
+ (NAME(aout,final_link)): Likewise.
+ * coffcode.h (coff_write_relocs): Change return type to boolean,
+ and return errors.
+ (coff_write_object_contents): Check coff_write_relocs return
+ value.
+ * i386os9k.c (os9k_swap_exec_header_in): Change return type to
+ boolean.
+ (os9k_object_p): Check os9k_swap_exec_header_in return value.
+ * oasys.c (oasys_read_record): Change return type to boolean.
+ (oasys_slurp_symbol_table: Check oasys_read_record return value.
+ (oasys_object_p, oasys_slurp_section_data): Likewise.
+ (oasys_write_record): Change return type to boolean.
+ (oasys_write_syms): Likewise. Also, check oasys_write_record
+ return value.
+ (oasys_write_sections): Check oasys_write_record return value.
+ (oasys_write_header): Change return type to boolean. Check
+ oasys_write_record return value.
+ (oasys_write_end, oasys_write_data): Likewise.
+ (oasys_write_object_contents): Check return values of
+ oasys_write_header, oasys_write_syms, oasys_write_data, and
+ oasys_write_end.
+ * srec.c (srec_write_record): Change return type to boolean.
+ (srec_write_header): Likewise. Also, check srec_write_record
+ return value.
+ (srec_write_section, srec_write_terminator): Likewise.
+ (srec_write_symbols): Change return type to boolean.
+ (internal_srec_write_object_contents): Check return value of
+ srec_write_symbols, srec_write_header, srec_write_section, and
+ srec_write_terminator.
+
* Makefile.in: Rebuilt dependencies.
Mon Apr 4 10:56:45 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
!= EXEC_BYTES_SIZE) {
- bfd_set_error (bfd_error_wrong_format);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
return 0;
}
for (;;) {
if (bfd_read ((PTR) ext, 1, sizeof (*ext), abfd) != sizeof (*ext)) {
- bfd_set_error (bfd_error_wrong_format);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
return 0;
}
switch (ext->e_type[0]) {
aout_adobe_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
- bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
- bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd);
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE))
+ return false;
/* Now write out the section information. Text first, data next, rest
afterward. */
}
/* Write final `sentinel` section header (with type of 0). */
- bfd_write ((PTR) sentinel, 1, sizeof (*sentinel), abfd);
+ if (bfd_write ((PTR) sentinel, 1, sizeof (*sentinel), abfd)
+ != sizeof (*sentinel))
+ return false;
/* Now write out reloc info, followed by syms and strings */
if (bfd_get_symcount (abfd) != 0)
{
- bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET);
+ if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET)
+ != 0)
+ return false;
if (! aout_32_write_syms (abfd))
return false;
- bfd_seek (abfd, (file_ptr)(N_TRELOFF(*exec_hdr(abfd))), SEEK_SET);
+ if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*exec_hdr(abfd))), SEEK_SET)
+ != 0)
+ return false;
for (sect = abfd->sections; sect; sect = sect->next) {
if (sect->flags & SEC_CODE) {
}
}
- bfd_seek (abfd, (file_ptr)(N_DRELOFF(*exec_hdr(abfd))), SEEK_SET);
+ if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*exec_hdr(abfd))), SEEK_SET)
+ != 0)
+ return false;
for (sect = abfd->sections; sect; sect = sect->next) {
if (sect->flags & SEC_DATA) {
}
/* regardless, once we know what we're doing, we might as well get going */
- bfd_seek (abfd, section->filepos + offset, SEEK_SET);
+ if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
+ return false;
if (count != 0) {
return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false;
struct external_exec exec_bytes;
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
!= EXEC_BYTES_SIZE) {
- bfd_set_error (bfd_error_wrong_format);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
return 0;
}
NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
!= EXEC_BYTES_SIZE) {
- bfd_set_error (bfd_error_wrong_format);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
return 0;
}
/*SUPPRESS529*/
void
- NAME (sunos, set_arch_mach) (abfd, machtype)
+#if ARCH_SIZE == 64
+sunos_64_set_arch_mach
+#else
+sunos_32_set_arch_mach
+#endif
+ (abfd, machtype)
bfd *abfd;
int machtype;
{
file header, symbols, and relocation. */
static boolean
- NAME (aout, sunos4_write_object_contents) (abfd)
+#if ARCH_SIZE == 64
+aout_64_sunos4_write_object_contents
+#else
+aout_32_sunos4_write_object_contents
+#endif
+ (abfd)
bfd *abfd;
{
struct external_exec exec_bytes;
intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
intcore->c_regs_pos = (long) (((struct external_sun3_core *) 0)->c_regs);
intcore->c_regs_size = sizeof (extcore->c_regs);
- NAME (aout, swap_exec_header_in) (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
+#if ARCH_SIZE == 64
+ aout_64_swap_exec_header_in
+#else
+ aout_32_swap_exec_header_in
+#endif
+ (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
intcore->c_len = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_len);
intcore->c_regs_pos = (long) (((struct external_sparc_core *) 0)->c_regs);
intcore->c_regs_size = sizeof (extcore->c_regs);
- NAME (aout, swap_exec_header_in) (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
+#if ARCH_SIZE == 64
+ aout_64_swap_exec_header_in
+#else
+ aout_32_swap_exec_header_in
+#endif
+ (abfd, &extcore->c_aouthdr, &intcore->c_aouthdr);
intcore->c_signo = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_signo);
intcore->c_tsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_tsize);
intcore->c_dsize = bfd_h_get_32 (abfd, (unsigned char *) &extcore->c_dsize);
if ((bfd_read ((PTR) extcore, 1, core_size, abfd)) != core_size)
{
- bfd_set_error (bfd_error_system_call);
bfd_release (abfd, (char *) mergem);
return 0;
}
if (bfd_read ((PTR) hdrp, 1, sizeof (struct ar_hdr), abfd)
!= sizeof (struct ar_hdr))
{
- bfd_set_error (bfd_error_no_more_archived_files);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_no_more_archived_files);
return NULL;
}
if (strncmp (hdr.ar_fmag, ARFMAG, 2))
+ sizeof (struct ar_hdr));
if (bfd_read (filename, 1, namelen, abfd) != namelen)
{
- bfd_set_error (bfd_error_no_more_archived_files);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_no_more_archived_files);
return NULL;
}
filename[namelen] = '\0';
if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG)
{
- bfd_set_error (bfd_error_wrong_format);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
return NULL;
}
if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
{
- bfd_set_error (bfd_error_malformed_archive);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
byebye:
bfd_release (abfd, (PTR) raw_armap);
return false;
if (bfd_read ((PTR) int_buf, 1, 4, abfd) != 4)
{
- bfd_set_error (bfd_error_malformed_archive);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
return false;
}
/* It seems that all numeric information in a coff archive is always
if (bfd_read ((PTR) raw_armap, 1, ptrsize, abfd) != ptrsize
|| bfd_read ((PTR) stringbase, 1, stringsize, abfd) != stringsize)
{
- bfd_set_error (bfd_error_malformed_archive);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
goto release_raw_armap;
}
if (i != 16)
return false;
- bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR);
+ if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
+ return false;
if (!strncmp (nextname, "__.SYMDEF ", 16))
return do_slurp_bsd_armap (abfd);
return false;
/* The archive has at least 16 bytes in it */
- bfd_seek (abfd, -16L, SEEK_CUR);
+ if (bfd_seek (abfd, -16L, SEEK_CUR) != 0)
+ return false;
if (!strncmp (nextname, "__.SYMDEF ", 16))
return do_slurp_bsd_armap (abfd);
if (bfd_read ((PTR) raw_armap, 1, mapdata->parsed_size, abfd) !=
mapdata->parsed_size)
{
- bfd_set_error (bfd_error_malformed_archive);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
byebyebye:
bfd_release (abfd, (PTR) raw_armap);
goto byebye;
if (bfd_read ((PTR) nextname, 1, 16, abfd) == 16)
{
- bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR);
+ if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)
+ return false;
if (strncmp (nextname, "ARFILENAMES/ ", 16) != 0 &&
strncmp (nextname, "// ", 16) != 0)
if (bfd_read ((PTR) bfd_ardata (abfd)->extended_names, 1,
namedata->parsed_size, abfd) != namedata->parsed_size)
{
- bfd_set_error (bfd_error_malformed_archive);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
bfd_release (abfd, (PTR) (bfd_ardata (abfd)->extended_names));
bfd_ardata (abfd)->extended_names = NULL;
goto byebye;
unsigned int elength = 0;
boolean makemap = bfd_has_map (arch);
boolean hasobjects = false; /* if no .o's, don't bother to make a map */
+ bfd_size_type wrote;
unsigned int i;
int tries;
if (!bfd_construct_extended_name_table (arch, &etable, &elength))
return false;
- bfd_seek (arch, (file_ptr) 0, SEEK_SET);
+ if (bfd_seek (arch, (file_ptr) 0, SEEK_SET) != 0)
+ return false;
#ifdef GNU960
- bfd_write (BFD_GNU960_ARMAG (arch), 1, SARMAG, arch);
+ wrote = bfd_write (BFD_GNU960_ARMAG (arch), 1, SARMAG, arch);
#else
- bfd_write (ARMAG, 1, SARMAG, arch);
+ wrote = bfd_write (ARMAG, 1, SARMAG, arch);
#endif
+ if (wrote != SARMAG)
+ return false;
if (makemap && hasobjects)
{
for (i = 0; i < sizeof (struct ar_hdr); i++)
if (((char *) (&hdr))[i] == '\0')
(((char *) (&hdr))[i]) = ' ';
- bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch);
- bfd_write (etable, 1, elength, arch);
+ if ((bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
+ != sizeof (struct ar_hdr))
+ || bfd_write (etable, 1, elength, arch) != elength)
+ return false;
if ((elength % 2) == 1)
- bfd_write ("\012", 1, 1, arch);
+ {
+ if (bfd_write ("\012", 1, 1, arch) != 1)
+ return false;
+ }
}
for (current = arch->archive_head; current; current = current->next)
remaining -= amt;
}
if ((arelt_size (current) % 2) == 1)
- bfd_write ("\012", 1, 1, arch);
+ {
+ if (bfd_write ("\012", 1, 1, arch) != 1)
+ return false;
+ }
}
/* Verify the timestamp in the archive file. If it would not be
for (i = 0; i < sizeof (struct ar_hdr); i++)
if (((char *) (&hdr))[i] == '\0')
(((char *) (&hdr))[i]) = ' ';
- bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch);
+ if (bfd_write ((char *) &hdr, 1, sizeof (struct ar_hdr), arch)
+ != sizeof (struct ar_hdr))
+ return false;
bfd_h_put_32 (arch, (bfd_vma) ranlibsize, (PTR) &temp);
- bfd_write (&temp, 1, sizeof (temp), arch);
+ if (bfd_write (&temp, 1, sizeof (temp), arch) != sizeof (temp))
+ return false;
for (count = 0; count < orl_count; count++)
{
last_elt = current;
bfd_h_put_32 (arch, ((map[count]).namidx), (PTR) &outs.s.string_offset);
bfd_h_put_32 (arch, firstreal, (PTR) &outs.file_offset);
- bfd_write ((char *) outp, 1, sizeof (outs), arch);
+ if (bfd_write ((char *) outp, 1, sizeof (outs), arch) != sizeof (outs))
+ return false;
}
/* now write the strings themselves */
bfd_h_put_32 (arch, stringsize, (PTR) &temp);
- bfd_write ((PTR) &temp, 1, sizeof (temp), arch);
+ if (bfd_write ((PTR) &temp, 1, sizeof (temp), arch) != sizeof (temp))
+ return false;
for (count = 0; count < orl_count; count++)
- bfd_write (*((map[count]).name), 1,
- strlen (*((map[count]).name)) + 1, arch);
+ {
+ size_t len = strlen (*map[count].name) + 1;
+
+ if (bfd_write (*map[count].name, 1, len, arch) != len)
+ return false;
+ }
/* The spec sez this should be a newline. But in order to be
bug-compatible for sun's ar we use a null. */
if (padit)
- bfd_write ("", 1, 1, arch);
+ {
+ if (bfd_write ("", 1, 1, arch) != 1)
+ return false;
+ }
return true;
}
(hdr.ar_date)[i] = ' ';
/* Write it into the file. */
- bfd_seek (arch, bfd_ardata (arch)->armap_datepos, SEEK_SET);
- if (bfd_write (hdr.ar_date, sizeof (hdr.ar_date), 1, arch)
- != sizeof (hdr.ar_date))
+ if (bfd_seek (arch, bfd_ardata (arch)->armap_datepos, SEEK_SET) != 0
+ || (bfd_write (hdr.ar_date, sizeof (hdr.ar_date), 1, arch)
+ != sizeof (hdr.ar_date)))
{
+ /* FIXME: bfd can't call perror. */
perror ("Writing updated armap timestamp");
return true; /* Some error while writing */
}
/* Write the ar header for this item and the number of symbols */
- bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), arch);
+ if (bfd_write ((PTR) &hdr, 1, sizeof (struct ar_hdr), arch)
+ != sizeof (struct ar_hdr))
+ return false;
bfd_write_bigendian_4byte_int (arch, symbol_count);
/* now write the strings themselves */
for (count = 0; count < symbol_count; count++)
- bfd_write ((PTR) * ((map[count]).name),
- 1,
- strlen (*((map[count]).name)) + 1, arch);
+ {
+ size_t len = strlen (*map[count].name) + 1;
+
+ if (bfd_write (*map[count].name, 1, len, arch) != len)
+ return false;
+ }
/* The spec sez this should be a newline. But in order to be
bug-compatible for arc960 we use a null. */
if (padit)
- bfd_write ("", 1, 1, arch);
+ {
+ if (bfd_write ("", 1, 1, arch) != 1)
+ return false;
+ }
return true;
}
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
!= EXEC_BYTES_SIZE) {
- bfd_set_error (bfd_error_wrong_format);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
return 0;
}
bout_swap_exec_header_out (abfd, exec_hdr (abfd), &swapped_hdr);
- bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
- bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd);
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || (bfd_write ((PTR) &swapped_hdr, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE))
+ return false;
/* Now write out reloc info, followed by syms and strings */
if (bfd_get_symcount (abfd) != 0)
{
- bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET);
+ if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*exec_hdr(abfd))), SEEK_SET)
+ != 0)
+ return false;
if (! aout_32_write_syms (abfd))
return false;
- bfd_seek (abfd, (file_ptr)(N_TROFF(*exec_hdr(abfd))), SEEK_SET);
+ if (bfd_seek (abfd, (file_ptr)(N_TROFF(*exec_hdr(abfd))), SEEK_SET) != 0)
+ return false;
if (!b_out_squirt_out_relocs (abfd, obj_textsec (abfd))) return false;
- bfd_seek (abfd, (file_ptr)(N_DROFF(*exec_hdr(abfd))), SEEK_SET);
+ if (bfd_seek (abfd, (file_ptr)(N_DROFF(*exec_hdr(abfd))), SEEK_SET)
+ != 0)
+ return false;
if (!b_out_squirt_out_relocs (abfd, obj_datasec (abfd))) return false;
}
}
/* regardless, once we know what we're doing, we might as well get going */
- bfd_seek (abfd, section->filepos + offset, SEEK_SET);
+ if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0)
+ return false;
if (count != 0) {
return (bfd_write ((PTR)location, 1, count, abfd) == count) ?true:false;
nread = bfd_read (buf, 1, 4, abfd);
if (nread != 4)
{
- /* Maybe the file is too small (FIXME: what about other errors). */
- bfd_set_error (bfd_error_wrong_format);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
return NULL;
}
crashinfo_offset = bfd_get_32 (abfd, buf);
nread = bfd_read (&crashinfo, 1, sizeof (crashinfo), abfd);
if (nread != sizeof (crashinfo))
{
- /* Maybe the file is too small (FIXME: what about other errors). */
- bfd_set_error (bfd_error_wrong_format);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
return NULL;
}
size = sizeof (h.hdr);
if (bfd_read(&h.hdr, 1, size, abfd) != size) {
- bfd_set_error (bfd_error_no_more_archived_files);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_no_more_archived_files);
return NULL;
}
size = atoi(h.hdr.ar_namlen); /* ar_name[] length */
size += size & 1;
if (bfd_read(&h.hdr._ar_name.ar_name[2], 1, size, abfd) != size) {
- bfd_set_error (bfd_error_no_more_archived_files);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_no_more_archived_files);
return NULL;
}
register struct artdata *art;
if (bfd_read (&hdr, sizeof (hdr), 1, abfd) != sizeof (hdr)) {
- bfd_set_error (bfd_error_wrong_format);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
return 0;
}
if (i != 16)
return false;
- bfd_seek (abfd, (file_ptr) -16, SEEK_CUR);
+ if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0)
+ return false;
/* Irix 4.0.5F apparently can use either an ECOFF armap or a
standard COFF armap. We could move the ECOFF armap stuff into
if (bfd_read ((PTR) raw_armap, 1, parsed_size, abfd) != parsed_size)
{
- bfd_set_error (bfd_error_malformed_archive);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_malformed_archive);
bfd_release (abfd, (PTR) raw_armap);
return false;
}
if (bfd_read ((PTR) armag, 1, SARMAG, abfd) != SARMAG
|| strncmp (armag, ARMAG, SARMAG) != 0)
{
- bfd_set_error (bfd_error_wrong_format);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
return (bfd_target *) NULL;
}
for (i = 0; i < phdr_cnt; i++)
{
elf_swap_phdr_out (abfd, i_phdrp + i, &x_phdr);
- bfd_seek (abfd, outbase, SEEK_SET);
- bfd_write ((PTR) & x_phdr, sizeof (x_phdr), 1, abfd);
+ if (bfd_seek (abfd, outbase, SEEK_SET) != 0
+ || (bfd_write ((PTR) & x_phdr, sizeof (x_phdr), 1, abfd)
+ != sizeof (x_phdr)))
+ return false;
outbase += sizeof (x_phdr);
}
elf_debug_file (i_ehdrp);
#endif
elf_swap_ehdr_out (abfd, i_ehdrp, &x_ehdr);
- bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
- bfd_write ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd);
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || (bfd_write ((PTR) & x_ehdr, sizeof (x_ehdr), 1, abfd)
+ != sizeof (x_ehdr)))
+ return false;
/* at this point we've concocted all the ELF sections... */
x_shdrp = (Elf_External_Shdr *)
#endif
elf_swap_shdr_out (abfd, i_shdrp[count], x_shdrp + count);
}
- bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET);
- bfd_write ((PTR) x_shdrp, sizeof (*x_shdrp), i_ehdrp->e_shnum, abfd);
+ if (bfd_seek (abfd, (file_ptr) i_ehdrp->e_shoff, SEEK_SET) != 0
+ || (bfd_write ((PTR) x_shdrp, sizeof (*x_shdrp), i_ehdrp->e_shnum, abfd)
+ != sizeof (*x_shdrp)))
+ return false;
+
/* need to dump the string table too... */
return true;
(*bed->elf_backend_section_processing) (abfd, i_shdrp[count]);
if (i_shdrp[count]->contents)
{
- bfd_seek (abfd, i_shdrp[count]->sh_offset, SEEK_SET);
- bfd_write (i_shdrp[count]->contents, i_shdrp[count]->sh_size, 1,
- abfd);
+ if (bfd_seek (abfd, i_shdrp[count]->sh_offset, SEEK_SET) != 0
+ || (bfd_write (i_shdrp[count]->contents, i_shdrp[count]->sh_size,
+ 1, abfd)
+ != i_shdrp[count]->sh_size))
+ return false;
}
}
if (asect->flags & SEC_CONSTRUCTOR)
return true;
- bfd_seek (abfd, asect->rel_filepos, SEEK_SET);
+ if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
+ return false;
native_relocs = (Elf_External_Rela *)
bfd_alloc (abfd, asect->reloc_count * sizeof (Elf_External_Rela));
if (!native_relocs)
bfd_set_error (bfd_error_no_memory);
return false;
}
- bfd_read ((PTR) native_relocs,
- sizeof (Elf_External_Rela), asect->reloc_count, abfd);
+ if (bfd_read ((PTR) native_relocs,
+ sizeof (Elf_External_Rela), asect->reloc_count, abfd)
+ != sizeof (Elf_External_Rela) * asect->reloc_count)
+ return false;
reloc_cache = (arelent *)
bfd_alloc (abfd, (size_t) (asect->reloc_count * sizeof (arelent)));
if (asect->flags & SEC_CONSTRUCTOR)
return true;
- bfd_seek (abfd, asect->rel_filepos, SEEK_SET);
+ if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
+ return false;
native_relocs = (Elf_External_Rel *)
bfd_alloc (abfd, asect->reloc_count * sizeof (Elf_External_Rel));
if (!native_relocs)
bfd_set_error (bfd_error_no_memory);
return false;
}
- bfd_read ((PTR) native_relocs,
- sizeof (Elf_External_Rel), asect->reloc_count, abfd);
+ if (bfd_read ((PTR) native_relocs,
+ sizeof (Elf_External_Rel), asect->reloc_count, abfd)
+ != sizeof (Elf_External_Rel) * asect->reloc_count)
+ return false;
reloc_cache = (arelent *)
bfd_alloc (abfd, (size_t) (asect->reloc_count * sizeof (arelent)));
/* this is really the sym table size but we store it in drelocs */
bfd_h_put_32 (abfd, bfd_get_symcount (abfd) * 12, exec_bytes.e_drelocs);
- bfd_seek (abfd, 0L, false);
- bfd_write ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd);
+ if (bfd_seek (abfd, 0L, false) != 0
+ || (bfd_write ((PTR) & exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+ != EXEC_BYTES_SIZE))
+ return false;
/* Write out the symbols, and then the relocs. We must write out
the symbols first so that we know the symbol indices. */
if (bfd_get_symcount (abfd) != 0)
{
- bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false);
-
+ if (bfd_seek (abfd, (long) (N_TRELOFF (*execp)), false) != 0)
+ return false;
if (!NAME (aout, squirt_out_relocs) (abfd, obj_textsec (abfd)))
return false;
- bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false);
-
+ if (bfd_seek (abfd, (long) (N_DRELOFF (*execp)), false) != 0)
+ return false;
if (!NAME (aout, squirt_out_relocs) (abfd, obj_datasec (abfd)))
return false;
}
return false;
}
syms = (struct external_nlist *) (strings + SYM_EXTRA_BYTES);
- bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET);
- if (bfd_read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes)
+ if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0
+ || bfd_read ((PTR) syms, symbol_bytes, 1, abfd) != symbol_bytes)
{
bfd_release (abfd, syms);
return false;
return false;
doit:
- bfd_seek (abfd, asect->rel_filepos, SEEK_SET);
+ if (bfd_seek (abfd, asect->rel_filepos, SEEK_SET) != 0)
+ return false;
each_size = obj_reloc_entry_size (abfd);
count = reloc_size / each_size;
val = bfd_read ((void *) &u, 1, sizeof u, abfd);
if (val != sizeof u)
{
- bfd_set_error (bfd_error_wrong_format);
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
return NULL;
}
case CORE_EXEC:
{
struct proc_exec proc_exec;
- bfd_read ((void *) &proc_exec, 1, core_header.len, abfd);
+ if (bfd_read ((void *) &proc_exec, 1, core_header.len, abfd)
+ != core_header.len)
+ break;
strncpy (core_command (abfd), proc_exec.cmd, MAXCOMLEN + 1);
}
break;
core_header.len,
(int) &proc_info - (int) &proc_info.hw_regs,
2);
- bfd_read (&proc_info, 1, core_header.len, abfd);
+ if (bfd_read (&proc_info, 1, core_header.len, abfd)
+ != core_header.len)
+ break;
core_signal (abfd) = proc_info.sig;
}
if (!core_regsec (abfd))
obj_reloc_entry_size (abfd)); \
NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
\
- bfd_seek (abfd, (file_ptr) 0, SEEK_SET); \
- bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd); \
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
+ if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
+ != EXEC_BYTES_SIZE) \
+ return false; \
/* Now write out reloc info, followed by syms and strings */ \
\
if (bfd_get_symcount (abfd) != 0) \
{ \
- bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET); \
+ if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) \
+ != 0) \
+ return false; \
\
if (! NAME(aout,write_syms)(abfd)) return false; \
\
- bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET); \
+ if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) \
+ != 0) \
+ return false; \
\
- if (!NAME(lynx,squirt_out_relocs) (abfd, obj_textsec (abfd))) return false; \
- bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET); \
+ if (!NAME(lynx,squirt_out_relocs) (abfd, obj_textsec (abfd))) \
+ return false; \
+ if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) \
+ != 0) \
+ return 0; \
\
- if (!NAME(lynx,squirt_out_relocs)(abfd, obj_datasec (abfd))) return false; \
+ if (!NAME(lynx,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
+ return false; \
} \
}
#endif
bfd *abfd;
bfd_byte byte;
{
- bfd_write ((PTR) & byte, 1, 1, abfd);
+ if (bfd_write ((PTR) & byte, 1, 1, abfd) != 1)
+ abort ();
}
static void
bfd_byte b[2];
b[1] = twobyte & 0xff;
b[0] = twobyte >> 8;
- bfd_write ((PTR) & b[0], 1, 2, abfd);
+ if (bfd_write ((PTR) & b[0], 1, 2, abfd) != 2)
+ abort ();
}
static void
buffer[0] = bytes >> 8;
buffer[1] = bytes & 0xff;
- bfd_write ((PTR) buffer, 1, 2, abfd);
+ if (bfd_write ((PTR) buffer, 1, 2, abfd) != 2)
+ abort ();
}
static void
{
BFD_FAIL ();
}
- bfd_write ((PTR) id, 1, length, abfd);
+ if (bfd_write ((PTR) id, 1, length, abfd) != length)
+ abort ();
}
\f
{
bfd_byte b[5];
ieee_write_int5 (b, value);
- bfd_write ((PTR) b, 1, 5, abfd);
+ if (bfd_write ((PTR) b, 1, 5, abfd) != 5)
+ abort ();
}
static boolean
}
ieee = IEEE_AR_DATA (abfd);
+ /* FIXME: Check return value. I'm not sure whether it needs to read
+ the entire buffer or not. */
bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
ieee->h.first_byte = buffer;
{
/* Past half way, reseek and reprime */
buffer_offset += ieee_pos (abfd);
- bfd_seek (abfd, buffer_offset, SEEK_SET);
+ if (bfd_seek (abfd, buffer_offset, SEEK_SET) != 0)
+ return NULL;
+ /* FIXME: Check return value. I'm not sure whether it
+ needs to read the entire buffer or not. */
bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
ieee->h.first_byte = buffer;
ieee->h.input_p = buffer;
for (i = 2; i < ieee->element_count; i++)
{
- bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET);
+ if (bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET) != 0)
+ return NULL;
+ /* FIXME: Check return value. I'm not sure whether it needs to
+ read the entire buffer or not. */
bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
ieee->h.first_byte = buffer;
ieee->h.input_p = buffer;
ieee_mkobject (abfd);
ieee = IEEE_DATA (abfd);
- bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ goto fail;
/* Read the first few bytes in to see if it makes sense */
+ /* FIXME: Check return value. I'm not sure whether it needs to read
+ the entire buffer or not. */
bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
ieee->h.input_p = buffer;
bfd_set_error (bfd_error_no_memory);
goto fail;
}
- bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ goto fail;
+ /* FIXME: Check return value. I'm not sure whether it needs to read
+ the entire buffer or not. */
bfd_read ((PTR) (IEEE_DATA (abfd)->h.first_byte), 1, ieee->w.r.me_record + 50, abfd);
ieee_slurp_sections (abfd);
ieee_write_byte (abfd, ieee_load_constant_bytes_enum);
/* Output a stream of bytes */
ieee_write_int (abfd, run);
- bfd_write ((PTR) (stream + current_byte_index),
- 1,
- run,
- abfd);
+ if (bfd_write ((PTR) (stream + current_byte_index),
+ 1,
+ run,
+ abfd)
+ != run)
+ return false;
current_byte_index += run;
}
}
{
/* Output a stream of bytes */
ieee_write_int (abfd, run);
- bfd_write ((PTR) (stream + current_byte_index),
- 1,
- run,
- abfd);
+ if (bfd_write ((PTR) (stream + current_byte_index),
+ 1,
+ run,
+ abfd)
+ != run)
+ return false;
current_byte_index += run;
}
/* Output any relocations here */
static void
fill ()
{
+ /* FIXME: Check return value. I'm not sure whether it needs to read
+ the entire buffer or not. */
bfd_read ((PTR) input_ptr_start, 1, input_ptr_end - input_ptr_start, input_bfd);
input_ptr = input_ptr_start;
}
static void
flush ()
{
- bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start, output_bfd);
+ if (bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start,
+ output_bfd)
+ != output_ptr - output_ptr_start)
+ abort ();
output_ptr = output_ptr_start;
output_buffer++;
}
input_ptr_start = input_ptr = input_buffer;
input_ptr_end = input_buffer + IBS;
input_bfd = input;
+ /* FIXME: Check return value. I'm not sure whether it needs to read
+ the entire buffer or not. */
bfd_read ((PTR) input_ptr_start, 1, IBS, input);
block ();
}
ieee_data_type *entry_ieee = IEEE_DATA (entry);
if (entry_ieee->w.r.debug_information_part)
{
- bfd_seek (entry, entry_ieee->w.r.debug_information_part, SEEK_SET);
+ if (bfd_seek (entry, entry_ieee->w.r.debug_information_part,
+ SEEK_SET)
+ != 0)
+ abort ();
relocate_debug (abfd, entry);
}
unsigned int i;
file_ptr old;
/* Fast forward over the header area */
- bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ return false;
ieee_write_byte (abfd, ieee_module_beginning_enum);
ieee_write_id (abfd, bfd_printable_name (abfd));
(bfd_byte) (bfd_arch_bits_per_address (abfd) / bfd_arch_bits_per_byte (abfd)));
old = bfd_tell (abfd);
- bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR);
+ if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0)
+ return false;
ieee->w.r.extension_record = bfd_tell (abfd);
- bfd_write ((char *) exten, 1, sizeof (exten), abfd);
+ if (bfd_write ((char *) exten, 1, sizeof (exten), abfd) != sizeof (exten))
+ return false;
if (abfd->flags & EXEC_P)
ieee_write_byte (abfd, 0x1);/* Absolute */
else
ieee_write_byte (abfd, 0x2);/* Relocateable */
ieee->w.r.environmental_record = bfd_tell (abfd);
- bfd_write ((char *) envi, 1, sizeof (envi), abfd);
+ if (bfd_write ((char *) envi, 1, sizeof (envi), abfd) != sizeof (envi))
+ return false;
output_bfd = abfd;
flush ();
/* Generate the header */
- bfd_seek (abfd, old, SEEK_SET);
+ if (bfd_seek (abfd, old, SEEK_SET) != 0)
+ return false;
for (i = 0; i < N_W_VARIABLES; i++)
{
val = bfd_read ((PTR)&coreout, 1, sizeof coreout, abfd);
if (val != sizeof coreout)
- return 0;
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ bfd_set_error (bfd_error_wrong_format);
+ return 0;
+ }
if (coreout.c_magic != CORE_MAGIC
|| coreout.c_version != CORE_VERSION1)
strncpy (core_command (abfd), coreout.c_name, CORE_NAMESIZE);
core_signal (abfd) = coreout.c_sigcause;
- bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET);
+ if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0)
+ return NULL;
for (i = 0; i < coreout.c_nvmap; i++)
{
|| idf->i_offset + idf->i_len != ids->i_offset)
return 0; /* Can't deal with non-contig regs */
- bfd_seek (abfd, idg->i_offset, SEEK_SET);
+ if (bfd_seek (abfd, idg->i_offset, SEEK_SET) != 0)
+ return NULL;
make_bfd_asection (abfd, ".reg",
SEC_ALLOC+SEC_HAS_CONTENTS,
obj_reloc_entry_size (abfd)); \
NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes); \
\
- bfd_seek (abfd, (file_ptr) 0, SEEK_SET); \
- bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd); \
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false; \
+ if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) \
+ != EXEC_BYTES_SIZE) \
+ return false; \
/* Now write out reloc info, followed by syms and strings */ \
\
if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \
&& bfd_get_symcount (abfd) != 0) \
{ \
- bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET); \
+ if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) \
+ != 0) \
+ return false; \
\
if (! NAME(aout,write_syms)(abfd)) return false; \
\
- bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET); \
+ if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) \
+ != 0) \
+ return false; \
\
- if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) return false; \
- bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET); \
+ if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd))) \
+ return false; \
+ if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) \
+ != 0) \
+ return false; \
\
- if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) return false; \
+ if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd))) \
+ return false; \
} \
}
#endif
{
bfd_byte buffer[4];
bfd_putb32(i, buffer);
- bfd_write((PTR)buffer, 4, 1, abfd);
+ if (bfd_write((PTR)buffer, 4, 1, abfd) != 4)
+ abort ();
}
long
/* Read the reloc from the file. */
if (bfd_read (&ext, sizeof ext, 1, abfd) != sizeof ext)
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
+ return false;
/* Swap in the fields. */
l_vaddr = bfd_h_get_32 (abfd, ext.l_vaddr);
if (bfd_read ((PTR) &symlength, sizeof (symlength), 1, abfd)
!= sizeof (symlength))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
sym -> symbol.the_bfd = abfd;
name = bfd_alloc (abfd, symlength + 1);
if (name == NULL)
return false;
}
if (bfd_read (name, symlength, 1, abfd) != symlength)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
name[symlength] = '\0';
sym -> symbol.name = name;
sym -> symbol.flags = 0;
sym -> symbol.value = 0;
sym -> symbol.section = &bfd_und_section;
if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
rcount = bfd_h_get_32 (abfd, temp);
nlm_relocs = ((struct nlm_relent *)
bfd_alloc (abfd, rcount * sizeof (struct nlm_relent)));
len = strlen (sym->name);
if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd) != sizeof(bfd_byte))
|| bfd_write (sym->name, len, 1, abfd) != len)
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
+ return false;
bfd_put_32 (abfd, count, temp);
if (bfd_write (temp, sizeof(temp), 1, abfd) != sizeof (temp))
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
+ return false;
for (i = 0; i < count; i++)
{
if (bfd_read ((PTR) x_fxdhdr, nlm_fixed_header_size (abfd), 1, abfd) !=
nlm_fixed_header_size (abfd))
- goto got_wrong_format_error;
+ {
+ if (bfd_get_error () != bfd_error_system_call)
+ goto got_wrong_format_error;
+ else
+ goto got_no_match;
+ }
/* Allocate an instance of the nlm_obj_tdata structure and hook it up to
the tdata pointer in the bfd. */
sizeof (nlm_variable_header (abfd)->descriptionLength),
1, abfd) !=
sizeof (nlm_variable_header (abfd)->descriptionLength))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
if (bfd_read ((PTR) nlm_variable_header (abfd)->descriptionText,
nlm_variable_header (abfd)->descriptionLength + 1,
1, abfd) !=
nlm_variable_header (abfd)->descriptionLength + 1)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
/* Read and convert the stackSize field. */
if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
nlm_variable_header (abfd)->stackSize = get_word (abfd, (bfd_byte *) temp);
/* Read and convert the reserved field. */
if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
nlm_variable_header (abfd)->reserved = get_word (abfd, (bfd_byte *) temp);
/* Read the oldThreadName field. This field is a fixed length string. */
sizeof (nlm_variable_header (abfd)->oldThreadName),
1, abfd) !=
sizeof (nlm_variable_header (abfd)->oldThreadName))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
/* Read the screen name length and text members. */
sizeof (nlm_variable_header (abfd)->screenNameLength),
1, abfd) !=
sizeof (nlm_variable_header (abfd)->screenNameLength))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
if (bfd_read ((PTR) nlm_variable_header (abfd)->screenName,
nlm_variable_header (abfd)->screenNameLength + 1,
1, abfd) !=
nlm_variable_header (abfd)->screenNameLength + 1)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
/* Read the thread name length and text members. */
sizeof (nlm_variable_header (abfd)->threadNameLength),
1, abfd) !=
sizeof (nlm_variable_header (abfd)->threadNameLength))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
if (bfd_read ((PTR) nlm_variable_header (abfd)->threadName,
nlm_variable_header (abfd)->threadNameLength + 1,
1, abfd) !=
nlm_variable_header (abfd)->threadNameLength + 1)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
return (true);
}
sizeof (nlm_variable_header (abfd)->descriptionLength),
1, abfd) !=
sizeof (nlm_variable_header (abfd)->descriptionLength))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
if (bfd_write ((PTR) nlm_variable_header (abfd)->descriptionText,
nlm_variable_header (abfd)->descriptionLength + 1,
1, abfd) !=
nlm_variable_header (abfd)->descriptionLength + 1)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
/* Convert and write the stackSize field. */
put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->stackSize,
(bfd_byte *) temp);
if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
/* Convert and write the reserved field. */
put_word (abfd, (bfd_vma) nlm_variable_header (abfd)->reserved,
(bfd_byte *) temp);
if (bfd_write ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
/* Write the oldThreadName field. This field is a fixed length string. */
sizeof (nlm_variable_header (abfd)->oldThreadName),
1, abfd) !=
sizeof (nlm_variable_header (abfd)->oldThreadName))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
/* Write the screen name length and text members. */
sizeof (nlm_variable_header (abfd)->screenNameLength),
1, abfd) !=
sizeof (nlm_variable_header (abfd)->screenNameLength))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
if (bfd_write ((PTR) nlm_variable_header (abfd)->screenName,
nlm_variable_header (abfd)->screenNameLength + 1,
1, abfd) !=
nlm_variable_header (abfd)->screenNameLength + 1)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
/* Write the thread name length and text members. */
sizeof (nlm_variable_header (abfd)->threadNameLength),
1, abfd) !=
sizeof (nlm_variable_header (abfd)->threadNameLength))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
if (bfd_write ((PTR) nlm_variable_header (abfd)->threadName,
nlm_variable_header (abfd)->threadNameLength + 1,
1, abfd) !=
nlm_variable_header (abfd)->threadNameLength + 1)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
return (true);
}
position = bfd_tell (abfd);
if (bfd_read ((PTR) tempstr, sizeof (tempstr), 1, abfd) !=
sizeof (tempstr))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
if (bfd_seek (abfd, position, SEEK_SET) == -1)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
if (strncmp (tempstr, "VeRsIoN#", 8) == 0)
{
Nlm_External_Version_Header thdr;
if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
memcpy (nlm_version_header (abfd)->stamp, thdr.stamp,
sizeof (thdr.stamp));
nlm_version_header (abfd)->majorVersion =
{
Nlm_External_Extended_Header thdr;
if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
memcpy (nlm_extended_header (abfd)->stamp, thdr.stamp,
sizeof (thdr.stamp));
nlm_extended_header (abfd)->languageID =
{
Nlm_External_Custom_Header thdr;
if (bfd_read ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
memcpy (nlm_custom_header (abfd)->stamp, thdr.stamp,
sizeof (thdr.stamp));
nlm_custom_header (abfd)->dataLength =
sizeof (nlm_copyright_header (abfd)->stamp),
1, abfd)
!= sizeof (nlm_copyright_header (abfd)->stamp))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
if (bfd_read ((PTR) & (nlm_copyright_header (abfd)
->copyrightMessageLength),
1, 1, abfd) != 1)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
/* The copyright message is a variable length string. */
if (bfd_read ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
nlm_copyright_header (abfd)->copyrightMessageLength + 1,
1, abfd) !=
nlm_copyright_header (abfd)->copyrightMessageLength + 1)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
}
else
{
put_word (abfd, (bfd_vma) nlm_version_header (abfd)->day,
(bfd_byte *) thdr.day);
if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
+ return false;
}
/* Write out the extended header if there is one. */
(bfd_vma) nlm_extended_header (abfd)->reserved5,
(bfd_byte *) thdr.reserved5);
if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
+ return false;
}
/* Write out the custom header if there is one. */
put_word (abfd, (bfd_vma) nlm_custom_header (abfd)->debugRecLength,
(bfd_byte *) thdr.debugRecLength);
if (bfd_write ((PTR) & thdr, sizeof (thdr), 1, abfd) != sizeof (thdr))
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
+ return false;
}
/* Write out the copyright header if there is one. */
memcpy (thdr.stamp, "CoPyRiGhT=", 10);
if (bfd_write ((PTR) thdr.stamp, sizeof (thdr.stamp), 1, abfd)
!= sizeof (thdr.stamp))
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
+ return false;
thdr.copyrightMessageLength[0] =
nlm_copyright_header (abfd)->copyrightMessageLength;
if (bfd_write ((PTR) thdr.copyrightMessageLength, 1, 1, abfd) != 1)
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
+ return false;
/* The copyright message is a variable length string. */
if (bfd_write ((PTR) nlm_copyright_header (abfd)->copyrightMessage,
nlm_copyright_header (abfd)->copyrightMessageLength + 1,
1, abfd) !=
nlm_copyright_header (abfd)->copyrightMessageLength + 1)
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
+ return false;
}
return true;
}
if (bfd_seek (abfd, i_fxdhdrp->publicsOffset, SEEK_SET) == -1)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
sym = ((nlm_symbol_type *)
bfd_zalloc (abfd, totsymcount * sizeof (nlm_symbol_type)));
{
if (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd)
!= sizeof (symlength))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
sym->symbol.the_bfd = abfd;
sym->symbol.name = bfd_alloc (abfd, symlength + 1);
if (!sym->symbol.name)
}
if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
!= symlength)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
/* Cast away const. */
((char *) (sym->symbol.name))[symlength] = '\0';
if (bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp))
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
sym->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
sym->symbol.value = get_word (abfd, temp);
if (set_public_section_func)
if (i_fxdhdrp->numberOfDebugRecords > 0)
{
if (bfd_seek (abfd, i_fxdhdrp->debugInfoOffset, SEEK_SET) == -1)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
symcount += i_fxdhdrp->numberOfDebugRecords;
while (abfd->symcount < symcount)
|| bfd_read ((PTR) temp, sizeof (temp), 1, abfd) != sizeof (temp)
|| (bfd_read ((PTR) & symlength, sizeof (symlength), 1, abfd)
!= sizeof (symlength)))
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
+ return false;
sym->symbol.the_bfd = abfd;
sym->symbol.name = bfd_alloc (abfd, symlength + 1);
if (!sym->symbol.name)
}
if (bfd_read ((PTR) sym->symbol.name, symlength, 1, abfd)
!= symlength)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
/* Cast away const. */
((char *) (sym->symbol.name))[symlength] = '\0';
sym->symbol.flags = BSF_LOCAL;
{
if (bfd_seek (abfd, i_fxdhdrp->externalReferencesOffset, SEEK_SET)
== -1)
- {
- bfd_set_error (bfd_error_system_call);
- return (false);
- }
+ return (false);
symcount += i_fxdhdrp->numberOfExternalReferences;
while (abfd->symcount < symcount)
if (bfd_seek (abfd, nlm_fixed_header (abfd)->relocationFixupOffset,
SEEK_SET) != 0)
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
+ return false;
count = nlm_fixed_header (abfd)->numberOfRelocationFixups;
rels = (arelent *) bfd_alloc (abfd, count * sizeof (arelent));
if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0
|| bfd_write (location, 1, count, abfd) != count)
- {
- bfd_set_error (bfd_error_system_call);
- return false;
- }
+ return false;
return true;
}
if (bfd_seek (abfd,
nlm_optional_prefix_size (abfd) + nlm_fixed_header_size (abfd),
SEEK_SET) != 0)
- {
- bfd_set_error (bfd_error_system_call);
- goto error_return;
- }
+ goto error_return;
if (nlm_swap_variable_header_out (abfd) == false
|| nlm_swap_auxiliary_headers_out (abfd) == false)
{
/* Advance to the relocs. */
if (bfd_seek (abfd, nlm_fixed_header (abfd)->relocationFixupOffset,
SEEK_SET) != 0)
- {
- bfd_set_error (bfd_error_system_call);
- goto error_return;
- }
+ goto error_return;
/* The format of the relocation entries is dependent upon the
particular target. We use an external routine to write the reloc
if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd)
!= sizeof (bfd_byte))
|| bfd_write (sym->name, len, 1, abfd) != len)
- {
- bfd_set_error (bfd_error_system_call);
- goto error_return;
- }
+ goto error_return;
put_word (abfd, offset, temp);
if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
- {
- bfd_set_error (bfd_error_system_call);
- goto error_return;
- }
+ goto error_return;
}
}
nlm_fixed_header (abfd)->numberOfPublics = c;
/* The type is 0 for data, 1 for code, 2 for absolute. */
if (bfd_write (&type, sizeof (bfd_byte), 1, abfd)
!= sizeof (bfd_byte))
- {
- bfd_set_error (bfd_error_system_call);
- goto error_return;
- }
+ goto error_return;
put_word (abfd, offset, temp);
if (bfd_write (temp, sizeof (temp), 1, abfd) != sizeof (temp))
- {
- bfd_set_error (bfd_error_system_call);
- goto error_return;
- }
+ goto error_return;
len = strlen (sym->name);
if ((bfd_write (&len, sizeof (bfd_byte), 1, abfd)
!= sizeof (bfd_byte))
|| bfd_write (sym->name, len, 1, abfd) != len)
- {
- bfd_set_error (bfd_error_system_call);
- goto error_return;
- }
+ goto error_return;
}
nlm_fixed_header (abfd)->numberOfDebugRecords = c;
}
nlm_swap_fixed_header_out (abfd, nlm_fixed_header (abfd), fixed_header);
if (bfd_write (fixed_header, nlm_fixed_header_size (abfd), 1, abfd)
!= nlm_fixed_header_size (abfd))
- {
- bfd_set_error (bfd_error_system_call);
- goto error_return;
- }
+ goto error_return;
if (fixed_header != NULL)
free (fixed_header);
boolean eof = false;
/* To the front of the file */
- bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
+ abort ();
while (eof == false)
{
char buffer[MAXCHUNK];
src++;
/* Fetch the type and the length and the checksum */
- bfd_read (src, 1, 5, abfd);
+ if (bfd_read (src, 1, 5, abfd) != 5)
+ abort (); /* FIXME */
type = src[2];
chars_on_line = HEX (src) - 5; /* Already read five char */
- bfd_read (src, 1, chars_on_line, abfd);
+ if (bfd_read (src, 1, chars_on_line, abfd) != chars_on_line)
+ abort (); /* FIXME */
src[chars_on_line] = 0; /* put a null at the end */
func (abfd, type, src);
tekhex_init ();
- bfd_seek (abfd, (file_ptr) 0, SEEK_SET);
- bfd_read (b, 1, 4, abfd);
+ if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
+ || bfd_read (b, 1, 4, abfd) != 4)
+ return NULL;
if (b[0] != '%' || !ISHEX (b[1]) || !ISHEX (b[2]) || !ISHEX (b[3]))
return (bfd_target *) NULL;
sum += sum_block[front[2]];
sum += sum_block[front[3]]; /* type */
TOHEX (front + 4, sum);
- bfd_write (front, 1, 6, abfd);
+ if (bfd_write (front, 1, 6, abfd) != 6)
+ abort ();
end[0] = '\n';
- bfd_write (start, 1, end - start + 1, abfd);
-
+ if (bfd_write (start, 1, end - start + 1, abfd) != end - start + 1)
+ abort ();
}
static boolean
}
/* And the terminator */
- bfd_write ("%7081010\n", 1, 9, abfd);
+ if (bfd_write ("%7081010\n", 1, 9, abfd) != 9)
+ abort ();
return true;
}