diff options
-rw-r--r-- | README | 17 | ||||
-rw-r--r-- | modutils/insmod.c | 156 |
2 files changed, 91 insertions, 82 deletions
@@ -33,23 +33,24 @@ Supported architectures: | |||
33 | 33 | ||
34 | BusyBox in general will build on any architecture supported by gcc. It has | 34 | BusyBox in general will build on any architecture supported by gcc. It has |
35 | a few specialized features added for __sparc__ and __alpha__. insmod | 35 | a few specialized features added for __sparc__ and __alpha__. insmod |
36 | functionality is currently limited to x86, ARM, SH3/4, powerpc, m68k, | 36 | functionality is currently limited to ARM, CRIS, H8/300, x86, ia64, |
37 | MIPS, cris, and v850e. | 37 | x86_64, m68k, MIPS, PowerPC, S390, SH3/4/5, Sparc, v850e, and x86_64 |
38 | for 2.4.x kernels. For 2.6.x kernels | ||
38 | 39 | ||
39 | Supported C Libraries: | 40 | Supported C Libraries: |
40 | 41 | ||
41 | glibc-2.0.x, glibc-2.1.x, glibc-2.2.x, glibc-2.3.x, uClibc. People | 42 | uClibc and glibc are supported. People have been looking at newlib and |
42 | are looking at newlib and diet-libc, but consider them unsupported, | 43 | diet-libc, but they are currently considered unsupported, untested, or |
43 | untested, or worse. Linux-libc5 is no longer supported -- you | 44 | worse. Linux-libc5 is no longer supported -- you should probably use uClibc |
44 | should probably use uClibc instead if you want a small C library. | 45 | instead if you want a small C library. |
45 | 46 | ||
46 | Supported kernels: | 47 | Supported kernels: |
47 | 48 | ||
48 | Full functionality requires Linux 2.2.x or better. A large fraction of the | 49 | Full functionality requires Linux 2.2.x or better. A large fraction of the |
49 | code should run on just about anything. While the current code is fairly | 50 | code should run on just about anything. While the current code is fairly |
50 | Linux specific, it should be fairly easy to port the majority of the code | 51 | Linux specific, it should be fairly easy to port the majority of the code |
51 | to, say, FreeBSD or Solaris, or Mac OS X, or even Windows (if you are into | 52 | to support, say, FreeBSD or Solaris, or Mac OS X, or even Windows (if you |
52 | that sort of thing). | 53 | are into that sort of thing). |
53 | 54 | ||
54 | ---------------- | 55 | ---------------- |
55 | 56 | ||
diff --git a/modutils/insmod.c b/modutils/insmod.c index 55a3e49be..d88dd1be6 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c | |||
@@ -2,8 +2,8 @@ | |||
2 | /* | 2 | /* |
3 | * Mini insmod implementation for busybox | 3 | * Mini insmod implementation for busybox |
4 | * | 4 | * |
5 | * This version of insmod supports x86, x86_64, ARM, SH3/4/5, powerpc, m68k, | 5 | * This version of insmod supports ARM, CRIS, H8/300, x86, ia64, x86_64, |
6 | * MIPS, v850e, and H8/300. | 6 | * m68k, MIPS, PowerPC, S390, SH3/4/5, Sparc, v850e, and x86_64. |
7 | * | 7 | * |
8 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> | 8 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> |
9 | * and Ron Alder <alder@lineo.com> | 9 | * and Ron Alder <alder@lineo.com> |
@@ -109,67 +109,82 @@ extern int insmod_ng_main( int argc, char **argv); | |||
109 | #endif | 109 | #endif |
110 | 110 | ||
111 | 111 | ||
112 | /* ARM support */ | ||
112 | #if defined(__arm__) | 113 | #if defined(__arm__) |
113 | #define CONFIG_USE_PLT_ENTRIES | ||
114 | #define CONFIG_PLT_ENTRY_SIZE 8 | ||
115 | #define CONFIG_USE_GOT_ENTRIES | ||
116 | #define CONFIG_GOT_ENTRY_SIZE 8 | ||
117 | #define CONFIG_USE_SINGLE | ||
118 | |||
119 | #define MATCH_MACHINE(x) (x == EM_ARM) | 114 | #define MATCH_MACHINE(x) (x == EM_ARM) |
120 | #define SHT_RELM SHT_REL | 115 | #define SHT_RELM SHT_REL |
121 | #define Elf32_RelM Elf32_Rel | 116 | #define Elf32_RelM Elf32_Rel |
122 | #define ELFCLASSM ELFCLASS32 | 117 | #define ELFCLASSM ELFCLASS32 |
123 | #endif | ||
124 | |||
125 | #if defined(__s390__) | ||
126 | #define CONFIG_USE_PLT_ENTRIES | 118 | #define CONFIG_USE_PLT_ENTRIES |
127 | #define CONFIG_PLT_ENTRY_SIZE 8 | 119 | #define CONFIG_PLT_ENTRY_SIZE 8 |
128 | #define CONFIG_USE_GOT_ENTRIES | 120 | #define CONFIG_USE_GOT_ENTRIES |
129 | #define CONFIG_GOT_ENTRY_SIZE 8 | 121 | #define CONFIG_GOT_ENTRY_SIZE 8 |
130 | #define CONFIG_USE_SINGLE | 122 | #define CONFIG_USE_SINGLE |
123 | #endif | ||
131 | 124 | ||
132 | #define MATCH_MACHINE(x) (x == EM_S390) | 125 | /* CRIS */ |
126 | #if defined(__cris__) | ||
127 | #define MATCH_MACHINE(x) (x == EM_CRIS) | ||
133 | #define SHT_RELM SHT_RELA | 128 | #define SHT_RELM SHT_RELA |
134 | #define Elf32_RelM Elf32_Rela | 129 | #define Elf32_RelM Elf32_Rela |
135 | #define ELFCLASSM ELFCLASS32 | 130 | #define ELFCLASSM ELFCLASS32 |
131 | #ifndef EM_CRIS | ||
132 | #define EM_CRIS 76 | ||
133 | #define R_CRIS_NONE 0 | ||
134 | #define R_CRIS_32 3 | ||
135 | #endif | ||
136 | #endif | 136 | #endif |
137 | 137 | ||
138 | #if defined(__i386__) | 138 | /* H8/300 */ |
139 | #define CONFIG_USE_GOT_ENTRIES | 139 | #if defined(__H8300H__) || defined(__H8300S__) |
140 | #define CONFIG_GOT_ENTRY_SIZE 4 | 140 | #define MATCH_MACHINE(x) (x == EM_H8_300) |
141 | #define SHT_RELM SHT_RELA | ||
142 | #define Elf32_RelM Elf32_Rela | ||
143 | #define ELFCLASSM ELFCLASS32 | ||
141 | #define CONFIG_USE_SINGLE | 144 | #define CONFIG_USE_SINGLE |
145 | #define SYMBOL_PREFIX "_" | ||
146 | #endif | ||
142 | 147 | ||
148 | /* x86 */ | ||
149 | #if defined(__i386__) | ||
143 | #ifndef EM_486 | 150 | #ifndef EM_486 |
144 | #define MATCH_MACHINE(x) (x == EM_386) | 151 | #define MATCH_MACHINE(x) (x == EM_386) |
145 | #else | 152 | #else |
146 | #define MATCH_MACHINE(x) (x == EM_386 || x == EM_486) | 153 | #define MATCH_MACHINE(x) (x == EM_386 || x == EM_486) |
147 | #endif | 154 | #endif |
148 | |||
149 | #define SHT_RELM SHT_REL | 155 | #define SHT_RELM SHT_REL |
150 | #define Elf32_RelM Elf32_Rel | 156 | #define Elf32_RelM Elf32_Rel |
151 | #define ELFCLASSM ELFCLASS32 | 157 | #define ELFCLASSM ELFCLASS32 |
158 | #define CONFIG_USE_GOT_ENTRIES | ||
159 | #define CONFIG_GOT_ENTRY_SIZE 4 | ||
160 | #define CONFIG_USE_SINGLE | ||
152 | #endif | 161 | #endif |
153 | 162 | ||
154 | #if defined(__x86_64__) | 163 | /* IA64, aka Itanium */ |
155 | #define MATCH_MACHINE(x) (x == EM_X86_64) | 164 | #if defined(__ia64__) |
156 | #define SHT_RELM SHT_REL | 165 | #define MATCH_MACHINE(x) (x == EM_IA_64) |
157 | #define Elf64_RelM Elf64_Rel | 166 | #define SHT_RELM SHT_RELA |
158 | #define ELFCLASSM ELFCLASS64 | 167 | #define Elf64_RelM Elf64_Rela |
168 | #define ELFCLASSM ELFCLASS64 | ||
159 | #endif | 169 | #endif |
160 | 170 | ||
171 | /* m68k */ | ||
161 | #if defined(__mc68000__) | 172 | #if defined(__mc68000__) |
162 | #define CONFIG_USE_GOT_ENTRIES | ||
163 | #define CONFIG_GOT_ENTRY_SIZE 4 | ||
164 | #define CONFIG_USE_SINGLE | ||
165 | |||
166 | #define MATCH_MACHINE(x) (x == EM_68K) | 173 | #define MATCH_MACHINE(x) (x == EM_68K) |
167 | #define SHT_RELM SHT_RELA | 174 | #define SHT_RELM SHT_RELA |
168 | #define Elf32_RelM Elf32_Rela | 175 | #define Elf32_RelM Elf32_Rela |
169 | #define ELFCLASSM ELFCLASS32 | 176 | #define ELFCLASSM ELFCLASS32 |
177 | #define CONFIG_USE_GOT_ENTRIES | ||
178 | #define CONFIG_GOT_ENTRY_SIZE 4 | ||
179 | #define CONFIG_USE_SINGLE | ||
170 | #endif | 180 | #endif |
171 | 181 | ||
182 | /* MIPS */ | ||
172 | #if defined(__mips__) | 183 | #if defined(__mips__) |
184 | #define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE) | ||
185 | #define SHT_RELM SHT_REL | ||
186 | #define Elf32_RelM Elf32_Rel | ||
187 | #define ELFCLASSM ELFCLASS32 | ||
173 | /* Account for ELF spec changes. */ | 188 | /* Account for ELF spec changes. */ |
174 | #ifndef EM_MIPS_RS3_LE | 189 | #ifndef EM_MIPS_RS3_LE |
175 | #ifdef EM_MIPS_RS4_BE | 190 | #ifdef EM_MIPS_RS4_BE |
@@ -178,92 +193,85 @@ extern int insmod_ng_main( int argc, char **argv); | |||
178 | #define EM_MIPS_RS3_LE 10 | 193 | #define EM_MIPS_RS3_LE 10 |
179 | #endif | 194 | #endif |
180 | #endif /* !EM_MIPS_RS3_LE */ | 195 | #endif /* !EM_MIPS_RS3_LE */ |
181 | |||
182 | #define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE) | ||
183 | #define SHT_RELM SHT_REL | ||
184 | #define Elf32_RelM Elf32_Rel | ||
185 | #define ELFCLASSM ELFCLASS32 | ||
186 | #define ARCHDATAM "__dbe_table" | 196 | #define ARCHDATAM "__dbe_table" |
187 | #endif | 197 | #endif |
188 | 198 | ||
199 | /* PowerPC */ | ||
189 | #if defined(__powerpc__) | 200 | #if defined(__powerpc__) |
201 | #define MATCH_MACHINE(x) (x == EM_PPC) | ||
202 | #define SHT_RELM SHT_RELA | ||
203 | #define Elf32_RelM Elf32_Rela | ||
204 | #define ELFCLASSM ELFCLASS32 | ||
190 | #define CONFIG_USE_PLT_ENTRIES | 205 | #define CONFIG_USE_PLT_ENTRIES |
191 | #define CONFIG_PLT_ENTRY_SIZE 16 | 206 | #define CONFIG_PLT_ENTRY_SIZE 16 |
192 | #define CONFIG_USE_PLT_LIST | 207 | #define CONFIG_USE_PLT_LIST |
193 | #define CONFIG_LIST_ARCHTYPE ElfW(Addr) | 208 | #define CONFIG_LIST_ARCHTYPE ElfW(Addr) |
194 | #define CONFIG_USE_LIST | 209 | #define CONFIG_USE_LIST |
210 | #define ARCHDATAM "__ftr_fixup" | ||
211 | #endif | ||
195 | 212 | ||
196 | #define MATCH_MACHINE(x) (x == EM_PPC) | 213 | /* S390 */ |
214 | #if defined(__s390__) | ||
215 | #define MATCH_MACHINE(x) (x == EM_S390) | ||
197 | #define SHT_RELM SHT_RELA | 216 | #define SHT_RELM SHT_RELA |
198 | #define Elf32_RelM Elf32_Rela | 217 | #define Elf32_RelM Elf32_Rela |
199 | #define ELFCLASSM ELFCLASS32 | 218 | #define ELFCLASSM ELFCLASS32 |
200 | #define ARCHDATAM "__ftr_fixup" | 219 | #define CONFIG_USE_PLT_ENTRIES |
201 | #endif | 220 | #define CONFIG_PLT_ENTRY_SIZE 8 |
202 | |||
203 | #if defined(__sh__) | ||
204 | #define CONFIG_USE_GOT_ENTRIES | 221 | #define CONFIG_USE_GOT_ENTRIES |
205 | #define CONFIG_GOT_ENTRY_SIZE 4 | 222 | #define CONFIG_GOT_ENTRY_SIZE 8 |
206 | #define CONFIG_USE_SINGLE | 223 | #define CONFIG_USE_SINGLE |
224 | #endif | ||
207 | 225 | ||
226 | /* SuperH */ | ||
227 | #if defined(__sh__) | ||
208 | #define MATCH_MACHINE(x) (x == EM_SH) | 228 | #define MATCH_MACHINE(x) (x == EM_SH) |
209 | #define SHT_RELM SHT_RELA | 229 | #define SHT_RELM SHT_RELA |
210 | #define Elf32_RelM Elf32_Rela | 230 | #define Elf32_RelM Elf32_Rela |
211 | #define ELFCLASSM ELFCLASS32 | 231 | #define ELFCLASSM ELFCLASS32 |
212 | 232 | #define CONFIG_USE_GOT_ENTRIES | |
233 | #define CONFIG_GOT_ENTRY_SIZE 4 | ||
234 | #define CONFIG_USE_SINGLE | ||
213 | /* the SH changes have only been tested in =little endian= mode */ | 235 | /* the SH changes have only been tested in =little endian= mode */ |
214 | /* I'm not sure about big endian, so let's warn: */ | 236 | /* I'm not sure about big endian, so let's warn: */ |
215 | |||
216 | #if defined(__sh__) && defined(__BIG_ENDIAN__) | 237 | #if defined(__sh__) && defined(__BIG_ENDIAN__) |
217 | #error insmod.c may require changes for use on big endian SH | 238 | #error insmod.c may require changes for use on big endian SH |
218 | #endif | 239 | #endif |
219 | 240 | /* it may or may not work on the SH1/SH2... Error on those also */ | |
220 | /* it may or may not work on the SH1/SH2... So let's error on those | 241 | #if ((!(defined(__SH3__) || defined(__SH4__) || defined(__SH5__)))) && (defined(__sh__)) |
221 | also */ | ||
222 | #if ((!(defined(__SH3__) || defined(__SH4__) || defined(__SH5__)))) && \ | ||
223 | (defined(__sh__)) | ||
224 | #error insmod.c may require changes for SH1 or SH2 use | 242 | #error insmod.c may require changes for SH1 or SH2 use |
225 | #endif | 243 | #endif |
226 | #endif | 244 | #endif |
227 | 245 | ||
246 | /* Sparc */ | ||
247 | #if defined(__sparc__) | ||
248 | #define MATCH_MACHINE(x) (x == EM_SPARC) | ||
249 | #define SHT_RELM SHT_RELA | ||
250 | #define Elf32_RelM Elf32_Rela | ||
251 | #define ELFCLASSM ELFCLASS32 | ||
252 | #endif | ||
253 | |||
254 | /* v850e */ | ||
228 | #if defined (__v850e__) | 255 | #if defined (__v850e__) |
256 | #define MATCH_MACHINE(x) ((x) == EM_V850 || (x) == EM_CYGNUS_V850) | ||
257 | #define SHT_RELM SHT_RELA | ||
258 | #define Elf32_RelM Elf32_Rela | ||
259 | #define ELFCLASSM ELFCLASS32 | ||
229 | #define CONFIG_USE_PLT_ENTRIES | 260 | #define CONFIG_USE_PLT_ENTRIES |
230 | #define CONFIG_PLT_ENTRY_SIZE 8 | 261 | #define CONFIG_PLT_ENTRY_SIZE 8 |
231 | #define CONFIG_USE_SINGLE | 262 | #define CONFIG_USE_SINGLE |
232 | |||
233 | #ifndef EM_CYGNUS_V850 /* grumble */ | 263 | #ifndef EM_CYGNUS_V850 /* grumble */ |
234 | #define EM_CYGNUS_V850 0x9080 | 264 | #define EM_CYGNUS_V850 0x9080 |
235 | #endif | 265 | #endif |
236 | |||
237 | #define MATCH_MACHINE(x) ((x) == EM_V850 || (x) == EM_CYGNUS_V850) | ||
238 | #define SHT_RELM SHT_RELA | ||
239 | #define Elf32_RelM Elf32_Rela | ||
240 | #define ELFCLASSM ELFCLASS32 | ||
241 | |||
242 | #define SYMBOL_PREFIX "_" | 266 | #define SYMBOL_PREFIX "_" |
243 | #endif | 267 | #endif |
244 | 268 | ||
245 | #if defined(__cris__) | 269 | /* X86_64 */ |
246 | #ifndef EM_CRIS | 270 | #if defined(__x86_64__) |
247 | #define EM_CRIS 76 | 271 | #define MATCH_MACHINE(x) (x == EM_X86_64) |
248 | #define R_CRIS_NONE 0 | 272 | #define SHT_RELM SHT_REL |
249 | #define R_CRIS_32 3 | 273 | #define Elf64_RelM Elf64_Rel |
250 | #endif | 274 | #define ELFCLASSM ELFCLASS64 |
251 | |||
252 | #define MATCH_MACHINE(x) (x == EM_CRIS) | ||
253 | #define SHT_RELM SHT_RELA | ||
254 | #define Elf32_RelM Elf32_Rela | ||
255 | #define ELFCLASSM ELFCLASS32 | ||
256 | #endif | ||
257 | |||
258 | #if defined(__H8300H__) || defined(__H8300S__) | ||
259 | #define CONFIG_USE_SINGLE | ||
260 | |||
261 | #define MATCH_MACHINE(x) (x == EM_H8_300) | ||
262 | #define SHT_RELM SHT_RELA | ||
263 | #define Elf32_RelM Elf32_Rela | ||
264 | |||
265 | #define ELFCLASSM ELFCLASS32 | ||
266 | #define SYMBOL_PREFIX "_" | ||
267 | #endif | 275 | #endif |
268 | 276 | ||
269 | #ifndef SHT_RELM | 277 | #ifndef SHT_RELM |
@@ -300,7 +308,7 @@ extern int insmod_ng_main( int argc, char **argv); | |||
300 | #ifndef MODUTILS_MODULE_H | 308 | #ifndef MODUTILS_MODULE_H |
301 | static const int MODUTILS_MODULE_H = 1; | 309 | static const int MODUTILS_MODULE_H = 1; |
302 | 310 | ||
303 | #ident "$Id: insmod.c,v 1.124 2004/08/28 00:43:06 andersen Exp $" | 311 | #ident "$Id: insmod.c,v 1.125 2004/09/02 23:03:25 andersen Exp $" |
304 | 312 | ||
305 | /*======================================================================*/ | 313 | /*======================================================================*/ |
306 | /* For sizeof() which are related to the module platform and not to the | 314 | /* For sizeof() which are related to the module platform and not to the |
@@ -458,7 +466,7 @@ int delete_module(const char *); | |||
458 | #ifndef MODUTILS_OBJ_H | 466 | #ifndef MODUTILS_OBJ_H |
459 | static const int MODUTILS_OBJ_H = 1; | 467 | static const int MODUTILS_OBJ_H = 1; |
460 | 468 | ||
461 | #ident "$Id: insmod.c,v 1.124 2004/08/28 00:43:06 andersen Exp $" | 469 | #ident "$Id: insmod.c,v 1.125 2004/09/02 23:03:25 andersen Exp $" |
462 | 470 | ||
463 | /* The relocatable object is manipulated using elfin types. */ | 471 | /* The relocatable object is manipulated using elfin types. */ |
464 | 472 | ||