diff mbox series

depmod: add support for symbol namespaces

Message ID 20191004094136.166621-1-maennich@google.com (mailing list archive)
State Rejected, archived
Headers show
Series depmod: add support for symbol namespaces | expand

Commit Message

Matthias Maennich Oct. 4, 2019, 9:41 a.m. UTC
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(-)

Comments

Lucas De Marchi Oct. 24, 2019, 3:02 p.m. UTC | #1
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
>
Matthias Maennich Oct. 24, 2019, 5:25 p.m. UTC | #2
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
>>
diff mbox series

Patch

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: