Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp131948imn; Fri, 29 Jul 2022 02:03:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vguTaXTv1l6KcawU6KUkep0bWWihWEDb0GGRA8TFTB088CBA2DPuEPHmrj3jVxZFOpQw3g X-Received: by 2002:a17:906:ef8c:b0:72e:dd32:4163 with SMTP id ze12-20020a170906ef8c00b0072edd324163mr2167175ejb.430.1659085404692; Fri, 29 Jul 2022 02:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659085404; cv=none; d=google.com; s=arc-20160816; b=qKLzAKJsmCzIoXFciUjJPr+8OWo4qBjWZmKu9R9RogUC+RwVKwdxYW7Pixpa3y7r08 sruhPXyD5R0Pyb4PJRpA23GLFDZbKN8L3sUcO5A5WgpKEH0XTCvW+o4eJr4Aw4RiNojX 7k6/7FTX4TwwoJXtYVr7AgQWk1hHYn2WZZIrL1EzulSEt4eZVgL3jsuU6Evij8oOyJJN 8dxfrTrN+z7s0RluMeD3PkiHsRHcSM3BUX9KdT0Ivvd84Lltn/3PMppN6ns2c8mRpvH+ heSK4fG2ZVCRgR7T+NOk8yUHlt2eTlt+pitPzBG2Tk8Qv9TkItiWM+JDJdtLeaD140/W zdOw== 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=kn5JxGZhYexjkTIEACr+a/Vy+TWVGE6FjiZFxRYnBkI=; b=WulXZaR4rpxIVYVhAgkYzAiiwFOQ8xCBOQ0uyqbdy9rET0hEP0zBcMJneSHWn7jBO/ wfv8JfnSeQKlQeTL2M1KGFxE0pTGNX5/G8JExdmZkA1re/J30TuIU+mFR31UjqFUlhQU y9REauK+PILfyjZa7LMf6IieEoMG89f3nWAaneecChbbz0tsuXdptXTgShudNKXwX17p f86XFPer4y8lZ3f8wIP9iXMEyjO9l5uo1+em3o9BCIDAfcJRldPeELnQY72GZJZF8ItV EkL/sRiVyz+QvQq46GpJXeuvW4gz6aVw1GxxQ9FF8DhKLHa+xpCV8E75P0C5hdnSWP+F 3jFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=YHcPCeFt; 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 lw8-20020a170906bcc800b0072b6e6512e5si2542905ejb.490.2022.07.29.02.02.56; Fri, 29 Jul 2022 02:03:24 -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=YHcPCeFt; 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 S232975AbiG2Ilh (ORCPT + 99 others); Fri, 29 Jul 2022 04:41:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230053AbiG2Ilg (ORCPT ); Fri, 29 Jul 2022 04:41:36 -0400 Received: from xry111.site (xry111.site [89.208.246.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B165FC14 for ; Fri, 29 Jul 2022 01:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1659084095; bh=DEm0AiZvgESD0YKH9m6+qJUmd8ZlwNHimBfcIFiEhRo=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=YHcPCeFtcom6xD7njxjurdv3QUa+CGRWyFVVt9n/9CkeE1dYmOVMKtMfDBMJiPURK 2N+WdPAKDJkh8H6ZCILDOI7bsgq6nB54g5sGRzp2OwX0ba4W6Uesbly1FvpiMsLSO8 4o100kBdCnOou1zot+XK3n2/bpBSGDUVsY40MGHQ= 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 132DF669EC; Fri, 29 Jul 2022 04:41:33 -0400 (EDT) Message-ID: <55e9722e962a3fe535f63206ac169538f902d0f2.camel@xry111.site> Subject: [PATCH v4 3/4] LoongArch: Remove -fplt and -Wa,-mla-* from CFLAGS From: Xi Ruoyao To: loongarch@lists.linux.dev Cc: linux-kernel@vger.kernel.org, WANG Xuerui , Huacai Chen , Youling Tang , Jinyang He Date: Fri, 29 Jul 2022 16:41:32 +0800 In-Reply-To: <32a74a218c76611f897fd1df1ad0059068621133.camel@xry111.site> References: <32a74a218c76611f897fd1df1ad0059068621133.camel@xry111.site> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.3 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 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 -fplt is the default of all supported compilers (GCC, and maybe Clang in the future), so it needs not to be explicitly specified. -Wa,-mla-* options were used to prevent the assembler from generating GOT accesses for "la.local" and "la.global" macros. But GCC >=3D 13 will generate GOT access explicitly without use of these macros by default if the assembler supports explicit specification for relocations. And, it's not recommended to override the default as the use of assembler macros may limit optimization. Now we can handle GOT and GOT-based relocations properly, so we can remove these options and use GOT access for both GCC 12 and 13 (or newer). GAS <=3D 2.39 does not support "la.got [reg], [sym] + [offset]" with a non-zero offset. So in the assembly code we explicitly use "la.pcrel" instead of "la" (now defaulted to "la.got") where a PC-relative addressing is suitable, in order to work around this limitation and keep the compatibility with old toolchains. Signed-off-by: Xi Ruoyao --- arch/loongarch/Makefile | 4 ---- arch/loongarch/kernel/head.S | 10 +++++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/loongarch/Makefile b/arch/loongarch/Makefile index 039dcc4fe1f3..800349ea9310 100644 --- a/arch/loongarch/Makefile +++ b/arch/loongarch/Makefile @@ -40,10 +40,6 @@ endif =20 cflags-y +=3D -G0 -pipe -msoft-float LDFLAGS_vmlinux +=3D -G0 -static -n -nostdlib -KBUILD_AFLAGS_KERNEL +=3D -Wa,-mla-global-with-pcrel -KBUILD_CFLAGS_KERNEL +=3D -Wa,-mla-global-with-pcrel -KBUILD_AFLAGS_MODULE +=3D -Wa,-mla-global-with-abs -KBUILD_CFLAGS_MODULE +=3D -fplt -Wa,-mla-global-with-abs,-mla-local-with-= abs =20 cflags-y +=3D -ffreestanding cflags-y +=3D $(call cc-option, -mno-check-zero-division) diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S index 74ea7bf6c8d6..193329ed6e8c 100644 --- a/arch/loongarch/kernel/head.S +++ b/arch/loongarch/kernel/head.S @@ -60,17 +60,17 @@ SYM_CODE_START(kernel_entry) # kernel entry point la.abs t0, 0f jirl zero, t0, 0 0: - la t0, __bss_start # clear .bss + la.pcrel t0, __bss_start # clear .bss st.d zero, t0, 0 - la t1, __bss_stop - LONGSIZE + la.pcrel t1, __bss_stop - LONGSIZE 1: addi.d t0, t0, LONGSIZE st.d zero, t0, 0 bne t0, t1, 1b =20 - la t0, fw_arg0 + la.pcrel t0, fw_arg0 st.d a0, t0, 0 # firmware arguments - la t0, fw_arg1 + la.pcrel t0, fw_arg1 st.d a1, t0, 0 =20 /* KSave3 used for percpu base, initialized as 0 */ @@ -78,7 +78,7 @@ SYM_CODE_START(kernel_entry) # kernel entry point /* GPR21 used for percpu base (runtime), initialized as 0 */ or u0, zero, zero =20 - la tp, init_thread_union + la.pcrel tp, init_thread_union /* Set the SP after an empty pt_regs. */ PTR_LI sp, (_THREAD_SIZE - 32 - PT_SIZE) PTR_ADD sp, sp, tp --=20 2.37.0