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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [services/] [loader/] [current/] [include/] [i386_elf.h] - Blame information for rev 819

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

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_LOADER_I386_ELF_H
2
#define CYGONCE_LOADER_I386_ELF_H
3
 
4
//==========================================================================
5
//
6
//      i386_elf.h
7
//
8
//      I386 specific ELF file format support
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-20
48
// Purpose:      Define I386 ELF support
49
// Description:  This file contains definitions for configuring the dynamic
50
//               loader to deal with the I386 specific parts of the ELF
51
//               file format.
52
//              
53
// Usage:
54
//              #include <cyg/loader/i386_elf.h>
55
//              ...
56
//              
57
//
58
//####DESCRIPTIONEND####
59
//
60
//==========================================================================
61
 
62
#include <pkgconf/system.h>
63
#include <pkgconf/hal.h>
64
 
65
#if defined(CYGPKG_HAL_I386)
66
 
67
#ifndef CYG_LOADER_DYNAMIC_LD
68
 
69
#include <cyg/infra/cyg_type.h>
70
 
71
//--------------------------------------------------------------------------
72
// Basic definitions
73
 
74
#define CYG_ELF_MACHINE     EM_386
75
 
76
//--------------------------------------------------------------------------
77
// Relocation types
78
// Taken from bfd/include/elf/i386.h - not currently sure which of these
79
// are actually used in executables.
80
 
81
#define R_386_NONE              0       /* No reloc */
82
#define R_386_32                1       /* Direct 32 bit  */
83
#define R_386_PC32              2       /* PC relative 32 bit */
84
#define R_386_GOT32             3       /* 32 bit GOT entry */
85
#define R_386_PLT32             4       /* 32 bit PLT address */
86
#define R_386_COPY              5       /* Copy symbol at runtime */
87
#define R_386_GLOB_DAT          6       /* Create GOT entry */
88
#define R_386_JUMP_SLOT         7       /* Create PLT entry */
89
#define R_386_RELATIVE          8       /* Adjust by program base */
90
#define R_386_GOTOFF            9       /* 32 bit offset to GOT */
91
#define R_386_GOTPC             10      /* 32 bit PC relative offset to GOT */
92
#define R_386_16                20
93
#define R_386_PC16              21
94
#define R_386_8                 22
95
#define R_386_PC8               23
96
#define R_386_max               24
97
     /* These are GNU extensions to enable C++ vtable garbage collection.  */
98
#define R_386_GNU_VTINHERIT     250
99
#define R_386_GNU_VTENTRY       251
100
 
101
//--------------------------------------------------------------------------
102
// Processor specific customization class for Cyg_LoadObject class.
103
 
104
#ifdef __cplusplus
105
 
106
class Cyg_LoadObject_Proc :
107
      public Cyg_LoadObject_Base
108
{
109
 public:
110
 
111
    inline Cyg_LoadObject_Proc()
112
        : Cyg_LoadObject_Base()
113
        {
114
        };
115
 
116
    inline Cyg_LoadObject_Proc( Cyg_LoaderStream& stream,
117
                    cyg_uint32 mode,
118
                    Cyg_LoaderMemAlloc *mem )
119
        : Cyg_LoadObject_Base( stream, mode, mem )
120
        {
121
        };
122
 
123
    inline ~Cyg_LoadObject_Proc() {};
124
 
125
    cyg_code apply_rel( unsigned char type, Elf32_Word sym, Elf32_Addr offset );
126
 
127
    cyg_code apply_rela( unsigned char type, Elf32_Word sym,
128
                         Elf32_Addr offset, Elf32_Sword addend );
129
};
130
 
131
//--------------------------------------------------------------------------
132
 
133
inline cyg_code Cyg_LoadObject_Proc::apply_rel( unsigned char type,
134
                                                Elf32_Word sym,
135
                                                Elf32_Addr offset )
136
{
137
    CYG_ADDRESS addr = (CYG_ADDRESS)(offset + base);
138
    CYG_ADDRESS saddr = CYG_LOADER_NULLSYMADDR;
139
 
140
    switch( type )
141
    {
142
 
143
    case R_386_32:                          /* Direct 32 bit  */
144
        saddr = get_sym_addr_from_ix(sym);
145
        if( saddr == CYG_LOADER_NULLSYMADDR )
146
            return CYG_LOADERR_NO_SYMBOL;
147
        *(CYG_WORD32 *)addr += saddr;
148
        break;
149
 
150
    case R_386_PC32:                        /* PC relative 32 bit */
151
        saddr = get_sym_addr_from_ix(sym);
152
        if( saddr == CYG_LOADER_NULLSYMADDR )
153
            return CYG_LOADERR_NO_SYMBOL;
154
        *(CYG_WORD32 *)addr += saddr;
155
        *(CYG_WORD32 *)addr -= (CYG_WORD32)addr;
156
        break;
157
 
158
    case R_386_GOT32:                       /* 32 bit GOT entry */
159
    case R_386_PLT32:                       /* 32 bit PLT address */
160
    case R_386_COPY:                        /* Copy symbol at runtime */
161
    case R_386_GLOB_DAT:                    /* Create GOT entry */
162
    case R_386_JUMP_SLOT:                   /* Create PLT entry */
163
        return CYG_LOADERR_INVALID_RELOC;
164
 
165
    case R_386_RELATIVE:                    /* Adjust by program base */
166
        *(CYG_WORD32 *)addr += base;
167
        break;
168
 
169
    case R_386_GOTOFF:                      /* 32 bit offset to GOT */
170
    case R_386_GOTPC:                       /* 32 bit PC relative offset to GOT */
171
    case R_386_16:
172
    case R_386_PC16:
173
    case R_386_8:
174
    case R_386_PC8:
175
    default:
176
        return CYG_LOADERR_INVALID_RELOC;
177
    }
178
    return 0;
179
}
180
 
181
inline cyg_code Cyg_LoadObject_Proc::apply_rela( unsigned char type,
182
                                                 Elf32_Word sym,
183
                                                 Elf32_Addr offset,
184
                                                 Elf32_Sword addend )
185
{
186
    // No RELA relocs in i386
187
    return CYG_LOADERR_INVALID_RELOC;
188
}
189
 
190
//--------------------------------------------------------------------------
191
 
192
#endif // __cplusplus
193
 
194
#else // CYG_LOADER_DYNAMIC_LD
195
 
196
//--------------------------------------------------------------------------
197
 
198
#define CYG_LOADER_DYNAMIC_PREFIX                                               \
199
        OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")     \
200
        OUTPUT_ARCH("i386")
201
 
202
/* Adjust the address for the data segment.  We want to adjust up to
203
   the same address within the page on the next page up.  */
204
#define CYG_LOADER_DYNAMIC_DATA_ALIGN                   \
205
        . = ALIGN(0x1000) + (. & (0x1000 - 1));
206
 
207
//--------------------------------------------------------------------------
208
 
209
#endif // CYG_LOADER_DYNAMIC_LD
210
 
211
#endif // defined(CYGPKG_HAL_I386) && __cplusplus
212
 
213
//--------------------------------------------------------------------------
214
#endif // ifndef CYGONCE_LOADER_I386_ELF_H
215
// End of i386_elf.h

powered by: WebSVN 2.1.0

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