enby/lib/elf/eheader.h

104 lines
3.6 KiB
C
Raw Normal View History

2025-09-26 15:31:59 +10:00
/* The ELF header resides at the beginning of an ELF file.
* It identifies the file as an ELF file and contains the information
* necessary for interpreting the contents of the file and locating
* the other components of the file.
* REF: https://gabi.xinuos.com/elf/02-eheader.html#elf-header
*/
#ifndef BFPG_ELF_HEADER_H
# define BFPG_ELF_HEADER_H
# include "eint.h"
# define EI_NIDENT (16)
typedef struct {
unsigned char e_ident[EI_NIDENT];
Elf32_Half e_type;
Elf32_Half e_machine;
Elf32_Word e_version;
Elf32_Addr e_entry;
Elf32_Off e_phoff;
Elf32_Off e_shoff;
Elf32_Word e_flags;
Elf32_Half e_ehsize;
Elf32_Half e_phentsize;
Elf32_Half e_phnum;
Elf32_Half e_shentsize;
Elf32_Half e_shnum;
Elf32_Half e_shstrndx;
} Elf32_Ehdr;
typedef struct {
unsigned char e_ident[EI_NIDENT];
Elf64_Half e_type;
Elf64_Half e_machine;
Elf64_Word e_version;
Elf64_Addr e_entry;
Elf64_Off e_phoff;
Elf64_Off e_shoff;
Elf64_Word e_flags;
Elf64_Half e_ehsize;
Elf64_Half e_phentsize;
Elf64_Half e_phnum;
Elf64_Half e_shentsize;
Elf64_Half e_shnum;
Elf64_Half e_shstrndx;
} Elf64_Ehdr;
/* == ElfN_Ehdr.e_ident[] ==
2025-09-26 15:31:59 +10:00
* EI_* macros define indexes into this this, and are followed
* by a series a macros defining legal values for that index.
*/
/* XXX: WARNING: TODO :WARNING :XXX */
# define E_IDENT_DESC ( \
"The initial bytes of an ELF file.\n\n" \
"Marks the file as an object file and provides machine-independent " \
"data with which to parse and interpret the files contents." )
2025-09-26 15:31:59 +10:00
/* == ElfN_Ehdr.e_type == */
enum e_type_t {
2025-09-26 15:31:59 +10:00
ET_NONE = 0, /* No file type */
ET_REL = 1, /* Relocatable file */
ET_EXEC = 2, /* Executable file */
ET_DYN = 3, /* Shared object file */
ET_CORE = 4, /* Core file */
ET_LOOS = 0xfe00, /* OS-specific range start */
ET_HIOS = 0xfeff, /* OS-specific range end */
ET_LOPROC = 0xff00, /* Processor-specific range start */
ET_HIPROC = 0xffff, /* Processor-specific range end */
};
# define E_TYPE_DESC ( \
"Identifies the object file type.\n\n" \
"ET_CORE is reserved and largely used by core files. " \
"However the actual file contents are left unspecified. " \
"Allowing projects to define their own extensions.\n\n" \
"Values ET_LOOS through ET_HIOS (inclusive) are reserved " \
"for OS-specific object file types.\n\n" \
"Values ET_LOPROC through ET_HIPROC (inclusive) are reserved " \
"for processor-specific object file types." )
2025-09-26 15:31:59 +10:00
/* == ElfN_Ehdr.e_machine == */
enum e_machine_t {
/* XXX: WARNING: TODO :WARNING :XXX */
};
#define E_MACHINE_DESC ()
/* == ElfN_Ehdr.e_version == */
enum e_version_t {
EV_NONE = 0, /* Invalid version */
EV_CURRENT = 1, /* Current Version */
};
#define E_VERSION_DESC ( \
"Version of ELF used.\n\n" \
"EV_CURRENT signifies the original file format. " \
"Extensions will use higher e_machine numbers" )
/* == ElfN_Ehdr.e_entry == */
#define E_ENTRY_DESC ( \
"Virtual address of the entry point.\n\n" \
"The system first transfers control to this virtual address, " \
"thus starting the process. If the file has no associated entry point, " \
"this member holds zero." )
2025-09-26 15:31:59 +10:00
#endif /* BFPG_ELF_HEADER_H */