From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by sourceware.org (Postfix) with ESMTPS id A3279388E81C for ; Thu, 4 Jun 2020 07:47:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A3279388E81C Received: by mail-pg1-x544.google.com with SMTP id 185so3082524pgb.10 for ; Thu, 04 Jun 2020 00:47:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=O584+yRhGEr+6Pp2n9tg4TWRmFQRDnJW/cbI7RczFCE=; b=A58uFhPvlP33e19bftYqGVjHeryAjKacX3BE3kzIy6ioPw3tXKbHCgivOyCK1/sdAf Mj0L7igMRVjLXvmUHngLV0dkPVC/93vceXymlnJe1F0xdZer0P22xASk/pbQlELWSGI4 a78/bLkAv1QBypgaxrvcG1zg8UK4RMMVZbRG9tbu49aEHbhcRp3uGhfn7zb6oeqwPFf3 55tAGoQ36RCXmENepAILY+p8tUahmteG/qdZDIQG7efHTOdKC+1PYGJLTi6P0YgNlZOh 7GM27WiqynJ+TFE4+oQY1VYRXe3WrDPMF6Z6pF0yeZw1oId8qpMZXh6JgD3/P+zVqFQs XEtg== X-Gm-Message-State: AOAM5336jmHHXLn1fK2esrn+thrYA9ceIMLUXeLrzDSCXViBfKmHg/YB sqle78w3rCI9OE0c8k30Ewg= X-Google-Smtp-Source: ABdhPJyJO517+YF5Q9D+CKxEm0FWia/MTC0GaRonITgqsfJGyhaWZ8d2jTg7cA3xGfAYNvXpu4c37g== X-Received: by 2002:a62:154f:: with SMTP id 76mr3060922pfv.322.1591256873850; Thu, 04 Jun 2020 00:47:53 -0700 (PDT) Received: from bubble.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id b10sm3476131pgk.50.2020.06.04.00.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 00:47:52 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 67FAC806BC; Thu, 4 Jun 2020 17:17:49 +0930 (ACST) Date: Thu, 4 Jun 2020 17:17:49 +0930 From: Alan Modra To: "H.J. Lu" Cc: Nick Clifton , "Maciej W. Rozycki" , Fangrui Song , Binutils Subject: Re: V3 [PATCH] ELF: Don't check relocations in non-loaded, non-alloced sections Message-ID: <20200604074749.GP29024@bubble.grove.modra.org> References: <20200602203831.286979-1-hjl.tools@gmail.com> <20200603164836.GA1696362@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-8.0 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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, 04 Jun 2020 07:47:55 -0000 On Wed, Jun 03, 2020 at 11:55:08AM -0700, H.J. Lu wrote: > --- a/bfd/elfxx-mips.c > +++ b/bfd/elfxx-mips.c > @@ -8618,7 +8618,6 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, > struct elf_link_hash_entry *h; > bfd_boolean can_make_dynamic_p; > bfd_boolean call_reloc_p; > - bfd_boolean constrain_symbol_p; > > r_symndx = ELF_R_SYM (abfd, rel->r_info); > r_type = ELF_R_TYPE (abfd, rel->r_info); > @@ -8653,12 +8652,6 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, > and if pointer equality therefore doesn't matter. */ > call_reloc_p = FALSE; > > - /* Set CONSTRAIN_SYMBOL_P if we need to take the relocation > - into account when deciding how to define the symbol. > - Relocations in nonallocatable sections such as .pdr and > - .debug* should have no effect. */ > - constrain_symbol_p = ((sec->flags & SEC_ALLOC) != 0); > - So "normal" sections will result in constrain_symbol_p being true. > switch (r_type) > { > case R_MIPS_CALL16: > @@ -8740,21 +8733,10 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, > case R_MIPS_NONE: > case R_MIPS_JALR: > case R_MICROMIPS_JALR: > - /* These relocations have empty fields and are purely there to > - provide link information. The symbol value doesn't matter. */ > - constrain_symbol_p = FALSE; > - break; > - But in for some special relocs it should be false. I think removing constrain_symbol_p is just wrong. You should keep it but initialise to true. -- Alan Modra Australia Development Lab, IBM