Skip to content

Commit

Permalink
Add BinaryFormat::native_object (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cr0a3 authored Apr 4, 2024
1 parent d2bb2a4 commit bbd6aa8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,21 @@ pub enum BinaryFormat {
Xcoff,
}

impl BinaryFormat {
/// The target's native binary format for relocatable object files.
///
/// Defaults to `Elf` for unknown platforms.
pub fn native_object() -> BinaryFormat {
if cfg!(target_os = "windows") {
BinaryFormat::Coff
} else if cfg!(target_os = "macos") {
BinaryFormat::MachO
} else {
BinaryFormat::Elf
}
}
}

/// The kind of a section.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
Expand Down

0 comments on commit bbd6aa8

Please sign in to comment.