From e6a1b963f6d0f7f15eb2aa1e86a498284dc5be99 Mon Sep 17 00:00:00 2001 From: Christopher Cole Date: Thu, 26 Jan 2023 17:43:14 -0800 Subject: [PATCH] Add C-style definitions for Elf[32|64]_Ehdr --- src/file.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/file.rs b/src/file.rs index 9a94df9..8f74336 100644 --- a/src/file.rs +++ b/src/file.rs @@ -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