| Message ID | CAMe9rOotgDmy9B3eGXZ8QuhrJmAGWaQUyP8aw2yhpzy-SDM8QA@mail.gmail.com |
|---|---|
| State | New |
| Headers |
Return-Path: <binutils-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 408C248FD395 for <patchwork@sourceware.org>; Sun, 30 Nov 2025 07:51:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 408C248FD395 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Jahsz+H7 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by sourceware.org (Postfix) with ESMTPS id 2A8CA48FD863 for <binutils@sourceware.org>; Sun, 30 Nov 2025 07:51:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2A8CA48FD863 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2A8CA48FD863 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1764489079; cv=none; b=VXp67WyTvbhh+Rzpqgx87XJQZCNSJZBp4KpCezMbIEw7KhAulU3/SDGiQmTK4vXexYjuRHdBNCQS6J/TtnylqCcl+KaoPNQkDuNDEDzf07EktKJLW+f5Et0m042ybcPEpLFIUtadqFCSJm560biPwArhnBDE7HooJgBe3BTQBzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1764489079; c=relaxed/simple; bh=MTNjIVCKn+oYPcnTyeLNEIvYy6gRWq7PKVqhZ2pbkgc=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=e1fPc+zvD2DWZtRkrpwJ3V7WqVMKowdppDzXJ7+Po0n2FJ9URKGkN3lCqDneSb0Jlk5yojFqV4goJoV+4DfasZfZSK6UO+WTz3A1dlT/oOt+u0xqSxfMel55/Mfdtm4wBlgGhAjP1xzuRLwnh2hqtXgQl4zY+Lec7dv2jVsp4jc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2A8CA48FD863 Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-341988c720aso2710611a91.3 for <binutils@sourceware.org>; Sat, 29 Nov 2025 23:51:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764489078; x=1765093878; darn=sourceware.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Y8Mbdl/EDByykIk9Pn6LQRZjGFRPNRUO+nqCreu/iSg=; b=Jahsz+H7KJJor0Udx4tDiSc8Kd/pAoz3uUKfEJn/Zf7zQW5i5Bx70+hq+qoQ1ulgPW JTcYQvWMjMj1y+4u3FzI0KFx/J8oaP5tpKs4IZNNvSbwMjQsPGoEKt0TU7HnTKzCOf4j sbSAGHHZHG2zhzDZSqFzay6oYGQ+5bodyX1cwTpbrzmLRqogRyFeTBnkxMJf+q1tWLwD ZAm8II0vuTUl344UCPAd3+Mfpo7PWFbttVsyG/5c3RgPGq2yjKfOjoNa0phH86TUt2Ad uGxp+G2ynhBbmciglMPxLHaTLgTvPtYHDvjQXmgF/bgrmx6VZwnscoIz0qbKzJmpheg3 5QaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764489078; x=1765093878; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Y8Mbdl/EDByykIk9Pn6LQRZjGFRPNRUO+nqCreu/iSg=; b=TFcI/QL01BeciQgPcRWmauCBlYHalLNDD0nykY4Y+gwtPU416smfeGfWrO7DURKRzl WW+1Pioh11Vn0QacA/OKMjvEpUuNGNHUkJq38w8mePYZdoK5f6eA7zCsQLfd1t1hpgzD y0/Dq83JrHyfKVvX5pcrtYBfzWVtsPr867FiGpN51qAoYGbOJuVNuSKjeXDHUxh9Df0x tjHGFg7CqLxOAb2jADggN/5yVcxufoKfjnqzuWk6xIvivF8NW5vEMEy+/Vex7Kv5rPja EfQUl8vF0+97vCN4B4Pe1AQHNrmgzUS+kZE5OtqFzZIG51p+iMBTJCq4XqoMHAg2KjJU xPZA== X-Gm-Message-State: AOJu0Yyn7zre2+IL212/zxxGKnhqBHho0yuEJ3CGTYetVgFQ17H3jnou S00gZiH62/1e7XVsbFKu0gXgilQpme651ez2X5Y7K+3QqfZK6IwpDtY2Xn9G7TypGR92CnahQDA 6xFHSTEFElxuZHRhkx1oeEIow+8kOSeg= X-Gm-Gg: ASbGncvMhmkJMhtREtw7H+D+Uw8qKtXEj6dZu8L1xEcVGo86yjGiFDW5n4wRXf/OWCO XU3XPRcZucabmF6lhtiA55B6VkYOx9kqtdiyr4HYPif39/P9nQ3slJldRJZNKgw7arU/AkNQ2ok cuXiIfWZJf0QwJcrV5HoLwlWzZErX/CVYhODI0+8D5aNj3PajJtOfjQkyC6iMlGRlcNF9dciU+K QS6yYsyE0v3uDCxsvw0lpbSvj4q1wxH5p8T6iRup1QHmdaz5CPoVB5UfQv2urkDEg1LBtXGg/BF CGny X-Google-Smtp-Source: AGHT+IHxrIoHPnCLQFTnN15g3HwqqHh5M5TU7ETO+35suYeo04t96izBNu3+Toahv2ZWEosFKg4OnQrom0lOJbxiFSk= X-Received: by 2002:a17:90b:2d4f:b0:341:c964:126c with SMTP id 98e67ed59e1d1-34733f5b790mr28903821a91.34.1764489077901; Sat, 29 Nov 2025 23:51:17 -0800 (PST) MIME-Version: 1.0 References: <CAMe9rOriA5M0dB1MJsW2Fj8SJ83DHmxqwTZM=4PjSDEi8-tzcQ@mail.gmail.com> <aSu1sPEr8TK0ZBQY@squeak.grove.modra.org> In-Reply-To: <aSu1sPEr8TK0ZBQY@squeak.grove.modra.org> From: "H.J. Lu" <hjl.tools@gmail.com> Date: Sun, 30 Nov 2025 15:50:39 +0800 X-Gm-Features: AWmQ_bkMfv5-UHzKfN1L-o_LqJxxi8E_KltvtiWcM42NhH0F-ee2dBkwNMgYRQM Message-ID: <CAMe9rOotgDmy9B3eGXZ8QuhrJmAGWaQUyP8aw2yhpzy-SDM8QA@mail.gmail.com> Subject: [PATCH] mips: Assert dynamic symbol counts only with dynamic sections To: Alan Modra <amodra@gmail.com>, "Maciej W. Rozycki" <macro@orcam.me.uk> Cc: Binutils <binutils@sourceware.org>, Nick Clifton <nickc@redhat.com>, Jan Beulich <JBeulich@suse.com> Content-Type: multipart/mixed; boundary="000000000000b2eabd0644cb2014" X-Spam-Status: No, score=-3012.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
mips: Assert dynamic symbol counts only with dynamic sections
|
|
Commit Message
H.J. Lu
Nov. 30, 2025, 7:50 a.m. UTC
On Sun, Nov 30, 2025 at 11:10 AM Alan Modra <amodra@gmail.com> wrote: > > OK. > After commit 54fbc12d6404b645363f901110a21f4410067df5 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri Nov 28 16:07:57 2025 +0800 elf: Renumber local dynamic symbols only if needed mips-linux got FAIL: MIPS magic __ehdr_start symbol test 1 (o32) FAIL: PR ld/21334 MIPS GOT16 relocation in static binary with assertion failures on BFD_ASSERT (hsd.max_local_dynindx <= htab->root.local_dynsymcount + 1); Since there are dynamic symbols only if there are dynamic sections, assert dynamic symbol counts only if there are dynamic sections. * elfxx-mips.c (mips_elf_sort_hash_table): Assert dynamic symbol counts only if there are dynamic sections.
Comments
On Sun, Nov 30, 2025 at 03:50:39PM +0800, H.J. Lu wrote: > elf: Renumber local dynamic symbols only if needed > > mips-linux got > > FAIL: MIPS magic __ehdr_start symbol test 1 (o32) > FAIL: PR ld/21334 MIPS GOT16 relocation in static binary That commit broke hppa64-linux too. hppa64-linux-gnu +FAIL: -u --export-dynamic-symbol foo archive hppa64-linux-gnu +FAIL: strip -shared (maxpage1) hppa64-linux-gnu +FAIL: objcopy -shared (maxpage1) hppa64-linux-gnu +FAIL: ld-elf/mbind1b hppa64-linux-gnu +FAIL: ld-elf/pr19617a hppa64-linux-gnu +FAIL: ld-elf/pr21384 hppa64-linux-gnu +FAIL: ld-elf/pr21389a hppa64-linux-gnu +FAIL: ld-elf/pr21389b hppa64-linux-gnu +FAIL: ld-elf/pr21562e hppa64-linux-gnu +FAIL: ld-elf/pr21562f hppa64-linux-gnu +FAIL: ld-elf/pr21562g hppa64-linux-gnu +FAIL: ld-elf/pr21562h hppa64-linux-gnu +FAIL: ld-elf/pr21903a hppa64-linux-gnu +FAIL: ld-elf/pr21903b hppa64-linux-gnu +FAIL: ld-elf/pr23658-1c hppa64-linux-gnu +FAIL: ld-elf/pr23658-1f hppa64-linux-gnu +FAIL: ld-elf/pr24511 hppa64-linux-gnu +FAIL: ld-elf/pr26979a hppa64-linux-gnu +FAIL: ld-elf/pr26979b hppa64-linux-gnu +FAIL: ld-elf/pr33291 hppa64-linux-gnu +FAIL: ld-elf/pr33599 hppa64-linux-gnu +FAIL: ld-elf/sizeofb hppa64-linux-gnu +FAIL: ld-elf/startofb hppa64-linux-gnu +FAIL: ld-elf/textaddr2 hppa64-linux-gnu +FAIL: ld-elf/textaddr5 hppa64-linux-gnu +FAIL: ld-elf/textaddr6 hppa64-linux-gnu +FAIL: Symbol export class test (auxiliary shared object) hppa64-linux-gnu +FAIL: objcopy --strip-section-headers --hash-style=sysv -shared (start) hppa64-linux-gnu +FAIL: strip --strip-section-headers --hash-style=sysv -shared (start) hppa64-linux-gnu -FAIL: readelf version information hppa64-linux-gnu +FAIL: Build pr22649-1.so hppa64-linux-gnu +FAIL: Build shared library for pr14170 hppa64-linux-gnu +FAIL: Build shared library for broken linker script test hppa64-linux-gnu +FAIL: Build pr17068.so hppa64-linux-gnu +FAIL: pr17068 link --as-needed lib in group hppa64-linux-gnu +FAIL: Build pr20995.so hppa64-linux-gnu +FAIL: Weak symbols in dynamic objects 1 (support) hppa64-linux-gnu +FAIL: Weak symbols in dynamic objects 1 (main test)
On Mon, Dec 1, 2025 at 6:50 AM Alan Modra <amodra@gmail.com> wrote: > > On Sun, Nov 30, 2025 at 03:50:39PM +0800, H.J. Lu wrote: > > elf: Renumber local dynamic symbols only if needed > > > > mips-linux got > > > > FAIL: MIPS magic __ehdr_start symbol test 1 (o32) > > FAIL: PR ld/21334 MIPS GOT16 relocation in static binary > > That commit broke hppa64-linux too. > > hppa64-linux-gnu +FAIL: -u --export-dynamic-symbol foo archive > hppa64-linux-gnu +FAIL: strip -shared (maxpage1) > hppa64-linux-gnu +FAIL: objcopy -shared (maxpage1) > hppa64-linux-gnu +FAIL: ld-elf/mbind1b > hppa64-linux-gnu +FAIL: ld-elf/pr19617a > hppa64-linux-gnu +FAIL: ld-elf/pr21384 > hppa64-linux-gnu +FAIL: ld-elf/pr21389a > hppa64-linux-gnu +FAIL: ld-elf/pr21389b > hppa64-linux-gnu +FAIL: ld-elf/pr21562e > hppa64-linux-gnu +FAIL: ld-elf/pr21562f > hppa64-linux-gnu +FAIL: ld-elf/pr21562g > hppa64-linux-gnu +FAIL: ld-elf/pr21562h > hppa64-linux-gnu +FAIL: ld-elf/pr21903a > hppa64-linux-gnu +FAIL: ld-elf/pr21903b > hppa64-linux-gnu +FAIL: ld-elf/pr23658-1c > hppa64-linux-gnu +FAIL: ld-elf/pr23658-1f > hppa64-linux-gnu +FAIL: ld-elf/pr24511 > hppa64-linux-gnu +FAIL: ld-elf/pr26979a > hppa64-linux-gnu +FAIL: ld-elf/pr26979b > hppa64-linux-gnu +FAIL: ld-elf/pr33291 > hppa64-linux-gnu +FAIL: ld-elf/pr33599 > hppa64-linux-gnu +FAIL: ld-elf/sizeofb > hppa64-linux-gnu +FAIL: ld-elf/startofb > hppa64-linux-gnu +FAIL: ld-elf/textaddr2 > hppa64-linux-gnu +FAIL: ld-elf/textaddr5 > hppa64-linux-gnu +FAIL: ld-elf/textaddr6 > hppa64-linux-gnu +FAIL: Symbol export class test (auxiliary shared object) > hppa64-linux-gnu +FAIL: objcopy --strip-section-headers --hash-style=sysv -shared (start) > hppa64-linux-gnu +FAIL: strip --strip-section-headers --hash-style=sysv -shared (start) > hppa64-linux-gnu -FAIL: readelf version information > hppa64-linux-gnu +FAIL: Build pr22649-1.so > hppa64-linux-gnu +FAIL: Build shared library for pr14170 > hppa64-linux-gnu +FAIL: Build shared library for broken linker script test > hppa64-linux-gnu +FAIL: Build pr17068.so > hppa64-linux-gnu +FAIL: pr17068 link --as-needed lib in group > hppa64-linux-gnu +FAIL: Build pr20995.so > hppa64-linux-gnu +FAIL: Weak symbols in dynamic objects 1 (support) > hppa64-linux-gnu +FAIL: Weak symbols in dynamic objects 1 (main test) > > -- > Alan Modra How can I reproduce it? I only got FAIL: ld-elf/pr19539 FAIL: ld-elf/pr19617a FAIL: PR ld/22269 FAIL: PR ld/22269 (-z dynamic-undefined-weak) FAIL: objcopy --strip-section-headers --hash-style=sysv -shared (start) FAIL: strip --strip-section-headers --hash-style=sysv -shared (start) FAIL: ld-elf/64ksec FAIL: DT_TEXTREL in shared lib FAIL: DT_TEXTREL map file warning FAIL: Build shared library for broken linker script test FAIL: Link using broken linker script FAIL: pr17068 link --as-needed lib in group FAIL: pr20995 with hppa64-linux-gnu cross binutils.
On Mon, Dec 01, 2025 at 07:13:00AM +0800, H.J. Lu wrote:
> How can I reproduce it? I only got
~/src/binutils-gdb/configure \
--disable-nls \
--disable-gdb --disable-gdbserver --disable-sim --disable-readline \
--disable-libbacktrace --disable-libdecnumber --disable-gprofng \
--enable-obsolete --target=hppa64-linux-gnu
Here's an example of a failing test
../gas/as-new -I/home/alan/src/binutils-gdb/ld/testsuite/ld-elf -o tmpdir/maxpage1.o /home/alan/src/binutils-gdb/ld/testsuite/ld-elf/maxpage1.s
./ld-new -o tmpdir/maxpage1 -shared -z stack-size=0 tmpdir/maxpage1.o
corrupted size vs. prev_size
Aborted (core dumped)
FAIL: strip -shared (maxpage1)
On Mon, Dec 01, 2025 at 11:57:44AM +1030, Alan Modra wrote: > On Mon, Dec 01, 2025 at 07:13:00AM +0800, H.J. Lu wrote: > > How can I reproduce it? I only got > > ~/src/binutils-gdb/configure \ > --disable-nls \ > --disable-gdb --disable-gdbserver --disable-sim --disable-readline \ > --disable-libbacktrace --disable-libdecnumber --disable-gprofng \ > --enable-obsolete --target=hppa64-linux-gnu > > Here's an example of a failing test > > ../gas/as-new -I/home/alan/src/binutils-gdb/ld/testsuite/ld-elf -o tmpdir/maxpage1.o /home/alan/src/binutils-gdb/ld/testsuite/ld-elf/maxpage1.s > ./ld-new -o tmpdir/maxpage1 -shared -z stack-size=0 tmpdir/maxpage1.o > corrupted size vs. prev_size > Aborted (core dumped) > > FAIL: strip -shared (maxpage1) A sanitizer build shows this is due to a buffer overflow at bfd/elflink.c:6504 in elf_collect_hash_codes.
On Mon, Dec 1, 2025 at 9:27 AM Alan Modra <amodra@gmail.com> wrote: > > On Mon, Dec 01, 2025 at 07:13:00AM +0800, H.J. Lu wrote: > > How can I reproduce it? I only got > > ~/src/binutils-gdb/configure \ > --disable-nls \ > --disable-gdb --disable-gdbserver --disable-sim --disable-readline \ > --disable-libbacktrace --disable-libdecnumber --disable-gprofng \ > --enable-obsolete --target=hppa64-linux-gnu I used a similar configuration with GCC 15. Which compiler did you use? > Here's an example of a failing test > > ../gas/as-new -I/home/alan/src/binutils-gdb/ld/testsuite/ld-elf -o tmpdir/maxpage1.o /home/alan/src/binutils-gdb/ld/testsuite/ld-elf/maxpage1.s > ./ld-new -o tmpdir/maxpage1 -shared -z stack-size=0 tmpdir/maxpage1.o > corrupted size vs. prev_size > Aborted (core dumped) > > FAIL: strip -shared (maxpage1) > > -- > Alan Modra
On Mon, Dec 1, 2025 at 9:36 AM Alan Modra <amodra@gmail.com> wrote: > > On Mon, Dec 01, 2025 at 11:57:44AM +1030, Alan Modra wrote: > > On Mon, Dec 01, 2025 at 07:13:00AM +0800, H.J. Lu wrote: > > > How can I reproduce it? I only got > > > > ~/src/binutils-gdb/configure \ > > --disable-nls \ > > --disable-gdb --disable-gdbserver --disable-sim --disable-readline \ > > --disable-libbacktrace --disable-libdecnumber --disable-gprofng \ > > --enable-obsolete --target=hppa64-linux-gnu > > > > Here's an example of a failing test > > > > ../gas/as-new -I/home/alan/src/binutils-gdb/ld/testsuite/ld-elf -o tmpdir/maxpage1.o /home/alan/src/binutils-gdb/ld/testsuite/ld-elf/maxpage1.s > > ./ld-new -o tmpdir/maxpage1 -shared -z stack-size=0 tmpdir/maxpage1.o > > corrupted size vs. prev_size > > Aborted (core dumped) > > > > FAIL: strip -shared (maxpage1) > > A sanitizer build shows this is due to a buffer overflow at > bfd/elflink.c:6504 in elf_collect_hash_codes. I used --enable-default-hash-style=gnu. Remove it reproduced the error. > -- > Alan Modra
The mips patch looks wrong to me. Why is mips_elf_sort_hash_table even doing anything? Oh, the test htab->root.dynsymcount == 0 should be htab->root.dynsymcount <= 1, because dynsymcount is initialised to 1 in _bfd_elf_link_hash_table_init. I'll apply that fix.
On Tue, 2 Dec 2025, Alan Modra wrote: > The mips patch looks wrong to me. Why is mips_elf_sort_hash_table > even doing anything? Oh, the test htab->root.dynsymcount == 0 should > be htab->root.dynsymcount <= 1, because dynsymcount is initialised to > 1 in _bfd_elf_link_hash_table_init. > > I'll apply that fix. Yeah, it seems to me like the right fix. Thank you for looking into it. Maciej
From e63ad8aeb72c21a00397d2366cb89d65e638b39c Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sun, 30 Nov 2025 15:32:53 +0800
Subject: [PATCH] mips: Assert dynamic symbol counts only with dynamic sections
After
commit 54fbc12d6404b645363f901110a21f4410067df5
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Fri Nov 28 16:07:57 2025 +0800
elf: Renumber local dynamic symbols only if needed
mips-linux got
FAIL: MIPS magic __ehdr_start symbol test 1 (o32)
FAIL: PR ld/21334 MIPS GOT16 relocation in static binary
with assertion failures on
BFD_ASSERT (hsd.max_local_dynindx <= htab->root.local_dynsymcount + 1);
Since there are dynamic symbols only if there are dynamic sections,
assert dynamic symbol counts only if there are dynamic sections.
* elfxx-mips.c (mips_elf_sort_hash_table): Assert dynamic symbol
counts only if there are dynamic sections.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
bfd/elfxx-mips.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index e37c45fec15..fe896839d76 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -4034,12 +4034,15 @@ mips_elf_sort_hash_table (bfd *abfd, struct bfd_link_info *info)
hsd.mipsxhash = NULL;
mips_elf_link_hash_traverse (htab, mips_elf_sort_hash_table_f, &hsd);
- /* There should have been enough room in the symbol table to
- accommodate both the GOT and non-GOT symbols. */
- BFD_ASSERT (hsd.max_local_dynindx <= htab->root.local_dynsymcount + 1);
- BFD_ASSERT (hsd.max_non_got_dynindx <= hsd.min_got_dynindx);
- BFD_ASSERT (hsd.max_unref_got_dynindx == htab->root.dynsymcount);
- BFD_ASSERT (htab->root.dynsymcount - hsd.min_got_dynindx == g->global_gotno);
+ if (htab->root.dynamic_sections_created)
+ {
+ /* There should have been enough room in the symbol table to
+ accommodate both the GOT and non-GOT symbols. */
+ BFD_ASSERT (hsd.max_local_dynindx <= htab->root.local_dynsymcount + 1);
+ BFD_ASSERT (hsd.max_non_got_dynindx <= hsd.min_got_dynindx);
+ BFD_ASSERT (hsd.max_unref_got_dynindx == htab->root.dynsymcount);
+ BFD_ASSERT (htab->root.dynsymcount - hsd.min_got_dynindx == g->global_gotno);
+ }
/* Now we know which dynamic symbol has the lowest dynamic symbol
table index in the GOT. */
--
2.52.0