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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uC-libc/] [include/] [linux/] [elf.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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