From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by sourceware.org (Postfix) with ESMTPS id 0C67A3858404 for ; Thu, 28 Oct 2021 13:31:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0C67A3858404 Received: by mail-qk1-x730.google.com with SMTP id r15so5735894qkp.8 for ; Thu, 28 Oct 2021 06:31:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=RL2atPQHFVfRPD9R0QN3y9MjJTgc6y3s23cmZQqZIWA=; b=XC4vPu9PQk4CSyivVtczRcpmqXfqA1TlZY1H8G3CovD1LinjZF8vT4yt3W3O1GNVVc wfDfmOSoeKw6E8+qizSHyZLMoadlO5RZdMd/SirLLXyGWqKjbyBAAFJDfZerqpruNjns q9RrHEg9jsQt/GvP2jOZ5V0jHns9ZakByx/HeETxOTgPdEzSiM+X/w8KxkWdPLya6W+p 2rASIM/GrDzoIkJ2r4KLh67NTJKGM30152E/w+0oz1y3ibm3MWdUao035JUE6rqNwBQg D316K6VzCgpK+n4CXwbZu2duOMPZMYOURjXUgEv4vyL7wiFoZOjV7wD+ej1sOTmNoEwX XmaA== X-Gm-Message-State: AOAM5306SSqhIhSn7YgSFC2JdeufKzepNkQjG8lmSz6fX+cXv9psRIi5 QEujmqeopG0sKiBdN7DyPram1A== X-Google-Smtp-Source: ABdhPJzmTD+KLpz4tpTl4v0bkuCQb6GOPU2czF9bWf7os9hru+rt2kWxVqbMs1yHfdiaEw1wk1h7pA== X-Received: by 2002:a37:9a90:: with SMTP id c138mr3579774qke.442.1635427914497; Thu, 28 Oct 2021 06:31:54 -0700 (PDT) Received: from ?IPV6:2804:431:c7cb:b64f:597e:dd64:5db8:5deb? ([2804:431:c7cb:b64f:597e:dd64:5db8:5deb]) by smtp.gmail.com with ESMTPSA id w9sm1985786qko.19.2021.10.28.06.31.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Oct 2021 06:31:54 -0700 (PDT) Message-ID: <649b2178-45d0-f9db-f672-66af0eed62e9@linaro.org> Date: Thu, 28 Oct 2021 10:31:52 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Subject: Re: [PATCH] riscv: Fix incorrect jal with HIDDEN_JUMPTARGET Content-Language: en-US To: Fangrui Song , libc-alpha@sourceware.org, Darius Rad , Palmer Dabbelt References: <20211028065019.3247061-1-maskray@google.com> From: Adhemerval Zanella In-Reply-To: <20211028065019.3247061-1-maskray@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, 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 13:31:56 -0000 On 28/10/2021 03:50, Fangrui Song 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. LGTM, thanks. I am testing a patch similar to this locally to make ldd build glibc. Reviewed-by: Adhemerval Zanella > --- > 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) >