public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] Preserve a few more bfd fields in check_format_matches
Date: Thu, 13 Apr 2023 05:40:41 +0000 (GMT)	[thread overview]
Message-ID: <20230413054041.9279B3858C54@sourceware.org> (raw)

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

                 reply	other threads:[~2023-04-13  5:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230413054041.9279B3858C54@sourceware.org \
    --to=amodra@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).