linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] depmod: add support for symbol namespaces
@ 2019-10-04  9:41 Matthias Maennich
  2019-10-24 15:02 ` Lucas De Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Maennich @ 2019-10-04  9:41 UTC (permalink / raw)
  To: linux-modules
  Cc: kernel-team, maennich, Stefan Wahren, Lucas De Marchi, Martijn Coenen

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] depmod: add support for symbol namespaces
  2019-10-04  9:41 [PATCH] depmod: add support for symbol namespaces Matthias Maennich
@ 2019-10-24 15:02 ` Lucas De Marchi
  2019-10-24 17:25   ` Matthias Maennich
  0 siblings, 1 reply; 3+ messages in thread
From: Lucas De Marchi @ 2019-10-24 15:02 UTC (permalink / raw)
  To: Matthias Maennich
  Cc: linux-modules, kernel-team, Stefan Wahren, Lucas De Marchi,
	Martijn Coenen

On Fri, Oct 04, 2019 at 10:41:36AM +0100, Matthias Maennich wrote:
>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>

with the new change merged in the kernel to remove the namespace from
the middle, my understanding is that we don't need this right?

Lucas De Marchi

>---
> 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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] depmod: add support for symbol namespaces
  2019-10-24 15:02 ` Lucas De Marchi
@ 2019-10-24 17:25   ` Matthias Maennich
  0 siblings, 0 replies; 3+ messages in thread
From: Matthias Maennich @ 2019-10-24 17:25 UTC (permalink / raw)
  To: Lucas De Marchi
  Cc: linux-modules, kernel-team, Stefan Wahren, Lucas De Marchi,
	Martijn Coenen

On Thu, Oct 24, 2019 at 08:02:01AM -0700, Lucas De Marchi wrote:
>On Fri, Oct 04, 2019 at 10:41:36AM +0100, Matthias Maennich wrote:
>>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>
>
>with the new change merged in the kernel to remove the namespace from
>the middle, my understanding is that we don't need this right?

Correct, we should not need this any longer.

Cheers,
Matthias

>
>Lucas De Marchi
>
>>---
>>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
>>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-10-24 17:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04  9:41 [PATCH] depmod: add support for symbol namespaces Matthias Maennich
2019-10-24 15:02 ` Lucas De Marchi
2019-10-24 17:25   ` Matthias Maennich

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).