Rust symbols can become quite long due to namespacing introduced by modules, types, traits, generics, etc. For instance, the following code: pub mod my_module { pub struct MyType; pub struct MyGenericType<T>(T); pub trait MyTrait { fn my_method() -> u32; } impl MyTrait for MyGenericType<MyType> { fn my_method() -> u32 { 42 } } } generates a symbol of length 96 when using the upcoming v0 mangling scheme: _RNvXNtCshGpAVYOtgW1_7example9my_moduleINtB2_13MyGenericTypeNtB2_6MyTypeENtB2_7MyTrait9my_method At the moment, Rust symbols may reach up to 300 in length. Setting 512 as the maximum seems like a reasonable choice to keep some headroom.
Unified · Split
| @@ -15,7 +15,7 @@ · 14 unmodified lines | |||
| 15 | 15 | ||
| 16 | #include <asm/sections.h> | 16 | #include <asm/sections.h> |
| 17 | 17 | ||
| 18 | #define KSYM_NAME_LEN 128 | 18 | #define KSYM_NAME_LEN 512 |
| 19 | #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s %s]") + \ | 19 | #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s %s]") + \ |
| 20 | (KSYM_NAME_LEN - 1) + \ | 20 | (KSYM_NAME_LEN - 1) + \ |
| 21 | 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + \ | 21 | 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + \ |
| @@ -213,7 +213,7 @@ static int klp_resolve_symbols(Elf_Shdr *sechdrs, const char *strtab, · 212 unmodified lines | |||
| 213 | * we use the smallest/strictest upper bound possible (56, based on | 213 | * we use the smallest/strictest upper bound possible (56, based on |
| 214 | * the current definition of MODULE_NAME_LEN) to prevent overflows. | 214 | * the current definition of MODULE_NAME_LEN) to prevent overflows. |
| 215 | */ | 215 | */ |
| 216 | BUILD_BUG_ON(MODULE_NAME_LEN < 56 || KSYM_NAME_LEN != 128); | 216 | BUILD_BUG_ON(MODULE_NAME_LEN < 56 || KSYM_NAME_LEN != 512); |
| 217 | 217 | ||
| 218 | relas = (Elf_Rela *) relasec->sh_addr; | 218 | relas = (Elf_Rela *) relasec->sh_addr; |
| 219 | /* For each rela in this klp relocation section */ | 219 | /* For each rela in this klp relocation section */ |
| @@ -227,7 +227,7 @@ static int klp_resolve_symbols(Elf_Shdr *sechdrs, const char *strtab, · 7 unmodified lines | |||
| 227 | 227 | ||
| 228 | /* Format: .klp.sym.sym_objname.sym_name,sympos */ | 228 | /* Format: .klp.sym.sym_objname.sym_name,sympos */ |
| 229 | cnt = sscanf(strtab + sym->st_name, | 229 | cnt = sscanf(strtab + sym->st_name, |
| 230 | ".klp.sym.%55[^.].%127[^,],%lu", | 230 | ".klp.sym.%55[^.].%511[^,],%lu", |
| 231 | sym_objname, sym_name, &sympos); | 231 | sym_objname, sym_name, &sympos); |
| 232 | if (cnt != 3) { | 232 | if (cnt != 3) { |
| 233 | pr_err("symbol %s has an incorrectly formatted name\n", | 233 | pr_err("symbol %s has an incorrectly formatted name\n", |
| @@ -30,7 +30,7 @@ · 29 unmodified lines | |||
| 30 | #define _stringify_1(x) #x | 30 | #define _stringify_1(x) #x |
| 31 | #define _stringify(x) _stringify_1(x) | 31 | #define _stringify(x) _stringify_1(x) |
| 32 | 32 | ||
| 33 | #define KSYM_NAME_LEN 128 | 33 | #define KSYM_NAME_LEN 512 |
| 34 | 34 | ||
| 35 | /* | 35 | /* |
| 36 | * A substantially bigger size than the current maximum. | 36 | * A substantially bigger size than the current maximum. |
| @@ -39,7 +39,7 @@ · 2 unmodified lines | |||
| 39 | * for the fscanf() format string. Therefore, a _Static_assert() is | 39 | * for the fscanf() format string. Therefore, a _Static_assert() is |
| 40 | * used instead to maintain the relationship with KSYM_NAME_LEN. | 40 | * used instead to maintain the relationship with KSYM_NAME_LEN. |
| 41 | */ | 41 | */ |
| 42 | #define KSYM_NAME_LEN_BUFFER 512 | 42 | #define KSYM_NAME_LEN_BUFFER 2048 |
| 43 | _Static_assert( | 43 | _Static_assert( |
| 44 | KSYM_NAME_LEN_BUFFER == KSYM_NAME_LEN * 4, | 44 | KSYM_NAME_LEN_BUFFER == KSYM_NAME_LEN * 4, |
| 45 | "Please keep KSYM_NAME_LEN_BUFFER in sync with KSYM_NAME_LEN" | 45 | "Please keep KSYM_NAME_LEN_BUFFER in sync with KSYM_NAME_LEN" |
| @@ -6,7 +6,7 @@ · 5 unmodified lines | |||
| 6 | #include <stdio.h> | 6 | #include <stdio.h> |
| 7 | #include <unistd.h> | 7 | #include <unistd.h> |
| 8 | 8 | ||
| 9 | #define KSYM_NAME_LEN 128 | 9 | #define KSYM_NAME_LEN 512 |
| 10 | 10 | ||
| 11 | struct module; | 11 | struct module; |
| 12 | 12 | ||
| @@ -97,7 +97,7 @@ struct perf_record_throttle { · 96 unmodified lines | |||
| 97 | }; | 97 | }; |
| 98 | 98 | ||
| 99 | #ifndef KSYM_NAME_LEN | 99 | #ifndef KSYM_NAME_LEN |
| 100 | #define KSYM_NAME_LEN 256 | 100 | #define KSYM_NAME_LEN 512 |
| 101 | #endif | 101 | #endif |
| 102 | 102 | ||
| 103 | struct perf_record_ksymbol { | 103 | struct perf_record_ksymbol { |
| @@ -7,7 +7,7 @@ · 6 unmodified lines | |||
| 7 | #include <linux/types.h> | 7 | #include <linux/types.h> |
| 8 | 8 | ||
| 9 | #ifndef KSYM_NAME_LEN | 9 | #ifndef KSYM_NAME_LEN |
| 10 | #define KSYM_NAME_LEN 256 | 10 | #define KSYM_NAME_LEN 512 |
| 11 | #endif | 11 | #endif |
| 12 | 12 | ||
| 13 | static inline u8 kallsyms2elf_binding(char type) | 13 | static inline u8 kallsyms2elf_binding(char type) |