Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp28486rdf; Mon, 20 Nov 2023 15:08:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhgYgK0Y0EuWTaSQ7kcGlPaJLsvFwyNuCYgnkZs3WlMLef8dclEwVKjZNAf8SKd/NTLgAx X-Received: by 2002:a05:6a00:238d:b0:6c3:1b8e:eb37 with SMTP id f13-20020a056a00238d00b006c31b8eeb37mr8036046pfc.6.1700521724514; Mon, 20 Nov 2023 15:08:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700521724; cv=none; d=google.com; s=arc-20160816; b=hNtkAIDbuZNtZi+8KoOUkaV0yfLYlXfRJmOzazKK/vopOTsHhe3pbV5hNgW26zf3/3 5HWY6v9YTNnVv70AeGQeC2tIGnNDe4CuredbLLw1goqR80P8Z/DqEvwxz5oKkZQOkgS0 IGeQIzf8/xDSQ2xjTe/cx0dL6L9HKbmUtkJH9wgC4Dl5jQS6lWzB+GccZSINQ6i+74+P 2wNUY2ALYzB/gJnhTy5HWTAK3krtTtKuYOV/EILT8dsp1yW+TG/OtauY9c5fQYbFK5j9 UpyW+HSk7PPcHdBBFhe3aM4CITLYShOCdoMdFumAaatbzq13SgCid7eF4gOkLMBRa0T/ CO4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lbcQGmH2hOx28Iu0BblOZYoc/a8oU+xbzR8FPKrRODI=; fh=rpuzCLcXcayAmY9JHAapG0xs7wT9lrWKiEySMDWz0ZE=; b=byUHS0WMZZgCIG18ckA7rFEbMCCzY2EoD55i3siJ9uaLitwUHLcPirLtjX0rgMW3NX PxMpH2ywG+eL79b2DaIVVM1NhjNUdCXCH0+Im0DEfRJ2Srqm59Fi6W7t0zrikP7wkbIx xnZxkeVP1k9z+UF6Qh+D/Vn952rdIcaaA8XgnFDXF5lLecAZqpBeI0R53KxFM01M3IFW 8gGI8TADV+Iv9iHDBKE3gls1Tdc4vfJhylVwJW52/DfjETTzAyiMK8tEX4F90LVg2NlS BKEoHuh7xinChaaNr4Otjr7dYRYdzK5UblnzI/F7pQ/KDel1DJl6y5CmkTXYldRnGpGG mE/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pm0ocCOu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id j3-20020a056a00130300b00690cd91cee7si9133926pfu.287.2023.11.20.15.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 15:08:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pm0ocCOu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2F2558097281; Mon, 20 Nov 2023 15:08:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229504AbjKTXIZ (ORCPT + 99 others); Mon, 20 Nov 2023 18:08:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjKTXIY (ORCPT ); Mon, 20 Nov 2023 18:08:24 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B51A2 for ; Mon, 20 Nov 2023 15:08:21 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00B7BC433C8; Mon, 20 Nov 2023 23:08:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700521699; bh=CFqoX8V2WNEiSzZISkGpjZgqDIO60dgqCnVyQdufY0k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Pm0ocCOuOM935pl00FZ7y8WqMAQHOpgOGaD6c9Umz3wSPv+b+ywRvOFVrGqJDsjpe MOsKExWGV46pb4wNHQhYNdmWdwFDRVCR/NvTlAfJC8ZM0zlAVG239yHgDJBfDTh0wJ 5LibP1FfBpF5Cnazh/45hzIPRACn0/CDLcwOYP6Iqmd1SaJ5Oc2HzW07QFFy7Nslwn Tn0X8yTzXAP70Gn8/WJ9CKIXnxzSTXPbukl5EMSXBQ6uXbqxGX11uklzQfh/I/Hux8 f4kJEYXAQR/Hsg36Qvqtp9TMUhuYYzAyQubKIN/oQJclZXgxyXYXTm0EuwEnbzWrhY YXmhg5H72w8Jw== Date: Mon, 20 Nov 2023 16:08:17 -0700 From: Nathan Chancellor To: WANG Rui Cc: Huacai Chen , WANG Xuerui , Jinyang He , Xi Ruoyao , linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, loongson-kernel@lists.loongnix.cn Subject: Re: [PATCH] LoongArch: Record pc instead of offset in la-abs relocation Message-ID: <20231120230817.GA2116806@dev-arch.thelio-3990X> References: <20231116130331.241395-1-wangrui@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231116130331.241395-1-wangrui@loongson.cn> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 20 Nov 2023 15:08:40 -0800 (PST) Hi Rui, On Thu, Nov 16, 2023 at 09:03:31PM +0800, WANG Rui wrote: > To clarify, the previous version functioned flawlessly. However, it's > worth noting that the LLVM's LoongArch backend currently lacks support > for cross-section label calculations. With this patch, we enable the use > of clang to compile relocatable kernels. > > Signed-off-by: WANG Rui Thanks a lot for the patch! This fixes the CONFIG_RELOCATABLE build for me as well. Tested-by: Nathan Chancellor Something I noticed while testing is that a kernel linked with ld.lld does not boot while one linked with ld.bfd did. I think this might be the same issue that Xuerui filed on our issue tracker but I figured I would mention it in case not: https://github.com/ClangBuiltLinux/linux/issues/1883 Cheers, Nathan > --- > arch/loongarch/include/asm/asmmacro.h | 3 +-- > arch/loongarch/include/asm/setup.h | 2 +- > arch/loongarch/kernel/relocate.c | 2 +- > 3 files changed, 3 insertions(+), 4 deletions(-) > > diff --git a/arch/loongarch/include/asm/asmmacro.h b/arch/loongarch/include/asm/asmmacro.h > index c9544f358c33..655db7d7a427 100644 > --- a/arch/loongarch/include/asm/asmmacro.h > +++ b/arch/loongarch/include/asm/asmmacro.h > @@ -609,8 +609,7 @@ > lu32i.d \reg, 0 > lu52i.d \reg, \reg, 0 > .pushsection ".la_abs", "aw", %progbits > - 768: > - .dword 768b-766b > + .dword 766b > .dword \sym > .popsection > #endif > diff --git a/arch/loongarch/include/asm/setup.h b/arch/loongarch/include/asm/setup.h > index a0bc159ce8bd..ee52fb1e9963 100644 > --- a/arch/loongarch/include/asm/setup.h > +++ b/arch/loongarch/include/asm/setup.h > @@ -25,7 +25,7 @@ extern void set_merr_handler(unsigned long offset, void *addr, unsigned long len > #ifdef CONFIG_RELOCATABLE > > struct rela_la_abs { > - long offset; > + long pc; > long symvalue; > }; > > diff --git a/arch/loongarch/kernel/relocate.c b/arch/loongarch/kernel/relocate.c > index 6c3eff9af9fb..288b739ca88d 100644 > --- a/arch/loongarch/kernel/relocate.c > +++ b/arch/loongarch/kernel/relocate.c > @@ -52,7 +52,7 @@ static inline void __init relocate_absolute(long random_offset) > for (p = begin; (void *)p < end; p++) { > long v = p->symvalue; > uint32_t lu12iw, ori, lu32id, lu52id; > - union loongarch_instruction *insn = (void *)p - p->offset; > + union loongarch_instruction *insn = (void *)p->pc; > > lu12iw = (v >> 12) & 0xfffff; > ori = v & 0xfff; > -- > 2.42.1 > >