Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/obj/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ 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;
Expand Down Expand Up @@ -231,6 +232,7 @@ 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,
Expand Down Expand Up @@ -267,9 +269,11 @@ 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,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These multiplications by 4 don't make sense to me, outside of the Mips26 case where it is indeed right

(also lo16/hi16 need to be joined together and lo16 relocations are s16's; maybe that's handled elsewhere or a todo for now though)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info, I'll check some MIPS objects to figure out what's proper here.

ObjRelocKind::Mips26 => (addend & 0x03FFFFFF) * 4,
_ => todo!(),
}
Expand Down
1 change: 1 addition & 0 deletions src/obj/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ pub enum ObjRelocKind {
// PpcAddr14,
PpcRel14,
PpcEmbSda21,
Mips32,
Mips26,
MipsHi16,
MipsLo16,
Expand Down
1 change: 1 addition & 0 deletions src/views/function_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ 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);
}
Expand Down