Created
February 16, 2015 20:57
-
-
Save halit/1c7d1b525162861024fe to your computer and use it in GitHub Desktop.
Toy elf header file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __ELF_H__ | |
#define __ELF_H__ | |
#include <stdint.h> | |
typedef uint16_t Elf32_Half; | |
typedef uint32_t Elf32_Off; | |
typedef uint32_t Elf32_Addr; | |
typedef uint32_t Elf32_Word; | |
typedef int32_t Elf32_Sword; | |
typedef uint16_t Elf64_Half; | |
typedef uint64_t Elf64_Off; | |
typedef uint64_t Elf64_Addr; | |
typedef uint32_t Elf64_Word; | |
typedef int32_t Elf64_Sword; | |
typedef uint64_t Elf64_Xword; | |
typedef uint64_t Elf64_Sxword; | |
#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_shtrndx; | |
} 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_shtrndx; | |
} Elf64_Ehdr; | |
enum { | |
EI_MAG0 = 0, | |
EI_MAG1 = 1, | |
EI_MAG2 = 2, | |
EI_MAG3 = 3, | |
EI_CLASS = 4, | |
EI_DATA = 5, | |
EI_VERSION = 6, | |
EI_OSABI = 7, | |
EI_ABIVERSION = 8, | |
EI_PAD = 9 | |
}; | |
#define ELFMAG0 0x7F | |
#define ELFMAG1 'E' | |
#define ELFMAG2 'L' | |
#define ELFMAG3 'F' | |
enum { | |
ELFCLASSNONE = 0, | |
ELFCLASS32 = 1, | |
ELFCLASS64 = 2 | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment