Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2271796imm; Mon, 16 Jul 2018 05:22:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcm/IciDLP0GFrae/y8uXJ0Xr5xunvTJoE3J3iZlOMZuvCrsid/9Bhmx81d/oG4KAcQzojD X-Received: by 2002:a63:4703:: with SMTP id u3-v6mr14916483pga.405.1531743777197; Mon, 16 Jul 2018 05:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531743777; cv=none; d=google.com; s=arc-20160816; b=KPdK4UjZKfsoH+1af4I2VteciEjq2P55aAHypr0RyXHgu8ukIdEJFzenEidJrmE3+Q VYIn0tlyxUZU4qkX3bbZ0rnuSGb1/6pNuY6ppxTihWFZtlLD9F9RjaQc4nS9NjXR3+Io f/uJ+j+pVPhdV53FpHRTxgie58Mx6JN7it4oUCRDTHFx5P2S1MjZtVxExBBHS2Qtikh3 mTfhoqEYt5YgvjzysqZVK+Vm6KAE2peN2jOgrgjVD3h1SA3JgxG7uyb6p1HwuYDPp1LF 6AQ0lnNORvGceSN/BYRAeZVHve2x890qvOYghZU46E6I79Xzwk6j4m6XP25MrFYHtbAX rKhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=eVZIJPfvWJqOSFveqFBy2DcrPUiSUudnPwDvBU+djl0=; b=qSJzC9+MYvAz/GldlxMujG+ek4yBfWryDZAKlEmPPvkaGAsyYmj5vOM4pJRZUee4dw 0jBbsvmSt1+368j/DDndve0FtH8gQ3NgbdfC641vU0a4c8OgeaktpxL3KzT/yVJ1ffjK ZwtPDli0LZsX8c9J3GPbmFC5lsPbbMGO6pePyNeAx2qtkMKtDfmyU1gGFhdk0o2O/ngT CMzaWVaYXvFy5ilbKHBro3MhA6wCr5iFfZGd+P5jZtr13FGaqHoBz3W/MmrSyrJfKmxO +e+MOjc1WZiikxyPdCbKV4Q9M7r5/b/T9B2+lljnzRfKeV1oogpqU0m30p6iWYRuUusg ithg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b="latej/bn"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12-v6si11114214pls.53.2018.07.16.05.22.42; Mon, 16 Jul 2018 05:22:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b="latej/bn"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731390AbeGPMtI (ORCPT + 99 others); Mon, 16 Jul 2018 08:49:08 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:40493 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731154AbeGPMsv (ORCPT ); Mon, 16 Jul 2018 08:48:51 -0400 Received: by mail-ed1-f68.google.com with SMTP id e19-v6so29791650edq.7 for ; Mon, 16 Jul 2018 05:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eVZIJPfvWJqOSFveqFBy2DcrPUiSUudnPwDvBU+djl0=; b=latej/bnQ6e2xx7dGFsNEEB0rGAz34NFJLp53eBusAUOwA8+V2T96PhEhXiAkFky8E 8VpfbWo9E0XwOGfOduqfJLTGmtT19P2zwY6yctG/fmh5+GWNroTe7jS1hDcFhM0boGkE VXaU0wFnVZn8jDlY/Hc3hJLlYz02uc2RLUiLxQDdpWXRSrMom3TrnhbdhV/jZo+mITFN 7DQFUMM8btSdMHO0peDNyberBR5yjc9wbAcmn2/D4Gf2TQ08bNIH77aHgMo8sUYmz1qd JcPocKJiNSrAzbzx57VOxVL0DlWf3Ix2tzSnnjY0DPfME+Yf8syI6b1mtxIPuwp9iujQ fcCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eVZIJPfvWJqOSFveqFBy2DcrPUiSUudnPwDvBU+djl0=; b=jHSwdxtECTMjOwEi30jv3R7kDZwt4pqXMDXAyHoGkHv6AbOWUtlBh3MGo4f3es9Spx kGLR3FOq7119CraaZngWpoO0jbk2v88KuQEdKfVExc5V1Yus2N9o9z4JDhMnyZoFW7fR iEEfZBb0359KDppP7yqWtVrsjM+hEJZs6Xs8eHsgknP0ra19v5tazsvKSPT2S9St915U dOmP4HYhJ2AoQA/j357QA5TmkTfLndA+pZeKRbuRiV+MppbupqAp3bOKrqZHT8nhS7f0 R6D7TF+eo9Dt8L0pyag9jEmxMd7Qq9mcMeQxQ+sHhHTMBv0tkBcbpleViKmsyRMfAFIj uCmw== X-Gm-Message-State: AOUpUlEV5HnMEIi6qYVwKfLWmBHzImURz7kB4sU1R+LjgNbx493exgmp xfogJE/bOrbTfikISFVB4hVii2wDYFs= X-Received: by 2002:a50:b5a5:: with SMTP id a34-v6mr16570081ede.88.1531743697889; Mon, 16 Jul 2018 05:21:37 -0700 (PDT) Received: from maco.fcp3.net (a83-162-234-235.adsl.xs4all.nl. [83.162.234.235]) by smtp.gmail.com with ESMTPSA id a9-v6sm4635471edi.26.2018.07.16.05.21.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 05:21:37 -0700 (PDT) From: Martijn Coenen To: linux-kernel@vger.kernel.org Cc: Martijn Coenen , Masahiro Yamada , Michal Marek , Geert Uytterhoeven , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Alan Stern , Greg Kroah-Hartman , Oliver Neukum , Arnd Bergmann , Jessica Yu , Stephen Boyd , Philippe Ombredanne , Kate Stewart , Sam Ravnborg , linux-kbuild@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-scsi@vger.kernel.org, linux-arch@vger.kernel.org, maco@google.com, sspatil@google.com, malchev@google.com, joelaf@google.com Subject: [PATCH 4/6] modpost: add support for generating namespace dependencies. Date: Mon, 16 Jul 2018 14:21:23 +0200 Message-Id: <20180716122125.175792-5-maco@android.com> X-Mailer: git-send-email 2.18.0.203.gfac676dfb9-goog In-Reply-To: <20180716122125.175792-1-maco@android.com> References: <20180716122125.175792-1-maco@android.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds an option to modpost to generate a .ns_deps file per module, containing the namespace depedencies for that module. This file can subsequently be used by other tools to automatically add newly introduced namespaces to the modules that require them, saving a lot of manual work. Signed-off-by: Martijn Coenen --- scripts/mod/modpost.c | 58 +++++++++++++++++++++++++++++++++++++++---- scripts/mod/modpost.h | 2 ++ 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index a56a8461a96a..be33d60d5527 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -39,6 +39,8 @@ static int sec_mismatch_verbose = 1; static int sec_mismatch_fatal = 0; /* ignore missing files */ static int ignore_missing_files; +/* Write namespace dependencies */ +static int write_ns_deps; enum export { export_plain, export_unused, export_gpl, @@ -2151,10 +2153,15 @@ static void check_exports(struct module *mod) else basename = mod->name; - if (exp->ns && !module_imports_namespace(mod, exp->ns)) { - warn("module %s uses symbol %s from namespace %s, " - "but does not import it.\n", - basename, exp->name, exp->ns); + if (exp->ns) { + add_namespace(&mod->required_namespaces, exp->ns); + + if (!write_ns_deps && + !module_imports_namespace(mod, exp->ns)) { + warn("module %s uses symbol %s from namespace " + "%s, but does not import it.\n", + basename, exp->name, exp->ns); + } } if (!mod->gpl_compatible) @@ -2457,6 +2464,38 @@ static void write_dump(const char *fname) free(buf.p); } +static void write_ns_deps_files(void) +{ + struct module *mod; + struct namespace_list *ns; + struct buffer ns_deps_buf = { }; + + for (mod = modules; mod; mod = mod->next) { + char fname[PATH_MAX]; + const char *basename; + + if (mod->skip) + continue; + + ns_deps_buf.pos = 0; + + for (ns = mod->required_namespaces; ns; ns = ns->next) + buf_printf(&ns_deps_buf, "%s\n", ns->namespace); + + if (ns_deps_buf.pos == 0) + continue; + + basename = strrchr(mod->name, '/'); + if (basename) + basename++; + else + basename = mod->name; + + sprintf(fname, ".tmp_versions/%s.ns_deps", basename); + write_if_changed(&ns_deps_buf, fname); + } +} + struct ext_sym_list { struct ext_sym_list *next; const char *file; @@ -2473,7 +2512,7 @@ int main(int argc, char **argv) struct ext_sym_list *extsym_iter; struct ext_sym_list *extsym_start = NULL; - while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:E")) != -1) { + while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:Ed")) != -1) { switch (opt) { case 'i': kernel_read = optarg; @@ -2517,6 +2556,9 @@ int main(int argc, char **argv) case 'E': sec_mismatch_fatal = 1; break; + case 'd': + write_ns_deps = 1; + break; default: exit(1); } @@ -2545,6 +2587,12 @@ int main(int argc, char **argv) check_exports(mod); } + if (write_ns_deps) { + /* Just write namespace dependencies and exit */ + write_ns_deps_files(); + return 0; + } + err = 0; for (mod = modules; mod; mod = mod->next) { diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 9626bf3e7424..92a926d375d2 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -126,6 +126,8 @@ struct module { struct buffer dev_table_buf; char srcversion[25]; int is_dot_o; + // Required namespace dependencies + struct namespace_list *required_namespaces; // Actual imported namespaces struct namespace_list *imported_namespaces; }; -- 2.18.0.203.gfac676dfb9-goog