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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [cpu/] [common/] [elf.h] - Blame information for rev 1782

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

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

powered by: WebSVN 2.1.0

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