Skip to content

Commit

Permalink
add m68k arch support
Browse files Browse the repository at this point in the history
  • Loading branch information
knickish committed Nov 7, 2024
1 parent 61dc7b0 commit 8d193e8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub enum Architecture {
X86_64_X32,
Hexagon,
LoongArch64,
M68k,
Mips,
Mips64,
Msp430,
Expand Down Expand Up @@ -66,6 +67,7 @@ impl Architecture {
Architecture::X86_64_X32 => Some(AddressSize::U32),
Architecture::Hexagon => Some(AddressSize::U32),
Architecture::LoongArch64 => Some(AddressSize::U64),
Architecture::M68k => Some(AddressSize::U32),
Architecture::Mips => Some(AddressSize::U32),
Architecture::Mips64 => Some(AddressSize::U64),
Architecture::Msp430 => Some(AddressSize::U16),
Expand Down
1 change: 1 addition & 0 deletions src/read/elf/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ where
(elf::EM_X86_64, true) => Architecture::X86_64,
(elf::EM_HEXAGON, _) => Architecture::Hexagon,
(elf::EM_LOONGARCH, true) => Architecture::LoongArch64,
(elf::EM_68K, false) => Architecture::M68k,
(elf::EM_MIPS, false) => Architecture::Mips,
(elf::EM_MIPS, true) => Architecture::Mips64,
(elf::EM_MSP430, _) => Architecture::Msp430,
Expand Down
12 changes: 12 additions & 0 deletions src/write/elf/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ impl<'a> Object<'a> {
Architecture::X86_64_X32 => true,
Architecture::Hexagon => true,
Architecture::LoongArch64 => true,
Architecture::M68k => false,
Architecture::Mips => false,
Architecture::Mips64 => true,
Architecture::Msp430 => true,
Expand Down Expand Up @@ -260,6 +261,16 @@ impl<'a> Object<'a> {
(K::PltRelative, E::LoongArchBranch, 26) => elf::R_LARCH_B26,
_ => return unsupported_reloc(),
},
Architecture::M68k => match (dbg!(kind), encoding, size) {
(RelocationKind::Absolute, _, 8) => elf::R_68K_8,
(RelocationKind::Absolute, _, 16) => elf::R_68K_16,
(RelocationKind::Absolute, _, 32) => elf::R_68K_32,
(RelocationKind::Relative, _, 16) => elf::R_68K_PC16,
(RelocationKind::Relative, _, 32) => elf::R_68K_PC32,
_ => {
return Err(Error(format!("unimplemented relocation {:?}", reloc)));
}
},
Architecture::Mips | Architecture::Mips64 => match (kind, encoding, size) {
(K::Absolute, _, 16) => elf::R_MIPS_16,
(K::Absolute, _, 32) => elf::R_MIPS_32,
Expand Down Expand Up @@ -543,6 +554,7 @@ impl<'a> Object<'a> {
(Architecture::X86_64_X32, None) => elf::EM_X86_64,
(Architecture::Hexagon, None) => elf::EM_HEXAGON,
(Architecture::LoongArch64, None) => elf::EM_LOONGARCH,
(Architecture::M68k, None) => elf::EM_68K,
(Architecture::Mips, None) => elf::EM_MIPS,
(Architecture::Mips64, None) => elf::EM_MIPS,
(Architecture::Msp430, None) => elf::EM_MSP430,
Expand Down

0 comments on commit 8d193e8

Please sign in to comment.