Skip to content

Commit 8e6185d

Browse files
committed
add option to show/hide unwinds
1 parent 66c7b83 commit 8e6185d

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

objdiff-core/config-schema.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@
215215
"name": "Calculate pooled data references",
216216
"description": "Display pooled data references in functions as fake relocations."
217217
},
218+
{
219+
"id": "ppc.showUnwinds",
220+
"type": "boolean",
221+
"default": false,
222+
"name": "Show unwinds",
223+
"description": "Show auto-generated SEH __unwind functions. Useful if you're trying to link."
224+
},
218225
{
219226
"id": "x86.formatter",
220227
"type": "choice",
@@ -279,7 +286,8 @@
279286
"name": "PowerPC",
280287
"properties": [
281288
"ppc.calculatePoolRelocations",
282-
"analyzeDataFlow"
289+
"analyzeDataFlow",
290+
"ppc.showUnwinds"
283291
]
284292
},
285293
{

objdiff-core/src/arch/arm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ impl Arch for ArchArm {
457457
if kind == SymbolKind::Function { address & !1 } else { address }
458458
}
459459

460-
fn extra_symbol_flags(&self, symbol: &object::Symbol) -> SymbolFlagSet {
460+
fn extra_symbol_flags(&self, symbol: &object::Symbol, _diff_config: &DiffObjConfig) -> SymbolFlagSet {
461461
let mut flags = SymbolFlagSet::default();
462462
if DisasmMode::from_object_symbol(symbol).is_some() {
463463
flags |= SymbolFlag::Hidden;

objdiff-core/src/arch/mips.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ impl Arch for ArchMips {
331331
}
332332
}
333333

334-
fn extra_symbol_flags(&self, symbol: &object::Symbol) -> SymbolFlagSet {
334+
fn extra_symbol_flags(&self, symbol: &object::Symbol, _diff_config: &DiffObjConfig) -> SymbolFlagSet {
335335
let mut flags = SymbolFlagSet::default();
336336
if self.ignored_symbols.contains(&symbol.index().0) {
337337
flags |= SymbolFlag::Ignored;

objdiff-core/src/arch/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ pub trait Arch: Any + Debug + Send + Sync {
376376

377377
fn symbol_address(&self, address: u64, _kind: SymbolKind) -> u64 { address }
378378

379-
fn extra_symbol_flags(&self, _symbol: &object::Symbol) -> SymbolFlagSet {
379+
fn extra_symbol_flags(&self, _symbol: &object::Symbol, _diff_config: &DiffObjConfig) -> SymbolFlagSet {
380380
SymbolFlagSet::default()
381381
}
382382

objdiff-core/src/arch/ppc/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ impl Arch for ArchPpc {
357357
}
358358
}
359359

360-
fn extra_symbol_flags(&self, symbol: &object::Symbol) -> SymbolFlagSet {
360+
fn extra_symbol_flags(&self, symbol: &object::Symbol, diff_config: &DiffObjConfig) -> SymbolFlagSet {
361361
// X360 COFFs should automatically hide all symbols starting with "except_data",
362362
// because those are not functions - they're pointers to exception data structs
363363
if self.extensions.eq(&powerpc::Extensions::xenon()) {
@@ -366,10 +366,7 @@ impl Arch for ArchPpc {
366366
if name.starts_with("except_data_"){
367367
SymbolFlag::Hidden.into()
368368
}
369-
// if the symbol name starts with __unwind and
370-
// TODO: a "show unwinds" modifier is unchecked,
371-
// hide the symbol
372-
else if name.starts_with("__unwind"){
369+
else if name.starts_with("__unwind") && !diff_config.ppc_show_unwinds {
373370
SymbolFlag::Hidden.into()
374371
}
375372
else {

objdiff-core/src/obj/read.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ fn map_symbol(
4141
symbol: &object::Symbol,
4242
section_indices: &[usize],
4343
split_meta: Option<&SplitMeta>,
44+
diff_config: &DiffObjConfig
4445
) -> Result<Symbol> {
4546
let mut name = symbol.name().context("Failed to process symbol name")?.to_string();
4647
let mut size = symbol.size();
@@ -57,7 +58,7 @@ fn map_symbol(
5758
size = 0;
5859
}
5960

60-
let mut flags = arch.extra_symbol_flags(symbol);
61+
let mut flags = arch.extra_symbol_flags(symbol, diff_config);
6162
if symbol.is_global() {
6263
flags |= SymbolFlag::Global;
6364
}
@@ -108,6 +109,7 @@ fn map_symbols(
108109
sections: &[Section],
109110
section_indices: &[usize],
110111
split_meta: Option<&SplitMeta>,
112+
diff_config: &DiffObjConfig,
111113
) -> Result<(Vec<Symbol>, Vec<usize>)> {
112114
let symbol_count = obj_file.symbols().count();
113115
let mut symbols = Vec::<Symbol>::with_capacity(symbol_count);
@@ -116,7 +118,7 @@ fn map_symbols(
116118
if symbol_indices.len() <= obj_symbol.index().0 {
117119
symbol_indices.resize(obj_symbol.index().0 + 1, usize::MAX);
118120
}
119-
let symbol = map_symbol(arch, obj_file, &obj_symbol, section_indices, split_meta)?;
121+
let symbol = map_symbol(arch, obj_file, &obj_symbol, section_indices, split_meta, diff_config)?;
120122
symbol_indices[obj_symbol.index().0] = symbols.len();
121123
symbols.push(symbol);
122124
}
@@ -936,7 +938,7 @@ pub fn parse(data: &[u8], config: &DiffObjConfig) -> Result<Object> {
936938
let (mut sections, section_indices) =
937939
map_sections(arch.as_ref(), &obj_file, split_meta.as_ref())?;
938940
let (mut symbols, symbol_indices) =
939-
map_symbols(arch.as_ref(), &obj_file, &sections, &section_indices, split_meta.as_ref())?;
941+
map_symbols(arch.as_ref(), &obj_file, &sections, &section_indices, split_meta.as_ref(), config)?;
940942
map_relocations(arch.as_ref(), &obj_file, &mut sections, &section_indices, &symbol_indices)?;
941943
parse_line_info(&obj_file, &mut sections, &section_indices, data)?;
942944
if config.combine_data_sections || config.combine_text_sections {

0 commit comments

Comments
 (0)