Skip to content

Commit 59bd06b

Browse files
authored
Fix M68k support (#749)
1 parent 9276955 commit 59bd06b

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

src/read/elf/relocation.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,12 @@ fn parse_relocation<Elf: FileHeader>(
350350
elf::R_68K_PC32 => (K::Relative, g, 32),
351351
elf::R_68K_PC16 => (K::Relative, g, 16),
352352
elf::R_68K_PC8 => (K::Relative, g, 8),
353-
elf::R_68K_GOT32 => (K::Got, g, 32),
354-
elf::R_68K_GOT16 => (K::Got, g, 16),
355-
elf::R_68K_GOT8 => (K::Got, g, 8),
353+
elf::R_68K_GOT32O => (K::Got, g, 32),
354+
elf::R_68K_GOT16O => (K::Got, g, 16),
355+
elf::R_68K_GOT8O => (K::Got, g, 8),
356+
elf::R_68K_GOT32 => (K::GotRelative, g, 32),
357+
elf::R_68K_GOT16 => (K::GotRelative, g, 16),
358+
elf::R_68K_GOT8 => (K::GotRelative, g, 8),
356359
elf::R_68K_PLT32 => (K::PltRelative, g, 32),
357360
elf::R_68K_PLT16 => (K::PltRelative, g, 16),
358361
elf::R_68K_PLT8 => (K::PltRelative, g, 8),

src/write/elf/object.rs

+16-13
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'a> Object<'a> {
135135
Architecture::X86_64_X32 => true,
136136
Architecture::Hexagon => true,
137137
Architecture::LoongArch64 => true,
138-
Architecture::M68k => false,
138+
Architecture::M68k => true,
139139
Architecture::Mips => false,
140140
Architecture::Mips64 => true,
141141
Architecture::Mips64_N32 => true,
@@ -265,18 +265,21 @@ impl<'a> Object<'a> {
265265
_ => return unsupported_reloc(),
266266
},
267267
Architecture::M68k => match (kind, encoding, size) {
268-
(RelocationKind::Absolute, _, 8) => elf::R_68K_8,
269-
(RelocationKind::Absolute, _, 16) => elf::R_68K_16,
270-
(RelocationKind::Absolute, _, 32) => elf::R_68K_32,
271-
(RelocationKind::Relative, _, 8) => elf::R_68K_PC8,
272-
(RelocationKind::Relative, _, 16) => elf::R_68K_PC16,
273-
(RelocationKind::Relative, _, 32) => elf::R_68K_PC32,
274-
(RelocationKind::Got, _, 8) => elf::R_68K_GOT8,
275-
(RelocationKind::Got, _, 16) => elf::R_68K_GOT16,
276-
(RelocationKind::Got, _, 32) => elf::R_68K_GOT32,
277-
(RelocationKind::PltRelative, _, 8) => elf::R_68K_PLT8,
278-
(RelocationKind::PltRelative, _, 16) => elf::R_68K_PLT16,
279-
(RelocationKind::PltRelative, _, 32) => elf::R_68K_PLT32,
268+
(K::Absolute, _, 8) => elf::R_68K_8,
269+
(K::Absolute, _, 16) => elf::R_68K_16,
270+
(K::Absolute, _, 32) => elf::R_68K_32,
271+
(K::Relative, _, 8) => elf::R_68K_PC8,
272+
(K::Relative, _, 16) => elf::R_68K_PC16,
273+
(K::Relative, _, 32) => elf::R_68K_PC32,
274+
(K::GotRelative, _, 8) => elf::R_68K_GOT8,
275+
(K::GotRelative, _, 16) => elf::R_68K_GOT16,
276+
(K::GotRelative, _, 32) => elf::R_68K_GOT32,
277+
(K::Got, _, 8) => elf::R_68K_GOT8O,
278+
(K::Got, _, 16) => elf::R_68K_GOT16O,
279+
(K::Got, _, 32) => elf::R_68K_GOT32O,
280+
(K::PltRelative, _, 8) => elf::R_68K_PLT8,
281+
(K::PltRelative, _, 16) => elf::R_68K_PLT16,
282+
(K::PltRelative, _, 32) => elf::R_68K_PLT32,
280283
_ => return unsupported_reloc(),
281284
},
282285
Architecture::Mips | Architecture::Mips64 | Architecture::Mips64_N32 => {

0 commit comments

Comments
 (0)