Merge pull request #2654 from Antiklesys/master
[RRG-proxmark3.git] / client / src / elf.h
blobf79675cfbe2577c4eef97a8c250860d7632d0ced
1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // ELF header
17 //-----------------------------------------------------------------------------
19 #ifndef __ELF_H__
20 #define __ELF_H__
22 #include "common.h"
24 typedef struct {
25 uint32_t p_type;
26 uint32_t p_offset;
27 uint32_t p_vaddr;
28 uint32_t p_paddr;
29 uint32_t p_filesz;
30 uint32_t p_memsz;
31 uint32_t p_flags;
32 uint32_t p_align;
33 } PACKED Elf32_Phdr_t;
35 #define EI_NIDENT 16
37 typedef struct {
38 unsigned char e_ident[EI_NIDENT];
39 uint16_t e_type;
40 uint16_t e_machine;
41 uint32_t e_version;
42 uint32_t e_entry;
43 uint32_t e_phoff;
44 uint32_t e_shoff;
45 uint32_t e_flags;
46 uint16_t e_ehsize;
47 uint16_t e_phentsize;
48 uint16_t e_phnum;
49 uint16_t e_shentsize;
50 uint16_t e_shnum;
51 uint16_t e_shstrndx;
52 } PACKED Elf32_Ehdr_t;
54 typedef struct {
55 uint32_t sh_name; // Section name, index in string tbl
56 uint32_t sh_type; // Type of section
57 uint32_t sh_flags; // Miscellaneous section attributes
58 uint32_t sh_addr; // Section virtual addr at execution
59 uint32_t sh_offset; // Section file offset
60 uint32_t sh_size; // Size of section in bytes
61 uint32_t sh_link; // Index of another section
62 uint32_t sh_info; // Additional section information
63 uint32_t sh_addralign; // Section alignment
64 uint32_t sh_entsize; // Entry size if section holds table
65 } PACKED Elf32_Shdr_t;
67 #define PT_NULL 0
68 #define PT_LOAD 1
69 #define PT_DYNAMIC 2
70 #define PT_INTERP 3
71 #define PT_NOTE 4
72 #define PT_SHLIB 5
73 #define PT_PHDR 6
75 #define ELFCLASS32 1
76 #define ELFCLASS64 2
78 #define ELFDATA2LSB 1
79 #define ELFDATA2MSB 2
81 #define EV_CURRENT 1
83 #define ET_NONE 0
84 #define ET_REL 1
85 #define ET_EXEC 2
86 #define ET_DYN 3
87 #define ET_CORE 4
89 #define EM_ARM 0x28
91 #define PF_R 4
92 #define PF_W 2
93 #define PF_X 1
95 #endif