[smsc75xx] Expose functionality shared with LAN78xx devices
[ipxe.git] / src / include / elf.h
1 #ifndef ELF_H
2 #define ELF_H
3
4 /**
5 * @file
6 *
7 * ELF headers
8 *
9 */
10
11 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
12
13 #include <stdint.h>
14
15 typedef uint32_t Elf32_Addr;
16 typedef uint16_t Elf32_Half;
17 typedef uint32_t Elf32_Off;
18 typedef int32_t Elf32_Sword;
19 typedef uint32_t Elf32_Word;
20
21 /** Length of ELF identifier */
22 #define EI_NIDENT 16
23
24 /** ELF header */
25 typedef struct {
26 unsigned char e_ident[EI_NIDENT];
27 Elf32_Half e_type;
28 Elf32_Half e_machine;
29 Elf32_Word e_version;
30 Elf32_Addr e_entry;
31 Elf32_Off e_phoff;
32 Elf32_Off e_shoff;
33 Elf32_Word e_flags;
34 Elf32_Half e_ehsize;
35 Elf32_Half e_phentsize;
36 Elf32_Half e_phnum;
37 Elf32_Half e_shentsize;
38 Elf32_Half e_shnum;
39 Elf32_Half e_shstrndx;
40 } Elf32_Ehdr;
41
42 /* ELF identifier indexes */
43 #define EI_MAG0 0
44 #define EI_MAG1 1
45 #define EI_MAG2 2
46 #define EI_MAG3 3
47 #define EI_CLASS 4
48 #define EI_DATA 5
49 #define EI_VERSION 6
50
51 /* ELF magic signature bytes */
52 #define ELFMAG0 0x7f
53 #define ELFMAG1 'E'
54 #define ELFMAG2 'L'
55 #define ELFMAG3 'F'
56
57 /* ELF classes */
58 #define ELFCLASS32 1
59
60 /* ELF data encodings */
61 #define ELFDATA2LSB 1
62
63 /* ELF versions */
64 #define EV_CURRENT 1
65
66 /** ELF program header */
67 typedef struct {
68 Elf32_Word p_type;
69 Elf32_Off p_offset;
70 Elf32_Addr p_vaddr;
71 Elf32_Addr p_paddr;
72 Elf32_Word p_filesz;
73 Elf32_Word p_memsz;
74 Elf32_Word p_flags;
75 Elf32_Word p_align;
76 } Elf32_Phdr;
77
78 /* ELF segment types */
79 #define PT_LOAD 1
80
81 #endif /* ELF_H */