Fix MIPS relocation addends; update cwdemangle, ppc750cl

This commit is contained in:
2022-11-05 13:16:44 -04:00
parent d04838fe4e
commit ff9b378445
6 changed files with 14 additions and 29 deletions

View File

@@ -4,6 +4,10 @@ use anyhow::{Context, Result};
use cwdemangle::demangle;
use flagset::Flags;
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,
SectionKind, Symbol, SymbolKind, SymbolSection,
};
@@ -50,7 +54,7 @@ fn to_obj_symbol(obj_file: &File<'_>, symbol: &Symbol<'_, '_>, addend: i64) -> R
};
Ok(ObjSymbol {
name: name.to_string(),
demangled_name: demangle(name),
demangled_name: demangle(name, &Default::default()),
address: symbol.address(),
section_address,
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>> {
let mut result = Vec::<ObjSection>::new();
for section in obj_file.sections() {
@@ -232,7 +224,6 @@ fn relocations_by_section(
}
},
ObjArchitecture::Mips => match kind {
R_MIPS_32 => ObjRelocKind::Mips32,
R_MIPS_26 => ObjRelocKind::Mips26,
R_MIPS_HI16 => ObjRelocKind::MipsHi16,
R_MIPS_LO16 => ObjRelocKind::MipsLo16,
@@ -269,11 +260,8 @@ fn relocations_by_section(
section.data[address as usize..address as usize + 4].try_into()?,
);
match kind {
ObjRelocKind::Absolute => addend * 4,
ObjRelocKind::MipsHi16 | ObjRelocKind::MipsLo16 => {
(addend & 0x0000FFFF) * 4
}
ObjRelocKind::Mips32 => addend * 4,
ObjRelocKind::Absolute => addend,
ObjRelocKind::MipsHi16 | ObjRelocKind::MipsLo16 => addend & 0x0000FFFF,
ObjRelocKind::Mips26 => (addend & 0x03FFFFFF) * 4,
_ => todo!(),
}

View File

@@ -133,7 +133,6 @@ pub enum ObjRelocKind {
// PpcAddr14,
PpcRel14,
PpcEmbSda21,
Mips32,
Mips26,
MipsHi16,
MipsLo16,

View File

@@ -55,7 +55,6 @@ fn write_reloc(reloc: &ObjReloc, color: Color32, job: &mut LayoutJob) {
ObjRelocKind::Absolute
| ObjRelocKind::PpcRel24
| ObjRelocKind::PpcRel14
| ObjRelocKind::Mips32
| ObjRelocKind::Mips26 => {
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| {
builder.sizes(Size::remainder(), 2).horizontal(|mut strip| {
let demangled = demangle(selected_symbol);
let demangled = demangle(selected_symbol, &Default::default());
strip.cell(|ui| {
ui.scope(|ui| {
ui.style_mut().override_text_style =

View File

@@ -1,6 +1,5 @@
use egui::{
text::LayoutJob, CollapsingHeader, Color32, Rgba, ScrollArea,
SelectableLabel, Ui, Widget,
text::LayoutJob, CollapsingHeader, Color32, Rgba, ScrollArea, SelectableLabel, Ui, Widget,
};
use egui_extras::{Size, StripBuilder};