1 |
1254 |
phoenix |
#ifndef CYGONCE_LOADER_PPC_ELF_H
|
2 |
|
|
#define CYGONCE_LOADER_PPC_ELF_H
|
3 |
|
|
|
4 |
|
|
//==========================================================================
|
5 |
|
|
//
|
6 |
|
|
// ppc_elf.h
|
7 |
|
|
//
|
8 |
|
|
// PowerPC 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 Red Hat, 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 version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
21 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License along
|
26 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
30 |
|
|
// or inline functions from this file, or you compile this file and link it
|
31 |
|
|
// with other works to produce a work based on this file, this file does not
|
32 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
33 |
|
|
// License. However the source code for this file must still be made available
|
34 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
37 |
|
|
// this file might be covered by the GNU General Public License.
|
38 |
|
|
//
|
39 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
40 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
41 |
|
|
// -------------------------------------------
|
42 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
43 |
|
|
//==========================================================================
|
44 |
|
|
//#####DESCRIPTIONBEGIN####
|
45 |
|
|
//
|
46 |
|
|
// Author(s): nickg
|
47 |
|
|
// Contributors: nickg
|
48 |
|
|
// Date: 2000-11-20
|
49 |
|
|
// Purpose: Define PowerPC ELF support
|
50 |
|
|
// Description: This file contains definitions for configuring the dynamic
|
51 |
|
|
// loader to deal with the PowerPC specific parts of the ELF
|
52 |
|
|
// file format.
|
53 |
|
|
//
|
54 |
|
|
// Usage:
|
55 |
|
|
// #include <cyg/loader/ppc_elf.h>
|
56 |
|
|
// ...
|
57 |
|
|
//
|
58 |
|
|
//
|
59 |
|
|
//####DESCRIPTIONEND####
|
60 |
|
|
//
|
61 |
|
|
//==========================================================================
|
62 |
|
|
|
63 |
|
|
#include <pkgconf/system.h>
|
64 |
|
|
#include <pkgconf/hal.h>
|
65 |
|
|
|
66 |
|
|
#if defined(CYGPKG_HAL_POWERPC)
|
67 |
|
|
|
68 |
|
|
#ifndef CYG_LOADER_DYNAMIC_LD
|
69 |
|
|
|
70 |
|
|
#include <cyg/infra/cyg_type.h>
|
71 |
|
|
|
72 |
|
|
//--------------------------------------------------------------------------
|
73 |
|
|
// Basic definitions
|
74 |
|
|
|
75 |
|
|
#define CYG_ELF_MACHINE EM_PPC
|
76 |
|
|
|
77 |
|
|
//--------------------------------------------------------------------------
|
78 |
|
|
// Relocation types
|
79 |
|
|
// Taken from binutils/include/elf/ppc.h - not currently sure which
|
80 |
|
|
// of these are actually used in executables.
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
#define R_PPC_NONE 0
|
84 |
|
|
#define R_PPC_ADDR32 1
|
85 |
|
|
#define R_PPC_ADDR24 2
|
86 |
|
|
#define R_PPC_ADDR16 3
|
87 |
|
|
#define R_PPC_ADDR16_LO 4
|
88 |
|
|
#define R_PPC_ADDR16_HI 5
|
89 |
|
|
#define R_PPC_ADDR16_HA 6
|
90 |
|
|
#define R_PPC_ADDR14 7
|
91 |
|
|
#define R_PPC_ADDR14_BRTAKEN 8
|
92 |
|
|
#define R_PPC_ADDR14_BRNTAKEN 9
|
93 |
|
|
#define R_PPC_REL24 10
|
94 |
|
|
#define R_PPC_REL14 11
|
95 |
|
|
#define R_PPC_REL14_BRTAKEN 12
|
96 |
|
|
#define R_PPC_REL14_BRNTAKEN 13
|
97 |
|
|
#define R_PPC_GOT16 14
|
98 |
|
|
#define R_PPC_GOT16_LO 15
|
99 |
|
|
#define R_PPC_GOT16_HI 16
|
100 |
|
|
#define R_PPC_GOT16_HA 17
|
101 |
|
|
#define R_PPC_PLTREL24 18
|
102 |
|
|
#define R_PPC_COPY 19
|
103 |
|
|
#define R_PPC_GLOB_DAT 20
|
104 |
|
|
#define R_PPC_JMP_SLOT 21
|
105 |
|
|
#define R_PPC_RELATIVE 22
|
106 |
|
|
#define R_PPC_LOCAL24PC 23
|
107 |
|
|
#define R_PPC_UADDR32 24
|
108 |
|
|
#define R_PPC_UADDR16 25
|
109 |
|
|
#define R_PPC_REL32 26
|
110 |
|
|
#define R_PPC_PLT32 27
|
111 |
|
|
#define R_PPC_PLTREL32 28
|
112 |
|
|
#define R_PPC_PLT16_LO 29
|
113 |
|
|
#define R_PPC_PLT16_HI 30
|
114 |
|
|
#define R_PPC_PLT16_HA 31
|
115 |
|
|
#define R_PPC_SDAREL16 32
|
116 |
|
|
#define R_PPC_SECTOFF 33
|
117 |
|
|
#define R_PPC_SECTOFF_LO 34
|
118 |
|
|
#define R_PPC_SECTOFF_HI 35
|
119 |
|
|
#define R_PPC_SECTOFF_HA 36
|
120 |
|
|
|
121 |
|
|
/* The remaining relocs are from the Embedded ELF ABI, and are not
|
122 |
|
|
in the SVR4 ELF ABI. */
|
123 |
|
|
#define R_PPC_EMB_NADDR32 101
|
124 |
|
|
#define R_PPC_EMB_NADDR16 102
|
125 |
|
|
#define R_PPC_EMB_NADDR16_LO 103
|
126 |
|
|
#define R_PPC_EMB_NADDR16_HI 104
|
127 |
|
|
#define R_PPC_EMB_NADDR16_HA 105
|
128 |
|
|
#define R_PPC_EMB_SDAI16 106
|
129 |
|
|
#define R_PPC_EMB_SDA2I16 107
|
130 |
|
|
#define R_PPC_EMB_SDA2REL 108
|
131 |
|
|
#define R_PPC_EMB_SDA21 109
|
132 |
|
|
#define R_PPC_EMB_MRKREF 110
|
133 |
|
|
#define R_PPC_EMB_RELSEC16 111
|
134 |
|
|
#define R_PPC_EMB_RELST_LO 112
|
135 |
|
|
#define R_PPC_EMB_RELST_HI 113
|
136 |
|
|
#define R_PPC_EMB_RELST_HA 114
|
137 |
|
|
#define R_PPC_EMB_BIT_FLD 115
|
138 |
|
|
#define R_PPC_EMB_RELSDA 116
|
139 |
|
|
|
140 |
|
|
/* These are GNU extensions to enable C++ vtable garbage collection. */
|
141 |
|
|
#define R_PPC_GNU_VTINHERIT 253
|
142 |
|
|
#define R_PPC_GNU_VTENTRY 254
|
143 |
|
|
|
144 |
|
|
/* This is a phony reloc to handle any old fashioned TOC16 references
|
145 |
|
|
that may still be in object files. */
|
146 |
|
|
#define R_PPC_TOC16 255
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
//--------------------------------------------------------------------------
|
150 |
|
|
// Processor specific customization class for Cyg_LoadObject class.
|
151 |
|
|
|
152 |
|
|
#ifdef __cplusplus
|
153 |
|
|
|
154 |
|
|
class Cyg_LoadObject_Proc :
|
155 |
|
|
public Cyg_LoadObject_Base
|
156 |
|
|
{
|
157 |
|
|
public:
|
158 |
|
|
|
159 |
|
|
inline Cyg_LoadObject_Proc()
|
160 |
|
|
: Cyg_LoadObject_Base()
|
161 |
|
|
{
|
162 |
|
|
};
|
163 |
|
|
|
164 |
|
|
inline Cyg_LoadObject_Proc( Cyg_LoaderStream& stream,
|
165 |
|
|
cyg_uint32 mode,
|
166 |
|
|
Cyg_LoaderMemAlloc *mem )
|
167 |
|
|
: Cyg_LoadObject_Base( stream, mode, mem )
|
168 |
|
|
{
|
169 |
|
|
};
|
170 |
|
|
|
171 |
|
|
inline ~Cyg_LoadObject_Proc() {};
|
172 |
|
|
|
173 |
|
|
cyg_code apply_rel( unsigned char type, Elf32_Word sym, Elf32_Addr offset );
|
174 |
|
|
|
175 |
|
|
cyg_code apply_rela( unsigned char type, Elf32_Word sym,
|
176 |
|
|
Elf32_Addr offset, Elf32_Sword addend );
|
177 |
|
|
};
|
178 |
|
|
|
179 |
|
|
//--------------------------------------------------------------------------
|
180 |
|
|
|
181 |
|
|
inline cyg_code Cyg_LoadObject_Proc::apply_rel( unsigned char type,
|
182 |
|
|
Elf32_Word sym,
|
183 |
|
|
Elf32_Addr offset )
|
184 |
|
|
{
|
185 |
|
|
return 0;
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
inline cyg_code Cyg_LoadObject_Proc::apply_rela( unsigned char type,
|
189 |
|
|
Elf32_Word sym,
|
190 |
|
|
Elf32_Addr offset,
|
191 |
|
|
Elf32_Sword addend )
|
192 |
|
|
{
|
193 |
|
|
return 0; // CYG_LOADERR_INVALID_RELOC;
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
//--------------------------------------------------------------------------
|
197 |
|
|
|
198 |
|
|
externC void abort() CYGBLD_ATTRIB_WEAK;
|
199 |
|
|
|
200 |
|
|
externC void abort() { for(;;); }
|
201 |
|
|
|
202 |
|
|
externC int strcmp(const char *a, const char *b) CYGBLD_ATTRIB_WEAK;
|
203 |
|
|
|
204 |
|
|
externC int strcmp(const char *a, const char *b) { return a==b; }
|
205 |
|
|
|
206 |
|
|
externC unsigned int strlen(const char *a) CYGBLD_ATTRIB_WEAK;
|
207 |
|
|
|
208 |
|
|
externC unsigned int strlen(const char *a) { return 1; }
|
209 |
|
|
|
210 |
|
|
//--------------------------------------------------------------------------
|
211 |
|
|
|
212 |
|
|
#endif // __cplusplus
|
213 |
|
|
|
214 |
|
|
#else // CYG_LOADER_DYNAMIC_LD
|
215 |
|
|
|
216 |
|
|
//--------------------------------------------------------------------------
|
217 |
|
|
|
218 |
|
|
#define CYG_LOADER_DYNAMIC_PREFIX \
|
219 |
|
|
OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") \
|
220 |
|
|
OUTPUT_ARCH("powerpc")
|
221 |
|
|
|
222 |
|
|
/* Adjust the address for the data segment. We want to adjust up to
|
223 |
|
|
the same address within the page on the next page up. */
|
224 |
|
|
#define CYG_LOADER_DYNAMIC_DATA_ALIGN \
|
225 |
|
|
. = ALIGN(0x1000) + (. & (0x1000 - 1));
|
226 |
|
|
|
227 |
|
|
//--------------------------------------------------------------------------
|
228 |
|
|
|
229 |
|
|
#endif // CYG_LOADER_DYNAMIC_LD
|
230 |
|
|
|
231 |
|
|
#endif // defined(CYGPKG_HAL_POWERPC) && __cplusplus
|
232 |
|
|
|
233 |
|
|
//--------------------------------------------------------------------------
|
234 |
|
|
#endif // ifndef CYGONCE_LOADER_PPC_ELF_H
|
235 |
|
|
// End of ppc_elf.h
|