ld: don't chance overrunning PE .reloc section content
authorJan Beulich <jbeulich@suse.com>
Mon, 15 Mar 2021 10:00:44 +0000 (11:00 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 15 Mar 2021 10:00:44 +0000 (11:00 +0100)
The allocation of reloc_d doesn't take reloc_s->size into account. There
is already padding being emitted up to the allocated size. While
reloc_s->size ought to still be zero at this point anyway (and hence the
code being deleted would have been just dead), don't risk writing past
the actual allocation.

ld/ChangeLog
ld/pe-dll.c

index fe68e6ded9befe780482e21b9fd3662ac3cd179b..01b93c52cb97dd52d3560907b53a7f2f386236ea 100644 (file)
@@ -1,3 +1,7 @@
+2021-03-15  Jan Beulich  <jbeulich@suse.com>
+
+       * pe-dll.c (generate_reloc): Drop padding to reloc_s->size.
+
 2021-03-12  Alan Modra  <amodra@gmail.com>
 
        * Makefile.am (ALL_EMULATION_SOURCES): Move riscv files to..
index afcf6fea93e4d8071acc3185d06b89df57844dc6..eaecb951efdfc04b63a0b83fe913860d1c4e37bc 100644 (file)
@@ -1752,9 +1752,6 @@ generate_reloc (bfd *abfd, struct bfd_link_info *info)
 
   if (page_ptr != (bfd_vma) -1)
     bfd_put_32 (abfd, reloc_sz - page_ptr, reloc_d + page_ptr + 4);
-
-  while (reloc_sz < reloc_s->size)
-    reloc_d[reloc_sz++] = 0;
 }
 
 /* Given the exiting def_file structure, print out a .DEF file that
This page took 0.027871 seconds and 4 git commands to generate.