Skip to content

Commit

Permalink
Fix M68k support (#749)
Browse files Browse the repository at this point in the history
  • Loading branch information
knickish authored Dec 19, 2024
1 parent 9276955 commit 59bd06b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
9 changes: 6 additions & 3 deletions src/read/elf/relocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,12 @@ fn parse_relocation<Elf: FileHeader>(
elf::R_68K_PC32 => (K::Relative, g, 32),
elf::R_68K_PC16 => (K::Relative, g, 16),
elf::R_68K_PC8 => (K::Relative, g, 8),
elf::R_68K_GOT32 => (K::Got, g, 32),
elf::R_68K_GOT16 => (K::Got, g, 16),
elf::R_68K_GOT8 => (K::Got, g, 8),
elf::R_68K_GOT32O => (K::Got, g, 32),
elf::R_68K_GOT16O => (K::Got, g, 16),
elf::R_68K_GOT8O => (K::Got, g, 8),
elf::R_68K_GOT32 => (K::GotRelative, g, 32),
elf::R_68K_GOT16 => (K::GotRelative, g, 16),
elf::R_68K_GOT8 => (K::GotRelative, g, 8),
elf::R_68K_PLT32 => (K::PltRelative, g, 32),
elf::R_68K_PLT16 => (K::PltRelative, g, 16),
elf::R_68K_PLT8 => (K::PltRelative, g, 8),
Expand Down
29 changes: 16 additions & 13 deletions src/write/elf/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl<'a> Object<'a> {
Architecture::X86_64_X32 => true,
Architecture::Hexagon => true,
Architecture::LoongArch64 => true,
Architecture::M68k => false,
Architecture::M68k => true,
Architecture::Mips => false,
Architecture::Mips64 => true,
Architecture::Mips64_N32 => true,
Expand Down Expand Up @@ -265,18 +265,21 @@ impl<'a> Object<'a> {
_ => return unsupported_reloc(),
},
Architecture::M68k => match (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, _, 8) => elf::R_68K_PC8,
(RelocationKind::Relative, _, 16) => elf::R_68K_PC16,
(RelocationKind::Relative, _, 32) => elf::R_68K_PC32,
(RelocationKind::Got, _, 8) => elf::R_68K_GOT8,
(RelocationKind::Got, _, 16) => elf::R_68K_GOT16,
(RelocationKind::Got, _, 32) => elf::R_68K_GOT32,
(RelocationKind::PltRelative, _, 8) => elf::R_68K_PLT8,
(RelocationKind::PltRelative, _, 16) => elf::R_68K_PLT16,
(RelocationKind::PltRelative, _, 32) => elf::R_68K_PLT32,
(K::Absolute, _, 8) => elf::R_68K_8,
(K::Absolute, _, 16) => elf::R_68K_16,
(K::Absolute, _, 32) => elf::R_68K_32,
(K::Relative, _, 8) => elf::R_68K_PC8,
(K::Relative, _, 16) => elf::R_68K_PC16,
(K::Relative, _, 32) => elf::R_68K_PC32,
(K::GotRelative, _, 8) => elf::R_68K_GOT8,
(K::GotRelative, _, 16) => elf::R_68K_GOT16,
(K::GotRelative, _, 32) => elf::R_68K_GOT32,
(K::Got, _, 8) => elf::R_68K_GOT8O,
(K::Got, _, 16) => elf::R_68K_GOT16O,
(K::Got, _, 32) => elf::R_68K_GOT32O,
(K::PltRelative, _, 8) => elf::R_68K_PLT8,
(K::PltRelative, _, 16) => elf::R_68K_PLT16,
(K::PltRelative, _, 32) => elf::R_68K_PLT32,
_ => return unsupported_reloc(),
},
Architecture::Mips | Architecture::Mips64 | Architecture::Mips64_N32 => {
Expand Down

0 comments on commit 59bd06b

Please sign in to comment.