OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [include/] [elf.h] - Blame information for rev 854

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 51 julius
#ifndef _LINUX_ELF_H
2
#define _LINUX_ELF_H
3
 
4
/*#if HAVE_CONFIG_H
5
#include <config.h>
6
#endif*/
7
 
8
#ifdef WORDS_BIGENDIAN
9
#define ELF_SHORT_H
10
#define ELF_LONG_H
11
#else
12
/* Load a short int from the following tables with big-endian formats */
13
#define ELF_SHORT_H(ps) ((((unsigned short)(ps) >> 8) & 0xff) |\
14
                         (((unsigned short)(ps) << 8) & 0xff00))
15
 
16
/* Load a long int from the following tables with big-endian formats */
17
#define ELF_LONG_H(ps) ((((unsigned long)(ps) >> 24) & 0xff) |\
18
                         (((unsigned long)(ps) >> 8) & 0xff00)|\
19
                         (((unsigned long)(ps) << 8) & 0xff0000)|\
20
                         (((unsigned long)(ps) << 24) & 0xff000000))
21
#endif
22
 
23
#ifdef OR32_TYPES
24 462 julius
typedef uint32_t Elf32_Addr;
25
typedef uint16_t Elf32_Half;
26
typedef uint32_t Elf32_Off;
27
typedef int32_t Elf32_Sword;
28
typedef uint32_t Elf32_Word;
29 51 julius
#else
30 462 julius
typedef unsigned long Elf32_Addr;
31
typedef unsigned short Elf32_Half;
32
typedef unsigned long Elf32_Off;
33
typedef long Elf32_Sword;
34
typedef unsigned long Elf32_Word;
35 51 julius
#endif
36
 
37
/* These constants are for the segment types stored in the image headers */
38
#define PT_NULL    0
39
#define PT_LOAD    1
40
#define PT_DYNAMIC 2
41
#define PT_INTERP  3
42
#define PT_NOTE    4
43
#define PT_SHLIB   5
44
#define PT_PHDR    6
45
#define PT_LOPROC  0x70000000
46
#define PT_HIPROC  0x7fffffff
47
 
48
/* These constants define the different elf file types */
49
#define ET_NONE   0
50
#define ET_REL    1
51
#define ET_EXEC   2
52
#define ET_DYN    3
53
#define ET_CORE   4
54
#define ET_LOPROC 5
55
#define ET_HIPROC 6
56
 
57
/* These constants define the various ELF target machines */
58
#define EM_NONE  0
59
#define EM_M32   1
60
#define EM_SPARC 2
61
#define EM_386   3
62
#define EM_68K   4
63
#define EM_88K   5
64 462 julius
#define EM_486   6              /* Perhaps disused */
65 51 julius
#define EM_860   7
66
 
67
#define EM_MIPS         8       /* MIPS R3000 (officially, big-endian only) */
68
 
69
#define EM_MIPS_RS4_BE 10       /* MIPS R4000 big-endian */
70
 
71
#define EM_SPARC64     11       /* SPARC v9 (not official) 64-bit */
72
 
73
#define EM_PARISC      15       /* HPPA */
74
 
75
#define EM_SPARC32PLUS 18       /* Sun's "v8plus" */
76
 
77
#define EM_PPC         20       /* PowerPC */
78
 
79
/*
80
 * This is an interim value that we will use until the committee comes
81
 * up with a final number.
82
 */
83
#define EM_ALPHA        0x9026
84
 
85
/* This is the info that is needed to parse the dynamic section of the file */
86
#define DT_NULL         0
87
#define DT_NEEDED       1
88
#define DT_PLTRELSZ     2
89
#define DT_PLTGOT       3
90
#define DT_HASH         4
91
#define DT_STRTAB       5
92
#define DT_SYMTAB       6
93
#define DT_RELA         7
94
#define DT_RELASZ       8
95
#define DT_RELAENT      9
96
#define DT_STRSZ        10
97
#define DT_SYMENT       11
98
#define DT_INIT         12
99
#define DT_FINI         13
100
#define DT_SONAME       14
101
#define DT_RPATH        15
102
#define DT_SYMBOLIC     16
103
#define DT_REL          17
104
#define DT_RELSZ        18
105
#define DT_RELENT       19
106
#define DT_PLTREL       20
107
#define DT_DEBUG        21
108
#define DT_TEXTREL      22
109
#define DT_JMPREL       23
110
#define DT_LOPROC       0x70000000
111
#define DT_HIPROC       0x7fffffff
112
 
113
/* This info is needed when parsing the symbol table */
114
#define STB_LOCAL  0
115
#define STB_GLOBAL 1
116
#define STB_WEAK   2
117
 
