From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by sourceware.org (Postfix) with ESMTP id 057A53858D20 for ; Tue, 8 Aug 2023 09:49:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 057A53858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=orcam.me.uk Received: by angie.orcam.me.uk (Postfix, from userid 500) id 662369200C3; Tue, 8 Aug 2023 11:49:23 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 5CED29200BF; Tue, 8 Aug 2023 10:49:23 +0100 (BST) Date: Tue, 8 Aug 2023 10:49:23 +0100 (BST) From: "Maciej W. Rozycki" To: Joseph Faulls cc: "binutils@sourceware.org" , "palmer@rivosinc.com" , "nelson@rivosinc.com" Subject: Re: [PATCH] RISC-V: Do not gp relax against an ABS symbol if it is far away. In-Reply-To: Message-ID: References: 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=-1163.2 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 27 Jul 2023, Joseph Faulls wrote: > Relaxations can cause the gp to move after it has been decided to gp > relax. Against an absolute symbol, the distance may change such that the > offset can no longer fit in the 12-bit immediate field. What's the use case for using AUIPC/LW to load an absolute symbol? Such symbols are not used in contexts where an address could alternatively be expected, so the correct sequence, and in PIC or PIE code indeed the only valid, for direct references from code is LUI/ADDI. Since you're fiddling with linker relaxation code here, you may well take the opportunity and relax it to LUI/ADDI, or ADDI alone if the value is small. There may be an issue with RV64 objects if the value turns out outside the 32-bit range though, which will be a relocation overflow. Maciej