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 59F323858D33 for ; Tue, 8 Aug 2023 12:04:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59F323858D33 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 3C04F9200C4; Tue, 8 Aug 2023 14:04:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 2F3169200BF; Tue, 8 Aug 2023 13:04:05 +0100 (BST) Date: Tue, 8 Aug 2023 13:04:05 +0100 (BST) From: "Maciej W. Rozycki" To: Joseph Faulls cc: "binutils@sourceware.org" , "palmer@rivosinc.com" , "nelson@rivosinc.com" Subject: RE: [EXTERNAL] 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 Tue, 8 Aug 2023, Joseph Faulls wrote: > > 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 > > For my clarification, are you saying that the AUIPC/LW should never have > been generated? If so, how is it possible for the compiler to know that > the symbol referenced will be an absolute symbol? No, the compiler won't ever know that a reference will ultimately resolve to an absolute symbol; I don't think there's a way to tell it. Then such symbols aren't usually used in compiled code as they are awkward to refer to (e.g. in C you'll only ever use `&symbol' to get at one). Most often I'd expect them to be referred in handcoded assembly, via the LI macro, and possibly defined via the GAS's or LD's `--defsym' command-line option, or in a linker script. Maciej