Skip to content

Commit ff9b378

Browse files
committed
Fix MIPS relocation addends; update cwdemangle, ppc750cl
1 parent d04838f commit ff9b378

File tree

6 files changed

+14
-29
lines changed

6 files changed

+14
-29
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ thiserror = "1.0.33"
2020
flagset = "0.4.3"
2121
object = "0.29.0"
2222
notify = "5.0.0"
23-
cwdemangle = { git = "https://github.com/encounter/cwdemangle", rev = "ba448f403320f32b808e0dcf3040c6424664acab" }
23+
cwdemangle = { git = "https://github.com/encounter/cwdemangle", rev = "64e8b3e083343783c5b3b6329ea940f375b057b3" }
2424
log = "0.4.17"
2525
rfd = { version = "0.10.0" } # , default-features = false, features = ['xdg-portal']
2626
egui_extras = "0.19.0"
27-
ppc750cl = { git = "https://github.com/encounter/ppc750cl", rev = "4d8e4733319312abf47cde193d7386e55744bdf8" }
27+
ppc750cl = { git = "https://github.com/encounter/ppc750cl", rev = "aa631a33de7882c679afca89350898b87cb3ba3f" }
2828
rabbitizer = { git = "https://github.com/encounter/rabbitizer-rs", rev = "10c279b2ef251c62885b1dcdcfe740b0db8e9956" }
2929
time = { version = "0.3.14", features = ["formatting", "local-offset"] }
3030

src/obj/elf.rs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ use anyhow::{Context, Result};
44
use cwdemangle::demangle;
55
use flagset::Flags;
66
use object::{
7+
elf::{
8+
R_MIPS_26, R_MIPS_HI16, R_MIPS_LO16, R_PPC_ADDR16_HA, R_PPC_ADDR16_HI, R_PPC_ADDR16_LO,
9+
R_PPC_EMB_SDA21, R_PPC_REL14, R_PPC_REL24,
10+
},
711
Architecture, File, Object, ObjectSection, ObjectSymbol, RelocationKind, RelocationTarget,
812
SectionKind, Symbol, SymbolKind, SymbolSection,
913
};
@@ -50,7 +54,7 @@ fn to_obj_symbol(obj_file: &File<'_>, symbol: &Symbol<'_, '_>, addend: i64) -> R
5054
};
5155
Ok(ObjSymbol {
5256
name: name.to_string(),
53-
demangled_name: demangle(name),
57+
demangled_name: demangle(name, &Default::default()),
5458
address: symbol.address(),
5559
section_address,
5660
size: symbol.size(),
@@ -63,18 +67,6 @@ fn to_obj_symbol(obj_file: &File<'_>, symbol: &Symbol<'_, '_>, addend: i64) -> R
6367
})
6468
}
6569

66-
const R_PPC_ADDR16_LO: u32 = 4;
67-
const R_PPC_ADDR16_HI: u32 = 5;
68-
const R_PPC_ADDR16_HA: u32 = 6;
69-
const R_PPC_REL24: u32 = 10;
70-
const R_PPC_REL14: u32 = 11;
71-
const R_PPC_EMB_SDA21: u32 = 109;
72-
73-
const R_MIPS_32: u32 = 2;
74-
const R_MIPS_26: u32 = 4;
75-
const R_MIPS_HI16: u32 = 5;
76-
const R_MIPS_LO16: u32 = 6;
77-
7870
fn filter_sections(obj_file: &File<'_>) -> Result<Vec<ObjSection>> {
7971
let mut result = Vec::<ObjSection>::new();
8072
for section in obj_file.sections() {
@@ -232,7 +224,6 @@ fn relocations_by_section(
232224
}
233225
},
234226
ObjArchitecture::Mips => match kind {
235-
R_MIPS_32 => ObjRelocKind::Mips32,
236227
R_MIPS_26 => ObjRelocKind::Mips26,
237228
R_MIPS_HI16 => ObjRelocKind::MipsHi16,
238229
R_MIPS_LO16 => ObjRelocKind::MipsLo16,
@@ -269,11 +260,8 @@ fn relocations_by_section(
269260
section.data[address as usize..address as usize + 4].try_into()?,
270261
);
271262
match kind {
272-
ObjRelocKind::Absolute => addend * 4,
273-
ObjRelocKind::MipsHi16 | ObjRelocKind::MipsLo16 => {
274-
(addend & 0x0000FFFF) * 4
275-
}
276-
ObjRelocKind::Mips32 => addend * 4,
263+
ObjRelocKind::Absolute => addend,
264+
ObjRelocKind::MipsHi16 | ObjRelocKind::MipsLo16 => addend & 0x0000FFFF,
277265
ObjRelocKind::Mips26 => (addend & 0x03FFFFFF) * 4,
278266
_ => todo!(),
279267
}

src/obj/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ pub enum ObjRelocKind {
133133
// PpcAddr14,
134134
PpcRel14,
135135
PpcEmbSda21,
136-
Mips32,
137136
Mips26,
138137
MipsHi16,
139138
MipsLo16,

src/views/function_diff.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ fn write_reloc(reloc: &ObjReloc, color: Color32, job: &mut LayoutJob) {
5555
ObjRelocKind::Absolute
5656
| ObjRelocKind::PpcRel24
5757
| ObjRelocKind::PpcRel14
58-
| ObjRelocKind::Mips32
5958
| ObjRelocKind::Mips26 => {
6059
write_reloc_name(reloc, color, job);
6160
}
@@ -361,7 +360,7 @@ pub fn function_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
361360
});
362361
strip.strip(|builder| {
363362
builder.sizes(Size::remainder(), 2).horizontal(|mut strip| {
364-
let demangled = demangle(selected_symbol);
363+
let demangled = demangle(selected_symbol, &Default::default());
365364
strip.cell(|ui| {
366365
ui.scope(|ui| {
367366
ui.style_mut().override_text_style =

src/views/symbol_diff.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use egui::{
2-
text::LayoutJob, CollapsingHeader, Color32, Rgba, ScrollArea,
3-
SelectableLabel, Ui, Widget,
2+
text::LayoutJob, CollapsingHeader, Color32, Rgba, ScrollArea, SelectableLabel, Ui, Widget,
43
};
54
use egui_extras::{Size, StripBuilder};
65

0 commit comments

Comments
 (0)