118
#define STT_NOTYPE  0
119
#define STT_OBJECT  1
120
#define STT_FUNC    2
121
#define STT_SECTION 3
122
#define STT_FILE    4
123
 
124
#define ELF32_ST_BIND(x) ((x) >> 4)
125
#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
126
 
127
/* Symbolic values for the entries in the auxiliary table
128
   put on the initial stack */
129 462 julius
#define AT_NULL   0             /* end of vector */
130
#define AT_IGNORE 1             /* entry should be ignored */
131
#define AT_EXECFD 2             /* file descriptor of program */
132
#define AT_PHDR   3             /* program headers for program */
133
#define AT_PHENT  4             /* size of program header entry */
134
#define AT_PHNUM  5             /* number of program headers */
135
#define AT_PAGESZ 6             /* system page size */
136
#define AT_BASE   7             /* base address of interpreter */
137
#define AT_FLAGS  8             /* flags */
138
#define AT_ENTRY  9             /* entry point of program */
139
#define AT_NOTELF 10            /* program is not ELF */
140
#define AT_UID    11            /* real uid */
141
#define AT_EUID   12            /* effective uid */
142
#define AT_GID    13            /* real gid */
143
#define AT_EGID   14            /* effective gid */
144 51 julius
 
145 462 julius
typedef struct dynamic {
146
        Elf32_Sword d_tag;
147
        union {
148
                Elf32_Sword d_val;
149
                Elf32_Addr d_ptr;
150
        } d_un;
151 51 julius
} Elf32_Dyn;
152
 
153
typedef struct {
154 462 julius
        unsigned long long d_tag;       /* entry tag value */
155
        union {
156
                unsigned long long d_val;
157
                unsigned long long d_ptr;
158
        } d_un;
159 51 julius
} Elf64_Dyn;
160
 
161
/* The following are used with relocations */
162
#define ELF32_R_SYM(x) ((x) >> 8)
163
#define ELF32_R_TYPE(x) ((x) & 0xff)
164
 
165
#define R_386_NONE      0
166
#define R_386_32        1
167
#define R_386_PC32      2
168
#define R_386_GOT32     3
169
#define R_386_PLT32     4
170
#define R_386_COPY      5
171
#define R_386_GLOB_DAT  6
172
#define R_386_JMP_SLOT  7
173
#define R_386_RELATIVE  8
174
#define R_386_GOTOFF    9
175
#define R_386_GOTPC     10
176
#define R_386_NUM       11
177
 
178
#define R_68K_NONE      0
179
#define R_68K_32        1
180
#define R_68K_16        2
181
#define R_68K_8         3
182
#define R_68K_PC32      4
183
#define R_68K_PC16      5
184
#define R_68K_PC8       6
185
#define R_68K_GOT32     7
186
#define R_68K_GOT16     8
187
#define R_68K_GOT8      9
188
#define R_68K_GOT32O    10
189
#define R_68K_GOT16O    11
190
#define R_68K_GOT8O     12
191
#define R_68K_PLT32     13
192
#define R_68K_PLT16     14
193
#define R_68K_PLT8      15
194
#define R_68K_PLT32O    16
195
#define R_68K_PLT16O    17
196
#define R_68K_PLT8O     18
197
#define R_68K_COPY      19
198
#define R_68K_GLOB_DAT  20
199
#define R_68K_JMP_SLOT  21
200
#define R_68K_RELATIVE  22
201
 
202
typedef struct elf32_rel {
203 462 julius
        Elf32_Addr r_offset;
204
        Elf32_Word r_info;
205 51 julius
} Elf32_Rel;
206
 
207
typedef struct elf64_rel {
208 462 julius
        unsigned long long r_offset;    /* Location at which to apply the action */
209
        unsigned long long r_info;      /* index and type of relocation */
210 51 julius
} Elf64_Rel;
211
 
212 462 julius
typedef struct elf32_rela {
213
        Elf32_Addr r_offset;
214
        Elf32_Word r_info;
215
        Elf32_Sword r_addend;
216 51 julius
} Elf32_Rela;
217
 
218
typedef struct elf64_rela {
219 462 julius
        unsigned long long r_offset;    /* Location at which to apply the action */
220
        unsigned long long r_info;      /* index and type of relocation */
221
        unsigned long long r_addend;    /* Constant addend used to compute value */
222 51 julius
} Elf64_Rela;
223
 
