Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic support for mips64/powerpc/powerpc64/riscv64 #303

Merged
merged 3 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ pub enum Architecture {
Arm,
I386,
Mips,
Mips64,
S390x,
Wasm32,
PowerPc,
PowerPc64,
Riscv32,
Riscv64,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add riscv32 too?

X86_64,
}

Expand All @@ -23,9 +28,14 @@ impl Architecture {
Architecture::Arm => Some(AddressSize::U32),
Architecture::I386 => Some(AddressSize::U32),
Architecture::Mips => Some(AddressSize::U32),
Architecture::Mips64 => Some(AddressSize::U64),
Architecture::S390x => Some(AddressSize::U64),
Architecture::Wasm32 => Some(AddressSize::U32),
Architecture::X86_64 => Some(AddressSize::U64),
Architecture::PowerPc => Some(AddressSize::U32),
Architecture::PowerPc64 => Some(AddressSize::U64),
Architecture::Riscv64 => Some(AddressSize::U64),
Architecture::Riscv32 => Some(AddressSize::U32),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,8 @@ pub const SHF_COMPRESSED: u32 = 1 << 11;
pub const SHF_MASKOS: u32 = 0x0ff0_0000;
/// Processor-specific section flags.
pub const SHF_MASKPROC: u32 = 0xf000_0000;
/// This section is excluded from the final executable or shared library.
pub const SHF_EXCLUDE: u32 = 0x8000_0000;

/// Section compression header.
///
Expand Down
10 changes: 10 additions & 0 deletions src/write/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ impl Object {
Architecture::X86_64 => true,
Architecture::S390x => true,
Architecture::Mips => false,
Architecture::Mips64 => false,
Architecture::PowerPc => false,
Architecture::PowerPc64 => false,
Architecture::Riscv64 => false,
Architecture::Riscv32 => false,
_ => {
return Err(Error(format!(
"unimplemented architecture {:?}",
Expand Down Expand Up @@ -349,6 +354,11 @@ impl Object {
Architecture::X86_64 => elf::EM_X86_64,
Architecture::S390x => elf::EM_S390,
Architecture::Mips => elf::EM_MIPS,
Architecture::Mips64 => elf::EM_MIPS,
Architecture::PowerPc => elf::EM_PPC,
Architecture::PowerPc64 => elf::EM_PPC64,
Architecture::Riscv64 => elf::EM_RISCV,
Architecture::Riscv32 => elf::EM_RISCV,
_ => {
return Err(Error(format!(
"unimplemented architecture {:?}",
Expand Down