Re: Set SEC_ELF_REVERSE_COPY earlier
authorAlan Modra <amodra@gmail.com>
Wed, 12 Jan 2022 05:11:22 +0000 (15:41 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 13 Jan 2022 03:42:43 +0000 (14:12 +1030)
Let's not rely on .init/.fini having relocs for the size sanity check.
This is mainly to squash reports of "my fuzzed object made ld hang".

bfd/elflink.c

index 107480286f3508569d12ea6770d11896a0573233..4529f83dbcab55f728b46cd5a08314a6d8fb9777 100644 (file)
@@ -11834,9 +11834,10 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
                  {
                    /* Reverse-copy input section to output.  */
 
-                   if (o->reloc_count != 0
-                       && (o->size * bed->s->int_rels_per_ext_rel
-                           != o->reloc_count * address_size))
+                   if ((o->size & (address_size - 1)) != 0
+                       || (o->reloc_count != 0
+                           && (o->size * bed->s->int_rels_per_ext_rel
+                               != o->reloc_count * address_size)))
                      {
                        _bfd_error_handler
                          /* xgettext:c-format */