aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorVijay Shankar <shank.vijay@yandex.com>2024-04-15 16:27:21 +0100
committerNick Clifton <nickc@redhat.com>2024-04-15 16:27:21 +0100
commitccbf42ec88f3e8bbb74dbdc1d6c9da3a9d805cff (patch)
treed023909642724092491a910941cb1631c8c098a5 /bfd
parent75670e0075df0f6fc8c324ea11de193a038274d6 (diff)
downloadgdb-ccbf42ec88f3e8bbb74dbdc1d6c9da3a9d805cff.zip
gdb-ccbf42ec88f3e8bbb74dbdc1d6c9da3a9d805cff.tar.gz
gdb-ccbf42ec88f3e8bbb74dbdc1d6c9da3a9d805cff.tar.bz2
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
Diffstat (limited to 'bfd')
-rw-r--r--bfd/elf.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index c305b40..889078d 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;
}
}