From patchwork Fri Mar 31 09:15:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 77678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp437075vqo; Fri, 31 Mar 2023 02:43:40 -0700 (PDT) X-Google-Smtp-Source: AKy350b4zxSi8SsTdF5sFVHL9Oj1CPtSPknwpvq7dVxFKvgYhBSempHob49mml+kQLxQ11xtICy0 X-Received: by 2002:a17:906:eda4:b0:947:a3ed:df91 with SMTP id sa4-20020a170906eda400b00947a3eddf91mr1752829ejb.70.1680255819896; Fri, 31 Mar 2023 02:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680255819; cv=none; d=google.com; s=arc-20160816; b=f/cTc6rjRybb7EnulvAok2qUOYkDbWu9Hpzv6w8vGNa+jDwecSPc31M68H7eSr0MHJ bFathUxtF0eR4yykLPWksJ3/b6OC4NYony7Tsq2HKjBbL3LadhUKzFXKiyrxyIUzUChS UVJo4EBxhtEL7I81XJQgHMNyB41RMk6UNWOdDJAmAYXdJClsO58dp4Iu2oc6Q6Y4wjJ2 z5QMqewW6MQi5SSp44pdAAk9VXJkkmI5EhcoXmnmTVhz6SICM+PjjRAWjT7eF7URFU+U LBE3WjbmwRY5r/AipWU/1mj5NozRELExXnL5BnFNJdH0iUbiUsqAQfgPwjOW9hY1zkNJ JYFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=hriaiYyqJf+L3ROtnONYx1hi35PN+XcbvnB6Mqs3Tqw=; b=hVwmBroKlrMuk4l3lg2MGrCiIHMnVP3XoJbnndqVFitAVm8d7wefiFXsV9KQYC1Kq2 Hdn9iTGHgEnz8kMkzV9aPy+8V5K5Lj2/OW99wtGu7HxgMsIKywb1sFwk8U4pazcCpbVA ky2AOsGXYEzcJAfrsNfqfsW1k1iO4f5JRrUcCmd+ZsNHigpFLZJN2gbGKTrWmD3TEijA Yeu35DBI4SAi+QovSlo9JSo9oHZRDgd8CWj49jHQewKF0D1RcQGwQyjQoTk42bPUvaeq tADa0/SMhY6Nn6LIUnuVAFLxxZettDDZRytgiN8sfKwze8uxXmSGmcGuQ2rtiGH0CRRP bQXA== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lo1-20020a170906fa0100b00933314f56fdsi1489930ejb.737.2023.03.31.02.43.15; Fri, 31 Mar 2023 02:43:39 -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; 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 S231703AbjCaJQf (ORCPT + 99 others); Fri, 31 Mar 2023 05:16:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231268AbjCaJQO (ORCPT ); Fri, 31 Mar 2023 05:16:14 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 69655C173; Fri, 31 Mar 2023 02:16:04 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8DxUOXTpCZkv+QUAA--.32142S3; Fri, 31 Mar 2023 17:16:03 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxC77OpCZkVfMRAA--.14538S4; Fri, 31 Mar 2023 17:16:02 +0800 (CST) From: Tiezhu Yang To: Luis Chamberlain Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH 2/3] module: Move is_arm_mapping_symbol() to module_symbol.h Date: Fri, 31 Mar 2023 17:15:52 +0800 Message-Id: <1680254153-14582-3-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1680254153-14582-1-git-send-email-yangtiezhu@loongson.cn> References: <1680254153-14582-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8DxC77OpCZkVfMRAA--.14538S4 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoWxAr18Gr1UWw1DCF47ArWfGrg_yoW5Cr1xpF n8Cw4rJr4rAr1UGa4fuw1vyr13uw4vgr4jyr9xKryxZrnIqF1vqrZrKr1Yvw1xXrZrGF40 9r4fZFW3CFWfZaUanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7AYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JrI_Jryl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS 0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JV W8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8QJ57UUUUU== X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761875926677734227?= X-GMAIL-MSGID: =?utf-8?q?1761875926677734227?= In order to avoid duplicated code, move is_arm_mapping_symbol() to include/linux/module_symbol.h, then remove is_arm_mapping_symbol() in the other places. Signed-off-by: Tiezhu Yang --- include/linux/module_symbol.h | 15 +++++++++++++++ kernel/module/kallsyms.c | 14 +------------- scripts/mod/modpost.c | 10 +--------- 3 files changed, 17 insertions(+), 22 deletions(-) create mode 100644 include/linux/module_symbol.h diff --git a/include/linux/module_symbol.h b/include/linux/module_symbol.h new file mode 100644 index 0000000..9fa4173 --- /dev/null +++ b/include/linux/module_symbol.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _LINUX_MODULE_SYMBOL_H +#define _LINUX_MODULE_SYMBOL_H + +/* This ignores the intensely annoying "mapping symbols" found in ELF files. */ +static inline int is_arm_mapping_symbol(const char *str) +{ + if (str[0] == '.' && str[1] == 'L') + return true; + return str[0] == '$' && + (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x') + && (str[2] == '\0' || str[2] == '.'); +} + +#endif /* _LINUX_MODULE_SYMBOL_H */ diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c index a9045fe..5de3207 100644 --- a/kernel/module/kallsyms.c +++ b/kernel/module/kallsyms.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -243,19 +244,6 @@ void init_build_id(struct module *mod, const struct load_info *info) } #endif -/* - * This ignores the intensely annoying "mapping symbols" found - * in ARM ELF files: $a, $t and $d. - */ -static inline int is_arm_mapping_symbol(const char *str) -{ - if (str[0] == '.' && str[1] == 'L') - return true; - return str[0] == '$' && - (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x') - && (str[2] == '\0' || str[2] == '.'); -} - static const char *kallsyms_symbol_name(struct mod_kallsyms *kallsyms, unsigned int symnum) { return kallsyms->strtab + kallsyms->symtab[symnum].st_name; diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 79a27cc..7241db8 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -22,6 +22,7 @@ #include #include "modpost.h" #include "../../include/linux/license.h" +#include "../../include/linux/module_symbol.h" /* Are we using CONFIG_MODVERSIONS? */ static bool modversions; @@ -1112,15 +1113,6 @@ static int secref_whitelist(const struct sectioncheck *mismatch, return 1; } -static inline int is_arm_mapping_symbol(const char *str) -{ - if (str[0] == '.' && str[1] == 'L') - return true; - return str[0] == '$' && - (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x') - && (str[2] == '\0' || str[2] == '.'); -} - /* * If there's no name there, ignore it; likewise, ignore it if it's * one of the magic symbols emitted used by current ARM tools.