linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Maennich <maennich@google.com>
To: linux-modules@vger.kernel.org
Cc: kernel-team@android.com, maennich@google.com,
	Stefan Wahren <stefan.wahren@i2se.com>,
	Lucas De Marchi <lucas.de.marchi@gmail.com>,
	Martijn Coenen <maco@android.com>
Subject: [PATCH] depmod: add support for symbol namespaces
Date: Fri,  4 Oct 2019 10:41:36 +0100	[thread overview]
Message-ID: <20191004094136.166621-1-maennich@google.com> (raw)

Linux v5.4 introduces symbol namespaces [1], [2].
They appear in the ksymtab as entries with the scheme

   __ksymtab_NAMESPACE.symbol_name

In order to support these at depmod time, strip out namespaces when
loading the System.map.

[1] https://lore.kernel.org/lkml/20190906103235.197072-1-maennich@google.com/
[2] https://lore.kernel.org/lkml/20191003075826.7478-1-yamada.masahiro@socionext.com/

Reported-by: Stefan Wahren <stefan.wahren@i2se.com>
Cc: Lucas De Marchi <lucas.de.marchi@gmail.com>
Cc: Martijn Coenen <maco@android.com>
Cc: linux-modules@vger.kernel.org
Signed-off-by: Matthias Maennich <maennich@google.com>
---
 tools/depmod.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/depmod.c b/tools/depmod.c
index 391afe9fe0a0..723f4c7be88c 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2576,7 +2576,7 @@ static int depmod_load_system_map(struct depmod *depmod, const char *filename)
 
 	/* eg. c0294200 R __ksymtab_devfs_alloc_devnum */
 	while (fgets(line, sizeof(line), fp) != NULL) {
-		char *p, *end;
+		char *p, *end, *delim;
 
 		linenum++;
 
@@ -2601,7 +2601,13 @@ static int depmod_load_system_map(struct depmod *depmod, const char *filename)
 		if (end != NULL)
 			*end = '\0';
 
-		depmod_symbol_add(depmod, p + ksymstr_len, true, 0, NULL);
+		/* Support for namespaced symbols: __ksymtab_NAMESPACE.symbol */
+		delim = strrchr(p + ksymstr_len, '.');
+		if (delim != NULL)
+			depmod_symbol_add(depmod, delim + 1, true, 0, NULL);
+		else
+			depmod_symbol_add(depmod, p + ksymstr_len, true, 0, NULL);
+
 		continue;
 
 	invalid_syntax:
-- 
2.23.0.581.g78d2f28ef7-goog


             reply	other threads:[~2019-10-04  9:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-04  9:41 Matthias Maennich [this message]
2019-10-24 15:02 ` [PATCH] depmod: add support for symbol namespaces Lucas De Marchi
2019-10-24 17:25   ` Matthias Maennich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191004094136.166621-1-maennich@google.com \
    --to=maennich@google.com \
    --cc=kernel-team@android.com \
    --cc=linux-modules@vger.kernel.org \
    --cc=lucas.de.marchi@gmail.com \
    --cc=maco@android.com \
    --cc=stefan.wahren@i2se.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).