224 462 julius
typedef struct elf32_sym {
225
        Elf32_Word st_name;
226
        Elf32_Addr st_value;
227
        Elf32_Word st_size;
228
        unsigned char st_info;
229
        unsigned char st_other;
230
        Elf32_Half st_shndx;
231 51 julius
} Elf32_Sym;
232
 
233
typedef struct elf64_sym {
234 462 julius
        unsigned int st_name;   /* Symbol name, index in string tbl */
235
        unsigned char st_info;  /* Type and binding attributes */
236
        unsigned char st_other; /* No defined meaning, 0 */
237
        unsigned short st_shndx;        /* Associated section index */
238
        unsigned long long st_value;    /* Value of the symbol */
239
        unsigned long long st_size;     /* Associated symbol size */
240 51 julius
} Elf64_Sym;
241
 
242
#define EI_NIDENT       16
243
 
244 462 julius
typedef struct elf32_hdr {
245
        unsigned char e_ident[EI_NIDENT];
246
        Elf32_Half e_type;
247
        Elf32_Half e_machine;
248
        Elf32_Word e_version;
249
        Elf32_Addr e_entry;     /* Entry point */
250
        Elf32_Off e_phoff;
251
        Elf32_Off e_shoff;
252
        Elf32_Word e_flags;
253
        Elf32_Half e_ehsize;
254
        Elf32_Half e_phentsize;
255
        Elf32_Half e_phnum;
256
        Elf32_Half e_shentsize;
257
        Elf32_Half e_shnum;
258
        Elf32_Half e_shstrndx;
259 51 julius
} Elf32_Ehdr;
260
 
261
typedef struct elf64_hdr {
262 462 julius
        unsigned char e_ident[16];      /* ELF "magic number" */
263
        short int e_type;
264
        short unsigned int e_machine;
265
        int e_version;
266
        unsigned long long e_entry;     /* Entry point virtual address */
267
        unsigned long long e_phoff;     /* Program header table file offset */
268
        unsigned long long e_shoff;     /* Section header table file offset */
269
        int e_flags;
270
        short int e_ehsize;
271
        short int e_phentsize;
272
        short int e_phnum;
273
        short int e_shentsize;
274
        short int e_shnum;
275
        short int e_shstrndx;
276 51 julius
} Elf64_Ehdr;
277
 
278
/* These constants define the permissions on sections in the program
279
   header, p_flags. */
280
#define PF_R            0x4
281
#define PF_W            0x2
282
#define PF_X            0x1
283
 
284 462 julius
typedef struct elf32_phdr {
285
        Elf32_Word p_type;
286
        Elf32_Off p_offset;
287
        Elf32_Addr p_vaddr;
288
        Elf32_Addr p_paddr;
289
        Elf32_Word p_filesz;
290
        Elf32_Word p_memsz;
291
        Elf32_Word p_flags;
292
        Elf32_Word p_align;
293 51 julius
} Elf32_Phdr;
294
 
295
typedef struct elf64_phdr {
296 462 julius
        int p_type;
297
        int p_flags;
298
        unsigned long long p_offset;    /* Segment file offset */
299
        unsigned long long p_vaddr;     /* Segment virtual address */
300
        unsigned long long p_paddr;     /* Segment physical address */
301
        unsigned long long p_filesz;    /* Segment size in file */
302
        unsigned long long p_memsz;     /* Segment size in memory */
303
        unsigned long long p_align;     /* Segment alignment, file & memory */
304 51 julius
} Elf64_Phdr;
305
 
306
/* sh_type */
307
#define SHT_NULL        0
308
#define SHT_PROGBITS    1
309
#define SHT_SYMTAB      2
310
#define SHT_STRTAB      3
311
#define SHT_RELA        4
312
#define SHT_HASH        5
313
#define SHT_DYNAMIC     6
314
#define SHT_NOTE        7
315
#define SHT_NOBITS      8
316
#define SHT_REL         9
317
#define SHT_SHLIB       10
318
#define SHT_DYNSYM      11
319
#define SHT_NUM         12
320
#define SHT_LOPROC      0x70000000
321
#define SHT_HIPROC      0x7fffffff
322
#define SHT_LOUSER      0x80000000
323
#define SHT_HIUSER      0xffffffff
324
 
325
/* sh_flags */
326
#define SHF_WRITE       0x1
327
#define SHF_ALLOC       0x2
328
#define SHF_EXECINSTR   0x4
329
#define SHF_MASKPROC    0xf0000000
330
 
331
/* special section indexes */
332
#define SHN_UNDEF       0
333
#define SHN_LORESERVE   0xff00
334
#define SHN_LOPROC      0xff00
335
#define SHN_HIPROC      0xff1f
336
#define SHN_ABS         0xfff1
337
#define SHN_COMMON      0xfff2
338
#define SHN_HIRESERVE   0xffff
339 462 julius
 
