Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4705429ybf; Wed, 4 Mar 2020 09:04:32 -0800 (PST) X-Google-Smtp-Source: ADFU+vuGfskjXo8m+16iE6TsOReheSj5n/+McL1pRmRwfJe9YJFkgi0JY0kslUrZ3VZEyJeS68Pb X-Received: by 2002:a05:6830:1c25:: with SMTP id f5mr1118858ote.253.1583341471812; Wed, 04 Mar 2020 09:04:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583341471; cv=none; d=google.com; s=arc-20160816; b=ZH0N3QwZshpJcMgurIZ2cC7LJ2/p/TqVrJDrqfsPV07e0vTKuuKVtWh3jvNlvcmsgw CF+B0MEkrONNXcxZyvJVJragv6AgTb8fYkDP6l4z8aztP6EJ8/ffKJs+Gdv7xNnpEopx 4yq9IBTP9Hyh9nD13tsdm3HOTIrI6f1I3YF3hAD9sBtea6I6EQlB5HJV+DNeVxnNlU2R q3NAwQ1W4dvXLLzw7MBaz377WGQG0KrB8PryW1+guifjxOm3vb2QxqE27AcySyksvgWG pv9DHKbdq87hhjURzLIL8yipN49KcniEjhPI2qlW5+rJ73OkTz2A7Jf8cc89vuLSeJhu XHpA== 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=U7KWR8nWaUVynWDushwn6ZpgxSLsLR+PW6dOvpSsLws=; b=SB8ymWCvpeErrkoTfhaB2EKrhh9GWWdKg6xsdFQy0XJTT8syG6AVxBSmcdKew9tAi6 pW3wdZ11fij7yHcUJQWuD/dUda5gPAVDgJfMBqPS8gg6hTlqorbJJQTn4W8AjjHMorPV V/fKEOtWijSJr+bSkYKr1N9qu4eFGKTS+87Wph6AyFcLBvMUNjjLO10OYvKr91ubdMyB SC/+fiz4/8KkPF/gw+QUbZfIDtkPVfCcTQOihTs0ajIzDhRDOZ3ZdbKyZrVF27oJrN1k +xDPoCx6G6AkVNKDrqb4qyPDUJR71paKE1I87NRGtzIGYx1S5i4srde/nosaaW1ZM0Nr mrmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nZcLEj0K; 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 v1si1575552oix.244.2020.03.04.09.04.18; Wed, 04 Mar 2020 09:04:31 -0800 (PST) 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=nZcLEj0K; 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 S1729863AbgCDREJ (ORCPT + 99 others); Wed, 4 Mar 2020 12:04:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:40860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727308AbgCDREI (ORCPT ); Wed, 4 Mar 2020 12:04:08 -0500 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 C869922B48; Wed, 4 Mar 2020 17:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583341448; bh=jn/uUffJq458TIftk9tVEIsDWPChKp3QU03s22kQWMw=; h=From:To:Cc:Subject:Date:From; b=nZcLEj0K+TlsI8XZeVLuArCpvVVu5vdOhzZZ+5kcQjJrlnYp6p9JXyPNJqPbjEo9z vq3zYMaxK691nZrus2xftAgMYSi4WahmtavLAuFgb3tKEKWvNp+H+JNDjhIIFTgwyV etEhmGZHmIBWmDhkwq7COFxSCnxfzjAlLUxMFy6I= From: Jessica Yu To: Masahiro Yamada Cc: Matthias Maennich , Lucas De Marchi , linux-kernel@vger.kernel.org, Jessica Yu Subject: [PATCH] modpost: move the namespace field in Module.symvers last Date: Wed, 4 Mar 2020 18:03:45 +0100 Message-Id: <20200304170345.21218-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). Fixes: cb9b55d21fe0 ("modpost: add support for symbol namespaces") Cc: stable@vger.kernel.org Signed-off-by: Jessica Yu --- 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 7edfdb2f4497..6ab235354f36 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2427,7 +2427,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) { @@ -2440,7 +2440,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; @@ -2448,16 +2448,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; @@ -2508,9 +2508,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