Skip to content

Commit

Permalink
fix some incorrect m68k relo mode assignments and change formatting t…
Browse files Browse the repository at this point in the history
…o match others
  • Loading branch information
knickish committed Nov 30, 2024
1 parent fb4446b commit abb393f
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 @@ -133,7 +133,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::Msp430 => true,
Expand Down Expand Up @@ -262,18 +262,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 => match (kind, encoding, size) {
Expand Down

0 comments on commit abb393f

Please sign in to comment.