This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Ignore degenerate PT_LOAD segments


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=325ba6fb34be799c885fad9287d883e86b835c84

commit 325ba6fb34be799c885fad9287d883e86b835c84
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Feb 17 09:21:17 2018 +1030

    Ignore degenerate PT_LOAD segments
    
    Fixes a failure triggered by -z separate-code.  p_memsz is tested
    rather than p_filesz for objcopy --only-keep-debug where p_filesz is
    set to zero.
    
    	PR 22845
    	* elf.c (assign_file_positions_for_non_load_sections): Ignore
    	degenerate zero size PT_LOAD segments when finding one overlapping
    	the PT_GNU_RELRO segment.

Diff:
---
 bfd/ChangeLog | 7 +++++++
 bfd/elf.c     | 1 +
 2 files changed, 8 insertions(+)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c314485..946c6bc 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2018-02-17  Alan Modra  <amodra@gmail.com>
+
+	PR 22845
+	* elf.c (assign_file_positions_for_non_load_sections): Ignore
+	degenerate zero size PT_LOAD segments when finding one overlapping
+	the PT_GNU_RELRO segment.
+
 2018-02-16  Alan Modra  <amodra@gmail.com>
 
 	* libbfd.c (_bfd_bool_bfd_false_error): Rename from bfd_false.
diff --git a/bfd/elf.c b/bfd/elf.c
index 397fa62..b069b59 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -5897,6 +5897,7 @@ assign_file_positions_for_non_load_sections (bfd *abfd,
 		   lm = lm->next, lp++)
 		{
 		  if (lp->p_type == PT_LOAD
+		      && lp->p_memsz != 0
 		      && lm->count != 0
 		      && lm->sections[lm->count - 1]->vma >= start
 		      && lm->sections[0]->vma < end)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]