From 6410f1c59485199c0c21f90c17a63867cedf4776 Mon Sep 17 00:00:00 2001 From: John Paul Adrian Glaubitz Date: Wed, 26 Jun 2024 10:57:11 +0200 Subject: [PATCH] Add Architecture::Sparc32Plus --- src/common.rs | 2 ++ src/read/elf/file.rs | 1 + src/write/elf/object.rs | 4 +++- tests/round_trip/mod.rs | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common.rs b/src/common.rs index 41f7191b..c9db8c33 100644 --- a/src/common.rs +++ b/src/common.rs @@ -28,6 +28,7 @@ pub enum Architecture { Sbf, Sharc, Sparc, + Sparc32Plus, Sparc64, Wasm32, Wasm64, @@ -72,6 +73,7 @@ impl Architecture { Architecture::Sbf => Some(AddressSize::U64), Architecture::Sharc => Some(AddressSize::U32), Architecture::Sparc => Some(AddressSize::U32), + Architecture::Sparc32Plus => Some(AddressSize::U32), Architecture::Sparc64 => Some(AddressSize::U64), Architecture::Wasm32 => Some(AddressSize::U32), Architecture::Wasm64 => Some(AddressSize::U64), diff --git a/src/read/elf/file.rs b/src/read/elf/file.rs index 107a5219..eb74c284 100644 --- a/src/read/elf/file.rs +++ b/src/read/elf/file.rs @@ -227,6 +227,7 @@ where (elf::EM_SBF, _) => Architecture::Sbf, (elf::EM_SHARC, false) => Architecture::Sharc, (elf::EM_SPARC, false) => Architecture::Sparc, + (elf::EM_SPARC32PLUS, false) => Architecture::Sparc32Plus, (elf::EM_SPARCV9, true) => Architecture::Sparc64, (elf::EM_XTENSA, false) => Architecture::Xtensa, _ => Architecture::Unknown, diff --git a/src/write/elf/object.rs b/src/write/elf/object.rs index ef97f4fd..0920a0dd 100644 --- a/src/write/elf/object.rs +++ b/src/write/elf/object.rs @@ -142,6 +142,7 @@ impl<'a> Object<'a> { Architecture::Sbf => false, Architecture::Sharc => true, Architecture::Sparc => true, + Architecture::Sparc32Plus => true, Architecture::Sparc64 => true, Architecture::Xtensa => true, _ => { @@ -412,7 +413,7 @@ impl<'a> Object<'a> { return Err(Error(format!("unimplemented relocation {:?}", reloc))); } }, - Architecture::Sparc => match (kind, encoding, size) { + Architecture::Sparc | Architecture::Sparc32Plus => match (kind, encoding, size) { // TODO: use R_SPARC_32 if aligned. (RelocationKind::Absolute, _, 32) => elf::R_SPARC_UA32, _ => { @@ -640,6 +641,7 @@ impl<'a> Object<'a> { (Architecture::Sbf, None) => elf::EM_SBF, (Architecture::Sharc, None) => elf::EM_SHARC, (Architecture::Sparc, None) => elf::EM_SPARC, + (Architecture::Sparc32Plus, None) => elf::EM_SPARC32PLUS, (Architecture::Sparc64, None) => elf::EM_SPARCV9, (Architecture::Xtensa, None) => elf::EM_XTENSA, _ => { diff --git a/tests/round_trip/mod.rs b/tests/round_trip/mod.rs index 11eb7576..3a592eb2 100644 --- a/tests/round_trip/mod.rs +++ b/tests/round_trip/mod.rs @@ -280,6 +280,7 @@ fn elf_any() { (Architecture::S390x, Endianness::Big), (Architecture::Sbf, Endianness::Little), (Architecture::Sparc, Endianness::Big), + (Architecture::Sparc32Plus, Endianness::Big), (Architecture::Sparc64, Endianness::Big), (Architecture::Xtensa, Endianness::Little), ]