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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [redboot/] [current/] [include/] [elf.h] - Blame information for rev 844

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

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_REDBOOT_ELF_H
2
#define CYGONCE_REDBOOT_ELF_H
3
 
4
//==========================================================================
5
//
6
//      elf.h
7
//
8
//      ELF file format definitions
9
//
10
//==========================================================================
11
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
12
// -------------------------------------------                              
13
// This file is part of eCos, the Embedded Configurable Operating System.   
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under    
17
// the terms of the GNU General Public License as published by the Free     
18
// Software Foundation; either version 2 or (at your option) any later      
19
// version.                                                                 
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT      
22
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
24
// for more details.                                                        
25
//
26
// You should have received a copy of the GNU General Public License        
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
29
//
30
// As a special exception, if other files instantiate templates or use      
31
// macros or inline functions from this file, or you compile this file      
32
// and link it with other works to produce a work based on this file,       
33
// this file does not by itself cause the resulting work to be covered by   
34
// the GNU General Public License. However the source code for this file    
35
// must still be made available in accordance with section (3) of the GNU   
36
// General Public License v2.                                               
37
//
38
// This exception does not invalidate any other reasons why a work based    
39
// on this file might be covered by the GNU General Public License.         
40
// -------------------------------------------                              
41
// ####ECOSGPLCOPYRIGHTEND####                                              
42
//==========================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):           nickg
46
// Contributors:        nickg
47
// Date:                2000-11-15
48
// Purpose:             Define ELF file format
49
// Description:         The types defined here describe the ELF file format.
50
//              
51
// Usage:       #include <cyg/loader/elf.h>
52
//
53
//####DESCRIPTIONEND####
54
//
55
//==========================================================================
56
//
57
// Quite a lot of this file was taken from the BSD exec_elf.h header file.
58
// Hence we should show you this...
59
//
60
/*      $OpenBSD: exec_elf.h,v 1.20 1999/09/19 16:16:49 kstailey Exp $  */
61
/*
62
 * Copyright (c) 1995, 1996 Erik Theisen.  All rights reserved.
63
 *
64
 * Redistribution and use in source and binary forms, with or without
65
 * modification, are permitted provided that the following conditions
66
 * are met:
67
 * 1. Redistributions of source code must retain the above copyright
68
 *    notice, this list of conditions and the following disclaimer.
69
 * 2. Redistributions in binary form must reproduce the above copyright
70
 *    notice, this list of conditions and the following disclaimer in the
71
 *    documentation and/or other materials provided with the distribution.
72
 * 3. The name of the author may not be used to endorse or promote products
73
 *    derived from this software without specific prior written permission
74
 *
75
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
76
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
77
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
78
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
79
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
80
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
81
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
82
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
83
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
84
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
85
 */
86
//==========================================================================
87
 
88
#include <cyg/infra/cyg_type.h>
89
 
90
// -------------------------------------------------------------------------
91
// Basic types:
92
 
93
typedef cyg_uint32 Elf32_Addr;
94
typedef cyg_uint32 Elf32_Off;
95
typedef cyg_uint16 Elf32_Half;
96
typedef cyg_uint32 Elf32_Word;
97
typedef cyg_int32  Elf32_Sword;
98
 
99
typedef cyg_uint64 Elf64_Addr;
100
typedef cyg_uint64 Elf64_Off;
101
typedef cyg_uint16 Elf64_Half;
102
typedef cyg_uint32 Elf64_Word;
103
typedef cyg_int32  Elf64_Sword;
104
typedef cyg_uint64 Elf64_Xword;
105
typedef cyg_int64  Elf64_Sxword;
106
 
107
// -------------------------------------------------------------------------
108
// ELF header
109
 
110
#define EI_NIDENT 16
111
 
112
typedef struct {
113
    unsigned char   e_ident[EI_NIDENT];
114
    Elf32_Half      e_type;
115
    Elf32_Half      e_machine;
116
    Elf32_Word      e_version;
117
    Elf32_Addr      e_entry;
118
    Elf32_Off       e_phoff;
119
    Elf32_Off       e_shoff;
120
    Elf32_Word      e_flags;
121
    Elf32_Half      e_ehsize;
122
    Elf32_Half      e_phentsize;
123
    Elf32_Half      e_phnum;
124
    Elf32_Half      e_shentsize;
125
    Elf32_Half      e_shnum;
126
    Elf32_Half      e_shtrndx;
127
} Elf32_Ehdr;
128
 
