Skip to content

Commit 9d5cf05

Browse files
authored
Merge branch 'main' into update-rabbitizer
2 parents 69e5c78 + 00ad0d8 commit 9d5cf05

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+5530
-858
lines changed

Cargo.lock

Lines changed: 12 additions & 12 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
@@ -14,7 +14,7 @@ strip = "debuginfo"
1414
codegen-units = 1
1515

1616
[workspace.package]
17-
version = "3.0.0-beta.10"
17+
version = "3.0.0-beta.11"
1818
authors = ["Luke Street <[email protected]>"]
1919
edition = "2024"
2020
license = "MIT OR Apache-2.0"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Supports:
1919
- ARM (GBA, DS, 3DS)
2020
- ARM64 (Switch)
2121
- MIPS (N64, PS1, PS2, PSP)
22-
- PowerPC (GameCube, Wii)
22+
- PowerPC (GameCube, Wii, PS3, Xbox 360)
2323
- SuperH (Saturn, Dreamcast)
2424
- x86, x86_64 (PC)
2525

objdiff-cli/src/cmd/diff.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,10 @@ fn run_oneshot(
203203
let output_format = OutputFormat::from_option(args.format.as_deref())?;
204204
let (diff_config, mapping_config) = build_config_from_args(args)?;
205205
let target = target_path
206-
.map(|p| {
207-
obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {}", p))
208-
})
206+
.map(|p| obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {p}")))
209207
.transpose()?;
210208
let base = base_path
211-
.map(|p| {
212-
obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {}", p))
213-
})
209+
.map(|p| obj::read::read(p.as_ref(), &diff_config).with_context(|| format!("Loading {p}")))
214210
.transpose()?;
215211
let result =
216212
diff::diff_objs(target.as_ref(), base.as_ref(), None, &diff_config, &mapping_config)?;
@@ -399,7 +395,7 @@ fn run_interactive(
399395
stdout(),
400396
EnterAlternateScreen,
401397
EnableMouseCapture,
402-
SetTitle(format!("{} - objdiff", symbol_name)),
398+
SetTitle(format!("{symbol_name} - objdiff")),
403399
)?;
404400
let backend = CrosstermBackend::new(stdout());
405401
let mut terminal = Terminal::new(backend)?;

objdiff-cli/src/cmd/report.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,14 @@ fn report_object(
177177
.target_path
178178
.as_ref()
179179
.map(|p| {
180-
obj::read::read(p.as_ref(), diff_config)
181-
.with_context(|| format!("Failed to open {}", p))
180+
obj::read::read(p.as_ref(), diff_config).with_context(|| format!("Failed to open {p}"))
182181
})
183182
.transpose()?;
184183
let base = object
185184
.base_path
186185
.as_ref()
187186
.map(|p| {
188-
obj::read::read(p.as_ref(), diff_config)
189-
.with_context(|| format!("Failed to open {}", p))
187+
obj::read::read(p.as_ref(), diff_config).with_context(|| format!("Failed to open {p}"))
190188
})
191189
.transpose()?;
192190
let result =
@@ -433,8 +431,8 @@ fn read_report(path: &Utf8PlatformPath) -> Result<Report> {
433431
std::io::stdin().read_to_end(&mut data)?;
434432
return Report::parse(&data).with_context(|| "Failed to load report from stdin");
435433
}
436-
let file = File::open(path).with_context(|| format!("Failed to open {}", path))?;
434+
let file = File::open(path).with_context(|| format!("Failed to open {path}"))?;
437435
let mmap =
438-
unsafe { memmap2::Mmap::map(&file) }.with_context(|| format!("Failed to map {}", path))?;
439-
Report::parse(mmap.as_ref()).with_context(|| format!("Failed to load report {}", path))
436+
unsafe { memmap2::Mmap::map(&file) }.with_context(|| format!("Failed to map {path}"))?;
437+
Report::parse(mmap.as_ref()).with_context(|| format!("Failed to load report {path}"))
440438
}

objdiff-cli/src/views/function_diff.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl UiView for FunctionDiffUi {
8787
.and_then(|(_, _, d)| d.match_percent)
8888
{
8989
line_r.spans.push(Span::styled(
90-
format!("{:.2}% ", percent),
90+
format!("{percent:.2}% "),
9191
Style::new().fg(match_percent_color(percent)),
9292
));
9393
}
@@ -97,7 +97,7 @@ impl UiView for FunctionDiffUi {
9797
.and_then(|t| t.format(&state.time_format).ok())
9898
.unwrap_or_else(|| "N/A".to_string());
9999
line_r.spans.push(Span::styled(
100-
format!("Last reload: {}", reload_time),
100+
format!("Last reload: {reload_time}"),
101101
Style::new().fg(Color::White),
102102
));
103103
line_r.spans.push(Span::styled(
@@ -538,15 +538,15 @@ impl FunctionDiffUi {
538538
let label_text = match segment.text {
539539
DiffText::Basic(text) => text.to_string(),
540540
DiffText::Line(num) => format!("{num} "),
541-
DiffText::Address(addr) => format!("{:x}:", addr),
541+
DiffText::Address(addr) => format!("{addr:x}:"),
542542
DiffText::Opcode(mnemonic, _op) => format!("{mnemonic} "),
543543
DiffText::Argument(arg) => arg.to_string(),
544544
DiffText::BranchDest(addr) => format!("{addr:x}"),
545545
DiffText::Symbol(sym) => {
546546
sym.demangled_name.as_ref().unwrap_or(&sym.name).clone()
547547
}
548548
DiffText::Addend(addend) => match addend.cmp(&0i64) {
549-
Ordering::Greater => format!("+{:#x}", addend),
549+
Ordering::Greater => format!("+{addend:#x}"),
550550
Ordering::Less => format!("-{:#x}", -addend),
551551
_ => String::new(),
552552
},

objdiff-core/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ ppc = [
9292
"any-arch",
9393
"dep:cwdemangle",
9494
"dep:cwextab",
95-
"dep:ppc750cl",
95+
"dep:powerpc",
9696
"dep:rlwinmdec",
9797
]
9898
x86 = [
@@ -128,7 +128,7 @@ itertools = { version = "0.14", default-features = false, features = ["use_alloc
128128
log = { version = "0.4", default-features = false, optional = true }
129129
memmap2 = { version = "0.9", optional = true }
130130
num-traits = { version = "0.2", default-features = false, optional = true }
131-
object = { git = "https://github.com/gimli-rs/object", rev = "a74579249e21ab8fcd3a86be588de336f18297cb", default-features = false, features = ["read_core", "elf", "pe"] }
131+
object = { git = "https://github.com/gimli-rs/object", rev = "16ff70aa6fbd97d6bb7b92375929f4d72414c32b", default-features = false, features = ["read_core", "elf", "coff"] }
132132
pbjson = { version = "0.7", default-features = false, optional = true }
133133
prost = { version = "0.13", default-features = false, features = ["prost-derive"], optional = true }
134134
regex = { version = "1.11", default-features = false, features = [], optional = true }
@@ -147,7 +147,7 @@ gimli = { version = "0.31", default-features = false, features = ["read"], optio
147147
# ppc
148148
cwdemangle = { version = "1.0", optional = true }
149149
cwextab = { version = "1.0", optional = true }
150-
ppc750cl = { version = "0.3", optional = true }
150+
powerpc = { version = "0.4", optional = true }
151151
rlwinmdec = { version = "1.1", optional = true }
152152

153153
# mips

objdiff-core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ objdiff-core contains the core functionality of [objdiff](https://github.com/enc
1111
- **`arm64`**: Enables the ARM64 backend powered by [yaxpeax-arm](https://github.com/iximeow/yaxpeax-arm).
1212
- **`arm`**: Enables the ARM backend powered by [unarm](https://github.com/AetiasHax/unarm).
1313
- **`mips`**: Enables the MIPS backend powered by [rabbitizer](https://github.com/Decompollaborate/rabbitizer).
14-
- **`ppc`**: Enables the PowerPC backend powered by [ppc750cl](https://github.com/encounter/ppc750cl).
14+
- **`ppc`**: Enables the PowerPC backend powered by [powerpc](https://github.com/encounter/powerpc-rs).
1515
- **`superh`**: Enables the SuperH backend powered by an included disassembler.
1616
- **`x86`**: Enables the x86 backend powered by [iced-x86](https://crates.io/crates/iced-x86).

objdiff-core/config_gen.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ pub struct ConfigGroup {
6060
}
6161

6262
fn build_doc(name: &str, description: Option<&str>) -> TokenStream {
63-
let mut doc = format!(" {}", name);
63+
let mut doc = format!(" {name}");
6464
let mut out = quote! { #[doc = #doc] };
6565
if let Some(description) = description {
66-
doc = format!(" {}", description);
66+
doc = format!(" {description}");
6767
out.extend(quote! { #[doc = ""] });
6868
out.extend(quote! { #[doc = #doc] });
6969
}
@@ -443,9 +443,9 @@ pub fn generate_diff_config() {
443443
}
444444
impl core::fmt::Display for ConfigPropertyValue {
445445
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
446-
match self {
447-
ConfigPropertyValue::Boolean(value) => write!(f, "{}", value),
448-
ConfigPropertyValue::Choice(value) => write!(f, "{}", value),
446+
match *self {
447+
ConfigPropertyValue::Boolean(value) => write!(f, "{value}"),
448+
ConfigPropertyValue::Choice(value) => f.write_str(value),
449449
}
450450
}
451451
}

objdiff-core/src/arch/arm.rs

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use object::{Endian as _, Object as _, ObjectSection as _, ObjectSymbol as _, el
1111
use unarm::{args, arm, thumb};
1212

1313
use crate::{
14-
arch::Arch,
14+
arch::{Arch, RelocationOverride, RelocationOverrideTarget},
1515
diff::{ArmArchVersion, ArmR9Usage, DiffObjConfig, display::InstructionPart},
1616
obj::{
1717
InstructionRef, Relocation, RelocationFlags, ResolvedInstructionRef, ResolvedRelocation,
@@ -356,47 +356,57 @@ impl Arch for ArchArm {
356356
Ok(())
357357
}
358358

359-
fn implcit_addend(
359+
fn relocation_override(
360360
&self,
361361
_file: &object::File<'_>,
362362
section: &object::Section,
363363
address: u64,
364-
_relocation: &object::Relocation,
365-
flags: RelocationFlags,
366-
) -> Result<i64> {
367-
let section_data = section.data()?;
368-
let address = address as usize;
369-
Ok(match flags {
370-
// ARM calls
371-
RelocationFlags::Elf(elf::R_ARM_PC24)
372-
| RelocationFlags::Elf(elf::R_ARM_XPC25)
373-
| RelocationFlags::Elf(elf::R_ARM_CALL) => {
374-
let data = section_data[address..address + 4].try_into()?;
375-
let addend = self.endianness.read_i32_bytes(data);
376-
let imm24 = addend & 0xffffff;
377-
(imm24 << 2) << 8 >> 8
378-
}
364+
relocation: &object::Relocation,
365+
) -> Result<Option<RelocationOverride>> {
366+
match relocation.flags() {
367+
// Handle ELF implicit relocations
368+
object::RelocationFlags::Elf { r_type } => {
369+
if relocation.has_implicit_addend() {
370+
let section_data = section.data()?;
371+
let address = address as usize;
372+
let addend = match r_type {
373+
// ARM calls
374+
elf::R_ARM_PC24 | elf::R_ARM_XPC25 | elf::R_ARM_CALL => {
375+
let data = section_data[address..address + 4].try_into()?;
376+
let addend = self.endianness.read_i32_bytes(data);
377+
let imm24 = addend & 0xffffff;
378+
(imm24 << 2) << 8 >> 8
379+
}
379380

380-
// Thumb calls
381-
RelocationFlags::Elf(elf::R_ARM_THM_PC22)
382-
| RelocationFlags::Elf(elf::R_ARM_THM_XPC22) => {
383-
let data = section_data[address..address + 2].try_into()?;
384-
let high = self.endianness.read_i16_bytes(data) as i32;
385-
let data = section_data[address + 2..address + 4].try_into()?;
386-
let low = self.endianness.read_i16_bytes(data) as i32;
381+
// Thumb calls
382+
elf::R_ARM_THM_PC22 | elf::R_ARM_THM_XPC22 => {
383+
let data = section_data[address..address + 2].try_into()?;
384+
let high = self.endianness.read_i16_bytes(data) as i32;
385+
let data = section_data[address + 2..address + 4].try_into()?;
386+
let low = self.endianness.read_i16_bytes(data) as i32;
387387

388-
let imm22 = ((high & 0x7ff) << 11) | (low & 0x7ff);
389-
(imm22 << 1) << 9 >> 9
390-
}
388+
let imm22 = ((high & 0x7ff) << 11) | (low & 0x7ff);
389+
(imm22 << 1) << 9 >> 9
390+
}
391391

392-
// Data
393-
RelocationFlags::Elf(elf::R_ARM_ABS32) => {
394-
let data = section_data[address..address + 4].try_into()?;
395-
self.endianness.read_i32_bytes(data)
396-
}
392+
// Data
393+
elf::R_ARM_ABS32 => {
394+
let data = section_data[address..address + 4].try_into()?;
395+
self.endianness.read_i32_bytes(data)
396+
}
397397

398-
flags => bail!("Unsupported ARM implicit relocation {flags:?}"),
399-
} as i64)
398+
flags => bail!("Unsupported ARM implicit relocation {flags:?}"),
399+
};
400+
Ok(Some(RelocationOverride {
401+
target: RelocationOverrideTarget::Keep,
402+
addend: addend as i64,
403+
}))
404+
} else {
405+
Ok(None)
406+
}
407+
}
408+
_ => Ok(None),
409+
}
400410
}
401411

402412
fn demangle(&self, name: &str) -> Option<String> {
@@ -575,7 +585,7 @@ fn push_args(
575585
arg_cb(InstructionPart::basic("}"))?;
576586
}
577587
args::Argument::CoprocNum(value) => {
578-
arg_cb(InstructionPart::opaque(format!("p{}", value)))?;
588+
arg_cb(InstructionPart::opaque(format!("p{value}")))?;
579589
}
580590
args::Argument::ShiftImm(shift) => {
581591
arg_cb(InstructionPart::opaque(shift.op.to_string()))?;

0 commit comments

Comments
 (0)