PR24041, Invalid Memory Address Dereference in elf_link_add_object_symbols

Alan Modra amodra@gmail.com
Mon Dec 31 05:27:00 GMT 2018


	PR 24041
	* elflink.c (elf_link_add_object_symbols): Don't segfault on
	crafted ET_DYN with no program headers.

diff --git a/bfd/elflink.c b/bfd/elflink.c
index f5b411bd62..6e421fb6cd 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -4186,7 +4186,7 @@ error_free_dyn:
 	 all sections contained fully therein.  This makes relro
 	 shared library sections appear as they will at run-time.  */
       phdr = elf_tdata (abfd)->phdr + elf_elfheader (abfd)->e_phnum;
-      while (--phdr >= elf_tdata (abfd)->phdr)
+      while (phdr-- > elf_tdata (abfd)->phdr)
 	if (phdr->p_type == PT_GNU_RELRO)
 	  {
 	    for (s = abfd->sections; s != NULL; s = s->next)

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list