Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp752471ybh; Wed, 11 Mar 2020 10:05:42 -0700 (PDT) X-Google-Smtp-Source: ADFU+vspbSnsfqSHZgPW7Q2Ey5bHOQV2nFIlWnrz9+CjvFF5NR5KApcwhoZOb/xdDbYJxptMN4oa X-Received: by 2002:aca:ea46:: with SMTP id i67mr2550163oih.149.1583946341928; Wed, 11 Mar 2020 10:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583946341; cv=none; d=google.com; s=arc-20160816; b=QicChtMlqII6J5WCf2II8hQCIOUbPKh9hU+NPnUDUqbiPopEyFQpbN5hkY+aZXi2LE 4LiKvWs00rKnlrs2Di/8zFzGRbMYjzGs+pgzPpWt/TRmmCBK2Or208FNVuwVfjCTmpOL naAtsv32OUS+va3lfcJ0WlRzIBSjw8dlU9R7a8Puvs6BvLbt1BoX77XjIDGgoivcdWyP XadoF5DGp7/32s08s+4EaH4Pviyej5LrRpkXxlRFwHN8yn5MjkayoUrQjlyxtCxUd7AN pqclJgy2VPWDBasb/nhUReRcOdrxi6alu6IWm+fU7F08nq4Oc8fGsUec/T1hJlHJjusq 0tlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=LcHRAeaTcjDKZ+8gfWu2Oe7AEBrIUiZq/CyVU88bQvM=; b=ivSSV+grgJ9lLxCvaRHeZ8isAtJYjdeWaf+Dim/JB+MeR18EtYQAkGUfIQbPfup05Y nNE/Mnlsws9/vSN/HEVQIet2dckqmD1AX4nYBL+5lpCQQr4gLe++foeyMbD/CrKaYGNe uQOcDDE5hHwcIUe66r7Mj49zEGsDBSWVcWmZoeLkyrQ3F1wxA+P6OymUHWIu0P2ddSLv 0RXF4GjReIc8J1jUE5F6KXtSfnZXowDhQnBBSywCAw2JnWyTE7UMYRNKqDSfx6iVHFa/ 5+gpW0mmdMIa97xBi+ERU2rQNIZtYZedxZ93JSyh5dYnMo9MyDwsOXdrMhHwxbb7yTin 7YEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="XB8m/z/x"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si402749ood.43.2020.03.11.10.05.27; Wed, 11 Mar 2020 10:05:41 -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=@kernel.org header.s=default header.b="XB8m/z/x"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730159AbgCKRCy (ORCPT + 99 others); Wed, 11 Mar 2020 13:02:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:35952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729734AbgCKRCy (ORCPT ); Wed, 11 Mar 2020 13:02:54 -0400 Received: from linux-8ccs.suse.de (p5B2812F9.dip0.t-ipconnect.de [91.40.18.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B72AD206BE; Wed, 11 Mar 2020 17:02:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583946174; bh=amUfcgSakdY7l26R+vimNifS5p83NM/XQAvGVR/k334=; h=From:To:Cc:Subject:Date:From; b=XB8m/z/xzXp5gGFex83FaswEmVj936r0IAW80OeX6P9zRS08ybz5LqY736RF6vIJ2 NEdUjjdZmxMbVKFJRI/zy29SiEz2yoy154tSoIKA97paTgWuGwct/YCVTqejZLdd+c 79xOE2K896MmtJBIP8vIcNsH2XK/pqnJcJ760pDY= From: Jessica Yu To: Masahiro Yamada Cc: Matthias Maennich , Lucas De Marchi , stable@vger.kernel.org, linux-kernel@vger.kernel.org, Jessica Yu Subject: [PATCH v2] modpost: move the namespace field in Module.symvers last Date: Wed, 11 Mar 2020 18:01:20 +0100 Message-Id: <20200311170120.12641-1-jeyu@kernel.org> X-Mailer: git-send-email 2.16.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to preserve backwards compatability with kmod tools, we have to move the namespace field in Module.symvers last, as the depmod -e -E option looks at the first three fields in Module.symvers to check symbol versions (and it's expected they stay in the original order of crc, symbol, module). In addition, update an ancient comment above read_dump() in modpost that suggested that the export type field in Module.symvers was optional. I suspect that there were historical reasons behind that comment that are no longer accurate. We have been unconditionally printing the export type since 2.6.18 (commit bd5cbcedf44), which is over a decade ago now. Fix up read_dump() to treat each field as non-optional. I suspect the original read_dump() code treated the export field as optional in order to support pre <= 2.6.18 Module.symvers (which did not have the export type field). Note that although symbol namespaces are optional, the field will not be omitted from Module.symvers if a symbol does not have a namespace. In this case, the field will simply be empty and the next delimiter or end of line will follow. Cc: stable@vger.kernel.org Fixes: cb9b55d21fe0 ("modpost: add support for symbol namespaces") Tested-by: Matthias Maennich Reviewed-by: Matthias Maennich Reviewed-by: Lucas De Marchi Signed-off-by: Jessica Yu --- v2: - Explain the changes to read_dump() and the comment (and provide historical context) in the commit message. (Lucas De Marchi) Documentation/kbuild/modules.rst | 4 ++-- scripts/export_report.pl | 2 +- scripts/mod/modpost.c | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Documentation/kbuild/modules.rst b/Documentation/kbuild/modules.rst index 69fa48ee93d6..e0b45a257f21 100644 --- a/Documentation/kbuild/modules.rst +++ b/Documentation/kbuild/modules.rst @@ -470,9 +470,9 @@ build. The syntax of the Module.symvers file is:: - + - 0xe1cc2a05 usb_stor_suspend USB_STORAGE drivers/usb/storage/usb-storage EXPORT_SYMBOL_GPL + 0xe1cc2a05 usb_stor_suspend drivers/usb/storage/usb-storage EXPORT_SYMBOL_GPL USB_STORAGE The fields are separated by tabs and values may be empty (e.g. if no namespace is defined for an exported symbol). diff --git a/scripts/export_report.pl b/scripts/export_report.pl index 548330e8c4e7..feb3d5542a62 100755 --- a/scripts/export_report.pl +++ b/scripts/export_report.pl @@ -94,7 +94,7 @@ if (defined $opt{'o'}) { # while ( <$module_symvers> ) { chomp; - my (undef, $symbol, $namespace, $module, $gpl) = split('\t'); + my (undef, $symbol, $module, $gpl, $namespace) = split('\t'); $SYMBOL { $symbol } = [ $module , "0" , $symbol, $gpl]; } close($module_symvers); diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index a3d8370f9544..e1963ef8c07c 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2421,7 +2421,7 @@ static void write_if_changed(struct buffer *b, const char *fname) } /* parse Module.symvers file. line format: - * 0x12345678symbolmodule[[export]something] + * 0x12345678symbolmoduleexportnamespace **/ static void read_dump(const char *fname, unsigned int kernel) { @@ -2434,7 +2434,7 @@ static void read_dump(const char *fname, unsigned int kernel) return; while ((line = get_next_line(&pos, file, size))) { - char *symname, *namespace, *modname, *d, *export, *end; + char *symname, *namespace, *modname, *d, *export; unsigned int crc; struct module *mod; struct symbol *s; @@ -2442,16 +2442,16 @@ static void read_dump(const char *fname, unsigned int kernel) if (!(symname = strchr(line, '\t'))) goto fail; *symname++ = '\0'; - if (!(namespace = strchr(symname, '\t'))) - goto fail; - *namespace++ = '\0'; - if (!(modname = strchr(namespace, '\t'))) + if (!(modname = strchr(symname, '\t'))) goto fail; *modname++ = '\0'; - if ((export = strchr(modname, '\t')) != NULL) - *export++ = '\0'; - if (export && ((end = strchr(export, '\t')) != NULL)) - *end = '\0'; + if (!(export = strchr(modname, '\t'))) + goto fail; + *export++ = '\0'; + if (!(namespace = strchr(export, '\t'))) + goto fail; + *namespace++ = '\0'; + crc = strtoul(line, &d, 16); if (*symname == '\0' || *modname == '\0' || *d != '\0') goto fail; @@ -2502,9 +2502,9 @@ static void write_dump(const char *fname) namespace = symbol->namespace; buf_printf(&buf, "0x%08x\t%s\t%s\t%s\t%s\n", symbol->crc, symbol->name, - namespace ? namespace : "", symbol->module->name, - export_str(symbol->export)); + export_str(symbol->export), + namespace ? namespace : ""); } symbol = symbol->next; } -- 2.16.4