File tree Expand file tree Collapse file tree
src/run/runner/wall_time/perf Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,20 @@ impl ModuleSymbols {
5151 return Err ( anyhow:: anyhow!( "No symbols found" ) ) ;
5252 }
5353
54+ // The base_addr from the mapping is where the module is actually loaded in memory (See ProcessSymbols::add_mapping),
55+ // but the symbol addresses from the ELF file assume the module is loaded at its preferred virtual address. We need to:
56+ // 1. Find the module's preferred base address from the ELF file or symbols
57+ // 2. Calculate the offset: actual_base - preferred_base
58+ // 3. Apply this offset to the symbol addresses
59+
60+ // Find the preferred base address from the minimum symbol address
61+ let preferred_base = symbols. iter ( ) . map ( |s| s. offset ) . min ( ) . unwrap_or ( 0 ) & !0xfff ; // Align to page boundary
62+
63+ // Convert absolute addresses to relative offsets
64+ for symbol in & mut symbols {
65+ symbol. offset = symbol. offset . saturating_sub ( preferred_base) ;
66+ }
67+
5468 Ok ( Self {
5569 path : path. as_ref ( ) . to_path_buf ( ) ,
5670 symbols,
You can’t perform that action at this time.
0 commit comments