Skip to content

Commit 3341b83

Browse files
committed
WIP implementation
1 parent 2d643eb commit 3341b83

File tree

13 files changed

+682
-50
lines changed

13 files changed

+682
-50
lines changed

objdiff-cli/src/views/function_diff.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ impl FunctionDiffUi {
570570
DiffTextColor::Normal => Color::Gray,
571571
DiffTextColor::Dim => Color::DarkGray,
572572
DiffTextColor::Bright => Color::White,
573+
DiffTextColor::DataFlow => Color::LightCyan,
573574
DiffTextColor::Replace => Color::Cyan,
574575
DiffTextColor::Delete => Color::Red,
575576
DiffTextColor::Insert => Color::Green,

objdiff-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ time = { version = "0.3", optional = true }
174174
encoding_rs = "0.8.35"
175175

176176
[target.'cfg(windows)'.dependencies]
177-
winapi = { version = "0.3", optional = true }
177+
winapi = { version = "0.3", optional = true, features = ["winbase"] }
178178

179179
# For Linux static binaries, use rustls
180180
[target.'cfg(target_os = "linux")'.dependencies]

objdiff-core/config-schema.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@
2525
}
2626
]
2727
},
28+
{
29+
"id": "analyzeDataFlow",
30+
"type": "boolean",
31+
"default": false,
32+
"name": "(Experimental) Perform data flow analysis",
33+
"description": "Use data flow analysis to display known information about register contents where possible"
34+
},
35+
{
36+
"id": "showDataFlow",
37+
"type": "boolean",
38+
"default": true,
39+
"name": "Show data flow",
40+
"description": "Show data flow analysis results in place of register name where present"
41+
},
2842
{
2943
"id": "spaceBetweenArgs",
3044
"type": "boolean",
@@ -264,7 +278,8 @@
264278
"id": "ppc",
265279
"name": "PowerPC",
266280
"properties": [
267-
"ppc.calculatePoolRelocations"
281+
"ppc.calculatePoolRelocations",
282+
"analyzeDataFlow"
268283
]
269284
},
270285
{

objdiff-core/src/arch/mod.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
use alloc::{borrow::Cow, boxed::Box, format, string::String, vec::Vec};
2-
use core::{ffi::CStr, fmt, fmt::Debug};
2+
use core::{ffi::CStr, fmt::{self, Debug}};
33

44
use anyhow::{Result, bail};
55
use encoding_rs::SHIFT_JIS;
66
use object::Endian as _;
77

88
use crate::{
99
diff::{
10-
DiffObjConfig,
11-
display::{ContextItem, HoverItem, InstructionPart},
10+
display::{ContextItem, HoverItem, InstructionPart}, DiffObjConfig
1211
},
1312
obj::{
14-
InstructionArg, InstructionRef, Object, ParsedInstruction, Relocation, RelocationFlags,
15-
ResolvedInstructionRef, ResolvedSymbol, Section, Symbol, SymbolFlagSet, SymbolKind,
13+
FlowAnalysisResult, InstructionArg, InstructionRef, Object, ParsedInstruction, Relocation, RelocationFlags, ResolvedInstructionRef, ResolvedSymbol, Section, Symbol, SymbolFlagSet, SymbolKind
1614
},
1715
util::ReallySigned,
1816
};
@@ -31,6 +29,7 @@ pub mod superh;
3129
pub mod x86;
3230

3331
/// Represents the type of data associated with an instruction
32+
#[derive(PartialEq)]
3433
pub enum DataType {
3534
Int8,
3635
Int16,
@@ -335,6 +334,17 @@ pub trait Arch: Send + Sync + Debug {
335334
Vec::new()
336335
}
337336

337+
// Perform detailed data flow analysis
338+
fn data_flow_analysis(
339+
&self,
340+
_obj: &Object,
341+
_symbol: &Symbol,
342+
_code: &[u8],
343+
_relocations: &[Relocation],
344+
) -> Option<Box<dyn FlowAnalysisResult>> {
345+
None
346+
}
347+
338348
fn implcit_addend(
339349
&self,
340350
file: &object::File<'_>,

0 commit comments

Comments
 (0)