From abb393fbc41dd5fb048289300a5c74d7765bacf4 Mon Sep 17 00:00:00 2001 From: kirk Date: Sat, 30 Nov 2024 21:00:03 +0000 Subject: [PATCH] fix some incorrect m68k relo mode assignments and change formatting to match others --- src/read/elf/relocation.rs | 9 ++++++--- src/write/elf/object.rs | 29 ++++++++++++++++------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/read/elf/relocation.rs b/src/read/elf/relocation.rs index 6115d929..5ea59d73 100644 --- a/src/read/elf/relocation.rs +++ b/src/read/elf/relocation.rs @@ -350,9 +350,12 @@ fn parse_relocation( 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), diff --git a/src/write/elf/object.rs b/src/write/elf/object.rs index 1c2828e7..d8ef3c95 100644 --- a/src/write/elf/object.rs +++ b/src/write/elf/object.rs @@ -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, @@ -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) {