From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 6019D3858405 for ; Thu, 28 Oct 2021 18:05:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6019D3858405 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dabbelt.com Received: by mail-pg1-x52c.google.com with SMTP id e65so7187349pgc.5 for ; Thu, 28 Oct 2021 11:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=KyljQ2jTz7LPqFs2EifdXnL+BNTZ2P6qfG98y+2Q320=; b=AMfNqsMC7U+lW/meo9rNqmwyB4vdNs7W8whMmEix6qlJC/IfGME0/BK04XhrTgD7me qP7Om0lMWjmZQWh576GQQ561+n5qgYbi85qHX6kHItsWfjtVCazXneqYdEGer9kjUE0a hmoILpRMByekRirtCZ7BpCxMJ2aLwJ56BHEhW0stD7LwwdM9UXmZOHpGS/3H8AmdqUqd VZZ22NDBV71KRVr/BFKXi8l3GYs9V0cWrfPqihZXnLrI0joeXIk/u2Z56YmTK7C/S2xL NGV4wTs2kCV2dSHSocYGjtK71eSH7yQmGPZhaSjA7TiTjW1Q1IT0Vczpz1o15IGrGcsh 4LOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=KyljQ2jTz7LPqFs2EifdXnL+BNTZ2P6qfG98y+2Q320=; b=AwmQ/Fm4VNNYSfLsCmo2h1gzsoIlmSIsBewEv6lBcqL/9FuY4QmUiMVg+wS2QHtNN+ ivFkglhgV04jlpq2GsLkS+SosOGVv9CHswajaEirVEzCSbe1nY6j6NKQM5fCFnmbyZg1 j+lLIVYpA9osWiwSFzfrJBSrKtRwk3Sbrz+AGy+btChzD65BFPFbPJEwyF4cCQzINFzr uE2iq4XBnlf4z8fYYQeLO/QVuterSdlwCT/XxkBw76rIwUCD310N/mQRdik4MNXlEUau MIh5tHMfQV8V17IzVqSoT8xeT2qZq7usb3q4/3TwMh+GNy6O1mMknsVIfR4VpDzHCYCV idew== X-Gm-Message-State: AOAM532oj07jMGfya2rSK0eAE5orR1jQ7uoW072gsEWXnb0Gh3qB7Re2 v+vGiR0HcfZUt5/m50n+TLtn+wUDOGNhow== X-Google-Smtp-Source: ABdhPJwMcC7yg650G/eNvHkklC7Dx0ireVYq1tZyxAx56Xv+hBtMOj1udoKr0FHag7yh/HsfEhBdTA== X-Received: by 2002:a63:2c91:: with SMTP id s139mr4263055pgs.116.1635444323149; Thu, 28 Oct 2021 11:05:23 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id ls7sm3857901pjb.16.2021.10.28.11.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Oct 2021 11:05:22 -0700 (PDT) Date: Thu, 28 Oct 2021 11:05:22 -0700 (PDT) X-Google-Original-Date: Thu, 28 Oct 2021 11:05:20 PDT (-0700) Subject: Re: [PATCH] riscv: Fix incorrect jal with HIDDEN_JUMPTARGET In-Reply-To: <20211028065019.3247061-1-maskray@google.com> CC: libc-alpha@sourceware.org, Darius Rad , adhemerval.zanella@linaro.org, maskray@google.com From: Palmer Dabbelt To: maskray@google.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Thu, 28 Oct 2021 18:05:26 -0000 On Wed, 27 Oct 2021 23:50:19 PDT (-0700), maskray@google.com wrote: > A non-local STV_DEFAULT defined symbol is by default preemptible in a > shared object. j/jal cannot target a preemptible symbol. On other > architectures, such a jump instruction either causes PLT [BZ #18822], or > if short-ranged, sometimes rejected by the linker (but not by GNU ld's > riscv port [ld PR/28509]). > > Use HIDDEN_JUMPTARGET to target a non-preemptible symbol instead. > > With this patch, ld.so and libc.so can be linked with LLD if source > files are compiled/assembled with -mno-relax/-Wa,-mno-relax. > --- > sysdeps/riscv/setjmp.S | 2 +- > sysdeps/unix/sysv/linux/riscv/setcontext.S | 5 +++-- > 2 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/sysdeps/riscv/setjmp.S b/sysdeps/riscv/setjmp.S > index 0b92016b31..bec7ff80f4 100644 > --- a/sysdeps/riscv/setjmp.S > +++ b/sysdeps/riscv/setjmp.S > @@ -21,7 +21,7 @@ > > ENTRY (_setjmp) > li a1, 0 > - j __sigsetjmp > + j HIDDEN_JUMPTARGET (__sigsetjmp) > END (_setjmp) > ENTRY (setjmp) > li a1, 1 > diff --git a/sysdeps/unix/sysv/linux/riscv/setcontext.S b/sysdeps/unix/sysv/linux/riscv/setcontext.S > index 9510518750..e44a68aad4 100644 > --- a/sysdeps/unix/sysv/linux/riscv/setcontext.S > +++ b/sysdeps/unix/sysv/linux/riscv/setcontext.S > @@ -95,6 +95,7 @@ LEAF (__setcontext) > 99: j __syscall_error > > END (__setcontext) > +libc_hidden_def (__setcontext) > weak_alias (__setcontext, setcontext) > > LEAF (__start_context) > @@ -108,7 +109,7 @@ LEAF (__start_context) > /* Invoke subsequent context if present, else exit(0). */ > mv a0, s2 > beqz s2, 1f > - jal __setcontext > -1: j exit > + jal HIDDEN_JUMPTARGET (__setcontext) > +1: j HIDDEN_JUMPTARGET (exit) > > END (__start_context) Acked-by: Palmer Dabbelt Thanks. Fangrui said he'd be able to commit this, which is fine with me.