summaryrefslogtreecommitdiffstats
path: root/include/arch/x86_64/elf.h
blob: 1aaf116622a54c983038ec6631d7b15b80b7c6b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef _JOVE_x86_64_ELF_H
#define _JOVE_x86_64_ELF_H 1

#include <stdint.h>

#define EI_MAG0 0x7F
#define EI_MAG1 'E'
#define EI_MAG2 'L'
#define EI_MAG3 'F'

#define EI_CLASS_32 1
#define EI_CLASS_64 2

#define EI_DATA_LE 1
#define EI_DATA_BE 2

#define EI_VERSION_CURRENT 1

#define ET_NONE 0
#define ET_REL 1
#define ET_EXEC 2
#define ET_DYN 3

typedef struct elf64_file_header
{
    union {
        struct {
            uint8_t ei_mag[4];
            uint8_t ei_class;
            uint8_t ei_data;
            uint8_t ei_version;
            uint8_t ei_osabi;
            uint8_t ei_abiver;
            uint8_t ei_pad[7];
        };
        uint8_t e_ident[16];
    };
    uint16_t e_type;
    uint16_t e_machine;
    uint32_t e_version;
    uint64_t e_entry;
    uint64_t e_phoff;
    uint64_t e_shoff;
    uint32_t e_flags;
    uint16_t e_ehsize;
    uint16_t e_phentsize;
    uint16_t e_phnum;
    uint16_t e_shentsize;
    uint16_t e_shnum;
    uint16_t e_shstrndx;
} elf_header_t;

#define PT_NULL 0
#define PT_LOAD 1
#define PT_DYNAMIC 2
#define PT_INTERP 3
#define PT_NOTE 4
#define PT_SHLIB 5
#define PT_PHDR 6
#define PT_TLS 7

#define PF_X 1
#define PF_W 2
#define PF_R 4

typedef struct elf64_program_header
{
    uint32_t p_type;
    uint32_t p_flags;
    uint64_t p_offset;
    uint64_t p_vaddr;
    uint64_t p_paddr;
    uint64_t p_filesz;
    uint64_t p_memsz;
    uint64_t p_align;
} elf_phdr_t;

#define SHT_NULL 0
#define SHT_PROGBITS 1

typedef struct elf64_section_header
{
    uint32_t sh_name;
    uint32_t sh_type;
    uint64_t sh_flags;
    uint64_t sh_addr;
    uint64_t sh_offset;
    uint64_t sh_size;
    uint64_t sh_addralign;
    uint64_t sh_entsize;
} elf_shdr_t;

#endif