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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [include/] [linux/] [elf.h] - Blame information for rev 1782

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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