Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
lto = true

[workspace.package]
version = "0.4.0"
version = "0.4.1"

[workspace]
resolver = "2"
Expand Down
27 changes: 16 additions & 11 deletions resym_core/src/pdb_file.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dashmap::DashMap;
#[cfg(target_arch = "wasm32")]
use instant::Instant;
use pdb::FallibleIterator;
use pdb::{AddressMap, FallibleIterator};
#[cfg(feature = "rayon")]
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};

Expand Down Expand Up @@ -127,6 +127,7 @@ where
pub debug_information: pdb::DebugInformation<'p>,
pub global_symbols: pdb::SymbolTable<'p>,
pub sections: Vec<pdb::ImageSectionHeader>,
pub address_map: pdb::AddressMap<'p>,
pub file_path: PathBuf,
pub xref_to_map: RwLock<DashMap<TypeIndex, Vec<TypeIndex>>>,
pdb: RwLock<pdb::PDB<'p, T>>,
Expand All @@ -142,6 +143,7 @@ impl<'p> PdbFile<'p, File> {
let debug_information = pdb.debug_information()?;
let global_symbols = pdb.global_symbols()?;
let sections = pdb.sections().unwrap_or_default().unwrap_or_default();
let address_map = pdb.address_map()?;
let machine_type = pdb.debug_information()?.machine_type()?;

let mut pdb_file = PdbFile {
Expand All @@ -153,6 +155,7 @@ impl<'p> PdbFile<'p, File> {
debug_information,
global_symbols,
sections,
address_map,
file_path: pdb_file_path.to_owned(),
xref_to_map: DashMap::default().into(),
pdb: pdb.into(),
Expand All @@ -175,6 +178,7 @@ impl<'p> PdbFile<'p, PDBDataSource> {
let debug_information = pdb.debug_information()?;
let global_symbols = pdb.global_symbols()?;
let sections = pdb.sections().unwrap_or_default().unwrap_or_default();
let address_map = pdb.address_map()?;
let machine_type = pdb.debug_information()?.machine_type()?;

let mut pdb_file = PdbFile {
Expand All @@ -186,6 +190,7 @@ impl<'p> PdbFile<'p, PDBDataSource> {
debug_information,
global_symbols,
sections,
address_map,
file_path: pdb_file_name.into(),
xref_to_map: DashMap::default().into(),
pdb: pdb.into(),
Expand All @@ -206,6 +211,7 @@ impl<'p> PdbFile<'p, PDBDataSource> {
let debug_information = pdb.debug_information()?;
let global_symbols = pdb.global_symbols()?;
let sections = pdb.sections().unwrap_or_default().unwrap_or_default();
let address_map = pdb.address_map()?;
let machine_type = pdb.debug_information()?.machine_type()?;

let mut pdb_file = PdbFile {
Expand All @@ -217,6 +223,7 @@ impl<'p> PdbFile<'p, PDBDataSource> {
debug_information,
global_symbols,
sections,
address_map,
file_path: pdb_file_name.into(),
xref_to_map: DashMap::default().into(),
pdb: pdb.into(),
Expand Down Expand Up @@ -1121,7 +1128,7 @@ where

// Functions and methods
pdb::SymbolData::Procedure(procedure) => {
let symbol_rva = symbol_rva(&procedure.offset, &self.sections)
let symbol_rva = symbol_rva(&procedure.offset, &self.address_map)
.map(|offset| format!("RVA=0x{:x} ", offset))
.unwrap_or_default();
if let Ok(type_name) = type_name(
Expand Down Expand Up @@ -1156,7 +1163,7 @@ where

// Global variables
pdb::SymbolData::Data(data) => {
let symbol_rva = symbol_rva(&data.offset, &self.sections)
let symbol_rva = symbol_rva(&data.offset, &self.address_map)
.map(|offset| format!("RVA=0x{:x} ", offset))
.unwrap_or_default();
if let Ok(type_name) = type_name(
Expand Down Expand Up @@ -1203,7 +1210,8 @@ where

// Public symbols
pdb::SymbolData::Public(data) => {
let symbol_rva = symbol_rva(&data.offset, &self.sections)
println!("{:x} {:x}", data.offset.offset, data.offset.section);
let symbol_rva = symbol_rva(&data.offset, &self.address_map)
.map(|offset| format!("RVA=0x{:x} ", offset))
.unwrap_or_default();
Some(
Expand Down Expand Up @@ -1369,16 +1377,13 @@ fn get_symbol_type(symbol_data: &pdb::SymbolData) -> SymbolKind {

fn symbol_rva(
symbol_offset: &pdb::PdbInternalSectionOffset,
sections: &[pdb::ImageSectionHeader],
translator: &AddressMap<'_>,
) -> Option<u32> {
if symbol_offset.section == 0 {
None
} else {
let section_offset = (symbol_offset.section - 1) as usize;

sections
.get(section_offset)
.map(|section_header| section_header.virtual_address + symbol_offset.offset)
}
else {
symbol_offset.to_internal_rva(translator)?.to_rva(translator).map(u32::from)
}
}

Expand Down