mirror of
https://github.com/encounter/objdiff.git
synced 2025-06-07 23:23:34 +00:00
Fix MIPS relocation addends; update cwdemangle, ppc750cl
This commit is contained in:
parent
d04838fe4e
commit
ff9b378445
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -520,8 +520,8 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cwdemangle"
|
name = "cwdemangle"
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
source = "git+https://github.com/encounter/cwdemangle?rev=ba448f403320f32b808e0dcf3040c6424664acab#ba448f403320f32b808e0dcf3040c6424664acab"
|
source = "git+https://github.com/encounter/cwdemangle?rev=64e8b3e083343783c5b3b6329ea940f375b057b3#64e8b3e083343783c5b3b6329ea940f375b057b3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"argh",
|
"argh",
|
||||||
]
|
]
|
||||||
@ -1723,7 +1723,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "ppc750cl"
|
name = "ppc750cl"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
source = "git+https://github.com/encounter/ppc750cl?rev=4d8e4733319312abf47cde193d7386e55744bdf8#4d8e4733319312abf47cde193d7386e55744bdf8"
|
source = "git+https://github.com/encounter/ppc750cl?rev=aa631a33de7882c679afca89350898b87cb3ba3f#aa631a33de7882c679afca89350898b87cb3ba3f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -20,11 +20,11 @@ thiserror = "1.0.33"
|
|||||||
flagset = "0.4.3"
|
flagset = "0.4.3"
|
||||||
object = "0.29.0"
|
object = "0.29.0"
|
||||||
notify = "5.0.0"
|
notify = "5.0.0"
|
||||||
cwdemangle = { git = "https://github.com/encounter/cwdemangle", rev = "ba448f403320f32b808e0dcf3040c6424664acab" }
|
cwdemangle = { git = "https://github.com/encounter/cwdemangle", rev = "64e8b3e083343783c5b3b6329ea940f375b057b3" }
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
rfd = { version = "0.10.0" } # , default-features = false, features = ['xdg-portal']
|
rfd = { version = "0.10.0" } # , default-features = false, features = ['xdg-portal']
|
||||||
egui_extras = "0.19.0"
|
egui_extras = "0.19.0"
|
||||||
ppc750cl = { git = "https://github.com/encounter/ppc750cl", rev = "4d8e4733319312abf47cde193d7386e55744bdf8" }
|
ppc750cl = { git = "https://github.com/encounter/ppc750cl", rev = "aa631a33de7882c679afca89350898b87cb3ba3f" }
|
||||||
rabbitizer = { git = "https://github.com/encounter/rabbitizer-rs", rev = "10c279b2ef251c62885b1dcdcfe740b0db8e9956" }
|
rabbitizer = { git = "https://github.com/encounter/rabbitizer-rs", rev = "10c279b2ef251c62885b1dcdcfe740b0db8e9956" }
|
||||||
time = { version = "0.3.14", features = ["formatting", "local-offset"] }
|
time = { version = "0.3.14", features = ["formatting", "local-offset"] }
|
||||||
|
|
||||||
|
@ -4,6 +4,10 @@ use anyhow::{Context, Result};
|
|||||||
use cwdemangle::demangle;
|
use cwdemangle::demangle;
|
||||||
use flagset::Flags;
|
use flagset::Flags;
|
||||||
use object::{
|
use object::{
|
||||||
|
elf::{
|
||||||
|
R_MIPS_26, R_MIPS_HI16, R_MIPS_LO16, R_PPC_ADDR16_HA, R_PPC_ADDR16_HI, R_PPC_ADDR16_LO,
|
||||||
|
R_PPC_EMB_SDA21, R_PPC_REL14, R_PPC_REL24,
|
||||||
|
},
|
||||||
Architecture, File, Object, ObjectSection, ObjectSymbol, RelocationKind, RelocationTarget,
|
Architecture, File, Object, ObjectSection, ObjectSymbol, RelocationKind, RelocationTarget,
|
||||||
SectionKind, Symbol, SymbolKind, SymbolSection,
|
SectionKind, Symbol, SymbolKind, SymbolSection,
|
||||||
};
|
};
|
||||||
@ -50,7 +54,7 @@ fn to_obj_symbol(obj_file: &File<'_>, symbol: &Symbol<'_, '_>, addend: i64) -> R
|
|||||||
};
|
};
|
||||||
Ok(ObjSymbol {
|
Ok(ObjSymbol {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
demangled_name: demangle(name),
|
demangled_name: demangle(name, &Default::default()),
|
||||||
address: symbol.address(),
|
address: symbol.address(),
|
||||||
section_address,
|
section_address,
|
||||||
size: symbol.size(),
|
size: symbol.size(),
|
||||||
@ -63,18 +67,6 @@ fn to_obj_symbol(obj_file: &File<'_>, symbol: &Symbol<'_, '_>, addend: i64) -> R
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const R_PPC_ADDR16_LO: u32 = 4;
|
|
||||||
const R_PPC_ADDR16_HI: u32 = 5;
|
|
||||||
const R_PPC_ADDR16_HA: u32 = 6;
|
|
||||||
const R_PPC_REL24: u32 = 10;
|
|
||||||
const R_PPC_REL14: u32 = 11;
|
|
||||||
const R_PPC_EMB_SDA21: u32 = 109;
|
|
||||||
|
|
||||||
const R_MIPS_32: u32 = 2;
|
|
||||||
const R_MIPS_26: u32 = 4;
|
|
||||||
const R_MIPS_HI16: u32 = 5;
|
|
||||||
const R_MIPS_LO16: u32 = 6;
|
|
||||||
|
|
||||||
fn filter_sections(obj_file: &File<'_>) -> Result<Vec<ObjSection>> {
|
fn filter_sections(obj_file: &File<'_>) -> Result<Vec<ObjSection>> {
|
||||||
let mut result = Vec::<ObjSection>::new();
|
let mut result = Vec::<ObjSection>::new();
|
||||||
for section in obj_file.sections() {
|
for section in obj_file.sections() {
|
||||||
@ -232,7 +224,6 @@ fn relocations_by_section(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
ObjArchitecture::Mips => match kind {
|
ObjArchitecture::Mips => match kind {
|
||||||
R_MIPS_32 => ObjRelocKind::Mips32,
|
|
||||||
R_MIPS_26 => ObjRelocKind::Mips26,
|
R_MIPS_26 => ObjRelocKind::Mips26,
|
||||||
R_MIPS_HI16 => ObjRelocKind::MipsHi16,
|
R_MIPS_HI16 => ObjRelocKind::MipsHi16,
|
||||||
R_MIPS_LO16 => ObjRelocKind::MipsLo16,
|
R_MIPS_LO16 => ObjRelocKind::MipsLo16,
|
||||||
@ -269,11 +260,8 @@ fn relocations_by_section(
|
|||||||
section.data[address as usize..address as usize + 4].try_into()?,
|
section.data[address as usize..address as usize + 4].try_into()?,
|
||||||
);
|
);
|
||||||
match kind {
|
match kind {
|
||||||
ObjRelocKind::Absolute => addend * 4,
|
ObjRelocKind::Absolute => addend,
|
||||||
ObjRelocKind::MipsHi16 | ObjRelocKind::MipsLo16 => {
|
ObjRelocKind::MipsHi16 | ObjRelocKind::MipsLo16 => addend & 0x0000FFFF,
|
||||||
(addend & 0x0000FFFF) * 4
|
|
||||||
}
|
|
||||||
ObjRelocKind::Mips32 => addend * 4,
|
|
||||||
ObjRelocKind::Mips26 => (addend & 0x03FFFFFF) * 4,
|
ObjRelocKind::Mips26 => (addend & 0x03FFFFFF) * 4,
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,6 @@ pub enum ObjRelocKind {
|
|||||||
// PpcAddr14,
|
// PpcAddr14,
|
||||||
PpcRel14,
|
PpcRel14,
|
||||||
PpcEmbSda21,
|
PpcEmbSda21,
|
||||||
Mips32,
|
|
||||||
Mips26,
|
Mips26,
|
||||||
MipsHi16,
|
MipsHi16,
|
||||||
MipsLo16,
|
MipsLo16,
|
||||||
|
@ -55,7 +55,6 @@ fn write_reloc(reloc: &ObjReloc, color: Color32, job: &mut LayoutJob) {
|
|||||||
ObjRelocKind::Absolute
|
ObjRelocKind::Absolute
|
||||||
| ObjRelocKind::PpcRel24
|
| ObjRelocKind::PpcRel24
|
||||||
| ObjRelocKind::PpcRel14
|
| ObjRelocKind::PpcRel14
|
||||||
| ObjRelocKind::Mips32
|
|
||||||
| ObjRelocKind::Mips26 => {
|
| ObjRelocKind::Mips26 => {
|
||||||
write_reloc_name(reloc, color, job);
|
write_reloc_name(reloc, color, job);
|
||||||
}
|
}
|
||||||
@ -361,7 +360,7 @@ pub fn function_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
|
|||||||
});
|
});
|
||||||
strip.strip(|builder| {
|
strip.strip(|builder| {
|
||||||
builder.sizes(Size::remainder(), 2).horizontal(|mut strip| {
|
builder.sizes(Size::remainder(), 2).horizontal(|mut strip| {
|
||||||
let demangled = demangle(selected_symbol);
|
let demangled = demangle(selected_symbol, &Default::default());
|
||||||
strip.cell(|ui| {
|
strip.cell(|ui| {
|
||||||
ui.scope(|ui| {
|
ui.scope(|ui| {
|
||||||
ui.style_mut().override_text_style =
|
ui.style_mut().override_text_style =
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use egui::{
|
use egui::{
|
||||||
text::LayoutJob, CollapsingHeader, Color32, Rgba, ScrollArea,
|
text::LayoutJob, CollapsingHeader, Color32, Rgba, ScrollArea, SelectableLabel, Ui, Widget,
|
||||||
SelectableLabel, Ui, Widget,
|
|
||||||
};
|
};
|
||||||
use egui_extras::{Size, StripBuilder};
|
use egui_extras::{Size, StripBuilder};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user