From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15177 invoked by alias); 15 Jan 2013 10:45:53 -0000 Received: (qmail 15104 invoked by uid 22791); 15 Jan 2013 10:45:51 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-pb0-f45.google.com (HELO mail-pb0-f45.google.com) (209.85.160.45) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 15 Jan 2013 10:45:45 +0000 Received: by mail-pb0-f45.google.com with SMTP id mc8so2775709pbc.4 for ; Tue, 15 Jan 2013 02:45:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.66.76.42 with SMTP id h10mr2144133paw.59.1358246744721; Tue, 15 Jan 2013 02:45:44 -0800 (PST) Received: by 10.68.25.202 with HTTP; Tue, 15 Jan 2013 02:45:44 -0800 (PST) In-Reply-To: <87mwwbx4ei.fsf@sandifor-thinkpad.stglab.manchester.uk.ibm.com> References: <87a9sj32qj.fsf@talisman.default> <87mwwbx4ei.fsf@sandifor-thinkpad.stglab.manchester.uk.ibm.com> Date: Tue, 15 Jan 2013 10:45:00 -0000 Message-ID: Subject: Re: invocation of mips_elf_multi_got can cause not enough GOT space for local GOT entries From: Robert Schiele To: Robert Schiele , binutils@sourceware.org, rdsandiford@googlemail.com Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00224.txt.bz2 On Mon, Jan 14, 2013 at 2:47 PM, Richard Sandiford wrote: > You'll need to do it consistently for all page_gotno tests > (mips_elf_merge_got_with, mips_elf_merge_gots, mips_elf_multi_got and > mips_elf_lay_out_got), otherwise you could end up merging GOTs based on > the current estimate and lay them out using the conservative one, which > could lead to overflow in the global region. But yeah, I think you'd > be safe changing those four places, as a local hack to get round the bug. So, with consistent you mean something like this? diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 4036273..24716dc 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -4276,8 +4276,6 @@ mips_elf_merge_got_with (struct mips_elf_bfd2got_hash *bfd2got, /* Work out how many page entries we would need for the combined GOT. */ estimate = arg->max_pages; - if (estimate >= from->page_gotno + to->page_gotno) - estimate = from->page_gotno + to->page_gotno; /* And conservatively estimate how many local and TLS entries would be needed. */ @@ -4337,8 +4335,6 @@ mips_elf_merge_gots (void **bfd2got_, void *p) /* Work out the number of page, local and TLS entries. */ estimate = arg->max_pages; - if (estimate > g->page_gotno) - estimate = g->page_gotno; estimate += g->local_gotno + g->tls_gotno; /* We place TLS GOT entries after both locals and globals. The globals @@ -4687,7 +4683,7 @@ mips_elf_multi_got (bfd *abfd, struct bfd_link_info *info, assign += htab->reserved_gotno; g->assigned_gotno = assign; g->local_gotno += assign; - g->local_gotno += (pages < g->page_gotno ? pages : g->page_gotno); + g->local_gotno += pages; assign = g->local_gotno + g->global_gotno + g->tls_gotno; /* Take g out of the direct list, and push it onto the reversed @@ -8918,11 +8914,6 @@ mips_elf_lay_out_got (bfd *output_bfd, struct bfd_link_info *info) sections. Is 5 enough? */ page_gotno = (loadable_size >> 16) + 5; - /* Choose the smaller of the two estimates; both are intended to be - conservative. */ - if (page_gotno > g->page_gotno) - page_gotno = g->page_gotno; - g->local_gotno += page_gotno; s->size += g->local_gotno * MIPS_ELF_GOT_SIZE (output_bfd); s->size += g->global_gotno * MIPS_ELF_GOT_SIZE (output_bfd); > FWIW, I experimented with one way of handling SEC_MERGE this weekend, > but ran out time before I had something I was happy with. Hope to > return to it again soon. That sounds promising, thanks! Robert