diff --git a/Cargo.lock b/Cargo.lock index 9772e64e..028e8a76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -120,9 +120,9 @@ dependencies = [ [[package]] name = "object" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 9dcc54a4..5112e810 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ addr2line = { version = "0.22.0", default-features = false } libc = { version = "0.2.146", default-features = false } [target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies.object] -version = "0.35.0" +version = "0.36.0" default-features = false features = ['read_core', 'elf', 'macho', 'pe', 'xcoff', 'unaligned', 'archive'] diff --git a/crates/as-if-std/Cargo.toml b/crates/as-if-std/Cargo.toml index 527d2105..c18e379f 100644 --- a/crates/as-if-std/Cargo.toml +++ b/crates/as-if-std/Cargo.toml @@ -21,7 +21,7 @@ miniz_oxide = { version = "0.7.0", optional = true, default-features = false } addr2line = { version = "0.22.0", optional = true, default-features = false } [target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies.object] -version = "0.35.0" +version = "0.36.0" default-features = false optional = true features = ['read_core', 'elf', 'macho', 'pe', 'xcoff', 'unaligned', 'archive'] diff --git a/src/symbolize/gimli/coff.rs b/src/symbolize/gimli/coff.rs index 759c827e..018cb494 100644 --- a/src/symbolize/gimli/coff.rs +++ b/src/symbolize/gimli/coff.rs @@ -51,19 +51,15 @@ impl<'a> Object<'a> { // note that the sections are 1-indexed because the zero section // is special (apparently). let mut symbols = Vec::new(); - let mut i = 0; - let len = symtab.len(); - while i < len { - let sym = symtab.symbol(i).ok()?; - i += 1 + sym.number_of_aux_symbols as usize; - let section_number = sym.section_number.get(LE); - if sym.derived_type() != object::pe::IMAGE_SYM_DTYPE_FUNCTION || section_number == 0 { + for (_, sym) in symtab.iter() { + if sym.derived_type() != object::pe::IMAGE_SYM_DTYPE_FUNCTION { continue; } + let Some(section_index) = sym.section() else { + continue; + }; let addr = usize::try_from(sym.value.get(LE)).ok()?; - let section = sections - .section(usize::try_from(section_number).ok()?) - .ok()?; + let section = sections.section(section_index).ok()?; let va = usize::try_from(section.virtual_address.get(LE)).ok()?; symbols.push((addr + va + image_base, sym)); } diff --git a/src/symbolize/gimli/macho.rs b/src/symbolize/gimli/macho.rs index 74ed8091..7a4a4919 100644 --- a/src/symbolize/gimli/macho.rs +++ b/src/symbolize/gimli/macho.rs @@ -281,20 +281,12 @@ impl<'a> Object<'a> { } } -fn object_mapping(path: &[u8]) -> Option { +fn object_mapping(file: &object::read::ObjectMapFile<'_>) -> Option { use super::mystd::ffi::OsStr; use super::mystd::os::unix::prelude::*; - let map; - - // `N_OSO` symbol names can be either `/path/to/object.o` or `/path/to/archive.a(object.o)`. - let member_name = if let Some((archive_path, member_name)) = split_archive_path(path) { - map = super::mmap(Path::new(OsStr::from_bytes(archive_path)))?; - Some(member_name) - } else { - map = super::mmap(Path::new(OsStr::from_bytes(path)))?; - None - }; + let map = super::mmap(Path::new(OsStr::from_bytes(file.path())))?; + let member_name = file.member(); Mapping::mk(map, |data, stash| { let data = match member_name { Some(member_name) => { @@ -314,16 +306,6 @@ fn object_mapping(path: &[u8]) -> Option { }) } -fn split_archive_path(path: &[u8]) -> Option<(&[u8], &[u8])> { - let (last, path) = path.split_last()?; - if *last != b')' { - return None; - } - let index = path.iter().position(|&x| x == b'(')?; - let (archive, rest) = path.split_at(index); - Some((archive, &rest[1..])) -} - pub(super) fn handle_split_dwarf<'data>( _package: Option<&gimli::DwarfPackage>>, _stash: &'data Stash,