summaryrefslogtreecommitdiff
path: root/bfd/bfd.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2013-01-26 02:07:58 +0000
committerAlan Modra <amodra@bigpond.net.au>2013-01-26 02:07:58 +0000
commit2f8f5697e4df9a119ea0c71aa920756e72fd1775 (patch)
tree57903d4313b74fb72a7e9517d2db57f77d8ed7b3 /bfd/bfd.c
parent3efc239754ec850208ad8200747f6c5694ea2c82 (diff)
downloadgdb-2f8f5697e4df9a119ea0c71aa920756e72fd1775.tar.gz
* 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/bfd.c')
-rw-r--r--bfd/bfd.c122
1 files changed, 0 insertions, 122 deletions
diff --git a/bfd/bfd.c b/bfd/bfd.c
index eed18960855..cf50b709238 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1687,128 +1687,6 @@ bfd_alt_mach_code (bfd *abfd, int alternative)
}
/*
-CODE_FRAGMENT
-
-.struct bfd_preserve
-.{
-. void *marker;
-. void *tdata;
-. flagword flags;
-. const struct bfd_arch_info *arch_info;
-. struct bfd_section *sections;
-. struct bfd_section *section_last;
-. unsigned int section_count;
-. struct bfd_hash_table section_htab;
-.};
-.
-*/
-
-/*
-FUNCTION
- bfd_preserve_save
-
-SYNOPSIS
- bfd_boolean bfd_preserve_save (bfd *, struct bfd_preserve *);
-
-DESCRIPTION
- When testing an object for compatibility with a particular
- target back-end, the back-end object_p function needs to set
- up certain fields in the bfd on successfully recognizing the
- object. This typically happens in a piecemeal fashion, with
- failures possible at many points. On failure, the bfd is
- supposed to be restored to its initial state, which is
- virtually impossible. However, restoring a subset of the bfd
- state works in practice. This function stores the subset and
- reinitializes the bfd.
-
-*/
-
-bfd_boolean
-bfd_preserve_save (bfd *abfd, struct bfd_preserve *preserve)
-{
- preserve->tdata = abfd->tdata.any;
- preserve->arch_info = abfd->arch_info;
- preserve->flags = abfd->flags;
- preserve->sections = abfd->sections;
- preserve->section_last = abfd->section_last;
- preserve->section_count = abfd->section_count;
- preserve->section_htab = abfd->section_htab;
-
- if (! bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc,
- sizeof (struct section_hash_entry)))
- return FALSE;
-
- abfd->tdata.any = NULL;
- abfd->arch_info = &bfd_default_arch_struct;
- abfd->flags &= BFD_FLAGS_SAVED;
- abfd->sections = NULL;
- abfd->section_last = NULL;
- abfd->section_count = 0;
-
- return TRUE;
-}
-
-/*
-FUNCTION
- bfd_preserve_restore
-
-SYNOPSIS
- void bfd_preserve_restore (bfd *, struct bfd_preserve *);
-
-DESCRIPTION
- This function restores bfd state saved by bfd_preserve_save.
- If MARKER is non-NULL in struct bfd_preserve then that block
- and all subsequently bfd_alloc'd memory is freed.
-
-*/
-
-void
-bfd_preserve_restore (bfd *abfd, struct bfd_preserve *preserve)
-{
- bfd_hash_table_free (&abfd->section_htab);
-
- abfd->tdata.any = preserve->tdata;
- abfd->arch_info = preserve->arch_info;
- abfd->flags = preserve->flags;
- abfd->section_htab = preserve->section_htab;
- abfd->sections = preserve->sections;
- abfd->section_last = preserve->section_last;
- abfd->section_count = preserve->section_count;
-
- /* bfd_release frees all memory more recently bfd_alloc'd than
- its arg, as well as its arg. */
- if (preserve->marker != NULL)
- {
- bfd_release (abfd, preserve->marker);
- preserve->marker = NULL;
- }
-}
-
-/*
-FUNCTION
- bfd_preserve_finish
-
-SYNOPSIS
- void bfd_preserve_finish (bfd *, struct bfd_preserve *);
-
-DESCRIPTION
- This function should be called when the bfd state saved by
- bfd_preserve_save is no longer needed. ie. when the back-end
- object_p function returns with success.
-
-*/
-
-void
-bfd_preserve_finish (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_preserve *preserve)
-{
- /* It would be nice to be able to free more memory here, eg. old
- tdata, but that's not possible since these blocks are sitting
- inside bfd_alloc'd memory. The section hash is on a separate
- objalloc. */
- bfd_hash_table_free (&preserve->section_htab);
-}
-
-/*
FUNCTION
bfd_emul_get_maxpagesize