From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::4]) by sourceware.org (Postfix) with ESMTP id 0F15B385042E for ; Sat, 27 Feb 2021 16:45:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0F15B385042E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=macro@orcam.me.uk Received: by angie.orcam.me.uk (Postfix, from userid 500) id B813E92009C; Sat, 27 Feb 2021 17:45:24 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id B61E292009B; Sat, 27 Feb 2021 17:45:24 +0100 (CET) Date: Sat, 27 Feb 2021 17:45:24 +0100 (CET) From: "Maciej W. Rozycki" To: Jiaxun Yang cc: "open list:MIPS" , binutils@sourceware.org, gcc@gcc.gnu.org, syq@debian.org, Matthew Fortune Subject: Re: HELP: MIPS PC Relative Addressing In-Reply-To: Message-ID: References: <3ddc0595-c443-868e-c0a4-08ae8934f116@flygoat.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-3488.5 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Feb 2021 16:45:27 -0000 On Thu, 25 Feb 2021, Jiaxun Yang wrote: > > You may want to use composed relocations to refer to .LA1 (R_MIPS_32) and > > .LA0 (R_MIPS_SUB). There may or may not be linker updates needed; unlike > > the RISC-V one the MIPS BFD backend already supports composed relocations > > with the usual ELF gABI semantics. It would be good to switch to RELA at > > this point universally too; none of new stuff will work with old linkers > > anyway. > > Thanks for your hint;-) > > I'm unsure about how should we express composed relocations in assembly :-/ Just like we already do; R_MIPS_SUB could be easily produced directly from the `-' operator. I note too that $pc is effectively used twice in the calculation, cancelling itself, so I think we can do better, though it seems to me the original semantics of %pcrel_hi/%pcrel_lo pseudo-ops wasn't thought well (I guess it was just blindly copied from %hi/%lo by adding PC-relative interpretation with no further thinking as to whether it is usable in reality). It seems to me that we could overload the semantics of these pseudo-ops in a compatible manner though. Also are you concerned about linker relaxation you're possibly working on here? I'm asking because a calculation like (.LA1 - .LA0) works out as an assembly constant normally, so it's not a concern really. And as I recall existing MIPS linker relaxation does not rely on label symbols anyway (and is probably not defined for plain R6 anyway as I reckon there is nothing to relax at the link stage for that ISA). Where it might start to matter is the microMIPS ISA however; offhand I don't remember what exactly it looks like at R6 though. > MIPS N32/N64 ABI is already using RELA, do you mean switch to RELA for o32 > as well? Yes, with "universally" I meant: "across all the ABIs". Maciej