129
typedef struct {
130
    unsigned char   e_ident[EI_NIDENT];
131
    Elf64_Half      e_type;
132
    Elf64_Half      e_machine;
133
    Elf64_Word      e_version;
134
    Elf64_Addr      e_entry;
135
    Elf64_Off       e_phoff;
136
    Elf64_Off       e_shoff;
137
    Elf64_Word      e_flags;
138
    Elf64_Half      e_ehsize;
139
    Elf64_Half      e_phentsize;
140
    Elf64_Half      e_phnum;
141
    Elf64_Half      e_shentsize;
142
    Elf64_Half      e_shnum;
143
    Elf64_Half      e_shtrndx;
144
} Elf64_Ehdr;
145
 
146
// -------------------------------------------------------------------------
147
/* e_ident[] identification indexes */
148
 
149
#define EI_MAG0         0               /* file ID */
150
#define EI_MAG1         1               /* file ID */
151
#define EI_MAG2         2               /* file ID */
152
#define EI_MAG3         3               /* file ID */
153
#define EI_CLASS        4               /* file class */
154
#define EI_DATA         5               /* data encoding */
155
#define EI_VERSION      6               /* ELF header version */
156
#define EI_OSABI        7               /* Operating system/ABI identification */
157
#define EI_ABIVERSION   8               /* ABI version */
158
#define EI_PAD          9               /* start of pad bytes */
159
 
160
// -------------------------------------------------------------------------
161
/* e_ident[] magic number */
162
 
163
#define ELFMAG0         0x7f            /* e_ident[EI_MAG0] */
164
#define ELFMAG1         'E'             /* e_ident[EI_MAG1] */
165
#define ELFMAG2         'L'             /* e_ident[EI_MAG2] */
166
#define ELFMAG3         'F'             /* e_ident[EI_MAG3] */
167
#define ELFMAG          "\177ELF"       /* magic */
168
#define SELFMAG         4               /* size of magic */
169
 
170
// -------------------------------------------------------------------------
171
/* e_ident[] file class */
172
 
173
#define ELFCLASSNONE    0               /* invalid */
174
#define ELFCLASS32      1               /* 32-bit objs */
175
#define ELFCLASS64      2               /* 64-bit objs */
176
#define ELFCLASSNUM     3               /* number of classes */
177
 
178
// -------------------------------------------------------------------------
179
/* e_ident[] data encoding */
180
 
181
#define ELFDATANONE     0               /* invalid */
182
#define ELFDATA2LSB     1               /* Little-Endian */
183
#define ELFDATA2MSB     2               /* Big-Endian */
184
#define ELFDATANUM      3               /* number of data encode defines */
185
 
186
// -------------------------------------------------------------------------
187
/* e_ident */
188
 
