Skip to content

Commit

Permalink
Add C-style definitions for Elf[32|64]_Ehdr
Browse files Browse the repository at this point in the history
  • Loading branch information
cole14 committed Jan 27, 2023
1 parent e786ecf commit e6a1b96
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,48 @@ pub enum Class {
ELF64,
}

/// C-style 32-bit ELF File Header definition
///
/// These C-style definitions are for users who want to implement their own ELF manipulation logic.
#[repr(C)]
pub struct Elf32_Ehdr {
pub e_ident: [u8; abi::EI_NIDENT],
pub e_type: u16,
pub e_machine: u16,
pub e_version: u32,
pub e_entry: u32,
pub e_phoff: u32,
pub e_shoff: u32,
pub e_flags: u32,
pub e_ehsize: u16,
pub e_phentsize: u16,
pub e_phnum: u16,
pub e_shentsize: u16,
pub e_shnum: u16,
pub e_shstrndx: u16,
}

/// C-style 64-bit ELF File Header definition
///
/// These C-style definitions are for users who want to implement their own ELF manipulation logic.
#[repr(C)]
pub struct Elf64_Ehdr {
pub e_ident: [u8; abi::EI_NIDENT],
pub e_type: u16,
pub e_machine: u16,
pub e_version: u32,
pub e_entry: u64,
pub e_phoff: u64,
pub e_shoff: u64,
pub e_flags: u32,
pub e_ehsize: u16,
pub e_phentsize: u16,
pub e_phnum: u16,
pub e_shentsize: u16,
pub e_shnum: u16,
pub e_shstrndx: u16,
}

/// Encapsulates the contents of the ELF File Header
///
/// The ELF File Header starts off every ELF file and both identifies the
Expand Down

0 comments on commit e6a1b96

Please sign in to comment.