From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id E01A31F953 for ; Thu, 2 Dec 2021 21:44:47 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D5D743857C7C for ; Thu, 2 Dec 2021 21:44:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5D743857C7C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1638481486; bh=Bbz59JNNvrercoombAO2zYtdPHQkxif4usxiQbcJ1e4=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=yxIfiJo1JG7EIbmVbJL+tdQs/+fk2b1L+VAc+3QIPE0x38U+7Gmol9ZqEw2oLv2Je B/zsFtskKRLQfo30ychR5OH2eNMLPw6HWI6dG+VblB7Hua8OmlFc9qCwN5RS9GzfdS nfNfEBetQpZRupsts81gihrh4HmRwXaeYjozTy2Y= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id B4AF73858010 for ; Thu, 2 Dec 2021 21:44:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B4AF73858010 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-496-hD4gEwfKPgeh2rLLR9n_6A-1; Thu, 02 Dec 2021 16:44:25 -0500 X-MC-Unique: hD4gEwfKPgeh2rLLR9n_6A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0EA5190D374; Thu, 2 Dec 2021 21:44:23 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.123]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 720D619C46; Thu, 2 Dec 2021 21:44:22 +0000 (UTC) To: Jessica Clarke Subject: Re: [PATCH] riscv: Resolve symbols directly for symbols with STO_RISCV_VARIANT_CC. References: <60359D93-BA59-486D-BCD5-8EB582700FA9@jrtc27.com> Date: Thu, 02 Dec 2021 22:44:20 +0100 In-Reply-To: <60359D93-BA59-486D-BCD5-8EB582700FA9@jrtc27.com> (Jessica Clarke's message of "Thu, 2 Dec 2021 21:06:33 +0000") Message-ID: <87r1auznpn.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Florian Weimer via Libc-alpha Reply-To: Florian Weimer Cc: libc-alpha@sourceware.org, kito.cheng@sifive.com, Andrew Waterman Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" * Jessica Clarke: > The intent of the spec is not to make repurposing just ra/sp/gp/tp as > anything other than their ABI-defined meanings (per table 1 of riscv-cc > and, in the case of the stack pointer, the alignment required by the > integer calling convention) legal unless you use STO_RISCV_VARIANT_CC, > so the glibc requirement, which is also true of FreeBSD for exactly the > same reasons, is intended to be what is specified. Upon re-reading what > was written I can see that requirement was lost or forgotten, so I=E2=80= =99ll > look at tightening it up, probably changing > > Any functions that use additional argument registers ... > > to > > Any functions that use registers in a way that is incompatible with > the register convention of the ABI in use ... > > I also note we currently only talk about the run-time linker preserving > argument registers, and say nothing about preserved registers, nor the > return address. I=E2=80=99m not sure quite why we do the former (maybe I= =E2=80=99ve > just forgotten a past conversation), I feel like that=E2=80=99s implied b= y lazy > binding being an implementation optimisation that must not break the > calling convention, but if we want to keep that language then it should > probably be changed to: > > Run-time linkers that use lazy binding must only clobber registers > defined as temporary registers for the ABI in use. > > Does that all sound sensible, and sufficient, to you? One further aspect is that glibc has dynamic linker plugins called auditors, and arbitrary code can run *after* a function has returned. For that to work, we need save registers used for return values as well. (The default dynamic linker trampoline sidesteps this because it makes a tail call to the actual implementation, based on what the core symbol binding routine in the dynamic linker has returned.) This is a fairly obscure feature, and I don't think anyone has a really good solution for their architecture today. There might also be better alternatives (e.g., if you know the signature of the function you are intercepting, you don't need a general solution for arbitrary calling conventions anymore). Do temporary registers overlap with return registers? Thanks, Florian