Skip to content

Commit 316958f

Browse files
committed
X: Try to change code size.
1 parent 6075eb0 commit 316958f

File tree

3 files changed

+4
-93
lines changed

3 files changed

+4
-93
lines changed

src/print.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,6 @@ impl BacktraceFrameFmt<'_, '_, '_> {
203203
lineno: Option<u32>,
204204
colno: Option<u32>,
205205
) -> fmt::Result {
206-
// Fuchsia is unable to symbolize within a process so it has a special
207-
// format which can be used to symbolize later. Print that instead of
208-
// printing addresses in our own format here.
209-
if cfg!(target_os = "fuchsia") {
210-
self.print_raw_fuchsia(frame_ip)?;
211-
} else {
212-
self.print_raw_generic(frame_ip, symbol_name, filename, lineno, colno)?;
213-
}
214-
self.symbol_index += 1;
215206
Ok(())
216207
}
217208

src/symbolize/gimli/coff.rs

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -37,71 +37,15 @@ pub fn get_image_base(data: &[u8]) -> Option<usize> {
3737

3838
impl<'a> Object<'a> {
3939
fn parse(data: &'a [u8]) -> Option<Object<'a>> {
40-
let dos_header = ImageDosHeader::parse(data).ok()?;
41-
let mut offset = dos_header.nt_headers_offset().into();
42-
let (nt_headers, _) = Pe::parse(data, &mut offset).ok()?;
43-
let sections = nt_headers.sections(data, offset).ok()?;
44-
let symtab = nt_headers.symbols(data).ok()?;
45-
let strings = symtab.strings();
46-
let image_base = usize::try_from(nt_headers.optional_header().image_base()).ok()?;
47-
48-
// Collect all the symbols into a local vector which is sorted
49-
// by address and contains enough data to learn about the symbol
50-
// name. Note that we only look at function symbols and also
51-
// note that the sections are 1-indexed because the zero section
52-
// is special (apparently).
53-
let mut symbols = Vec::new();
54-
let mut i = 0;
55-
let len = symtab.len();
56-
while i < len {
57-
let sym = symtab.symbol(i).ok()?;
58-
i += 1 + sym.number_of_aux_symbols as usize;
59-
let section_number = sym.section_number.get(LE);
60-
if sym.derived_type() != object::pe::IMAGE_SYM_DTYPE_FUNCTION || section_number == 0 {
61-
continue;
62-
}
63-
let addr = usize::try_from(sym.value.get(LE)).ok()?;
64-
let section = sections
65-
.section(usize::try_from(section_number).ok()?)
66-
.ok()?;
67-
let va = usize::try_from(section.virtual_address.get(LE)).ok()?;
68-
symbols.push((addr + va + image_base, sym));
69-
}
70-
symbols.sort_unstable_by_key(|x| x.0);
71-
Some(Object {
72-
data,
73-
sections,
74-
strings,
75-
symbols,
76-
})
40+
None
7741
}
7842

7943
pub fn section(&self, _: &Stash, name: &str) -> Option<&'a [u8]> {
80-
Some(
81-
self.sections
82-
.section_by_name(self.strings, name.as_bytes())?
83-
.1
84-
.pe_data(self.data)
85-
.ok()?,
86-
)
44+
None
8745
}
8846

8947
pub fn search_symtab<'b>(&'b self, addr: u64) -> Option<&'b [u8]> {
90-
// Note that unlike other formats COFF doesn't embed the size of
91-
// each symbol. As a last ditch effort search for the *closest*
92-
// symbol to a particular address and return that one. This gets
93-
// really wonky once symbols start getting removed because the
94-
// symbols returned here can be totally incorrect, but we have
95-
// no idea of knowing how to detect that.
96-
let addr = usize::try_from(addr).ok()?;
97-
let i = match self.symbols.binary_search_by_key(&addr, |p| p.0) {
98-
Ok(i) => i,
99-
// typically `addr` isn't in the array, but `i` is where
100-
// we'd insert it, so the previous position must be the
101-
// greatest less than `addr`
102-
Err(i) => i.checked_sub(1)?,
103-
};
104-
self.symbols[i].1.name(self.strings).ok()
48+
None
10549
}
10650

10751
pub(super) fn search_object_map(&self, _addr: u64) -> Option<(&Context<'_>, u64)> {

src/symbolize/gimli/elf.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,7 @@ impl Mapping {
4545

4646
/// Load debuginfo from an external debug file.
4747
fn new_debug(original_path: &Path, path: PathBuf, crc: Option<u32>) -> Option<Mapping> {
48-
let map = super::mmap(&path)?;
49-
Mapping::mk(map, |map, stash| {
50-
let object = Object::parse(&map)?;
51-
52-
if let Some(_crc) = crc {
53-
// TODO: check crc
54-
}
55-
56-
// Try to locate a supplementary object file.
57-
let mut sup = None;
58-
if let Some((path_sup, build_id_sup)) = object.gnu_debugaltlink_path(&path) {
59-
if let Some(map_sup) = super::mmap(&path_sup) {
60-
let map_sup = stash.cache_mmap(map_sup);
61-
if let Some(sup_) = Object::parse(map_sup) {
62-
if sup_.build_id() == Some(build_id_sup) {
63-
sup = Some(sup_);
64-
}
65-
}
66-
}
67-
}
68-
69-
let dwp = Mapping::load_dwarf_package(original_path, stash);
70-
71-
Context::new(stash, object, sup, dwp)
72-
})
48+
None
7349
}
7450

7551
/// Try to locate a DWARF package file.

0 commit comments

Comments
 (0)