This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] PowerPC64 .branch_lt size change leads to "stubs don't match calculated size"
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 26 Jan 2018 05:21:38 -0000
- Subject: [binutils-gdb] PowerPC64 .branch_lt size change leads to "stubs don't match calculated size"
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ba21f5646454c418e75eb06f6bf1a00a173641ca
commit ba21f5646454c418e75eb06f6bf1a00a173641ca
Author: Alan Modra <amodra@gmail.com>
Date: Fri Jan 26 12:25:09 2018 +1030
PowerPC64 .branch_lt size change leads to "stubs don't match calculated size"
https://bugzilla.redhat.com/show_bug.cgi?id=1523457
I haven't analyzed this myself, I'm relying on Nick's excellent
analysis. What I believe is happening is that after some number of
stub sizing iterations, a long-branch stub needs to be converted to a
plt-branch, but either due to stub alignment or other stubs shrinking
in size, the stub group section size doesn't change.
That means we exit from ppc64_elf_size_stubs after sizing with an
incorrect layout, in fact the additional .branch_lt entry overlays
.got! Since .TOC. is normally set to .got + 0x8000 the stub sizing
code decides that entry is within +/-32k of the TOC pointer and so a
three insn stub is sufficient. When we come to build the stubs using
a correct non-overlaying layout, a four insn plt-branch stub is
generated and the stub group size doesn't match that calculated
earlier.
* elf64-ppc.c (ppc64_elf_size_stubs): Iterate sizing when
.branch_lt changes size.
Diff:
---
bfd/ChangeLog | 5 +++++
bfd/elf64-ppc.c | 6 ++++++
2 files changed, 11 insertions(+)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ba377ab..4ad0127 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-26 Alan Modra <amodra@gmail.com>
+
+ * elf64-ppc.c (ppc64_elf_size_stubs): Iterate sizing when
+ .branch_lt changes size.
+
2018-01-25 Alan Modra <amodra@gmail.com>
PR 22746
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index b2d288b..5cbb035 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -12702,6 +12702,9 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
stub_sec->flags &= ~SEC_RELOC;
}
+ if (htab->stub_iteration <= STUB_SHRINK_ITER
+ || htab->brlt->rawsize < htab->brlt->size)
+ htab->brlt->rawsize = htab->brlt->size;
htab->brlt->size = 0;
htab->brlt->reloc_count = 0;
htab->brlt->flags &= ~SEC_RELOC;
@@ -12757,6 +12760,9 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
break;
if (group == NULL
+ && (htab->brlt->rawsize == htab->brlt->size
+ || (htab->stub_iteration > STUB_SHRINK_ITER
+ && htab->brlt->rawsize > htab->brlt->size))
&& (htab->glink_eh_frame == NULL
|| htab->glink_eh_frame->rawsize == htab->glink_eh_frame->size))
break;