From 9ab8247228844bb6608d6b2c99b6d8732bab08c1 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Wed, 20 Jul 2016 07:50:42 -0700 Subject: [PATCH] Check p_paddr for program header space 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 | 4 +++- ld/ChangeLog | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bfd/elf.c b/bfd/elf.c index ebcf40a9257..2cc64e8d524 100644 --- 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"), diff --git a/ld/ChangeLog b/ld/ChangeLog index b7442751328..a2493d0daf4 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2016-07-20 H.J. Lu + + PR ld/20376 + * elf.c (assign_file_positions_for_load_sections): Also check + p_paddr for program header space. + 2016-07-20 Alan Modra * ldexp.c (exp_unop, exp_binop, exp_trinop, exp_nameop): Don't -- 2.30.2