340 51 julius
typedef struct elf32_shdr {
341 462 julius
        Elf32_Word sh_name;
342
        Elf32_Word sh_type;
343
        Elf32_Word sh_flags;
344
        Elf32_Addr sh_addr;
345
        Elf32_Off sh_offset;
346
        Elf32_Word sh_size;
347
        Elf32_Word sh_link;
348
        Elf32_Word sh_info;
349
        Elf32_Word sh_addralign;
350
        Elf32_Word sh_entsize;
351 51 julius
} Elf32_Shdr;
352
 
353
typedef struct elf64_shdr {
354 462 julius
        unsigned int sh_name;   /* Section name, index in string tbl */
355
        unsigned int sh_type;   /* Type of section */
356
        unsigned long long sh_flags;    /* Miscellaneous section attributes */
357
        unsigned long long sh_addr;     /* Section virtual addr at execution */
358
        unsigned long long sh_offset;   /* Section file offset */
359
        unsigned long long sh_size;     /* Size of section in bytes */
360
        unsigned int sh_link;   /* Index of another section */
361
        unsigned int sh_info;   /* Additional section information */
362
        unsigned long long sh_addralign;        /* Section alignment */
363
        unsigned long long sh_entsize;  /* Entry size if section holds table */
364 51 julius
} Elf64_Shdr;
365
 
366 462 julius
#define EI_MAG0         0        /* e_ident[] indexes */
367 51 julius
#define EI_MAG1         1
368
#define EI_MAG2         2
369
#define EI_MAG3         3
370
#define EI_CLASS        4
371
#define EI_DATA         5
372
#define EI_VERSION      6
373
#define EI_PAD          7
374
 
375 462 julius
#define ELFMAG0         0x7f    /* EI_MAG */
376 51 julius
#define ELFMAG1         'E'
377
#define ELFMAG2         'L'
378
#define ELFMAG3         'F'
379
#define ELFMAG          "\177ELF"
380
#define SELFMAG         4
381
 
382 462 julius
#define ELFCLASSNONE    0        /* EI_CLASS */
383 51 julius
#define ELFCLASS32      1
384
#define ELFCLASS64      2
385
#define ELFCLASSNUM     3
386
 
387 462 julius
#define ELFDATANONE     0        /* e_ident[EI_DATA] */
388 51 julius
#define ELFDATA2LSB     1
389
#define ELFDATA2MSB     2
390
 
391 462 julius
#define EV_NONE         0        /* e_version, EI_VERSION */
392 51 julius
#define EV_CURRENT      1
393
#define EV_NUM          2
394
 
395
/* Notes used in ET_CORE */
396
#define NT_PRSTATUS     1
397
#define NT_PRFPREG      2
398
#define NT_PRPSINFO     3
399
#define NT_TASKSTRUCT   4
400
 
401
/* Note header in a PT_NOTE section */
402
typedef struct elf32_note {
403 462 julius
        Elf32_Word n_namesz;    /* Name size */
404
        Elf32_Word n_descsz;    /* Content size */
405
        Elf32_Word n_type;      /* Content type */
406 51 julius
} Elf32_Nhdr;
407
 
408
/* Note header in a PT_NOTE section */
409
/*
410
 * For now we use the 32 bit version of the structure until we figure
411
 * out whether we need anything better.  Note - on the Alpha, "unsigned int"
412
 * is only 32 bits.
413
 */
414
typedef struct elf64_note {
415 462 julius
        unsigned int n_namesz;  /* Name size */
416
        unsigned int n_descsz;  /* Content size */
417
        unsigned int n_type;    /* Content type */
418 51 julius
} Elf64_Nhdr;
419
 
420
#ifdef __mc68000__
421
#define ELF_START_MMAP 0xC0000000
422
#endif
423
#ifdef __i386__
424
#define ELF_START_MMAP 0x80000000
425
#endif
426
 
427
#if ELF_CLASS == ELFCLASS32
428
 
429 462 julius
extern Elf32_Dyn _DYNAMIC[];
430 51 julius
#define elfhdr          elf32_hdr
431
#define elf_phdr        elf32_phdr
432
#define elf_note        elf32_note
433
 
434
#else
435
 
436 462 julius
extern Elf64_Dyn _DYNAMIC[];
437 51 julius
#define elfhdr          elf64_hdr
438
#define elf_phdr        elf64_phdr
439
#define elf_note        elf64_note
440
 
441
#endif
442
 
443
#endif /* _LINUX_ELF_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.