Received: by 2002:ac0:b7d5:0:0:0:0:0 with SMTP id v21csp117662ime; Thu, 28 Jul 2022 19:30:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vDeC+lqp3oFQ//mChdNjdJHvvjgXPpCR2oDxYZQtsKojk5LOYWJrJr7ao/auEGxWu+VtZa X-Received: by 2002:a05:6402:42c3:b0:43b:c870:9b54 with SMTP id i3-20020a05640242c300b0043bc8709b54mr1581544edc.11.1659061810902; Thu, 28 Jul 2022 19:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659061810; cv=none; d=google.com; s=arc-20160816; b=GqLdJ71sHFX6JABBf7/eV1YEO2Fl2nCV7qPXoWonlkznsCPoW3x6dhYuy8r6rxpFAj xnOhNiRIRQ9kaFRhj1moCDTvIGrpdFdB8BGN68rWpUIrF0a8I7O+xoMlr0NR4bc52zfp v9RMwzBSN2wpTxlG0u4Z/VQx50uhOPW6yfDJaPCU1n+HtyMZvJGZv2DUX3G8J5n16sOY s2NJkah5K5YbqAo25qMmqivo4Se9HD90G3VToo2MmFOPbpfbMihbG2TRFOrUqmt8cdBO pIiUEoA16J7w6jgoMP45K7r/Oc1xAPNccdKHAOBMZ3UXmdEjYeVK8zGVqqpzbl05kJsR t8IA== 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=KN1WHegEUVgyh3/0vhAyMbxdX7YVUTsD8fE0FttsCXM=; b=NXTfMv36NOqXGkZpdIzoWog2kl9rrDhJdNDqFm35X9EzcDX6vcXmp4kpFt02JQyx0e kgUEXH/RAPRLVuGj3NztS/RuOJhJqmacDZdOEHO0MFla+eLZM9W2yXxaDVsdzMuDGzLS 2N7cxa36WEKVcuwrpfUv0q8BE5eHorEzp4K6fBmk40HOqvn4dCG42pUpgKWBwmXmLC26 EQ+BUo1mhuadpFsM5fl7QkMOfuo/Vh3Se8HZSZWzee4Se1bWKzvReWZLamNjhXs+WNyr L6Uc//f+6En4AW/6uXeZ5mV/WkUetG1DU0Ffs8kshN7fZT7uvdj73K4W9bxJWrDkTaN6 y1HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b=INJrpYgH; 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 v10-20020a17090690ca00b0072f2e142584si1832798ejw.772.2022.07.28.19.29.46; Thu, 28 Jul 2022 19:30:10 -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=INJrpYgH; 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 S231897AbiG2CKA (ORCPT + 99 others); Thu, 28 Jul 2022 22:10:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229643AbiG2CJ6 (ORCPT ); Thu, 28 Jul 2022 22:09:58 -0400 Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB30479EE4 for ; Thu, 28 Jul 2022 19:09:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1659060594; bh=eKojhGSrp5Nzdwbp8zmcNPFzO/9cxIKBEXrBgbRon5Q=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=INJrpYgHv2XlnNjM4pbSiZAbH0MW6V2t5UKFYKfWXk3q4ctNIAA15gp0axYAKqkI3 xszjq0BkKPashPapR2nhymh8LpfgQxTKrhXNxpY/NUyPF+bku/oNdq36ScE8oh9TjE uwp21KUPp1dmVQZ1I9jsSwPPZSEVrqL/ijk9Re8U= 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)) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 2E83A65929; Thu, 28 Jul 2022 22:09:52 -0400 (EDT) Message-ID: <4da7ce6a6e5b6d609c37ebf6815caacc3b3b8297.camel@xry111.site> Subject: [PATCH v3 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 10:09:51 +0800 In-Reply-To: References: 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, so these options are ineffective for symbol addressing in C code with GCC >=3D 13. 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