aboutsummaryrefslogtreecommitdiff
path: root/bfd/pef.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2013-01-26 02:08:01 +0000
committerAlan Modra <amodra@gmail.com>2013-01-26 02:08:01 +0000
commitc9ba0c87bf3595762506825b30f0ebcb9da53129 (patch)
tree9de13a5457cd32f950d7d63cf1b2bb0fc000779b /bfd/pef.c
parent39c88814382afb7476b342dc3e1333171d72a144 (diff)
downloadfsf-binutils-gdb-c9ba0c87bf3595762506825b30f0ebcb9da53129.zip
fsf-binutils-gdb-c9ba0c87bf3595762506825b30f0ebcb9da53129.tar.gz
fsf-binutils-gdb-c9ba0c87bf3595762506825b30f0ebcb9da53129.tar.bz2
* bfd.c (struct bfd_preserve, bfd_preserve_save, bfd_preserve_restore,
bfd_preserve_finish): Move to.. * format.c: ..here, splitting out.. (bfd_reinit): ..this. New function. (bfd_check_format_matches): Use bfd_preserve_save/restore to keep bfd state for a match. * elfcode.h (elf_object_p): Don't use bfd_preserve_save/restore. * elfcore.h (elf_core_file_p): Likewise. * mach-o.c (bfd_mach_o_header_p): Likewise. * pef.c (bfd_pef_object_p, bfd_pef_xlib_object_p): Likewise. * xsym.c (bfd_sym_object_p): Likewise. * mmo.c (mmo_scan): Clear abfd->symcount. * opncls.c (_bfd_new_bfd): Use a smaller section hash table. * section.c (bfd_section_list_clear): Clear section_htab.count. * bfd-in2.h: Regenerate.
Diffstat (limited to 'bfd/pef.c')
-rw-r--r--bfd/pef.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/bfd/pef.c b/bfd/pef.c
index ca4c454..6c52e0f 100644
--- a/bfd/pef.c
+++ b/bfd/pef.c
@@ -583,34 +583,28 @@ bfd_pef_read_header (bfd *abfd, bfd_pef_header *header)
static const bfd_target *
bfd_pef_object_p (bfd *abfd)
{
- struct bfd_preserve preserve;
bfd_pef_header header;
+ bfd_pef_data_struct *mdata;
- preserve.marker = NULL;
if (bfd_pef_read_header (abfd, &header) != 0)
goto wrong;
if (header.tag1 != BFD_PEF_TAG1 || header.tag2 != BFD_PEF_TAG2)
goto wrong;
- preserve.marker = bfd_zalloc (abfd, sizeof (bfd_pef_data_struct));
- if (preserve.marker == NULL
- || !bfd_preserve_save (abfd, &preserve))
+ mdata = (bfd_pef_data_struct *) bfd_zalloc (abfd, sizeof (*mdata));
+ if (mdata == NULL)
goto fail;
- if (bfd_pef_scan (abfd, &header,
- (bfd_pef_data_struct *) preserve.marker) != 0)
+ if (bfd_pef_scan (abfd, &header, mdata))
goto wrong;
- bfd_preserve_finish (abfd, &preserve);
return abfd->xvec;
wrong:
bfd_set_error (bfd_error_wrong_format);
fail:
- if (preserve.marker != NULL)
- bfd_preserve_restore (abfd, &preserve);
return NULL;
}
@@ -1124,7 +1118,6 @@ bfd_pef_xlib_scan (bfd *abfd, bfd_pef_xlib_header *header)
static const bfd_target *
bfd_pef_xlib_object_p (bfd *abfd)
{
- struct bfd_preserve preserve;
bfd_pef_xlib_header header;
if (bfd_pef_xlib_read_header (abfd, &header) != 0)
@@ -1141,20 +1134,12 @@ bfd_pef_xlib_object_p (bfd *abfd)
return NULL;
}
- if (! bfd_preserve_save (abfd, &preserve))
- {
- bfd_set_error (bfd_error_wrong_format);
- return NULL;
- }
-
if (bfd_pef_xlib_scan (abfd, &header) != 0)
{
- bfd_preserve_restore (abfd, &preserve);
bfd_set_error (bfd_error_wrong_format);
return NULL;
}
- bfd_preserve_finish (abfd, &preserve);
return abfd->xvec;
}