From 840dd99239e817e680e0f870edd1f56c1eebb45a Mon Sep 17 00:00:00 2001 From: Christopher Cole Date: Thu, 26 Jan 2023 13:14:41 -0800 Subject: [PATCH] Add C-style definitions for Elf[32|64]_Rel and Elf[32|64]_Rela --- src/relocation.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/relocation.rs b/src/relocation.rs index 740d75e..5d8e485 100644 --- a/src/relocation.rs +++ b/src/relocation.rs @@ -6,6 +6,24 @@ use crate::parse::{ParseAt, ParseError, ParsingIterator}; pub type RelIterator<'data, E> = ParsingIterator<'data, E, Rel>; pub type RelaIterator<'data, E> = ParsingIterator<'data, E, Rela>; +/// C-style 32-bit ELF Relocation definition +/// +/// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[repr(C)] +pub struct Elf32_Rel { + pub r_offset: u32, + pub r_info: u32, +} + +/// C-style 64-bit ELF Relocation definition +/// +/// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[repr(C)] +pub struct Elf64_Rel { + pub r_offset: u64, + pub r_info: u64, +} + #[derive(Debug, Clone, PartialEq, Eq)] pub struct Rel { pub r_offset: u64, @@ -51,6 +69,26 @@ impl ParseAt for Rel { } } +/// C-style 32-bit ELF Relocation (with addend) definition +/// +/// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[repr(C)] +pub struct Elf32_Rela { + pub r_offset: u32, + pub r_info: u32, + pub r_addend: i32, +} + +/// C-style 64-bit ELF Relocation (with addend) definition +/// +/// These C-style definitions are for users who want to implement their own ELF manipulation logic. +#[repr(C)] +pub struct Elf64_Rela { + pub r_offset: u64, + pub r_info: u64, + pub r_addend: i64, +} + #[derive(Debug, Clone, PartialEq, Eq)] pub struct Rela { pub r_offset: u64,