Skip to contentSkip to conversation

depmod: add support for symbol namespaces

PATCH In review Matthias Maennich 2 participants 3 messages Oct 4, 2019 – Oct 24, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 depmod: add support for symbol namespaces

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/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/

---
 tools/depmod.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/depmod.c +8 -2
index 391afe9fe0a0..723f4c7be88c 100644
@@ -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:
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
#1 lore raw
Quoted 8 lines · Matthias Maennich

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.

Quoted 8 lines

[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/

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

Quoted 35 lines

---
tools/depmod.c | 10 ++++++++--

1 file changed, 8 insertions(+), 2 deletions(-)
tools/depmod.c +8 -2
index 391afe9fe0a0..723f4c7be88c 100644
@@ -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:
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
#2 lore raw
Quoted 12 lines · Lucas De Marchi
Quoted 11 lines · Matthias Maennich

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/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/

Quoted 8 lines
Quoted 5 lines

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

Quoted 38 lines

Lucas De Marchi

Quoted 35 lines

---
tools/depmod.c | 10 ++++++++--

1 file changed, 8 insertions(+), 2 deletions(-)
tools/depmod.c +8 -2
index 391afe9fe0a0..723f4c7be88c 100644
@@ -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:
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog