Check p_paddr for program header space
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 20 Jul 2016 14:50:42 +0000 (07:50 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 20 Jul 2016 14:50:56 +0000 (07:50 -0700)
Issue an error if p_paddr becomes invalid when allocating space for
program headers.

PR ld/20376
* elf.c (assign_file_positions_for_load_sections): Also check
p_paddr for program header space.

bfd/elf.c
ld/ChangeLog

index ebcf40a92578b588c19312b1e4e521fff8ddad14..2cc64e8d524ace5a15fce54df9b149e35801cebf 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5271,7 +5271,9 @@ assign_file_positions_for_load_sections (bfd *abfd,
          p->p_memsz = bed->s->sizeof_ehdr;
          if (m->count > 0)
            {
-             if (p->p_vaddr < (bfd_vma) off)
+             if (p->p_vaddr < (bfd_vma) off
+                 || (!m->p_paddr_valid
+                     && p->p_paddr < (bfd_vma) off))
                {
                  (*_bfd_error_handler)
                    (_("%B: Not enough room for program headers, try linking with -N"),
index b7442751328cd83b287dd73c0ba6a8e7f1a7305b..a2493d0daf47eccfda7722a3b5b7ca8e38383d90 100644 (file)
@@ -1,3 +1,9 @@
+2016-07-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/20376
+       * elf.c (assign_file_positions_for_load_sections): Also check
+       p_paddr for program header space.
+
 2016-07-20  Alan Modra  <amodra@gmail.com>
 
        * ldexp.c (exp_unop, exp_binop, exp_trinop, exp_nameop): Don't