From: Nick Clifton <nickc@sourceware.org>
To: binutils-cvs@sourceware.org
Subject: [binutils-gdb] When mapping sections to segments ensure that we do not add sections whose VMA->LMA relationship doe
Date: Mon, 15 Apr 2024 15:28:43 +0000 (GMT) [thread overview]
Message-ID: <20240415152843.67A6B3858C98@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ccbf42ec88f3e8bbb74dbdc1d6c9da3a9d805cff
commit ccbf42ec88f3e8bbb74dbdc1d6c9da3a9d805cff
Author: Vijay Shankar <shank.vijay@yandex.com>
Date: Mon Apr 15 16:27:21 2024 +0100
When mapping sections to segments ensure that we do not add sections whose VMA->LMA relationship does not match the relationship of earlier sections in the segment.
PR 31540
Diff:
---
bfd/elf.c | 12 +++++++++---
binutils/testsuite/binutils-all/pr25662.ld | 2 ++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/bfd/elf.c b/bfd/elf.c
index c305b40eca3..889078db097 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -8394,7 +8394,9 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd)
/* Check to see if any sections in the input BFD
covered by ELF program header have changed. */
Elf_Internal_Phdr *segment;
- asection *section, *osec;
+ asection * section;
+ asection * osec;
+ asection * prev;
unsigned int i, num_segments;
Elf_Internal_Shdr *this_hdr;
const struct elf_backend_data *bed;
@@ -8425,7 +8427,7 @@ copy_private_bfd_data (bfd *ibfd, bfd *obfd)
|| segment->p_type == PT_DYNAMIC))
goto rewrite;
- for (section = ibfd->sections;
+ for (section = prev = ibfd->sections;
section != NULL; section = section->next)
{
/* We mark the output section so that we know it comes
@@ -8446,9 +8448,13 @@ 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)
+ || 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)
goto rewrite;
}
+ prev = section;
}
}
diff --git a/binutils/testsuite/binutils-all/pr25662.ld b/binutils/testsuite/binutils-all/pr25662.ld
index 19ef1391f8d..4951184f88e 100644
--- a/binutils/testsuite/binutils-all/pr25662.ld
+++ b/binutils/testsuite/binutils-all/pr25662.ld
@@ -12,4 +12,6 @@ SECTIONS
.text : { *(.text) } > ROM
.bss : { *(.bss) } > RAM
+
+ /DISCARD/ : { *(.*) }
}
reply other threads:[~2024-04-15 15:28 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=20240415152843.67A6B3858C98@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).