4 * Copyright (C) 2017 Linus Torvalds
5 * Modified work Copyright (C) 2017 @teras (https://github.com/teras)
6 * (Shortened version -- original work found here:
7 * https://github.com/torvalds/linux/blob/master/include/uapi/linux/elf.h)
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 typedef uint16_t Elf32_Half
;
32 typedef uint16_t Elf64_Half
;
33 typedef uint32_t Elf32_Word
;
34 typedef uint32_t Elf64_Word
;
35 typedef uint64_t Elf64_Xword
;
36 typedef uint32_t Elf32_Addr
;
37 typedef uint64_t Elf64_Addr
;
38 typedef uint32_t Elf32_Off
;
39 typedef uint64_t Elf64_Off
;
43 typedef struct elf32_hdr
{
44 unsigned char e_ident
[EI_NIDENT
];
48 Elf32_Addr e_entry
; /* Entry point */
53 Elf32_Half e_phentsize
;
55 Elf32_Half e_shentsize
;
57 Elf32_Half e_shstrndx
;
60 typedef struct elf64_hdr
{
61 unsigned char e_ident
[EI_NIDENT
]; /* ELF "magic number" */
65 Elf64_Addr e_entry
; /* Entry point virtual address */
66 Elf64_Off e_phoff
; /* Program header table file offset */
67 Elf64_Off e_shoff
; /* Section header table file offset */
70 Elf64_Half e_phentsize
;
72 Elf64_Half e_shentsize
;
74 Elf64_Half e_shstrndx
;
77 typedef struct elf32_shdr
{
86 Elf32_Word sh_addralign
;
87 Elf32_Word sh_entsize
;
90 typedef struct elf64_shdr
{
91 Elf64_Word sh_name
; /* Section name, index in string tbl */
92 Elf64_Word sh_type
; /* Type of section */
93 Elf64_Xword sh_flags
; /* Miscellaneous section attributes */
94 Elf64_Addr sh_addr
; /* Section virtual addr at execution */
95 Elf64_Off sh_offset
; /* Section file offset */
96 Elf64_Xword sh_size
; /* Size of section in bytes */
97 Elf64_Word sh_link
; /* Index of another section */
98 Elf64_Word sh_info
; /* Additional section information */
99 Elf64_Xword sh_addralign
; /* Section alignment */
100 Elf64_Xword sh_entsize
; /* Entry size if section holds table */
103 /* Note header in a PT_NOTE section */
104 typedef struct elf32_note
{
105 Elf32_Word n_namesz
; /* Name size */
106 Elf32_Word n_descsz
; /* Content size */
107 Elf32_Word n_type
; /* Content type */
111 #define ELFDATA2LSB 1
112 #define ELFDATA2MSB 2