xref: /haiku/headers/private/storage/Elf.h (revision 1d9d47fc72028bb71b5f232a877231e59cfe2438)
1 // Elf.h
2 
3 #ifndef _ELF_H
4 #define _ELF_H
5 
6 // types
7 typedef uint32		Elf32_Addr;
8 typedef uint16		Elf32_Half;
9 typedef uint32		Elf32_Off;
10 typedef int32		Elf32_Sword;
11 typedef uint32		Elf32_Word;
12 
13 // e_ident indices
14 #define EI_MAG0		0
15 #define EI_MAG1		1
16 #define EI_MAG2		2
17 #define EI_MAG3		3
18 #define EI_CLASS	4
19 #define EI_DATA		5
20 #define EI_VERSION	6
21 #define EI_PAD		7
22 #define EI_NIDENT	16
23 
24 // object file 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 // e_ident EI_CLASS and EI_DATA values
43 #define ELFCLASSNONE	0
44 #define ELFCLASS32		1
45 #define ELFCLASS64		2
46 #define ELFDATANONE		0
47 #define ELFDATA2LSB		1
48 #define ELFDATA2MSB		2
49 
50 // program header
51 typedef struct {
52 	Elf32_Word	p_type;
53 	Elf32_Off	p_offset;
54 	Elf32_Addr	p_vaddr;
55 	Elf32_Addr	p_paddr;
56 	Elf32_Word	p_filesz;
57 	Elf32_Word	p_memsz;
58 	Elf32_Word	p_flags;
59 	Elf32_Word	p_align;
60 } Elf32_Phdr;
61 
62 // p_type
63 #define PT_NULL		0
64 #define PT_LOAD		1
65 #define PT_DYNAMIC	2
66 #define PT_INTERP	3
67 #define PT_NOTE		4
68 #define PT_SHLIB	5
69 #define PT_PHDIR	6
70 #define PT_LOPROC	0x70000000
71 #define PT_HIPROC	0x7fffffff
72 
73 // section header
74 typedef struct {
75 	Elf32_Word	sh_name;
76 	Elf32_Word	sh_type;
77 	Elf32_Word	sh_flags;
78 	Elf32_Addr	sh_addr;
79 	Elf32_Off	sh_offset;
80 	Elf32_Word	sh_size;
81 	Elf32_Word	sh_link;
82 	Elf32_Word	sh_info;
83 	Elf32_Word	sh_addralign;
84 	Elf32_Word	sh_entsize;
85 } Elf32_Shdr;
86 
87 // sh_type values
88 #define SHT_NULL		0
89 #define SHT_PROGBITS	1
90 #define SHT_SYMTAB		2
91 #define SHT_STRTAB		3
92 #define SHT_RELA		4
93 #define SHT_HASH		5
94 #define SHT_DYNAMIC		6
95 #define SHT_NOTE		7
96 #define SHT_NOBITS		8
97 #define SHT_REL			9
98 #define SHT_SHLIB		10
99 #define SHT_DYNSYM		11
100 #define SHT_LOPROC		0x70000000
101 #define SHT_HIPROC		0x7fffffff
102 #define SHT_LOUSER		0x80000000
103 #define SHT_HIUSER		0xffffffff
104 
105 #endif	// _ELF_H
106 
107 
108