/* Support for the generic parts of COFF, for BFD.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001
+ 2000, 2001, 2002
Free Software Foundation, Inc.
Written by Cygnus Support.
flagword oflags = abfd->flags;
bfd_vma ostart = bfd_get_start_address (abfd);
PTR tdata;
+ PTR tdata_save;
bfd_size_type readsize; /* length of file_info */
unsigned int scnhsz;
char *external_sections;
/* Set up the tdata area. ECOFF uses its own routine, and overrides
abfd->flags. */
+ tdata_save = abfd->tdata.any;
tdata = bfd_coff_mkobject_hook (abfd, (PTR) internal_f, (PTR) internal_a);
if (tdata == NULL)
- return 0;
+ goto fail2;
scnhsz = bfd_coff_scnhsz (abfd);
readsize = (bfd_size_type) nscns * scnhsz;
/* Set the arch/mach *before* swapping in sections; section header swapping
may depend on arch/mach info. */
- if (bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f) == false)
+ if (! bfd_coff_set_arch_mach_hook (abfd, (PTR) internal_f))
goto fail;
/* Now copy data as required; construct all asections etc */
fail:
bfd_release (abfd, tdata);
+ fail2:
+ abfd->tdata.any = tdata_save;
abfd->flags = oflags;
bfd_get_start_address (abfd) = ostart;
return (const bfd_target *) NULL;
filehdr = bfd_alloc (abfd, filhsz);
if (filehdr == NULL)
- return 0;
+ return NULL;
if (bfd_bread (filehdr, filhsz, abfd) != filhsz)
{
if (bfd_get_error () != bfd_error_system_call)
bfd_set_error (bfd_error_wrong_format);
- return 0;
+ bfd_release (abfd, filehdr);
+ return NULL;
}
bfd_coff_swap_filehdr_in (abfd, filehdr, &internal_f);
bfd_release (abfd, filehdr);
only read in f_opthdr bytes in the call to bfd_bread. We should
also attempt to catch corrupt or non-COFF binaries with a strange
value for f_opthdr. */
- if (bfd_coff_bad_format_hook (abfd, &internal_f) == false
+ if (! bfd_coff_bad_format_hook (abfd, &internal_f)
|| internal_f.f_opthdr > aoutsz)
{
bfd_set_error (bfd_error_wrong_format);
- return 0;
+ return NULL;
}
nscns = internal_f.f_nscns;
opthdr = bfd_alloc (abfd, aoutsz);
if (opthdr == NULL)
- return 0;
+ return NULL;
if (bfd_bread (opthdr, (bfd_size_type) internal_f.f_opthdr, abfd)
!= internal_f.f_opthdr)
{
- return 0;
+ bfd_release (abfd, opthdr);
+ return NULL;
}
bfd_coff_swap_aouthdr_in (abfd, opthdr, (PTR) &internal_a);
+ bfd_release (abfd, opthdr);
}
return coff_real_object_p (abfd, nscns, &internal_f,
combined_entry_type e[10];
};
struct foo *f;
- f = (struct foo *) bfd_alloc (abfd, (bfd_size_type) sizeof (*f));
+
+ f = (struct foo *) bfd_zalloc (abfd, (bfd_size_type) sizeof (*f));
if (!f)
{
bfd_set_error (bfd_error_no_error);
return NULL;
}
- memset ((char *) f, 0, sizeof (*f));
coff_symbol_from (abfd, sym)->native = csym = f->e;
}
csym[0].u.syment.n_sclass = C_STAT;
if (internal_ptr->u.syment._n._n_name[i] == '\0')
break;
- newstring = (PTR) bfd_alloc (abfd, (bfd_size_type) (i + 1));
+ newstring = (PTR) bfd_zalloc (abfd, (bfd_size_type) (i + 1));
if (newstring == NULL)
return (NULL);
- memset (newstring, 0, i + 1);
strncpy (newstring, internal_ptr->u.syment._n._n_name, i);
internal_ptr->u.syment._n._n_n._n_offset = (long int) newstring;
internal_ptr->u.syment._n._n_n._n_zeroes = 0;
bfd *abfd;
{
bfd_size_type amt = sizeof (coff_symbol_type);
- coff_symbol_type *new = (coff_symbol_type *) bfd_alloc (abfd, amt);
+ coff_symbol_type *new = (coff_symbol_type *) bfd_zalloc (abfd, amt);
if (new == NULL)
return (NULL);
- memset (new, 0, sizeof *new);
new->symbol.section = 0;
new->native = 0;
new->lineno = (alent *) NULL;
next = auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l;
llnos = auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_lnnoptr;
fprintf (file,
- _("AUX tagndx %ld ttlsiz 0x%lx lnnos %ld next %ld"),
+ "AUX tagndx %ld ttlsiz 0x%lx lnnos %ld next %ld",
tagndx, auxp->u.auxent.x_sym.x_misc.x_fsize,
llnos, next);
break;
bfd *abfd ATTRIBUTE_UNUSED;
const char *name;
{
- return name[0] == '.' && name[1] == 'L';
+ return (boolean) (name[0] == '.' && name[1] == 'L');
}
/* Provided a BFD, a section and an offset (in bytes, not octets) into the
{
size_t size;
- if (reloc == false)
+ if (! reloc)
{
size = bfd_coff_filhsz (abfd) + bfd_coff_aoutsz (abfd);
}
combined_entry_type * native;
bfd_size_type amt = sizeof (* native);
- native = (combined_entry_type *) bfd_alloc (abfd, amt);
+ native = (combined_entry_type *) bfd_zalloc (abfd, amt);
if (native == NULL)
return false;
- memset (native, 0, sizeof (* native));
-
native->u.syment.n_type = T_NULL;
native->u.syment.n_sclass = class;