From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 607C1383A309 for ; Fri, 3 Jun 2022 03:10:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 607C1383A309 Received: by mail-pf1-x429.google.com with SMTP id j6so6215307pfe.13 for ; Thu, 02 Jun 2022 20:10:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=GrD9ouDOAkodUtuIfqrRueOV9vJjYojv3JFYYD2Z6PE=; b=Y+9UIvPEzvH79uH9pP51AJ2yLaAkDJmiIpBmdrQIrBArfvr6FWFa8w53kmcqQ/aMrC 6EzEZ0F/SQ6/oFBi/l05sgeLCuF/bqgL6kaijAEAxG7OhUwJs7zRD0rpn0tbvV+UifWu i0iB470iL0KryuaHAb24k9AyV0JQ3bxqp0RkdGzlpP63EjrBrieQDF7PMPivykqMxNXt rGAMGHB7q7BbMNWOLgoeZRFLyQSRCuR5LCChRKzE6r706KUltllwKAH/Cz0//GpwPV97 7mTOfIElPUiTrK1Ki4yQR7Tkds9piCBsXhuCiAQeoB9osDRnU5GWqfYTq0P99iAZrd9g hgBQ== X-Gm-Message-State: AOAM5311Xm/Y6BYlTEJv2oonhm1gmF1qRflBPA2L1Ds4LXIntrSwEmTs A3R7eVzOm7GPd4rUPY+baJABODoxx5o= X-Google-Smtp-Source: ABdhPJyT8ypNqQ8sFJjNtaCjMCq7+i1R0dYUjDZBa0k6b63a6+72lrQ+CMAkika3HAkhSq2e2nVwsg== X-Received: by 2002:a63:90ca:0:b0:3fc:8c61:c83d with SMTP id a193-20020a6390ca000000b003fc8c61c83dmr6716937pge.203.1654225805117; Thu, 02 Jun 2022 20:10:05 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id d20-20020a056a00199400b0051878e8cc13sm4567347pfl.116.2022.06.02.20.10.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 20:10:04 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id AA695114015F; Fri, 3 Jun 2022 12:40:01 +0930 (ACST) Date: Fri, 3 Jun 2022 12:40:01 +0930 From: Alan Modra To: binutils@sourceware.org Subject: mips_gprel_reloc segfault Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3037.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Jun 2022 03:10:08 -0000 Not just the undefined section has a NULL owner, the absolute section has too. Which means we can't find output_bfd for __gp. Also, may as well test directly for output_bfd == NULL. * coff-mips.c (mips_gprel_reloc): Don't segfault on any of bfd_is_const_section sections. diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index 9614d338abe..d4dc1bd3c19 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -593,11 +593,10 @@ mips_gprel_reloc (bfd *abfd ATTRIBUTE_UNUSED, { relocatable = false; output_bfd = symbol->section->output_section->owner; + if (output_bfd == NULL) + return bfd_reloc_undefined; } - if (bfd_is_und_section (symbol->section) && ! relocatable) - return bfd_reloc_undefined; - /* We have to figure out the gp value, so that we can adjust the symbol value correctly. We look up the symbol _gp in the output BFD. If we can't find it, we're stuck. We cache it in the ECOFF -- Alan Modra Australia Development Lab, IBM