Skip to content

Implementation of basic data flow analysis for PowerPC #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions objdiff-cli/src/views/function_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ impl FunctionDiffUi {
DiffTextColor::Normal => Color::Gray,
DiffTextColor::Dim => Color::DarkGray,
DiffTextColor::Bright => Color::White,
DiffTextColor::DataFlow => Color::LightCyan,
DiffTextColor::Replace => Color::Cyan,
DiffTextColor::Delete => Color::Red,
DiffTextColor::Insert => Color::Green,
Expand Down
2 changes: 1 addition & 1 deletion objdiff-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ time = { version = "0.3", optional = true }
encoding_rs = "0.8.35"

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

# For Linux static binaries, use rustls
[target.'cfg(target_os = "linux")'.dependencies]
Expand Down
17 changes: 16 additions & 1 deletion objdiff-core/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@
}
]
},
{
"id": "analyzeDataFlow",
"type": "boolean",
"default": false,
"name": "(Experimental) Perform data flow analysis",
"description": "Use data flow analysis to display known information about register contents where possible"
},
{
"id": "showDataFlow",
"type": "boolean",
"default": true,
"name": "Show data flow",
"description": "Show data flow analysis results in place of register name where present"
},
{
"id": "spaceBetweenArgs",
"type": "boolean",
Expand Down Expand Up @@ -264,7 +278,8 @@
"id": "ppc",
"name": "PowerPC",
"properties": [
"ppc.calculatePoolRelocations"
"ppc.calculatePoolRelocations",
"analyzeDataFlow"
]
},
{
Expand Down
20 changes: 15 additions & 5 deletions objdiff-core/src/arch/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
use alloc::{borrow::Cow, boxed::Box, format, string::String, vec::Vec};
use core::{ffi::CStr, fmt, fmt::Debug};
use core::{ffi::CStr, fmt::{self, Debug}};

use anyhow::{Result, bail};
use encoding_rs::SHIFT_JIS;
use object::Endian as _;

use crate::{
diff::{
DiffObjConfig,
display::{ContextItem, HoverItem, InstructionPart},
display::{ContextItem, HoverItem, InstructionPart}, DiffObjConfig
},
obj::{
InstructionArg, InstructionRef, Object, ParsedInstruction, Relocation, RelocationFlags,
ResolvedInstructionRef, ResolvedSymbol, Section, Symbol, SymbolFlagSet, SymbolKind,
FlowAnalysisResult, InstructionArg, InstructionRef, Object, ParsedInstruction, Relocation, RelocationFlags, ResolvedInstructionRef, ResolvedSymbol, Section, Symbol, SymbolFlagSet, SymbolKind
},
util::ReallySigned,
};
Expand All @@ -31,6 +29,7 @@ pub mod superh;
pub mod x86;

/// Represents the type of data associated with an instruction
#[derive(PartialEq)]
pub enum DataType {
Int8,
Int16,
Expand Down Expand Up @@ -335,6 +334,17 @@ pub trait Arch: Send + Sync + Debug {
Vec::new()
}

// Perform detailed data flow analysis
fn data_flow_analysis(
&self,
_obj: &Object,
_symbol: &Symbol,
_code: &[u8],
_relocations: &[Relocation],
) -> Option<Box<dyn FlowAnalysisResult>> {
None
}

fn implcit_addend(
&self,
file: &object::File<'_>,
Expand Down
Loading