summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPirama Arumuga Nainar <pirama@google.com>2019-08-08 08:42:20 -0700
committerPirama Arumuga Nainar <pirama@google.com>2019-08-08 17:52:21 +0000
commit9bd56e9c06218734024e8f3583ffd271e0d07b59 (patch)
tree731735e3e09adae8ca30b5dc6153de936e8ea1ed
parent71b0f9d8c88783f15c51dbb4ebeed38744adbdab (diff)
downloadbinutils-9bd56e9c06218734024e8f3583ffd271e0d07b59.tar.gz
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. This change is backport of commit 325ba6fb34be799c885fad9287d883e86b835c84 - https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f2731e0c374e5323ce4cdae2bcc7b7fe22da1a6f to binutils-2.27. It is needed to cleanly cherry-pick dbc88fc14992c556b94e77de563a8f7abcb0b653. Bug: http://b/135627985 Change-Id: Ic860cd5fa2992214b45b3bd0c8c5f1a222973533
-rw-r--r--binutils-2.27/bfd/elf.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/binutils-2.27/bfd/elf.c b/binutils-2.27/bfd/elf.c
index 39d94b01..de2027da 100644
--- a/binutils-2.27/bfd/elf.c
+++ b/binutils-2.27/bfd/elf.c
@@ -5674,6 +5674,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)