add ELF data types

This commit is contained in:
Emile Clark-Boman 2025-09-26 14:05:50 +10:00
parent 885dfbb100
commit 29a66b5663
2 changed files with 32 additions and 0 deletions

6
lib/elf/README.md Normal file
View file

@ -0,0 +1,6 @@
# Executable and Linkable Format (ELF)
## References:
1. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format
2. https://gabi.xinuos.com/
3. https://github.com/xinuos/gabi

26
lib/elf/elf.h Normal file
View file

@ -0,0 +1,26 @@
/*
* REF: https://gabi.xinuos.com/elf/01-intro.html
*/
#include <stdint.h>
/* Byte alignment for the ELF data types will always match the size.
* For example a structure containing an Elf32_Addr member will
* be aligned on a 4-byte boundary within the file.
*/
/* 32-Bit Data Types */
typedef uint32_t Elf32_Addr; /* Unsigned program address */
typedef uint32_t Elf32_Off; /* Unsigned file offset */
typedef uint16_t Elf32_Half; /* Unsigned medium integer */
typedef uint32_t Elf32_Word; /* Unsigned integer */
typedef int32_t Elf32_Sword; /* Signed integer */
/* 64-Bit Data Types */
typedef uint64_t Elf64_Addr; /* Unsigned program address */
typedef uint64_t Elf64_Off; /* Unsigned file offset */
typedef uint16_t Elf64_Half; /* Unsigned medium integer */
typedef uint32_t Elf64_Word; /* Unsigned integer */
typedef int32_t Elf64_Sword; /* Signed integer */
typedef uint64_t Elf64_Xword; /* Unsigned long integer */
typedef int64_t Elf64_Sxword; /* Signed long integer */