Skip to content

Commit

Permalink
Add Architecture::Sparc32
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed Jun 24, 2024
1 parent 7b58f78 commit d482326
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub enum Architecture {
S390x,
Sbf,
Sharc,
Sparc32,
Sparc64,
Wasm32,
Wasm64,
Expand Down Expand Up @@ -70,6 +71,7 @@ impl Architecture {
Architecture::S390x => Some(AddressSize::U64),
Architecture::Sbf => Some(AddressSize::U64),
Architecture::Sharc => Some(AddressSize::U32),
Architecture::Sparc32 => Some(AddressSize::U32),
Architecture::Sparc64 => Some(AddressSize::U64),
Architecture::Wasm32 => Some(AddressSize::U32),
Architecture::Wasm64 => Some(AddressSize::U64),
Expand Down
1 change: 1 addition & 0 deletions src/read/elf/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ where
(elf::EM_S390, true) => Architecture::S390x,
(elf::EM_SBF, _) => Architecture::Sbf,
(elf::EM_SHARC, false) => Architecture::Sharc,
(elf::EM_SPARC, false) => Architecture::Sparc32,
(elf::EM_SPARCV9, true) => Architecture::Sparc64,
(elf::EM_XTENSA, false) => Architecture::Xtensa,
_ => Architecture::Unknown,
Expand Down
9 changes: 9 additions & 0 deletions src/write/elf/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ impl<'a> Object<'a> {
Architecture::S390x => true,
Architecture::Sbf => false,
Architecture::Sharc => true,
Architecture::Sparc32 => true,
Architecture::Sparc64 => true,
Architecture::Xtensa => true,
_ => {
Expand Down Expand Up @@ -411,6 +412,13 @@ impl<'a> Object<'a> {
return Err(Error(format!("unimplemented relocation {:?}", reloc)));
}
},
Architecture::Sparc32 => match (kind, encoding, size) {
// TODO: use R_SPARC_32 if aligned.
(RelocationKind::Absolute, _, 32) => elf::R_SPARC_UA32,
_ => {
return Err(Error(format!("unimplemented relocation {:?}", reloc)));
}
},
Architecture::Sparc64 => match (kind, encoding, size) {
// TODO: use R_SPARC_32/R_SPARC_64 if aligned.
(RelocationKind::Absolute, _, 32) => elf::R_SPARC_UA32,
Expand Down Expand Up @@ -631,6 +639,7 @@ impl<'a> Object<'a> {
(Architecture::S390x, None) => elf::EM_S390,
(Architecture::Sbf, None) => elf::EM_SBF,
(Architecture::Sharc, None) => elf::EM_SHARC,
(Architecture::Sparc32, None) => elf::EM_SPARC,
(Architecture::Sparc64, None) => elf::EM_SPARCV9,
(Architecture::Xtensa, None) => elf::EM_XTENSA,
_ => {
Expand Down
1 change: 1 addition & 0 deletions tests/round_trip/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ fn elf_any() {
(Architecture::Riscv64, Endianness::Little),
(Architecture::S390x, Endianness::Big),
(Architecture::Sbf, Endianness::Little),
(Architecture::Sparc32, Endianness::Big),
(Architecture::Sparc64, Endianness::Big),
(Architecture::Xtensa, Endianness::Little),
]
Expand Down

0 comments on commit d482326

Please sign in to comment.