public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@sourceware.org>
To: binutils-cvs@sourceware.org
Subject: [binutils-gdb] Fix test for sections with different VMA<->LMA relationships so that it only applies to allocated se
Date: Tue, 16 Apr 2024 16:55:36 +0000 (GMT)	[thread overview]
Message-ID: <20240416165536.A4C2E3858431@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b6fc194038ce0744532d6471499326114c0f0d90

commit b6fc194038ce0744532d6471499326114c0f0d90
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Apr 16 17:54:13 2024 +0100

    Fix test for sections with different VMA<->LMA relationships so that it only applies to allocated sections, and only sections in the same segment are checked.
    
      PR 31450

Diff:
---
 bfd/elf.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/bfd/elf.c b/bfd/elf.c
index 889078db097..52a6a2f56c3 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -8427,7 +8427,7 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 		  || segment->p_type == PT_DYNAMIC))
 	    goto rewrite;
 
-	  for (section = prev = ibfd->sections;
+	  for (section = ibfd->sections, prev = NULL;
 	       section != NULL; section = section->next)
 	    {
 	      /* We mark the output section so that we know it comes
@@ -8448,13 +8448,20 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd)
 		      || section->vma != osec->vma
 		      || section->size != osec->size
 		      || section->rawsize != osec->rawsize
-		      || section->alignment_power != osec->alignment_power
-		      /* PR 31450: Make sure this section's vma to lma
-			 relationship is the same as previous section's.  */
-		      || section->lma - section->vma != prev->lma - prev->vma)
+		      || section->alignment_power != osec->alignment_power)
 		    goto rewrite;
+
+		  /* PR 31450: If this is an allocated section then make sure
+		     that this section's vma to lma relationship is the same
+		     as previous (allocated) section's.  */
+		  if (prev != NULL
+		      && section->flags & SEC_ALLOC
+		      && section->lma - section->vma != prev->lma - prev->vma)
+		    goto rewrite;
+
+		  if (section->flags & SEC_ALLOC)
+		    prev = section;
 		}
-	      prev = section;
 	    }
 	}

                 reply	other threads:[~2024-04-16 16:55 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=20240416165536.A4C2E3858431@sourceware.org \
    --to=nickc@sourceware.org \
    --cc=binutils-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).