Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp158584imn; Fri, 29 Jul 2022 03:06:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR4dc7FgPyfMFvd6WD26eCV2TbsleIR/qA07MOe/PCqBa23Z7dS4onS2pOOSC6Qrg+HQgY2y X-Received: by 2002:a17:903:2351:b0:16d:9468:bb02 with SMTP id c17-20020a170903235100b0016d9468bb02mr3070799plh.82.1659089192282; Fri, 29 Jul 2022 03:06:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659089192; cv=none; d=google.com; s=arc-20160816; b=eAEpthXD/OOKCzXuZxnZH6q+D7DCTjId/oGRCgDo7ZzBZnSMSMNsND/Ap6LsZd1GiD 33QN+z4F1eOWXpfMfUCJTa35rs/2bkuume+h09X5bHNqlhj5LtH3QP8TFWxqsBhfGYqq VID2zsa2Hbp4j9ZupwGmsvTVl4OaPzGEPEspK3jtBM8PR1r94PIfEaEM+AeQTGf96iJS MyUD0HEysA2qP5PFRxGLiakH5ZXYbFqf8NAC09AyYHdxXJ0nfz51oVqNujzB8vZc2baL /y1JPQYSfAB7fQTl3eYbTK0ZMxMtJ9eRUksM2BM0EB1gmY6IReD8fk25BVE5NeBAi/JW /M7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=De5D/szTP1aySG5BFqGFzRsZCYZ5LOv+ATNxAM330O0=; b=YLdOUwHwRLjh/kHP4Ot0yKwl2s55vh4N9jmB2WAkw+EwqmQHPx+KF7nZ2aD5YokoCW VSt6icEaudiprP5uW/FriPCjic7nUHNRy7+LEyYkghG4huHN9qcbr490uWiaVHHUaHWQ I1LxP7JojWyKlXtM6R/Jv/U6MqYpIL9rIELTLStE9j1XHEYAJMTj3syV+vUYr3vFdJgn O3eDKPC4aXJDQCY9OmQ5fNH9Q26q1JNUX6jqoSjlhWtrL4WFnXvUGnrv3XFzfXQhYqcD pICTbycTmNWiilcOkufRY8GuduzWr8NlIg1K5Xda5oXZGPe+z1mfEINkMWZ5D9sbTutn 7x1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=NuUwrClV; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b24-20020a17090a991800b001f22cc15dcasi3101156pjp.112.2022.07.29.03.06.16; Fri, 29 Jul 2022 03:06:32 -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=@xen0n.name header.s=mail header.b=NuUwrClV; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235686AbiG2Jrd (ORCPT + 99 others); Fri, 29 Jul 2022 05:47:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235657AbiG2Jrc (ORCPT ); Fri, 29 Jul 2022 05:47:32 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3C2D1F609 for ; Fri, 29 Jul 2022 02:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1659088044; bh=UeD/jfW+A1CZ4GGUNDiEY/6KnggkPxlj/RfG5x+Rv0I=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NuUwrClVrzg2dJWV5RaVGqUmWLW3Zt7Bn8ld/apkyKhtTebLosFw4r/PvzeuzEwWh /BArHVzVKs0tVhWK4KcU13DwrI0Cj3gIHmoazr+I1ilDz4cYLOMEYTUQn0i5XkReBd oC8rR74WpVMRDbyLFEAepFK21sLFrZKhjF6oVM1M= Received: from [100.100.57.219] (unknown [220.248.53.61]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id A7DA060610; Fri, 29 Jul 2022 17:47:24 +0800 (CST) Message-ID: <4a61d1a5-539f-25f9-4acd-92e107bc99a0@xen0n.name> Date: Fri, 29 Jul 2022 17:47:24 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:105.0) Gecko/20100101 Thunderbird/105.0a1 Subject: Re: [PATCH v4 0/4] LoongArch: Support new relocation types Content-Language: en-US To: Xi Ruoyao , loongarch@lists.linux.dev Cc: linux-kernel@vger.kernel.org, Huacai Chen , Youling Tang , Jinyang He References: <32a74a218c76611f897fd1df1ad0059068621133.camel@xry111.site> From: WANG Xuerui In-Reply-To: <32a74a218c76611f897fd1df1ad0059068621133.camel@xry111.site> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 2022/7/29 16:38, Xi Ruoyao wrote: > The version 2.00 of LoongArch ELF ABI specification introduced new > relocation types, and the development tree of Binutils and GCC has > started to use them. If the kernel is built with the latest snapshot of > Binutils or GCC, it will fail to load the modules because of unrecognized > relocation types in modules. > > Add support for GOT and new relocation types for the module loader, so > the kernel (with modules) can be built with the "normal" code model and > function properly. > > This series does not break the compatibility with old toolchain using > stack-based relocation types, so with the patches applied the kernel can > be be built with both old and new toolchains. > > Tested by building the kernel with both Binutils & GCC master branch and > my system Binutils & GCC (without new relocation type support), running > both the builds with 35 in-tree modules loaded, and loading one module > with 20 GOT loads (loaded addresses verified by comparing with > /proc/kallsyms). > > Changes from v3 to v4: > > - No code change. Reword the commit message of the 3rd patch again > based on suggestion from Huacai. > > Changes from v2 to v3: > > - Use `union loongarch_instruction` instead of explicit bit shifts > applying the relocation. Suggested by Youling. > - For R_LARCH_B26, move the alignment check before the range check to be > consistent with stack pop relocations. Suggested by Youling. > - Reword the commit message of the 3rd patch. Suggested by Huacai. > > Changes from v1 to v2: > > - Fix a stupid programming error (confusion between the number of PLT > entries and the number of GOT entries). (Bug spotted by Youling). > - Synthesize the _GLOBAL_OFFSET_TABLE_ symbol with module.lds, instead > of faking it at runtime. The 3rd patch from V1 is now merged into > the 1st patch because it would be a one-line change. (Suggested by > Jinyang). > - Keep reloc_rela_handlers[] ordered by the relocation type ID. > (Suggested by Youling). > - Remove -fplt along with -Wa,-mla-* options because it's the default. > (Suggested by Youling). > > Xi Ruoyao (4): > LoongArch: Add section of GOT for kernel module > LoongArch: Support R_LARCH_SOP_PUSH_GPREL relocation type in kernel > module > LoongArch: Remove -fplt and -Wa,-mla-* from CFLAGS > LoongArch: Support modules with new relocation types > > arch/loongarch/Makefile | 4 -- > arch/loongarch/include/asm/elf.h | 37 ++++++++++ > arch/loongarch/include/asm/module.h | 23 ++++++ > arch/loongarch/include/asm/module.lds.h | 1 + > arch/loongarch/kernel/head.S | 10 +-- > arch/loongarch/kernel/module-sections.c | 51 +++++++++++-- > arch/loongarch/kernel/module.c | 96 +++++++++++++++++++++++++ > 7 files changed, 209 insertions(+), 13 deletions(-) > Thanks very much for the timely adaptation. I'm rebuilding my Gentoo toolchain from upstream HEAD, will test this weekend. -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/