Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1839213rwe; Fri, 2 Sep 2022 04:51:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR7e4zJ1NXRG4tT5PY9EPrgSWM9jgiJT6bbWoXoLXLpdVlrGD6uwHraqgefZUVV671sYi+RQ X-Received: by 2002:a05:6a00:114f:b0:528:2c7a:634c with SMTP id b15-20020a056a00114f00b005282c7a634cmr35691587pfm.41.1662119472245; Fri, 02 Sep 2022 04:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662119472; cv=none; d=google.com; s=arc-20160816; b=aIHo1qoiy2cNLKOGIMUTWEEodIcfJ+UslQswUXNRuSvpcoR4a/OuMmvO83YiHA0uAl XWdPDhmr6xUyObrEbzCtxm3+wfJ56o3nbI8bgF3PbSMjEKK1x/iV50teOeOWb0iP31qU mApxpYhs8XK4oZPh0+Ia7oD24n9dyVEX23rHZbrwWyb/tTSmHdKLRrJfLSstJxWZsDEe PyKIldAhNwEEVk/zs/Zas+Win/Ydrc0Ld12iqF8ph7qgVehyHq3xwlv0InL3H6nh1p1F oXPEHdeORb5IV/E+mEgZw+UR13cbB2YaV02ct6TvfZYwaywAnG0hxgObXryvnehPY/So p+TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=rFyj/oy6Tq5oo4+SvgvXbAA+R2fXY5QC8A9hGOZ0HHM=; b=pUiGjFtpI05AxEfjtlENDaJ+6UrWR9DclkaNz0urxe5T2M3lsqFeDWUD4wcFfWnI3n TyraRG2qF9gJJ8w3KYsBkseP8A3vQ6ftcTpIhspCs+bonK+QQ+X5Xq5G4Plb/yAYmHX4 HhTirj1Z5OruIY4FtNDfBSGVW290CuNsLj+vVK/sBTPPHW75HayJVXPLFqUd0BwRElDr XHHVyod4hPS32Y6wdtW1CRSewD56JyDLtWXSvXcOcoaYHwwBCbMtJV2oofs/TDZ/ZW6K XGoBzQsM2teR/YhWQzfcB7YahhGPIoc5LRjY9OXWJp0jk+3DXuZblaNjL0q0r5nDzQUw 2TWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=fOVkMWdp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a6552c9000000b0042b77aa55fdsi1718161pgp.464.2022.09.02.04.50.45; Fri, 02 Sep 2022 04:51:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=fOVkMWdp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235854AbiIBLb1 (ORCPT + 99 others); Fri, 2 Sep 2022 07:31:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235784AbiIBLbJ (ORCPT ); Fri, 2 Sep 2022 07:31:09 -0400 Received: from xry111.site (xry111.site [89.208.246.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9240101FB for ; Fri, 2 Sep 2022 04:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1662118051; bh=rFyj/oy6Tq5oo4+SvgvXbAA+R2fXY5QC8A9hGOZ0HHM=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=fOVkMWdp0pxK2RWZpFq34GF6+sKwscbm/IhvLZqKS6peqvOIjMQjQd0TZ+ft20b44 GdYAomPWU0U2r/P51r6e6UmGk1FRbMge/rx/h2FteoS3MH3MxOEU60Z44ElUe1xQ3K TXILwbifVC389WOymN3/TjyARzpLtTIaAU4Jpa4M= Received: from localhost.localdomain (xry111.site [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 72E2C6682D; Fri, 2 Sep 2022 07:27:30 -0400 (EDT) Message-ID: <4df8a26c49a35c1fce36d80c370f738fa71a2bef.camel@xry111.site> Subject: Re: [PATCH 1/3] LoongArch: tools: Add relocs tool support From: Xi Ruoyao To: Youling Tang , Huacai Chen Cc: linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, Xuerui Wang , Jiaxun Yang Date: Fri, 02 Sep 2022 19:27:28 +0800 In-Reply-To: References: <1662113335-14282-1-git-send-email-tangyouling@loongson.cn> <1662113335-14282-2-git-send-email-tangyouling@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.45.2 MIME-Version: 1.0 X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD, PDS_OTHER_BAD_TLD,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2022-09-02 at 19:10 +0800, Xi Ruoyao wrote: > Hi Youling, >=20 > On Fri, 2022-09-02 at 18:08 +0800, Youling Tang wrote: > > This tool is based on the arch/mips/boot/tools/relocs tool. >=20 > I've dig some history of MIPS relocatable kernel > (https://lwn.net/Articles/682020/): >=20 > =C2=A0=C2=A0 * Kernel is compiled & statically linked as normal, with no = position > =C2=A0=C2=A0=C2=A0=C2=A0 independent code. MIPS before R6 only has limite= d relative jump > =C2=A0=C2=A0=C2=A0=C2=A0 instructions so the vast majority of jumps are a= bsolute. To compile > =C2=A0=C2=A0=C2=A0=C2=A0 the kernel position independent would introduce = a highly undesireable > =C2=A0=C2=A0=C2=A0=C2=A0 overhead. Relocating the static binary gives a s= mall startup time > =C2=A0=C2=A0=C2=A0=C2=A0 penalty but the kernel otherwise perforns normal= ly. >=20 > Unlike (pre-r6) MIPS, LoongArch has a complete support for PIC, and > currently LoongArch toolchain always produces PIC (except, if -Wa,-mla- > {local,global}-with-abs or la.abs macros are used explicitly). >=20 > So would it be easier to review and correct the uses of "la.abs" in the > code, and make the main kernel image a real PIE?=C2=A0 Then we can load i= t > everywhere w/o any need to do relocation at load time. Arrgh, doing so will need to get rid of GOT (the GCC patch for this is still under review) or we still need to relocate the GOT at least :(. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University