From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id 7E6DE3858D32 for ; Thu, 13 Apr 2023 05:40:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7E6DE3858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1031.google.com with SMTP id g3so15298142pja.2 for ; Wed, 12 Apr 2023 22:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681364433; x=1683956433; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=4xHVo2InjBCq12oSWJH8AodE/Am0+SaMfzMSxwRoAHY=; b=QYbIcruKehHfCyn0Qz+C7EGD1iyH06mQ9C6AhILjdspsThDWPc5fpE/aGxHhPowwsj +4JUkaqzi3Ct5vWcAdOR74YPSOeh5QDoInHlFAfQIrf609JfmY7LawQxHMwuy8JhPOZl Y1Kwqjit5wgXocG/kOjFJ1ls15ucA/fZuaJYQv57DscMmaFClnYWEJQDeGd9XcVKqyeT OkBu8KsptM0qU+qJi9VhU2KZa3WGZOdolOZfHWcS9YX4MCUmlKFTmqHHWAoI1CIlWp/S NzyyXuAK+PofUBQd6qv73hVzmDc4RdkC1+fUaH4MqJbzofRbISke5R+mDBIYajTzGk8q xnkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681364433; x=1683956433; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4xHVo2InjBCq12oSWJH8AodE/Am0+SaMfzMSxwRoAHY=; b=YPBywF5KZFZVd1WNPCJ94CbABuxb+B7SfO5NRXVFOo9UJvgnjER4DJDdPSLoO9jykg oFDfqiLpMpMkXtNo7lN2DtQ5AGOkgJIz65U5a3jV3ReWAbza4kGMhsUZrgKIk9FH+xFi r82YNzGGNr3hc5Dxdgp358wC0ssK5QjJUxzryZat42Px95i3KGZ38mdzu8m+IvbKv01A 3ExX4L2lfgj4LGosUCnFVksbVZbPmgfxr/KuP5zkN+WR3QLHpuIQ4Tg3b7YQPAI8oav9 hGPfgLL4Ebu919itx1eUM8YcFOwbAvbGXwPK0hvbPAZMIeuP1tfp4NB8xjuNxSbGYHd3 gf/A== X-Gm-Message-State: AAQBX9elM4Xg7gbsPfFt8ajNvVNczSOf+H0F3VZwNUmH5rQqPP3UxRtf RsrlfAp0Hbgk4jGAlYqrOkKnM/VTdGE= X-Google-Smtp-Source: AKy350bOFUCtDetnasjAf8PUfg2t0rGMS5pB65mD32aUqkRTgfPjHiM3hXml6q/hfV5Rzin2opgCjg== X-Received: by 2002:a05:6a20:a885:b0:ec:60a:d04c with SMTP id ca5-20020a056a20a88500b000ec060ad04cmr910754pzb.28.1681364432950; Wed, 12 Apr 2023 22:40:32 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id bm17-20020a056a00321100b00580e3917af7sm422412pfb.117.2023.04.12.22.40.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 22:40:32 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 0FD7D1142C37; Thu, 13 Apr 2023 15:10:30 +0930 (ACST) Date: Thu, 13 Apr 2023 15:10:30 +0930 From: Alan Modra To: binutils@sourceware.org Subject: Preserve a few more bfd fields in check_format_matches Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3035.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 --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 -- Alan Modra Australia Development Lab, IBM