From a2b6955f73942c7069dd61148569aaaa5da476f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Thu, 17 Oct 2024 13:53:37 -0700 Subject: [PATCH] cli: Add support for symbolizing kernel addresses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for symbolization of kernel addresses to the program. Right now we do not expose any additional options and just rely on the "default" kernel symbolization source. $ cargo run -p blazecli -- symbolize kernel 0x0000000000019008 0xffffffffc005e378 > 0x00000000019008: espfix_stack @ 0x19008+0x0 > 0xffffffffc005e378: bpf_prog_6deef7357e7b4530_sd_fw_ingress @ 0xffffffffc005e2dc+0x9c Signed-off-by: Daniel Müller --- cli/CHANGELOG.md | 5 +++++ cli/src/args.rs | 8 ++++++++ cli/src/main.rs | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index c1ad0e8c1..3c2a3f41c 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -1,3 +1,8 @@ +Unreleased +---------- +- Added support for symbolization of kernel addresses + + 0.1.6 ----- - Added `--procmap-query` option to `normalize user` sub-command diff --git a/cli/src/args.rs b/cli/src/args.rs index acb4ae5cc..3fa175f3a 100644 --- a/cli/src/args.rs +++ b/cli/src/args.rs @@ -175,6 +175,7 @@ pub mod symbolize { Elf(Elf), Gsym(Gsym), Process(Process), + Kernel(Kernel), } #[derive(Debug, Arguments)] @@ -246,4 +247,11 @@ pub mod symbolize { #[clap(long)] pub no_map_files: bool, } + + #[derive(Debug, Arguments)] + pub struct Kernel { + /// The addresses to symbolize. + #[arg(value_parser = parse_addr)] + pub addrs: Vec, + } } diff --git a/cli/src/main.rs b/cli/src/main.rs index e1a2a31f8..9b1f6ed89 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -255,6 +255,15 @@ fn symbolize(symbolize: args::symbolize::Symbolize) -> Result<()> { let input = symbolize::Input::AbsAddr(addrs); (src, input, addrs) } + args::symbolize::Symbolize::Kernel(args::symbolize::Kernel { + ref addrs, + }) => { + let kernel = symbolize::Kernel::default(); + let src = symbolize::Source::from(kernel); + let addrs = addrs.as_slice(); + let input = symbolize::Input::AbsAddr(addrs); + (src, input, addrs) + } }; let symbolizer = builder.build();