OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [or1ksim/] [cpu/] [common/] [elf.h] - Blame information for rev 159

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

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

powered by: WebSVN 2.1.0

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