From: Nick Desaulniers <ndesaulniers@google.com>
To: ojeda@kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Alex Gaynor <alex.gaynor@gmail.com>,
Geoffrey Thomas <geofft@ldpreload.com>,
Finn Behrens <me@kloenk.de>,
Adam Bratschi-Kaye <ark.email@gmail.com>,
Wedson Almeida Filho <wedsonaf@google.com>
Subject: Re: [PATCH 02/17] kallsyms: increase maximum kernel symbol length to 512
Date: Wed, 14 Jul 2021 11:20:44 -0700 [thread overview]
Message-ID: <CAKwvOdmhRuF5eTZ2ztZBrL6BvDkA57B7OfVuvCaEMfV8nkLXCQ@mail.gmail.com> (raw)
In-Reply-To: <20210704202756.29107-3-ojeda@kernel.org>
On Sun, Jul 4, 2021 at 1:28 PM <ojeda@kernel.org> wrote:
>
> From: Miguel Ojeda <ojeda@kernel.org>
>
> Rust symbols can become quite long due to namespacing introduced
> by modules, types, traits, generics, etc. For instance, for:
>
> 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
For C++ demangling, we have c++filt.
A quick search turned up: https://github.com/luser/rustfilt
but if the v0 mangling scheme is upcoming, I doubt a repo that hasn't
been updated supports an upcoming scheme. Is there a more official
equivalent?
Do we demangle rust symbols when printing a trace from a warn/panic?
That would be nice.
>
> 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.
>
> Co-developed-by: Alex Gaynor <alex.gaynor@gmail.com>
> Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
> Co-developed-by: Geoffrey Thomas <geofft@ldpreload.com>
> Signed-off-by: Geoffrey Thomas <geofft@ldpreload.com>
> Co-developed-by: Finn Behrens <me@kloenk.de>
> Signed-off-by: Finn Behrens <me@kloenk.de>
> Co-developed-by: Adam Bratschi-Kaye <ark.email@gmail.com>
> Signed-off-by: Adam Bratschi-Kaye <ark.email@gmail.com>
> Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com>
> Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
> ---
> include/linux/kallsyms.h | 2 +-
> kernel/livepatch/core.c | 4 ++--
> scripts/kallsyms.c | 2 +-
> tools/include/linux/kallsyms.h | 2 +-
> tools/include/linux/lockdep.h | 2 +-
> tools/lib/perf/include/perf/event.h | 2 +-
> tools/lib/symbol/kallsyms.h | 2 +-
> 7 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
> index 465060acc98..5cdc6903abc 100644
> --- a/include/linux/kallsyms.h
> +++ b/include/linux/kallsyms.h
> @@ -14,7 +14,7 @@
>
> #include <asm/sections.h>
>
> -#define KSYM_NAME_LEN 128
> +#define KSYM_NAME_LEN 512
> #define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \
> 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1)
>
> diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> index 335d988bd81..73874e5edfd 100644
> --- a/kernel/livepatch/core.c
> +++ b/kernel/livepatch/core.c
> @@ -213,7 +213,7 @@ static int klp_resolve_symbols(Elf64_Shdr *sechdrs, const char *strtab,
> * we use the smallest/strictest upper bound possible (56, based on
> * the current definition of MODULE_NAME_LEN) to prevent overflows.
> */
> - BUILD_BUG_ON(MODULE_NAME_LEN < 56 || KSYM_NAME_LEN != 128);
> + BUILD_BUG_ON(MODULE_NAME_LEN < 56 || KSYM_NAME_LEN != 512);
>
> relas = (Elf_Rela *) relasec->sh_addr;
> /* For each rela in this klp relocation section */
> @@ -227,7 +227,7 @@ static int klp_resolve_symbols(Elf64_Shdr *sechdrs, const char *strtab,
>
> /* Format: .klp.sym.sym_objname.sym_name,sympos */
> cnt = sscanf(strtab + sym->st_name,
> - ".klp.sym.%55[^.].%127[^,],%lu",
> + ".klp.sym.%55[^.].%511[^,],%lu",
> sym_objname, sym_name, &sympos);
> if (cnt != 3) {
> pr_err("symbol %s has an incorrectly formatted name\n",
> diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
> index bcdabee13aa..9bab5f55ade 100644
> --- a/scripts/kallsyms.c
> +++ b/scripts/kallsyms.c
> @@ -27,7 +27,7 @@
>
> #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
>
> -#define KSYM_NAME_LEN 128
> +#define KSYM_NAME_LEN 512
>
> struct sym_entry {
> unsigned long long addr;
> diff --git a/tools/include/linux/kallsyms.h b/tools/include/linux/kallsyms.h
> index efb6c3f5f2a..5a37ccbec54 100644
> --- a/tools/include/linux/kallsyms.h
> +++ b/tools/include/linux/kallsyms.h
> @@ -6,7 +6,7 @@
> #include <stdio.h>
> #include <unistd.h>
>
> -#define KSYM_NAME_LEN 128
> +#define KSYM_NAME_LEN 512
>
> struct module;
>
> diff --git a/tools/include/linux/lockdep.h b/tools/include/linux/lockdep.h
> index e56997288f2..d9c163f3ab2 100644
> --- a/tools/include/linux/lockdep.h
> +++ b/tools/include/linux/lockdep.h
> @@ -47,7 +47,7 @@ static inline int debug_locks_off(void)
>
> #define task_pid_nr(tsk) ((tsk)->pid)
>
> -#define KSYM_NAME_LEN 128
> +#define KSYM_NAME_LEN 512
> #define printk(...) dprintf(STDOUT_FILENO, __VA_ARGS__)
> #define pr_err(format, ...) fprintf (stderr, format, ## __VA_ARGS__)
> #define pr_warn pr_err
> diff --git a/tools/lib/perf/include/perf/event.h b/tools/lib/perf/include/perf/event.h
> index 4d0c02ba3f7..095d60144a7 100644
> --- a/tools/lib/perf/include/perf/event.h
> +++ b/tools/lib/perf/include/perf/event.h
> @@ -95,7 +95,7 @@ struct perf_record_throttle {
> };
>
> #ifndef KSYM_NAME_LEN
> -#define KSYM_NAME_LEN 256
> +#define KSYM_NAME_LEN 512
> #endif
>
> struct perf_record_ksymbol {
> diff --git a/tools/lib/symbol/kallsyms.h b/tools/lib/symbol/kallsyms.h
> index 72ab9870454..542f9b059c3 100644
> --- a/tools/lib/symbol/kallsyms.h
> +++ b/tools/lib/symbol/kallsyms.h
> @@ -7,7 +7,7 @@
> #include <linux/types.h>
>
> #ifndef KSYM_NAME_LEN
> -#define KSYM_NAME_LEN 256
> +#define KSYM_NAME_LEN 512
> #endif
>
> static inline u8 kallsyms2elf_binding(char type)
> --
> 2.32.0
>
--
Thanks,
~Nick Desaulniers
next prev parent reply other threads:[~2021-07-14 18:21 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-04 20:27 [PATCH 00/17] Rust support ojeda
2021-07-04 20:27 ` [PATCH 01/17] kallsyms: support big kernel symbols (2-byte lengths) ojeda
2021-07-04 20:52 ` Linus Torvalds
2021-07-04 21:15 ` Miguel Ojeda
2021-07-04 21:28 ` Linus Torvalds
2021-07-04 21:04 ` Matthew Wilcox
2021-07-04 21:17 ` Miguel Ojeda
2021-07-04 21:33 ` Matthew Wilcox
2021-07-04 21:49 ` Matthew Wilcox
2021-07-04 22:07 ` Miguel Ojeda
2021-07-04 22:20 ` Gary Guo
2021-07-04 22:42 ` Matthew Wilcox
2021-07-04 23:14 ` Gary Guo
2021-07-13 18:02 ` Kent Overstreet
2021-07-04 21:20 ` Gary Guo
2021-07-05 4:35 ` Willy Tarreau
2021-07-04 20:27 ` [PATCH 02/17] kallsyms: increase maximum kernel symbol length to 512 ojeda
2021-07-14 18:20 ` Nick Desaulniers [this message]
2021-07-14 19:04 ` Linus Torvalds
2021-07-14 20:09 ` Eric W. Biederman
2021-07-14 20:21 ` Linus Torvalds
2021-07-14 20:48 ` Eric W. Biederman
2021-07-14 22:40 ` Linus Torvalds
2021-07-14 20:19 ` Miguel Ojeda
2021-07-04 20:27 ` [PATCH 03/17] Makefile: generate `CLANG_FLAGS` even in GCC builds ojeda
2021-07-14 18:13 ` Nick Desaulniers
2021-07-14 18:16 ` Nick Desaulniers
2021-07-14 20:31 ` Miguel Ojeda
2021-07-04 20:27 ` [PATCH 04/17] vsprintf: add new `%pA` format specifier ojeda
2021-07-07 20:31 ` Nick Desaulniers
2021-07-07 22:33 ` Miguel Ojeda
2021-07-04 20:27 ` [PATCH 05/17] rust: add C helpers ojeda
2021-07-07 10:19 ` Marco Elver
2021-07-09 10:31 ` Marco Elver
2021-07-09 14:32 ` Miguel Ojeda
2021-07-04 20:27 ` [PATCH 06/17] rust: add `compiler_builtins` crate ojeda
2021-07-04 20:27 ` [PATCH 07/17] rust: add `alloc` crate ojeda
2021-07-04 20:27 ` [PATCH 08/17] rust: add `build_error` crate ojeda
2021-07-04 20:27 ` [PATCH 09/17] rust: add `macros` crate ojeda
2021-07-04 20:27 ` [PATCH 10/17] rust: add `kernel` crate ojeda
2021-07-04 20:27 ` [PATCH 11/17] rust: export generated symbols ojeda
2021-07-04 20:27 ` [PATCH 12/17] Kbuild: add Rust support ojeda
2021-07-04 20:27 ` [PATCH 13/17] docs: add Rust documentation ojeda
2021-07-05 5:02 ` Willy Tarreau
2021-07-06 0:06 ` Miguel Ojeda
2021-07-06 2:09 ` Willy Tarreau
2021-07-14 18:37 ` Nick Desaulniers
2021-07-14 19:55 ` Miguel Ojeda
2021-07-04 20:27 ` [PATCH 14/17] samples: add Rust examples ojeda
2021-07-04 20:27 ` [PATCH 15/17] scripts: add `generate_rust_analyzer.py` ojeda
2021-07-05 5:05 ` Willy Tarreau
2021-07-05 23:41 ` Miguel Ojeda
2021-07-04 20:27 ` [PATCH 16/17] MAINTAINERS: Rust ojeda
2021-07-06 0:26 ` Pedro Tammela
2021-07-06 22:14 ` Miguel Ojeda
2021-07-04 20:27 ` [RFC PATCH 17/17] Android: Binder IPC in Rust (WIP) ojeda
2021-07-04 23:11 ` [PATCH 00/17] Rust support Miguel Ojeda
2021-07-07 6:43 ` Christoph Hellwig
2021-07-07 12:33 ` Miguel Ojeda
2021-07-07 12:50 ` Greg Kroah-Hartman
2021-07-07 14:07 ` Wedson Almeida Filho
2021-07-07 14:12 ` Christoph Hellwig
2021-07-07 15:02 ` Greg Kroah-Hartman
2021-07-07 20:56 ` Finn Behrens
2021-07-08 0:58 ` Matthew Wilcox
2021-07-08 6:39 ` [PATCH 00/17] Rust support, NVMe Geert Stappers
2021-07-08 8:29 ` Finn Behrens
2021-07-22 22:55 ` [PATCH 00/17] Rust support Wedson Almeida Filho
2021-07-23 1:17 ` Matthew Wilcox
2021-07-23 11:33 ` [PATCH 00/17] Rust support, GPIO driver Geert Stappers
2021-07-23 15:08 ` [PATCH 00/17] Rust support Keith Busch
2021-07-07 10:51 ` Marco Elver
2021-07-07 11:28 ` Miguel Ojeda
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=CAKwvOdmhRuF5eTZ2ztZBrL6BvDkA57B7OfVuvCaEMfV8nkLXCQ@mail.gmail.com \
--to=ndesaulniers@google.com \
--cc=alex.gaynor@gmail.com \
--cc=ark.email@gmail.com \
--cc=geofft@ldpreload.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@kloenk.de \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=wedsonaf@google.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).