diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2025-06-21 06:52:00 +0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2025-06-23 22:28:14 +0800 |
commit | 41461010eb7c79fee7a9d5f6209accdaac66cc6b (patch) | |
tree | cad69f660b241c89065b7bb4c32ff580e67cd680 | |
parent | a66ed82cf04ed4527882af57e2bffec065ed47e0 (diff) | |
download | binutils-41461010eb7c79fee7a9d5f6209accdaac66cc6b.zip binutils-41461010eb7c79fee7a9d5f6209accdaac66cc6b.tar.gz binutils-41461010eb7c79fee7a9d5f6209accdaac66cc6b.tar.bz2 |
elf: Report corrupted group section
Report corrupted group section instead of trying to recover.
PR binutils/33050
* elf.c (bfd_elf_set_group_contents): Report corrupted group
section.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
-rw-r--r-- | bfd/elf.c | 23 |
1 files changed, 10 insertions, 13 deletions
@@ -3971,20 +3971,17 @@ bfd_elf_set_group_contents (bfd *abfd, asection *sec, void *failedptrarg) break; } - /* We should always get here with loc == sec->contents + 4, but it is - possible to craft bogus SHT_GROUP sections that will cause segfaults - in objcopy without checking loc here and in the loop above. */ - if (loc == sec->contents) - BFD_ASSERT (0); - else + /* We should always get here with loc == sec->contents + 4. Return + an error for bogus SHT_GROUP sections. */ + loc -= 4; + if (loc != sec->contents) { - loc -= 4; - if (loc != sec->contents) - { - BFD_ASSERT (0); - memset (sec->contents + 4, 0, loc - sec->contents); - loc = sec->contents; - } + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: corrupted group section: `%pA'"), + abfd, sec); + bfd_set_error (bfd_error_bad_value); + *failedptr = true; + return; } H_PUT_32 (abfd, sec->flags & SEC_LINK_ONCE ? GRP_COMDAT : 0, loc); |