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,
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);
}