]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/file/readelf.h
unfinished sblive driver, playback/mixer only for now - not enabled in
[FreeBSD/FreeBSD.git] / usr.bin / file / readelf.h
1 /*
2  * readelf.h 
3  * @(#)$FreeBSD$
4  *
5  * Provide elf data structures for non-elf machines, allowing file
6  * non-elf hosts to determine if an elf binary is stripped.
7  * Note: cobbled from the linux header file, with modifications
8  */
9 #ifndef __fake_elf_h__
10 #define __fake_elf_h__
11
12 typedef unsigned int    Elf32_Addr;
13 typedef unsigned short  Elf32_Half;
14 typedef unsigned int    Elf32_Off;
15 typedef unsigned int    Elf32_Word;
16 typedef unsigned char   Elf32_Char;
17
18 /* XXX: We need 64 bit numbers here */
19 typedef u_quad_t        Elf64_Addr;
20 typedef unsigned short  Elf64_Half;
21 typedef u_quad_t        Elf64_Off;
22 typedef unsigned int    Elf64_Word;
23 typedef unsigned char   Elf64_Char;
24
25 #define EI_NIDENT       16
26
27 typedef struct {
28     Elf32_Char  e_ident[EI_NIDENT];
29     Elf32_Half  e_type;
30     Elf32_Half  e_machine;
31     Elf32_Word  e_version;
32     Elf32_Addr  e_entry;  /* Entry point */
33     Elf32_Off   e_phoff;
34     Elf32_Off   e_shoff;
35     Elf32_Word  e_flags;
36     Elf32_Half  e_ehsize;
37     Elf32_Half  e_phentsize;
38     Elf32_Half  e_phnum;
39     Elf32_Half  e_shentsize;
40     Elf32_Half  e_shnum;
41     Elf32_Half  e_shstrndx;
42 } Elf32_Ehdr;
43
44 typedef struct {
45     Elf64_Char  e_ident[EI_NIDENT];
46     Elf64_Half  e_type;
47     Elf64_Half  e_machine;
48     Elf64_Word  e_version;
49     Elf64_Addr  e_entry;  /* Entry point */
50     Elf64_Off   e_phoff;
51     Elf64_Off   e_shoff;
52     Elf64_Word  e_flags;
53     Elf64_Half  e_ehsize;
54     Elf64_Half  e_phentsize;
55     Elf64_Half  e_phnum;
56     Elf64_Half  e_shentsize;
57     Elf64_Half  e_shnum;
58     Elf64_Half  e_shstrndx;
59 } Elf64_Ehdr;
60
61 /* e_type */
62 #define ET_EXEC         2
63 #define ET_CORE         4
64
65 /* sh_type */
66 #define SHT_SYMTAB      2
67 #define SHT_NOTE        7
68
69 /* elf type */
70 #define ELFDATANONE     0               /* e_ident[EI_DATA] */
71 #define ELFDATA2LSB     1
72 #define ELFDATA2MSB     2
73
74 /* elf class */
75 #define ELFCLASSNONE    0
76 #define ELFCLASS32      1
77 #define ELFCLASS64      2
78
79 /* magic number */
80 #define EI_MAG0         0               /* e_ident[] indexes */
81 #define EI_MAG1         1
82 #define EI_MAG2         2
83 #define EI_MAG3         3
84 #define EI_CLASS        4
85 #define EI_DATA         5
86 #define EI_VERSION      6
87 #define EI_PAD          7
88
89 #define ELFMAG0         0x7f            /* EI_MAG */
90 #define ELFMAG1         'E'
91 #define ELFMAG2         'L'
92 #define ELFMAG3         'F'
93 #define ELFMAG          "\177ELF"
94
95 typedef struct {
96     Elf32_Word  p_type;
97     Elf32_Off   p_offset;
98     Elf32_Addr  p_vaddr;
99     Elf32_Addr  p_paddr;
100     Elf32_Word  p_filesz;
101     Elf32_Word  p_memsz;
102     Elf32_Word  p_flags;
103     Elf32_Word  p_align;
104 } Elf32_Phdr;
105
106 #define PT_NULL         0               /* p_type */
107 #define PT_LOAD         1
108 #define PT_DYNAMIC      2
109 #define PT_INTERP       3
110 #define PT_NOTE         4
111 #define PT_SHLIB        5
112 #define PT_PHDR         6
113 #define PT_NUM          7
114
115 typedef struct {
116     Elf32_Word  sh_name;
117     Elf32_Word  sh_type;
118     Elf32_Word  sh_flags;
119     Elf32_Addr  sh_addr;
120     Elf32_Off   sh_offset;
121     Elf32_Word  sh_size;
122     Elf32_Word  sh_link;
123     Elf32_Word  sh_info;
124     Elf32_Word  sh_addralign;
125     Elf32_Word  sh_entsize;
126 } Elf32_Shdr;
127
128 typedef struct {
129     Elf64_Word  sh_name;
130     Elf64_Word  sh_type;
131     Elf64_Off   sh_flags;
132     Elf64_Addr  sh_addr;
133     Elf64_Off   sh_offset;
134     Elf64_Off   sh_size;
135     Elf64_Word  sh_link;
136     Elf64_Word  sh_info;
137     Elf64_Off   sh_addralign;
138     Elf64_Off   sh_entsize;
139 } Elf64_Shdr;
140
141 /* Notes used in ET_CORE */
142 #define NT_PRSTATUS     1
143 #define NT_PRFPREG      2
144 #define NT_PRPSINFO     3
145 #define NT_TASKSTRUCT   4
146
147 /* Note header in a PT_NOTE section */
148 typedef struct elf_note {
149   Elf32_Word    n_namesz;       /* Name size */
150   Elf32_Word    n_descsz;       /* Content size */
151   Elf32_Word    n_type;         /* Content type */
152 } Elf32_Nhdr;
153
154 typedef struct {
155     Elf64_Word  n_namesz;
156     Elf64_Word  n_descsz;
157     Elf64_Word  n_type;
158 } Elf64_Nhdr;
159
160 #define NT_PRSTATUS     1
161 #define NT_PRFPREG      2
162 #define NT_PRPSINFO     3
163 #define NT_PRXREG       4
164 #define NT_PLATFORM     5
165 #define NT_AUXV         6
166
167 #endif