public inbox for binutils-cvs@sourceware.org
 help / color / mirror / Atom feed
* [binutils-gdb] bfd_elf_set_group_contents assertion
@ 2022-08-17  8:01 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-08-17  8:01 UTC (permalink / raw)
  To: bfd-cvs

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

commit 7744e3278b9f24d8a1a2dd74f75986bd9060724c
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Aug 17 17:14:16 2022 +0930

    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.

Diff:
---
 bfd/elf.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/bfd/elf.c b/bfd/elf.c
index 2e01d7e9a44..35aa45e3b90 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);
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-17  8:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-17  8:01 [binutils-gdb] bfd_elf_set_group_contents assertion Alan Modra

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).