* [binutils-gdb] Preserve a few more bfd fields in check_format_matches
@ 2023-04-13 5:40 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2023-04-13 5:40 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24a6c5ae36d0ceb0eb77a8b8e40f63ebbbbb052c
commit 24a6c5ae36d0ceb0eb77a8b8e40f63ebbbbb052c
Author: Alan Modra <amodra@gmail.com>
Date: Thu Apr 13 15:03:16 2023 +0930
Preserve a few more bfd fields in check_format_matches
AOUT and COFF targets set symcount and start_address in their object_p
functions. If these are used anywhere then it would pay to save and
restore them so that a successful match gets the values expected
rather than that for a later unsuccessful target match.
* format.c (struct bfd_preserve): Move some fields. Add
symcount, read_only and start_address.
(bfd_preserve_save): Save..
(bfd_preserve_restore): ..and restore..
(bfd_reinit): ..and zero new fields.
Diff:
---
bfd/format.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/bfd/format.c b/bfd/format.c
index 66b45ae1979..c790f86d202 100644
--- a/bfd/format.c
+++ b/bfd/format.c
@@ -102,13 +102,16 @@ struct bfd_preserve
const struct bfd_iovec *iovec;
void *iostream;
const struct bfd_arch_info *arch_info;
+ const struct bfd_build_id *build_id;
+ bfd_cleanup cleanup;
struct bfd_section *sections;
struct bfd_section *section_last;
unsigned int section_count;
unsigned int section_id;
+ unsigned int symcount;
+ bool read_only;
+ bfd_vma start_address;
struct bfd_hash_table section_htab;
- const struct bfd_build_id *build_id;
- bfd_cleanup cleanup;
};
/* When testing an object for compatibility with a particular target
@@ -133,6 +136,9 @@ bfd_preserve_save (bfd *abfd, struct bfd_preserve *preserve,
preserve->section_last = abfd->section_last;
preserve->section_count = abfd->section_count;
preserve->section_id = _bfd_section_id;
+ preserve->symcount = abfd->symcount;
+ preserve->read_only = abfd->read_only;
+ preserve->start_address = abfd->start_address;
preserve->section_htab = abfd->section_htab;
preserve->marker = bfd_alloc (abfd, 1);
preserve->build_id = abfd->build_id;
@@ -183,6 +189,9 @@ bfd_reinit (bfd *abfd, unsigned int section_id,
abfd->tdata.any = NULL;
abfd->arch_info = &bfd_default_arch_struct;
io_reinit (abfd, preserve);
+ abfd->symcount = 0;
+ abfd->read_only = 0;
+ abfd->start_address = 0;
abfd->build_id = NULL;
bfd_section_list_clear (abfd);
}
@@ -202,6 +211,9 @@ bfd_preserve_restore (bfd *abfd, struct bfd_preserve *preserve)
abfd->section_last = preserve->section_last;
abfd->section_count = preserve->section_count;
_bfd_section_id = preserve->section_id;
+ abfd->symcount = preserve->symcount;
+ abfd->read_only = preserve->read_only;
+ abfd->start_address = preserve->start_address;
abfd->build_id = preserve->build_id;
/* bfd_release frees all memory more recently bfd_alloc'd than
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-13 5:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13 5:40 [binutils-gdb] Preserve a few more bfd fields in check_format_matches Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).