+2016-06-27 Alan Modra <amodra@gmail.com>
+
+ PR ld/19264
+ * elf64-ppc.c (STUB_SHRINK_ITER): Define.
+ (ppc64_elf_size_stubs): Exit stub sizing loop past STUB_SHRINK_ITER
+ if shrinking stubs.
+ (ppc64_elf_size_stubs): Adjust to suit.
+
2016-06-27 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
* elf32-dlx.h: New file.
if (!group_sections (info, stub_group_size, stubs_always_before_branch))
return FALSE;
+#define STUB_SHRINK_ITER 20
+ /* Loop until no stubs added. After iteration 20 of this loop we may
+ exit on a stub section shrinking. This is to break out of a
+ pathological case where adding stubs on one iteration decreases
+ section gaps (perhaps due to alignment), which then requires
+ fewer or smaller stubs on the next iteration. */
+
while (1)
{
bfd *input_bfd;
stub_sec != NULL;
stub_sec = stub_sec->next)
if ((stub_sec->flags & SEC_LINKER_CREATED) == 0
- && stub_sec->rawsize != stub_sec->size)
+ && stub_sec->rawsize != stub_sec->size
+ && (htab->stub_iteration <= STUB_SHRINK_ITER
+ || stub_sec->rawsize < stub_sec->size))
break;
- /* Exit from this loop when no stubs have been added, and no stubs
- have changed size. */
if (stub_sec == NULL
&& (htab->glink_eh_frame == NULL
|| htab->glink_eh_frame->rawsize == htab->glink_eh_frame->size))
stub_sec->contents = bfd_zalloc (htab->params->stub_bfd, stub_sec->size);
if (stub_sec->contents == NULL)
return FALSE;
- /* We want to check that built size is the same as calculated
- size. rawsize is a convenient location to use. */
- stub_sec->rawsize = stub_sec->size;
stub_sec->size = 0;
}
if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
{
stub_sec_count += 1;
- if (stub_sec->rawsize != stub_sec->size)
+ if (stub_sec->rawsize != stub_sec->size
+ && (htab->stub_iteration <= STUB_SHRINK_ITER
+ || stub_sec->rawsize < stub_sec->size))
break;
}