aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2024-04-16 17:54:13 +0100
committerNick Clifton <nickc@redhat.com>2024-04-16 17:54:13 +0100
commitb6fc194038ce0744532d6471499326114c0f0d90 (patch)
tree2128bb0a55e3cd8d861cf2e76b3abb3ff0d31e2b /bfd
parent12f5356130c2cda10e2589e74a8716563050dccb (diff)
downloadgdb-b6fc194038ce0744532d6471499326114c0f0d90.zip
gdb-b6fc194038ce0744532d6471499326114c0f0d90.tar.gz
gdb-b6fc194038ce0744532d6471499326114c0f0d90.tar.bz2
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
Diffstat (limited to 'bfd')
-rw-r--r--bfd/elf.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 889078d..52a6a2f 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;
}
}