aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-08-17 17:14:16 +0930
committerAlan Modra <amodra@gmail.com>2022-08-17 17:29:42 +0930
commit7744e3278b9f24d8a1a2dd74f75986bd9060724c (patch)
tree1a34f2b9c608340886093320b3cc5bfe9651667a /bfd/elf.c
parent31e43bfffbc585a59d07f21f191317a714476e38 (diff)
downloadgdb-7744e3278b9f24d8a1a2dd74f75986bd9060724c.zip
gdb-7744e3278b9f24d8a1a2dd74f75986bd9060724c.tar.gz
gdb-7744e3278b9f24d8a1a2dd74f75986bd9060724c.tar.bz2
bfd_elf_set_group_contents assertion
objcopy of broken SHT_GROUP sections shouldn't write garbage. * elf.c (bfd_elf_set_group_contents): If number of entries is unexpected, fill out section with zeros.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 2e01d7e..35aa45e 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3614,7 +3614,12 @@ bfd_elf_set_group_contents (bfd *abfd, asection *sec, void *failedptrarg)
}
loc -= 4;
- BFD_ASSERT (loc == sec->contents);
+ if (loc != sec->contents)
+ {
+ BFD_ASSERT (0);
+ memset (sec->contents + 4, 0, loc - sec->contents);
+ loc = sec->contents;
+ }
H_PUT_32 (abfd, sec->flags & SEC_LINK_ONCE ? GRP_COMDAT : 0, loc);
}