From patchwork Mon Dec 19 20:46:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 34769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp2607627wrn; Mon, 19 Dec 2022 12:48:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf5cOCGJUq3Qro76C32L5sEQaxaO/JFCj4EvMc3ghmwrv0K9iYEp86m4mLXrmW5DbPP32SVU X-Received: by 2002:a05:6a00:be7:b0:578:16e6:815d with SMTP id x39-20020a056a000be700b0057816e6815dmr40385018pfu.21.1671482891687; Mon, 19 Dec 2022 12:48:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671482891; cv=none; d=google.com; s=arc-20160816; b=WktgSGb1Bns5it+ADtwTd7wHBUrokr+T/2F470wu4MnfWTRQeE1cTm3y5vfG58rWWo CqQt7ZEvjbtGhhzUyrZyVLJ3IxzuMFKeSrbIPXa56ejL4G1X6Ec3asaQYS0vxnjpQ30e zPEspncpzgH6/WPCWfsxONkzldqBGpNbgXGH8ICI+XW+7DFNGA2CxqpbHmZ8Nn+DalhB SAXLNRnV+LYQjsPBaRh5vPJeNGzSf5/XggYg39a1WZ5CCDSQS9ijUW8krbY+L4l7cx4e DeyaFx0KIYQNXr0Ll6Pz4RgmlMSKoOBFS8zN945M/z7bEhkrJhJ3+TKaqZ2/3UWt4b1Z A2kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=RHzej/1PRqREjwzL8yy+/gC2rwJnW9I5Nh9PS4uQu5Q=; b=IJlkY224gMx5hSzpe+9ohzyF+kx9OTdWNcz6HJd4Azj8JfmBipXwHer3JA3NvVfJhH S6bTlvegYdahkiSB21QUFcjkd6kKuuUz9lXC71mv9OW19lOFWPiH8lIauURPdPpSiDPV DL/yLQE/1CTD2ivZazdsQrWMLJgOEN4QF6GqwweuyLUoKdgBAql2elGlwcJuSgdNszWe dcRSFj06tLVrJAvExrLNXa5qyLz7xHQ9PXFjVjAtabHUi8eNKhKZANUwWdqyhahED5O3 9/urEMBYQWHDu3fOFWYotk25IzS1dxzpQ4BjOH2FJZWcMf6uYTla6ynw9OVDs3Hq8Jds MHLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qF7j3UMv; 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=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a056a00199500b0056cd91516b6si847820pfl.325.2022.12.19.12.47.58; Mon, 19 Dec 2022 12:48:11 -0800 (PST) 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=@google.com header.s=20210112 header.b=qF7j3UMv; 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=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232747AbiLSUrP (ORCPT + 99 others); Mon, 19 Dec 2022 15:47:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231726AbiLSUqk (ORCPT ); Mon, 19 Dec 2022 15:46:40 -0500 Received: from mail-il1-x14a.google.com (mail-il1-x14a.google.com [IPv6:2607:f8b0:4864:20::14a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B2C21276F for ; Mon, 19 Dec 2022 12:46:30 -0800 (PST) Received: by mail-il1-x14a.google.com with SMTP id j3-20020a056e02154300b00304bc968ef1so7171962ilu.4 for ; Mon, 19 Dec 2022 12:46:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=RHzej/1PRqREjwzL8yy+/gC2rwJnW9I5Nh9PS4uQu5Q=; b=qF7j3UMvzJCUsQLLBjLgzSlmOXfqeEaNvw3PLXzeRWDcyY3bD8OOA38EQdGqqCZrSa iZncq8o51eeujFRZtBj6GVXss1cKEXggq6R/z5mdQ5oGh7e4OTlkwSEut6Vgt5ailuuP Ed8N28NG0EMmlAF45ESity6Pkkw741SVRjm2mDeGj1255GePszv1dQ+FkisGc7bA9Zi+ PxalhtbeDVQuKtLNXx40YFKl4kZTz7hZ9GB7/D2GRe8u5St+PZ3YIZZ29RK+RgepiQRB Zd9kHw0ZtKBVgwDl7AT/HspdSRo1e7RQggsVmuqHRJipm5Guv5SA6HoxE4OVIO2cVfY1 Ztbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RHzej/1PRqREjwzL8yy+/gC2rwJnW9I5Nh9PS4uQu5Q=; b=yZEXx5zI4tw+CwOWp2hwvZGdXjdlLSPwwj89Jk3D6TwsHcKQGGqKwDKHGsaWPJLXo7 cW9WVrT0sj14BpaOPqPcb1uezKdpeaeuA2BWrFzHLar2pE4tm6IOCEOWAueQ02b84Oxh mihp/AWNfSQm8IH2hEu3YQ2BSSk+U+UrVV0RCbjXy7Kd+t9TTdGbOtzigITw/7izVpry CBiB6Yi0lQ3f5HrWFRGG7kSxyh9ZgDYoMbvSu34QW1xhO5V+PYe/91xNyUVVZ33jj99G 4SBA0CAWS+P0y7HXoLm9e/ZGzyUe0/CjVEp2IAvh13/QtA3MVYtdvdoqh1ezUURjbEVH YXoA== X-Gm-Message-State: ANoB5pnWNml4qZywNi49JXiW7gELyfK6G3ZXxGpOwQkkUqieJSOro+CV adN0lQJQ2Vb8dY18kTNLfDPBRht2pSVqkv4= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a92:cd83:0:b0:300:56a5:ae19 with SMTP id r3-20020a92cd83000000b0030056a5ae19mr43568707ilb.72.1671482789512; Mon, 19 Dec 2022 12:46:29 -0800 (PST) Date: Mon, 19 Dec 2022 14:46:15 -0600 In-Reply-To: <20221219204619.2205248-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219191855.2010466-1-allenwebb@google.com> <20221219204619.2205248-1-allenwebb@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221219204619.2205248-8-allenwebb@google.com> Subject: [PATCH v9 07/10] modpost: Add -b option for emitting built-in aliases From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: Luis Chamberlain , Greg Kroah-Hartman , "Rafael J. Wysocki" , Allen Webb X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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?1752410891894371247?= X-GMAIL-MSGID: =?utf-8?q?1752676844665318572?= This adds an unimplemented command line flag for writing the built-in aliases to a file. Signed-off-by: Allen Webb --- scripts/mod/modpost.c | 23 +++++++++++++++++++++-- scripts/mod/modpost.h | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 2c80da0220c3..e38d6b2ceea4 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2165,6 +2165,19 @@ static void write_if_changed(struct buffer *b, const char *fname) write_buf(b, fname); } +/* Write the builtin aliases to the specified file. */ +static void write_builtin(const char *fname) +{ + struct buffer buf = { }; + struct module *mod; + + list_for_each_entry(mod, &modules, list) + buf_write(&buf, mod->modalias_buf.p, mod->modalias_buf.pos); + + write_if_changed(&buf, fname); + free(buf.p); +} + static void write_vmlinux_export_c_file(struct module *mod) { struct buffer buf = { }; @@ -2321,13 +2334,16 @@ int main(int argc, char **argv) { struct module *mod; char *missing_namespace_deps = NULL; - char *dump_write = NULL, *files_source = NULL; + char *builtin_write = NULL, *dump_write = NULL, *files_source = NULL; int opt; LIST_HEAD(dump_lists); struct dump_list *dl, *dl2; - while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) { + while ((opt = getopt(argc, argv, "b:ei:mnT:o:awENd:")) != -1) { switch (opt) { + case 'b': + builtin_write = optarg; + break; case 'e': external_module = true; break; @@ -2390,6 +2406,9 @@ int main(int argc, char **argv) write_mod_c_file(mod); } + if (builtin_write) + write_builtin(builtin_write); + if (missing_namespace_deps) write_namespace_deps_files(missing_namespace_deps); diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 34fe5fc0b02c..c55a6aeb46bf 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -123,6 +123,7 @@ struct module { bool has_init; bool has_cleanup; struct buffer dev_table_buf; + struct buffer modalias_buf; char srcversion[25]; // Missing namespace dependencies struct list_head missing_namespaces;