Skip to content

Commit a1f2a53

Browse files
committed
Unify context menu / hover tooltip code + UI improvements
1 parent 8461b35 commit a1f2a53

26 files changed

+1723
-1088
lines changed

Cargo.lock

Lines changed: 5 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deny.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,12 @@ allow-git = []
239239

240240
[sources.allow-org]
241241
# github.com organizations to allow git sources for
242-
github = ["encounter"]
242+
github = [
243+
"CelestialAmber", # cwextab, rlwinmdec
244+
"Decompollaborate", # rabbitizer
245+
"enarx", # flagset
246+
"encounter",
247+
]
243248
# gitlab.com organizations to allow git sources for
244249
gitlab = []
245250
# bitbucket.org organizations to allow git sources for

objdiff-core/Cargo.toml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ all = [
3030
]
3131
# Implicit, used to check if any arch is enabled
3232
any-arch = [
33-
"dep:byteorder",
3433
"dep:flagset",
3534
"dep:heck",
3635
"dep:log",
@@ -40,7 +39,6 @@ any-arch = [
4039
"dep:quote",
4140
"dep:regex",
4241
"dep:similar",
43-
"dep:strum",
4442
"dep:syn",
4543
]
4644
bindings = [
@@ -71,14 +69,12 @@ serde = [
7169
]
7270
std = [
7371
"anyhow/std",
74-
"byteorder?/std",
7572
"flagset?/std",
7673
"log?/std",
7774
"num-traits?/std",
7875
"object/std",
7976
"prost?/std",
8077
"serde?/std",
81-
"strum?/std",
8278
"typed-path?/std",
8379
"dep:filetime",
8480
"dep:memmap2",
@@ -92,6 +88,7 @@ ppc = [
9288
"dep:cwdemangle",
9389
"dep:cwextab",
9490
"dep:ppc750cl",
91+
"dep:rlwinmdec",
9592
]
9693
x86 = [
9794
"any-arch",
@@ -117,21 +114,19 @@ features = ["all"]
117114

118115
[dependencies]
119116
anyhow = { version = "1.0", default-features = false }
120-
byteorder = { version = "1.5", default-features = false, optional = true }
121117
filetime = { version = "0.2", optional = true }
122-
flagset = { version = "0.4", default-features = false, optional = true }
118+
flagset = { version = "0.4", default-features = false, optional = true, git = "https://github.com/enarx/flagset.git", rev = "a1fe9369b3741e43fec45da1998e83b9d78966a2" }
119+
itertools = { version = "0.14", default-features = false, features = ["use_alloc"] }
123120
log = { version = "0.4", default-features = false, optional = true }
124121
memmap2 = { version = "0.9", optional = true }
125122
num-traits = { version = "0.2", default-features = false, optional = true }
126123
object = { version = "0.36", default-features = false, features = ["read_core", "elf", "pe"] }
127124
pbjson = { version = "0.7", default-features = false, optional = true }
128125
prost = { version = "0.13", default-features = false, features = ["prost-derive"], optional = true }
126+
regex = { version = "1.11", default-features = false, features = [], optional = true }
129127
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
130128
similar = { version = "2.7", default-features = false, optional = true, git = "https://github.com/encounter/similar.git", branch = "no_std" }
131-
strum = { version = "0.26", default-features = false, features = ["derive"], optional = true }
132129
typed-path = { version = "0.10", default-features = false, optional = true }
133-
regex = { version = "1.11", default-features = false, features = [], optional = true }
134-
itertools = { version = "0.14", default-features = false, features = ["use_alloc"] }
135130

136131
# config
137132
globset = { version = "0.4", default-features = false, optional = true }
@@ -143,8 +138,9 @@ gimli = { version = "0.31", default-features = false, features = ["read"], optio
143138

144139
# ppc
145140
cwdemangle = { version = "1.0", optional = true }
146-
cwextab = { version = "1.0", optional = true, git = "https://github.com/encounter/cwextab.git" }
141+
cwextab = { version = "1.0", optional = true, git = "https://github.com/CelestialAmber/cwextab.git" }
147142
ppc750cl = { version = "0.3", optional = true }
143+
rlwinmdec = { version = "1.1", optional = true, git = "https://github.com/CelestialAmber/rlwinmdec.git" }
148144

149145
# mips
150146
rabbitizer = { git = "https://github.com/Decompollaborate/rabbitizer.git", branch = "🦀", default-features = false, optional = true }
@@ -196,4 +192,4 @@ syn = { version = "2.0", optional = true }
196192
[dev-dependencies]
197193
# Enable all features for tests
198194
objdiff-core = { path = ".", features = ["all"] }
199-
insta = "1.42.1"
195+
insta = "1.42"

objdiff-core/src/arch/arm.rs

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use alloc::{
2-
borrow::Cow,
32
collections::BTreeMap,
43
format,
54
string::{String, ToString},
65
vec::Vec,
76
};
8-
use core::ops::Range;
97

108
use anyhow::{bail, Result};
119
use arm_attr::{enums::CpuArch, tag::Tag, BuildAttrs};
@@ -16,8 +14,8 @@ use crate::{
1614
arch::Arch,
1715
diff::{display::InstructionPart, ArmArchVersion, ArmR9Usage, DiffObjConfig},
1816
obj::{
19-
InstructionRef, RelocationFlags, ResolvedRelocation, ScannedInstruction, SymbolFlag,
20-
SymbolFlagSet, SymbolKind,
17+
InstructionRef, RelocationFlags, ResolvedInstructionRef, ResolvedRelocation,
18+
ScannedInstruction, SymbolFlag, SymbolFlagSet, SymbolKind,
2119
},
2220
};
2321

@@ -252,23 +250,19 @@ impl Arch for ArchArm {
252250

253251
fn display_instruction(
254252
&self,
255-
ins_ref: InstructionRef,
256-
code: &[u8],
257-
relocation: Option<ResolvedRelocation>,
258-
_function_range: Range<u64>,
259-
_section_index: usize,
253+
resolved: ResolvedInstructionRef,
260254
diff_config: &DiffObjConfig,
261255
cb: &mut dyn FnMut(InstructionPart) -> Result<()>,
262256
) -> Result<()> {
263-
let (ins, parsed_ins) = self.parse_ins_ref(ins_ref, code, diff_config)?;
264-
cb(InstructionPart::opcode(parsed_ins.mnemonic, ins_ref.opcode))?;
265-
if ins == unarm::Ins::Data && relocation.is_some() {
257+
let (ins, parsed_ins) = self.parse_ins_ref(resolved.ins_ref, resolved.code, diff_config)?;
258+
cb(InstructionPart::opcode(parsed_ins.mnemonic, resolved.ins_ref.opcode))?;
259+
if ins == unarm::Ins::Data && resolved.relocation.is_some() {
266260
cb(InstructionPart::reloc())?;
267261
} else {
268262
push_args(
269263
&parsed_ins,
270-
relocation,
271-
ins_ref.address as u32,
264+
resolved.relocation,
265+
resolved.ins_ref.address as u32,
272266
self.display_options(diff_config),
273267
cb,
274268
)?;
@@ -325,17 +319,38 @@ impl Arch for ArchArm {
325319
.and_then(|s| s.demangle(&cpp_demangle::DemangleOptions::default()).ok())
326320
}
327321

328-
fn display_reloc(&self, flags: RelocationFlags) -> Cow<'static, str> {
329-
Cow::Owned(format!("<{flags:?}>"))
322+
fn reloc_name(&self, flags: RelocationFlags) -> Option<&'static str> {
323+
match flags {
324+
RelocationFlags::Elf(r_type) => match r_type {
325+
elf::R_ARM_NONE => Some("R_ARM_NONE"),
326+
elf::R_ARM_ABS32 => Some("R_ARM_ABS32"),
327+
elf::R_ARM_REL32 => Some("R_ARM_REL32"),
328+
elf::R_ARM_ABS16 => Some("R_ARM_ABS16"),
329+
elf::R_ARM_ABS8 => Some("R_ARM_ABS8"),
330+
elf::R_ARM_THM_PC22 => Some("R_ARM_THM_PC22"),
331+
elf::R_ARM_THM_XPC22 => Some("R_ARM_THM_XPC22"),
332+
elf::R_ARM_PC24 => Some("R_ARM_PC24"),
333+
elf::R_ARM_XPC25 => Some("R_ARM_XPC25"),
334+
elf::R_ARM_CALL => Some("R_ARM_CALL"),
335+
_ => None,
336+
},
337+
_ => None,
338+
}
330339
}
331340

332-
fn get_reloc_byte_size(&self, flags: RelocationFlags) -> usize {
341+
fn data_reloc_size(&self, flags: RelocationFlags) -> usize {
333342
match flags {
334343
RelocationFlags::Elf(r_type) => match r_type {
344+
elf::R_ARM_NONE => 0,
335345
elf::R_ARM_ABS32 => 4,
336346
elf::R_ARM_REL32 => 4,
337347
elf::R_ARM_ABS16 => 2,
338348
elf::R_ARM_ABS8 => 1,
349+
elf::R_ARM_THM_PC22 => 4,
350+
elf::R_ARM_THM_XPC22 => 4,
351+
elf::R_ARM_PC24 => 4,
352+
elf::R_ARM_XPC25 => 4,
353+
elf::R_ARM_CALL => 4,
339354
_ => 1,
340355
},
341356
_ => 1,

0 commit comments

Comments
 (0)