Skip to content

Commit f92750f

Browse files
authored
Merge pull request #766 from philipc/object
Update `object` to 0.40.0
2 parents bfe2c30 + a0a9736 commit f92750f

8 files changed

Lines changed: 26 additions & 23 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ addr2line = { version = "0.25.0", default-features = false }
4848
libc = { version = "0.2.156", default-features = false }
4949

5050
[target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies.object]
51-
version = "0.39.0"
51+
version = "0.40.0"
5252
default-features = false
5353
features = ['read_core', 'elf', 'macho', 'pe', 'xcoff', 'unaligned', 'archive']
5454

crates/as-if-std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ruzstd = { version = "0.8.1", optional = true, default-features = false }
2222
addr2line = { version = "0.25.0", optional = true, default-features = false }
2323

2424
[target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies.object]
25-
version = "0.39.0"
25+
version = "0.40.0"
2626
default-features = false
2727
optional = true
2828
features = ['read_core', 'elf', 'macho', 'pe', 'xcoff', 'unaligned', 'archive']

src/print/fuchsia.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl<'a> Iterator for NoteIter<'a> {
200200
Some(Note {
201201
name: name,
202202
desc: desc,
203-
tipe: nhdr.n_type.get(NE),
203+
tipe: nhdr.n_type.get(NE).0,
204204
})
205205
}
206206
}

src/symbolize/gimli/coff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use core::convert::TryFrom;
66
use object::LittleEndian as LE;
77
use object::pe::{ImageDosHeader, ImageSymbol};
88
use object::read::StringTable;
9-
use object::read::coff::ImageSymbol as _;
9+
use object::read::coff::Symbol as _;
1010
use object::read::pe::{ImageNtHeaders, ImageOptionalHeader, SectionTable};
1111

1212
#[cfg(target_pointer_width = "32")]

src/symbolize/gimli/elf.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ impl<'a> Object<'a> {
219219
// Check for DWARF-standard (gABI) compression, i.e., as generated
220220
// by ld's `--compress-debug-sections=zlib-gabi` and
221221
// `--compress-debug-sections=zstd` flags.
222-
let flags: u64 = section.sh_flags(self.endian).into();
223-
if (flags & u64::from(SHF_COMPRESSED)) == 0 {
222+
if !section.sh_flags(self.endian).contains(SHF_COMPRESSED) {
224223
// Not compressed.
225224
return Some(data.0);
226225
}

src/symbolize/gimli/macho.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn find_header(data: &'_ [u8]) -> Option<(&'_ Mach, &'_ [u8])> {
163163
pub struct Object<'a> {
164164
endian: NativeEndian,
165165
data: &'a [u8],
166-
dwarf: Option<&'a [MachSection]>,
166+
dwarf: Option<(&'a MachSegment, &'a [MachSection])>,
167167
syms: Vec<(&'a [u8], u64)>,
168168
syms_sort_by_name: bool,
169169
// Only set for executables/libraries, and not the source object files.
@@ -185,7 +185,10 @@ impl<'a> Object<'a> {
185185
if let Some((segment, section_data)) = MachSegment::from_command(command).ok()? {
186186
// Object files should have all sections in a single unnamed segment load command.
187187
if segment.name() == b"__DWARF" || (is_object && segment.name() == b"") {
188-
dwarf = segment.sections(endian, section_data).ok();
188+
dwarf = segment
189+
.sections(endian, section_data)
190+
.ok()
191+
.map(|sections| (segment, sections));
189192
}
190193
} else if let Some(symtab) = command.symtab().ok()? {
191194
let symbols = symtab.symbols::<Mach, _>(endian, data).ok()?;
@@ -228,16 +231,19 @@ impl<'a> Object<'a> {
228231

229232
pub fn section(&self, _: &Stash, name: &str) -> Option<&'a [u8]> {
230233
let name = name.as_bytes();
231-
let dwarf = self.dwarf?;
232-
let section = dwarf.into_iter().find(|section| {
233-
let section_name = section.name();
234-
section_name == name || {
235-
section_name.starts_with(b"__")
236-
&& name.starts_with(b".")
237-
&& &section_name[2..] == &name[1..]
238-
}
239-
})?;
240-
Some(section.data(self.endian, self.data).ok()?)
234+
let (segment, sections) = self.dwarf?;
235+
let (section, offset) = segment
236+
.section_offsets(self.endian, sections)
237+
.filter_map(|section| section.ok())
238+
.find(|(section, _offset)| {
239+
let section_name = section.name();
240+
section_name == name || {
241+
section_name.starts_with(b"__")
242+
&& name.starts_with(b".")
243+
&& &section_name[2..] == &name[1..]
244+
}
245+
})?;
246+
Some(section.data(self.endian, self.data, offset).ok()?)
241247
}
242248

243249
pub fn search_symtab<'b>(&'b self, addr: u64) -> Option<&'b [u8]> {

src/symbolize/gimli/xcoff.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,8 @@ impl<'a> Object<'a> {
103103
fn get_concrete_size(file: &XcoffFile<'a, Xcoff>, sym: &XcoffSymbol<'a, '_, Xcoff>) -> u64 {
104104
match sym.flags() {
105105
SymbolFlags::Xcoff {
106-
n_sclass: _,
107-
x_smtyp: _,
108-
x_smclas: _,
109106
containing_csect: Some(index),
107+
..
110108
} => {
111109
if let Ok(tgt_sym) = file.symbol_by_index(index) {
112110
Self::get_concrete_size(file, &tgt_sym)

0 commit comments

Comments
 (0)