From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 5CEE93858C2C for ; Thu, 9 Sep 2021 14:14:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5CEE93858C2C Received: by mail-pg1-x52a.google.com with SMTP id g184so1903669pgc.6 for ; Thu, 09 Sep 2021 07:14:44 -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:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6qHB/iNUI4xJPubhhdZQeHrOjW5sAZh+zEkuSub0+M0=; b=GIPBsdGlxWvcHHUFzyzylZGMa6xtRe61E3HX3B9ON8pc2VC/Ul4UGAVM1ISvL81tgY RMgKELlhmxFKVCbqlU9xct7+52LXDWDhZgDczoy2fhqd2n6J7f8xZ8+1TRsxkMieiFjL gR7UEngnCInhDEVHIrXJNa8JxF4M+UDn00nh83/rvMk1EkHgdyRMZeJcD56jjqPA5QfW YNbDel/3ClpwkZxz/SydpmZCJLK5SZObXqA+/8Dog2ZuASyhHZgwHgSMm3/sDo2E9IXa 8prQaAiVJE/88zkvRjvkBUlc6U7g7DfvEymQP318Cw9vA1Ks6TCYqBmN465OLXL2gfct aSug== X-Gm-Message-State: AOAM531qZm2/k5khHQj0OCN8+u+1BI76b76CHv20a+vGHuEBpUdHjfCk hTGSF0Git0atrVyxMe50ASZvd6mXlDs= X-Google-Smtp-Source: ABdhPJxM1HZRVFgIrwpx7Ns3hV3FSYrlW3HKX73cU287GPmfMLEFxmEXCasErVi8FeVTYPe2/MQNGg== X-Received: by 2002:aa7:8718:0:b0:405:1645:16c3 with SMTP id b24-20020aa78718000000b00405164516c3mr3178282pfo.32.1631196883351; Thu, 09 Sep 2021 07:14:43 -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 g3sm2636120pgj.66.2021.09.09.07.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 07:14:41 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 42350114038D; Thu, 9 Sep 2021 23:44:38 +0930 (ACST) Date: Thu, 9 Sep 2021 23:44:38 +0930 From: Alan Modra To: "Maciej W. Rozycki" Cc: Chenghua Xu , binutils@sourceware.org Subject: Re: PR28306, segfault in _bfd_mips_elf_reloc_unshuffle Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3033.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Thu, 09 Sep 2021 14:14:46 -0000 On Thu, Sep 09, 2021 at 11:51:48AM +0200, Maciej W. Rozycki wrote: > On Wed, 8 Sep 2021, Alan Modra wrote: > > + /* ld -r or gas. */ > > relocatable = (output_bfd != NULL); > > > > - if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) > > + /* We only use bfd_reloc_offset_in_range for final linking because > > + mips object files may use relocations that seem to access beyond > > + section limits. gas/testsuite/gas/mips/dla-reloc.s is an example > > + that puts R_MIPS_SUB, a 64-bit relocation, on the last > > + instruction in the section. If final linking that object file > > + the R_MIPS_SUB won't be processed here since it applies to the > > + addend for the next reloc rather than the section contents. */ > > + if (!relocatable > > + && !bfd_reloc_offset_in_range (reloc_entry->howto, abfd, > > + input_section, reloc_entry->address)) > > return bfd_reloc_outofrange; > > Would a correct check be feasible here? For a composed relocation only > the final entry is applied to output, so could we instead check if there > is a follow-up relocation? I don't think there is any easy and safe way of doing that. Even though there is a nice tidy array of NULL terminated arelent pointers, the special_function doesn't see an arelent** but rather an arelent*. Hmm, how about replacing !relocatable above with !(relocatable && !reloc_entry->howto->partial_inplace) ie. the condition under which _bfd_mips_elf_generic_reloc writes section contents? -- Alan Modra Australia Development Lab, IBM