189
#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
190
                      (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
191
                      (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
192
                      (ehdr).e_ident[EI_MAG3] == ELFMAG3)
193
 
194
// -------------------------------------------------------------------------
195
/* e_type */
196
 
197
#define ET_NONE         0               /* No file type */
198
#define ET_REL          1               /* relocatable file */
199
#define ET_EXEC         2               /* executable file */
200
#define ET_DYN          3               /* shared object file */
201
#define ET_CORE         4               /* core file */
202
#define ET_NUM          5               /* number of types */
203
#define ET_LOOS         0xfe00          /* Operating system-specific */
204
#define ET_HIOS         0xfeff          /* Operating system-specific */
205
#define ET_LOPROC       0xff00          /* reserved range for processor */
206
#define ET_HIPROC       0xffff          /*  specific e_type */
207
 
208
// -------------------------------------------------------------------------
209
/* e_machine */
210
// The following values taken from 22 June 2000 SysV ABI spec, updated with
211
// extra values from binutils elf/common.h.
212
 
213
#define EM_NONE                 0       // No machine
214
#define EM_M32                  1       // AT&T WE 32100
215
#define EM_SPARC                2       // SPARC
216
#define EM_386                  3       // Intel 80386
217
#define EM_68K                  4       // Motorola 68000
218
#define EM_88K                  5       // Motorola 88000
219
#define EM_860                  7       // Intel 80860
220
#define EM_MIPS                 8       // MIPS I Architecture
221
#define EM_S370                 9       // IBM System/370 Processor
222
#define EM_MIPS_RS3_LE          10      // MIPS RS3000 Little-endian
223
#define EM_PARISC               15      // Hewlett-Packard PA-RISC
224
#define EM_VPP500               17      // Fujitsu VPP500
225
#define EM_SPARC32PLUS          18      // Enhanced instruction set SPARC
226
#define EM_960                  19      // Intel 80960
227
#define EM_PPC                  20      // PowerPC
228
#define EM_PPC64                21      // 64-bit PowerPC
229
#define EM_V800                 36      // NEC V800
230
#define EM_FR20                 37      // Fujitsu FR20
231
#define EM_RH32                 38      // TRW RH-32
232
#define EM_RCE                  39      // Motorola RCE
233
#define EM_ARM                  40      // Advanced RISC Machines ARM
234
#define EM_ALPHA                41      // Digital Alpha
235
#define EM_SH                   42      // Hitachi SH
236
#define EM_SPARCV9              43      // SPARC Version 9
237
#define EM_TRICORE              44      // Siemens Tricore embedded processor
238
#define EM_ARC                  45      // Argonaut RISC Core, Argonaut Technologies Inc.
239
#define EM_H8_300               46      // Hitachi H8/300
240
#define EM_H8_300H              47      // Hitachi H8/300H
241
#define EM_H8S                  48      // Hitachi H8S
242
#define EM_H8_500               49      // Hitachi H8/500
243
#define EM_IA_64                50      // Intel IA-64 processor architecture
244
#define EM_MIPS_X               51      // Stanford MIPS-X
245
#define EM_COLDFIRE             52      // Motorola ColdFire
246
#define EM_68HC12               53      // Motorola M68HC12
247
#define EM_MMA                  54      // Fujitsu MMA Multimedia Accelerator
248
#define EM_PCP                  55      // Siemens PCP
249
#define EM_NCPU                 56      // Sony nCPU embedded RISC processor
250
#define EM_NDR1                 57      // Denso NDR1 microprocessor
251
#define EM_STARCORE             58      // Motorola Star*Core processor
252
#define EM_ME16                 59      // Toyota ME16 processor
253
#define EM_ST100                60      // STMicroelectronics ST100 processor
254
#define EM_TINYJ                61      // Advanced Logic Corp. TinyJ embedded processor family
255
#define EM_FX66                 66      // Siemens FX66 microcontroller
256
#define EM_ST9PLUS              67      // STMicroelectronics ST9+ 8/16 bit microcontroller
257
#define EM_ST7                  68      // STMicroelectronics ST7 8-bit microcontroller
258
#define EM_68HC16               69      // Motorola MC68HC16 Microcontroller
259
#define EM_68HC11               70      // Motorola MC68HC11 Microcontroller
260
#define EM_68HC08               71      // Motorola MC68HC08 Microcontroller
261
#define EM_68HC05               72      // Motorola MC68HC05 Microcontroller
262
#define EM_SVX                  73      // Silicon Graphics SVx
263
#define EM_ST19                 74      // STMicroelectronics ST19 8-bit microcontroller
264
#define EM_VAX                  75      // Digital VAX
265
#define EM_CRIS                 76      // Axis Communications 32-bit embedded processor
266
#define EM_JAVELIN              77      // Infineon Technologies 32-bit embedded processor
267
#define EM_FIREPATH             78      // Element 14 64-bit DSP Processor
268
#define EM_ZSP                  79      // LSI Logic 16-bit DSP Processor
269
#define EM_MMIX                 80      // Donald Knuth's educational 64-bit processor
270
#define EM_HUANY                81      // Harvard University machine-independent object files
271
#define EM_PRISM                82      // SiTera Prism
272
 
273
/* Cygnus PowerPC ELF backend.  Written in the absence of an ABI.  */
274
#define EM_CYGNUS_POWERPC 0x9025
275
 
276
/* Old version of Sparc v9, from before the ABI; this should be
277
   removed shortly.  */
278
#define EM_OLD_SPARCV9  11
279
 
280
/* Old version of PowerPC, this should be removed shortly. */
281
#define EM_PPC_OLD      17
282
 
283
/* Cygnus ARC ELF backend.  Written in the absence of an ABI.  */
284
#define EM_CYGNUS_ARC 0x9040
285
 
286
/* Cygnus M32R ELF backend.  Written in the absence of an ABI.  */
287
#define EM_CYGNUS_M32R 0x9041
288
 
289
/* Alpha backend magic number.  Written in the absence of an ABI.  */
290
//#define EM_ALPHA        0x9026
291
 
292
/* D10V backend magic number.  Written in the absence of an ABI.  */
293
#define EM_CYGNUS_D10V  0x7650
294
 
295
/* D30V backend magic number.  Written in the absence of an ABI.  */
296
#define EM_CYGNUS_D30V  0x7676
297
 
298
/* V850 backend magic number.  Written in the absense of an ABI.  */
299
#define EM_CYGNUS_V850  0x9080
300
 
301
/* mn10200 and mn10300 backend magic numbers.
302
   Written in the absense of an ABI.  */
303
#define EM_CYGNUS_MN10200       0xdead
304
#define EM_CYGNUS_MN10300       0xbeef
305
 
306
/* FR30 magic number - no EABI available.  */
307
#define EM_CYGNUS_FR30          0x3330
308
 
309
/* AVR magic number
310
   Written in the absense of an ABI.  */
311
#define EM_AVR                  0x1057
312
 
313
// -------------------------------------------------------------------------
314
/* Version */
315
 
316
#define EV_NONE         0               /* Invalid */
317
#define EV_CURRENT      1               /* Current */
318
#define EV_NUM          2               /* number of versions */
319
 
320
// -------------------------------------------------------------------------
321
/* Section Header */
322
 
323
typedef struct {
324
    Elf32_Word  sh_name;        /* name - index into section header
325
                                   string table section */
326
    Elf32_Word  sh_type;        /* type */
327
    Elf32_Word  sh_flags;       /* flags */
328
    Elf32_Addr  sh_addr;        /* address */
329
    Elf32_Off   sh_offset;      /* file offset */
330
    Elf32_Word  sh_size;        /* section size */
331
    Elf32_Word  sh_link;        /* section header table index link */
332
    Elf32_Word  sh_info;        /* extra information */
333
    Elf32_Word  sh_addralign;   /* address alignment */
334
    Elf32_Word  sh_entsize;     /* section entry size */
335
} Elf32_Shdr;
336
 
337
typedef struct {
338
    Elf64_Word  sh_name;        /* section name */
339
    Elf64_Word  sh_type;        /* section type */
340
    Elf64_Xword sh_flags;       /* section flags */
341
    Elf64_Addr  sh_addr;        /* virtual address */
342
    Elf64_Off   sh_offset;      /* file offset */
343
    Elf64_Xword sh_size;        /* section size */
344
    Elf64_Word  sh_link;        /* link to another */
345
    Elf64_Word  sh_info;        /* misc info */
346
    Elf64_Xword sh_addralign;   /* memory alignment */
347
    Elf64_Xword sh_entsize;     /* table entry size */
348
} Elf64_Shdr;
349
 
350
// -------------------------------------------------------------------------
351
/* Special Section Indexes */
352
 
353
#define SHN_UNDEF       0               /* undefined */
354
#define SHN_LORESERVE   0xff00          /* lower bounds of reserved indexes */
355
#define SHN_LOPROC      0xff00          /* reserved range for processor */
356
#define SHN_HIPROC      0xff1f          /*   specific section indexes */
357
#define SHN_LOOS        0xff20          /* reserved range for operating */
358
#define SHN_HIOS        0xff3f          /*   system specific section indexes */
359
#define SHN_ABS         0xfff1          /* absolute value */
360
#define SHN_COMMON      0xfff2          /* common symbol */
361
#define SHN_XINDEX      0xffff          /* escape value for oversize index */
362
#define SHN_HIRESERVE   0xffff          /* upper bounds of reserved indexes */
363
 
364
// -------------------------------------------------------------------------
365
/* sh_type */
366
 
367
#define SHT_NULL        0               /* inactive */
368
#define SHT_PROGBITS    1               /* program defined information */
369
#define SHT_SYMTAB      2               /* symbol table section */
370
#define SHT_STRTAB      3               /* string table section */
371
#define SHT_RELA        4               /* relocation section with addends*/
372
#define SHT_HASH        5               /* symbol hash table section */
373
#define SHT_DYNAMIC     6               /* dynamic section */
374
#define SHT_NOTE        7               /* note section */
375
#define SHT_NOBITS      8               /* no space section */
376
#define SHT_REL         9               /* relation section without addends */
377
#define SHT_SHLIB       10              /* reserved - purpose unknown */
378
#define SHT_DYNSYM      11              /* dynamic symbol table section */
379
#define SHT_INIT_ARRAY  14              /* init procedure array */
380
#define SHT_FINI_ARRAY  15              /* fini procedure array */
381
#define SHT_PREINIT_ARRAY 16            /* preinit procedure array */
382
#define SHT_GROUP       17              /* section group */
383
#define SHT_SYMTAB_SHNDX 18             /* oversize index table */
384
#define SHT_NUM         19              /* number of section types */
385
#define SHT_LOOS        0x60000000      /* reserved range for O/S */
386
#define SHT_HIOS        0x6fffffff      /*  specific section header types */
387
#define SHT_LOPROC      0x70000000      /* reserved range for processor */
388
#define SHT_HIPROC      0x7fffffff      /*  specific section header types */
389
#define SHT_LOUSER      0x80000000      /* reserved range for application */
390
#define SHT_HIUSER      0xffffffff      /*  specific indexes */
391
 
392
// -------------------------------------------------------------------------
393
/* Section names */
394
 
395
#define ELF_BSS         ".bss"          /* uninitialized data */
396
#define ELF_DATA        ".data"         /* initialized data */
397
#define ELF_DEBUG       ".debug"        /* debug */
398
#define ELF_DYNAMIC     ".dynamic"      /* dynamic linking information */
399
#define ELF_DYNSTR      ".dynstr"       /* dynamic string table */
400
#define ELF_DYNSYM      ".dynsym"       /* dynamic symbol table */
401
#define ELF_FINI        ".fini"         /* termination code */
402
#define ELF_GOT         ".got"          /* global offset table */
403
#define ELF_HASH        ".hash"         /* symbol hash table */
404
#define ELF_INIT        ".init"         /* initialization code */
405
#define ELF_REL_DATA    ".rel.data"     /* relocation data */
406
#define ELF_REL_FINI    ".rel.fini"     /* relocation termination code */
407
#define ELF_REL_INIT    ".rel.init"     /* relocation initialization code */
408
#define ELF_REL_DYN     ".rel.dyn"      /* relocaltion dynamic link info */
409
#define ELF_REL_RODATA  ".rel.rodata"   /* relocation read-only data */
410
#define ELF_REL_TEXT    ".rel.text"     /* relocation code */
411
#define ELF_RODATA      ".rodata"       /* read-only data */
412
#define ELF_SHSTRTAB    ".shstrtab"     /* section header string table */
413
#define ELF_STRTAB      ".strtab"       /* string table */
414
#define ELF_SYMTAB      ".symtab"       /* symbol table */
415
#define ELF_TEXT        ".text"         /* code */
416
 
417
// -------------------------------------------------------------------------
418
/* Section Attribute Flags - sh_flags */
419
 
420
#define SHF_WRITE               0x001           /* Writable */
421
#define SHF_ALLOC               0x002           /* occupies memory */
422
#define SHF_EXECINSTR           0x004           /* executable */
423
#define SHF_MERGE               0x010           /* merge data */
424
#define SHF_STRINGS             0x020           /* contains strings */
425
#define SHF_INFO_LINK           0x040           /* link in sh_info field */
426
#define SHF_LINK_ORDER          0x080           /* preserve link order */
427
#define SHF_OS_NONCONFORMING    0x100           /* special OS-specific */
428
                                                /*  processing needed */
429
#define SHF_GROUP               0x200           /* member of group */
430
#define SHF_MASKOS              0x0ff00000      /* reserved bits for OS */
431
                                                /*  specific section attributes */
432
#define SHF_MASKPROC            0xf0000000      /* reserved bits for processor */
433
                                                /*  specific section attributes */
434
 
435
// -------------------------------------------------------------------------
436
/* Symbol Table Entry */
437
 
438
typedef struct {
439
    Elf32_Word          st_name;        /* name - index into string table */
440
    Elf32_Addr          st_value;       /* symbol value */
441
    Elf32_Word          st_size;        /* symbol size */
442
    unsigned char       st_info;        /* type and binding */
443
    unsigned char       st_other;       /* visibility */
444
    Elf32_Half          st_shndx;       /* section header index */
445
} Elf32_Sym;
446
 
447
typedef struct {
448
    Elf64_Word          st_name;        /* Symbol name index in str table */
449
    unsigned char       st_info;        /* type / binding attrs */
450
    unsigned char       st_other;       /* visibility */
451
    Elf64_Half          st_shndx;       /* section index of symbol */
452
    Elf64_Addr          st_value;       /* value of symbol */
453
    Elf64_Xword          st_size;        /* size of symbol */
454
} Elf64_Sym;
455
 
456
// -------------------------------------------------------------------------
457
/* Symbol table index */
458
 
459
#define STN_UNDEF       0               /* undefined */
460
 
461
/* Extract symbol info - st_info */
462
#define ELF32_ST_BIND(x)        ((x) >> 4)
463
#define ELF32_ST_TYPE(x)        (((unsigned int) x) & 0xf)
464
#define ELF32_ST_INFO(b,t)      (((b) << 4) + ((t) & 0xf))
465
 
466
#define ELF64_ST_BIND(x)        ((x) >> 4)
467
#define ELF64_ST_TYPE(x)        (((unsigned int) x) & 0xf)
468
#define ELF64_ST_INFO(b,t)      (((b) << 4) + ((t) & 0xf))
469
 
470
#define ELF32_ST_VISIBILITY(o)  ((o)&0x3)
471
#define ELF64_ST_VISIBILITY(o)  ((o)&0x3)
472
 
473
// -------------------------------------------------------------------------
474
/* Symbol Binding - ELF32_ST_BIND - st_info */
475
 
476
#define STB_LOCAL       0               /* Local symbol */
477
#define STB_GLOBAL      1               /* Global symbol */
478
#define STB_WEAK        2               /* like global - lower precedence */
479
#define STB_NUM         3               /* number of symbol bindings */
480
#define STB_LOOS        10              /* reserved range for OS */
481
#define STB_HIOS        12              /*  specific symbol bindings */
482
#define STB_LOPROC      13              /* reserved range for processor */
483
#define STB_HIPROC      15              /*  specific symbol bindings */
484
 
485
// -------------------------------------------------------------------------
486
/* Symbol type - ELF32_ST_TYPE - st_info */
487
 
488
#define STT_NOTYPE      0               /* not specified */
489
#define STT_OBJECT      1               /* data object */
490
#define STT_FUNC        2               /* function */
491
#define STT_SECTION     3               /* section */
492
#define STT_FILE        4               /* file */
493
#define STT_COMMON      5               /* common block */
494
#define STT_NUM         6               /* number of symbol types */
495
#define STT_LOOS        10              /* reserved range for OS */
496
#define STT_HIOS        12              /*  specific symbol types */
497
#define STT_LOPROC      13              /* reserved range for processor */
498
#define STT_HIPROC      15              /*  specific symbol types */
499
 
500
// -------------------------------------------------------------------------
501
// symbol visibility in st_other
502
 
503
#define STV_DEFAULT     0               /* default to binding type */
504
#define STV_INTERNAL    1               /* processor specific */
505
#define STV_HIDDEN      2               /* invisible */
506
#define STV_PROTECTED   3               /* non-premptable */
507
 
508
// -------------------------------------------------------------------------
509
// 32 bit relocation records
510
 
511
/* Relocation entry with implicit addend */
512
typedef struct
513
{
514
        Elf32_Addr      r_offset;       /* offset of relocation */
515
        Elf32_Word      r_info;         /* symbol table index and type */
516
} Elf32_Rel;
517
 
518
/* Relocation entry with explicit addend */
519
typedef struct
520
{
521
        Elf32_Addr      r_offset;       /* offset of relocation */
522
        Elf32_Word      r_info;         /* symbol table index and type */
523
        Elf32_Sword     r_addend;
524
} Elf32_Rela;
525
 
526
/* Extract relocation info - r_info */
527
#define ELF32_R_SYM(i)          ((i) >> 8)
528
#define ELF32_R_TYPE(i)         ((unsigned char) (i))
529
#define ELF32_R_INFO(s,t)       (((s) << 8) + (unsigned char)(t))
530
 
531
// -------------------------------------------------------------------------
532
// 64 bit equivalents of above structures and macros.
533
 
534
typedef struct {
535
        Elf64_Addr      r_offset;       /* where to do it */
536
        Elf64_Xword     r_info;         /* index & type of relocation */
537
} Elf64_Rel;
538
 
539
typedef struct {
540
        Elf64_Addr      r_offset;       /* where to do it */
541
        Elf64_Xword     r_info;         /* index & type of relocation */
542
        Elf64_Sxword    r_addend;       /* adjustment value */
543
} Elf64_RelA;
544
 
545
#define ELF64_R_SYM(info)       ((info) >> 32)
546
#define ELF64_R_TYPE(info)      ((info) & 0xFFFFFFFF)
547
#define ELF64_R_INFO(s,t)       (((s) << 32) + (u_int32_t)(t))
548
 
549
// -------------------------------------------------------------------------
550
/* Program Header */
551
 
552
typedef struct {
553
    Elf32_Word  p_type;         /* segment type */
554
    Elf32_Off   p_offset;       /* segment offset */
555
    Elf32_Addr  p_vaddr;        /* virtual address of segment */
556
    Elf32_Addr  p_paddr;        /* physical address - ignored? */
557
    Elf32_Word  p_filesz;       /* number of bytes in file for seg. */
558
    Elf32_Word  p_memsz;        /* number of bytes in mem. for seg. */
559
    Elf32_Word  p_flags;        /* flags */
560
    Elf32_Word  p_align;        /* memory alignment */
561
} Elf32_Phdr;
562
 
563
typedef struct {
564
    Elf64_Word  p_type;         /* entry type */
565
    Elf64_Word  p_flags;        /* flags */
566
    Elf64_Off   p_offset;       /* offset */
567
    Elf64_Addr  p_vaddr;        /* virtual address */
568
    Elf64_Addr  p_paddr;        /* physical address */
569
    Elf64_Xword p_filesz;       /* file size */
570
    Elf64_Xword p_memsz;        /* memory size */
571
    Elf64_Xword p_align;        /* memory & file alignment */
572
} Elf64_Phdr;
573
 
574
// -------------------------------------------------------------------------
575
/* Segment types - p_type */
576
 
577
#define PT_NULL         0               /* unused */
578
#define PT_LOAD         1               /* loadable segment */
579
#define PT_DYNAMIC      2               /* dynamic linking section */
580
#define PT_INTERP       3               /* the RTLD */
581
#define PT_NOTE         4               /* auxiliary information */
582
#define PT_SHLIB        5               /* reserved - purpose undefined */
583
#define PT_PHDR         6               /* program header */
584
#define PT_NUM          7               /* Number of segment types */
585
#define PT_LOOS         0x60000000      /* reserved range for OS */
586
#define PT_HIOS         0x6fffffff      /*  specific segment types */
587
#define PT_LOPROC       0x70000000      /* reserved range for processor */
588
#define PT_HIPROC       0x7fffffff      /*  specific segment types */
589
 
590
// -------------------------------------------------------------------------
591
/* Segment flags - p_flags */
592
 
593
#define PF_X            0x1             /* Executable */
594
#define PF_W            0x2             /* Writable */
595
#define PF_R            0x4             /* Readable */
596
#define PF_MASKOS       0x0ff00000      /* reserved bits for OS */
597
                                        /*  specific segment flags */
598
#define PF_MASKPROC     0xf0000000      /* reserved bits for processor */
599
                                        /*  specific segment flags */
600
 
601
// -------------------------------------------------------------------------
602
/* Dynamic structure */
603
 
604
typedef struct {
605
    Elf32_Sword         d_tag;  /* controls meaning of d_val */
606
    union {
607
        Elf32_Word      d_val;  /* Multiple meanings - see d_tag */
608
        Elf32_Addr      d_ptr;  /* program virtual address */
609
    } d_un;
610
} Elf32_Dyn;
611
 
612
extern Elf32_Dyn        _DYNAMIC[];     /* XXX not 64-bit clean */
613
 
614
typedef struct {
615
    Elf64_Sxword        d_tag;  /* controls meaning of d_val */
616
    union {
617
        Elf64_Xword     d_val;
618
        Elf64_Addr      d_ptr;
619
    } d_un;
620
} Elf64_Dyn;
621
 
622
// -------------------------------------------------------------------------
623
/* Dynamic Array Tags - d_tag */
624
 
625
#define DT_NULL         0               /* marks end of _DYNAMIC array */
626
#define DT_NEEDED       1               /* string table offset of needed lib */
627
#define DT_PLTRELSZ     2               /* size of relocation entries in PLT */
628
#define DT_PLTGOT       3               /* address PLT/GOT */
629
#define DT_HASH         4               /* address of symbol hash table */
630
#define DT_STRTAB       5               /* address of string table */
631
#define DT_SYMTAB       6               /* address of symbol table */
632
#define DT_RELA         7               /* address of relocation table */
633
#define DT_RELASZ       8               /* size of relocation table */
634
#define DT_RELAENT      9               /* size of relocation entry */
635
#define DT_STRSZ        10              /* size of string table */
636
#define DT_SYMENT       11              /* size of symbol table entry */
637
#define DT_INIT         12              /* address of initialization func. */
638
#define DT_FINI         13              /* address of termination function */
639
#define DT_SONAME       14              /* string table offset of shared obj */
640
#define DT_RPATH        15              /* string table offset of library
641
                                           search path */
642
#define DT_SYMBOLIC     16              /* start sym search in shared obj. */
643
#define DT_REL          17              /* address of rel. tbl. w addends */
644
#define DT_RELSZ        18              /* size of DT_REL relocation table */
645
#define DT_RELENT       19              /* size of DT_REL relocation entry */
646
#define DT_PLTREL       20              /* PLT referenced relocation entry */
647
#define DT_DEBUG        21              /* bugger */
648
#define DT_TEXTREL      22              /* Allow rel. mod. to unwritable seg */
649
#define DT_JMPREL       23              /* add. of PLT's relocation entries */
650
#define DT_BIND_NOW     24              /* Bind now regardless of env setting */
651
#define DT_INIT_ARRAY   25              /* init array address */
652
#define DT_FINI_ARRAY   26              /* fini array address */
653
#define DT_INIT_ARRAYSZ 27              /* init array size */
654
#define DT_FINI_ARRAYSZ 28              /* fini array size */
655
#define DT_RUNPATH      29              /* library search path */
656
#define DT_FLAGS        30              /* flags */
657
#define DT_ENCODING     32              /* encoding rules start here */
658
#define DT_PREINIT_ARRAY 32             /* preinit array address */
659
#define DT_PREINIT_ARRAYSZ 33           /* preinit array size */
660
#define DT_NUM          26              /* Number used. */
661
#define DT_LOOS         0x60000000      /* reserved range for OS */
662
#define DT_HIOS         0x6fffffff      /*  specific dynamic array tags */
663
#define DT_LOPROC       0x70000000      /* reserved range for processor */
664
#define DT_HIPROC       0x7fffffff      /*  specific dynamic array tags */
665
 
666
// -------------------------------------------------------------------------
667
// Values for DT_FLAGS entry
668
 
669
#define DF_ORIGIN       0x1             /* Uses $ORIGIN substitution string */
670
#define DF_SYMBOLIC     0x2             /* search for symbols here first */
671
#define DF_TEXTREL      0x4             /* text may be relocatable */
672
#define DF_BIND_NOW     0x8             /* bind references now, dammit */
673
 
674
// -------------------------------------------------------------------------
675
/* Note Definitions */
676
 
677
typedef struct {
678
    Elf32_Word namesz;
679
    Elf32_Word descsz;
680
    Elf32_Word type;
681
} Elf32_Note;
682
 
683
typedef struct {
684
    Elf64_Word namesz;
685
    Elf64_Word descsz;
686
    Elf64_Word type;
687
} Elf64_Note;
688
 
689
// -------------------------------------------------------------------------
690
// Hash table structure
691
// The same structure is used by both 32 and 64 bit formats
692
 
693
typedef struct {
694
    Elf32_Word          nbucket;        /* number of buckets */
695
    Elf32_Word          nchain;         /* number of chains */
696
 
697
    /* The buckets follow this structure in memory and the chains
698
       follow those. */
699
} Elf_Hash;
700
 
701
// -------------------------------------------------------------------------
702
#endif // ifndef CYGONCE_REDBOOT_ELF_H
703
// EOF elf.h

powered by: WebSVN 2.1.0

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