From patchwork Sun May 21 16:04:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 96894 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp977698vqo; Sun, 21 May 2023 10:15:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7r8yjTezQZuml5qTFnql7eK2K4aDG27beK8/5vzibsMjW+OKpU7wDp2rUWhx+3bJUBcbC4 X-Received: by 2002:a17:903:22cf:b0:1a5:22a6:4e6a with SMTP id y15-20020a17090322cf00b001a522a64e6amr10760159plg.51.1684689323360; Sun, 21 May 2023 10:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684689323; cv=none; d=google.com; s=arc-20160816; b=HasPm0+bvvYpzIQ4lNG4Lb6+xIFbvZSYfwW4GAOcEd+tI48BSHwRDDQGs87FS9PjUB hrd8p8ENfryfVdJdWmF6oD7pTkEEELB44hrImXMPppDRh42vbLz2MJHst5/U+nWiOEIu PwHpOQBAgHk+vaSpGf1T+cuqihN5p+bGV1vcWHykIWYF9PcVCfoziUA19z8bj3B+ry/u q4FsEF3RdJmtzrEpdFsZV6qwb8Nphwy7JpVninPMwwMWb718TBLmv/4psxrPDUGTDX21 wyEC/uGRHoB3dEbxb7bVin2fABqsrNGWe0Pwtfznt4Ejn7nJjEf/WONMerBuVcj9sCC6 FsrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ffMyViiSZmMqGIshP3oWLiaQKcLchdm2iKPzfibF/1Q=; b=qlFolTLdELhKBq2yg0qGl/yoM+kd273JeSdILMusRUQUbkp2RfHIKEyNoqdLk5UE/2 go/B2tvVrJNaSITlrUP6KWER7/8BEcSHOwEuNx/QWCm3VPa8sn1LcKjbVxxd5jtXy1+0 R65PMyAMmkC+QhUwfOSfrEabKW5Ky9a3kGDWWtYOHJAt9xlQ47ifWvkYKmRpO4YRLuAK d0DvSjybx6kChz+8fPPxEXqFSTWYL6LEwxgxNAptVt3RNi+YSwYbYQQLhAgOalVTgjwO VPJMile/hTEG6IMbUgvNcxURbD/f9Pd2eUIzroxsLYoPi8mwXw8hEQ3yxXei4v0QMRdt Z92w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EVgHH4vJ; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10-20020a170902744a00b001a4ee96c00bsi3171515plt.357.2023.05.21.10.15.08; Sun, 21 May 2023 10:15:23 -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=@kernel.org header.s=k20201202 header.b=EVgHH4vJ; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231251AbjEUQGl (ORCPT + 99 others); Sun, 21 May 2023 12:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231173AbjEUQGS (ORCPT ); Sun, 21 May 2023 12:06:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53BDF124; Sun, 21 May 2023 09:05:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2E52460FB0; Sun, 21 May 2023 16:05:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 699FAC433D2; Sun, 21 May 2023 16:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684685146; bh=xkkHzfnL3ubXNCXhol2tJvXMJSRLG0VEcBb56VUY1PA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EVgHH4vJtM2RM6heu4Np31j75OuIt6w1WnPM3+OgbM1iI6dOK0EfPNRbPgKMZm8O4 GCa3kGdPYcvS5eN70GFAgbIc9A6LmVNAmJZzH6Qh253361qyDNp3ik1XQxksXGAPzo 3AsvNW+lrkx0fO7KDFp6y1U5AgYzjc2k35N94XXzMZFe54H8dDzi+Srei1IplPWpKU GIn7uOo9EEYo4xS830Tfh2fh7AJB5s3V7huCYuvoi81ufvdD/tINYf55fB47MWnovY VxprJvKl67DEizW/gbCfj0Y2+GX1fXy7PxQ3RZ1IFwupxCY4aOrkofNBnl1BwKmF3u J2xV5zqMcPqwA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Masahiro Yamada Subject: [PATCH v6 18/20] modpost: remove *_sections[] arrays Date: Mon, 22 May 2023 01:04:23 +0900 Message-Id: <20230521160426.1881124-19-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230521160426.1881124-1-masahiroy@kernel.org> References: <20230521160426.1881124-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766524791949178956?= X-GMAIL-MSGID: =?utf-8?q?1766524791949178956?= Use PATTERNS() macros to remove unneeded array definitions. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index b5f7f4811c39..852cc164c77e 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -823,24 +823,6 @@ static void check_section(const char *modname, struct elf_info *elf, #define ALL_TEXT_SECTIONS ALL_INIT_TEXT_SECTIONS, ALL_EXIT_TEXT_SECTIONS, \ TEXT_SECTIONS, OTHER_TEXT_SECTIONS -/* init data sections */ -static const char *const init_data_sections[] = - { ALL_INIT_DATA_SECTIONS, NULL }; - -/* all init sections */ -static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL }; - -/* all text sections */ -static const char *const text_sections[] = { ALL_TEXT_SECTIONS, NULL }; - -/* data section */ -static const char *const data_sections[] = { DATA_SECTIONS, NULL }; - -static const char *const head_sections[] = { ".head.text*", NULL }; -static const char *const linker_symbols[] = - { "__init_begin", "_sinittext", "_einittext", NULL }; -static const char *const optim_symbols[] = { "*.constprop.*", NULL }; - enum mismatch { TEXT_TO_ANY_INIT, DATA_TO_ANY_INIT, @@ -1006,14 +988,14 @@ static int secref_whitelist(const char *fromsec, const char *fromsym, const char *tosec, const char *tosym) { /* Check for pattern 1 */ - if (match(tosec, init_data_sections) && - match(fromsec, data_sections) && + if (match(tosec, PATTERNS(ALL_INIT_DATA_SECTIONS)) && + match(fromsec, PATTERNS(DATA_SECTIONS)) && strstarts(fromsym, "__param")) return 0; /* Check for pattern 1a */ if (strcmp(tosec, ".init.text") == 0 && - match(fromsec, data_sections) && + match(fromsec, PATTERNS(DATA_SECTIONS)) && strstarts(fromsym, "__param_ops_")) return 0; @@ -1036,18 +1018,18 @@ static int secref_whitelist(const char *fromsec, const char *fromsym, return 0; /* Check for pattern 3 */ - if (match(fromsec, head_sections) && - match(tosec, init_sections)) + if (strstarts(fromsec, ".head.text") && + match(tosec, PATTERNS(ALL_INIT_SECTIONS))) return 0; /* Check for pattern 4 */ - if (match(tosym, linker_symbols)) + if (match(tosym, PATTERNS("__init_begin", "_sinittext", "_einittext"))) return 0; /* Check for pattern 5 */ - if (match(fromsec, text_sections) && - match(tosec, init_sections) && - match(fromsym, optim_symbols)) + if (match(fromsec, PATTERNS(ALL_TEXT_SECTIONS)) && + match(tosec, PATTERNS(ALL_INIT_SECTIONS)) && + match(fromsym, PATTERNS("*.constprop.*"))) return 0; return 1;