diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-04-12 00:28:59 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-04-12 00:28:59 +0000 |
commit | b1591d1f8b9444c770771c9482d708dd5e497829 (patch) | |
tree | 4feb93c48d1ba8b6d182498db1b2ad94d61098ac | |
parent | a3603e845ef93dfc4027659fbe75d60c302f428a (diff) | |
download | busybox-w32-b1591d1f8b9444c770771c9482d708dd5e497829.tar.gz busybox-w32-b1591d1f8b9444c770771c9482d708dd5e497829.tar.bz2 busybox-w32-b1591d1f8b9444c770771c9482d708dd5e497829.zip |
Fix handling of endianness.
-Erik
-rw-r--r-- | modutils/insmod.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/modutils/insmod.c b/modutils/insmod.c index a3680ab1a..cbd423e18 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c | |||
@@ -140,7 +140,7 @@ | |||
140 | #ifndef MODUTILS_MODULE_H | 140 | #ifndef MODUTILS_MODULE_H |
141 | static const int MODUTILS_MODULE_H = 1; | 141 | static const int MODUTILS_MODULE_H = 1; |
142 | 142 | ||
143 | #ident "$Id: insmod.c,v 1.80 2002/04/01 14:25:51 miles Exp $" | 143 | #ident "$Id: insmod.c,v 1.81 2002/04/12 00:28:59 andersen Exp $" |
144 | 144 | ||
145 | /* This file contains the structures used by the 2.0 and 2.1 kernels. | 145 | /* This file contains the structures used by the 2.0 and 2.1 kernels. |
146 | We do not use the kernel headers directly because we do not wish | 146 | We do not use the kernel headers directly because we do not wish |
@@ -357,12 +357,19 @@ int delete_module(const char *); | |||
357 | #ifndef MODUTILS_OBJ_H | 357 | #ifndef MODUTILS_OBJ_H |
358 | static const int MODUTILS_OBJ_H = 1; | 358 | static const int MODUTILS_OBJ_H = 1; |
359 | 359 | ||
360 | #ident "$Id: insmod.c,v 1.80 2002/04/01 14:25:51 miles Exp $" | 360 | #ident "$Id: insmod.c,v 1.81 2002/04/12 00:28:59 andersen Exp $" |
361 | 361 | ||
362 | /* The relocatable object is manipulated using elfin types. */ | 362 | /* The relocatable object is manipulated using elfin types. */ |
363 | 363 | ||
364 | #include <stdio.h> | 364 | #include <stdio.h> |
365 | #include <elf.h> | 365 | #include <elf.h> |
366 | #include <endian.h> | ||
367 | |||
368 | #if __BYTE_ORDER == __LITTLE_ENDIAN | ||
369 | #define ELFDATAM ELFDATA2LSB | ||
370 | #elif __BYTE_ORDER == __BIG_ENDIAN | ||
371 | #define ELFDATAM ELFDATA2MSB | ||
372 | #endif | ||
366 | 373 | ||
367 | 374 | ||
368 | /* Machine-specific elf macros for i386 et al. */ | 375 | /* Machine-specific elf macros for i386 et al. */ |
@@ -382,37 +389,24 @@ static const int MODUTILS_OBJ_H = 1; | |||
382 | 389 | ||
383 | #define ELFCLASSM ELFCLASS32 | 390 | #define ELFCLASSM ELFCLASS32 |
384 | 391 | ||
385 | #if (defined(__mc68000__)) | ||
386 | #define ELFDATAM ELFDATA2MSB | ||
387 | #endif | ||
388 | |||
389 | |||
390 | 392 | ||
391 | #if defined(__sh__) | 393 | #if defined(__sh__) |
392 | 394 | ||
393 | #define MATCH_MACHINE(x) (x == EM_SH) | 395 | #define MATCH_MACHINE(x) (x == EM_SH) |
394 | #define SHT_RELM SHT_RELA | 396 | #define SHT_RELM SHT_RELA |
395 | #define Elf32_RelM Elf32_Rela | 397 | #define Elf32_RelM Elf32_Rela |
396 | #define ELFDATAM ELFDATA2LSB | ||
397 | 398 | ||
398 | #elif defined(__arm__) | 399 | #elif defined(__arm__) |
399 | 400 | ||
400 | #define MATCH_MACHINE(x) (x == EM_ARM) | 401 | #define MATCH_MACHINE(x) (x == EM_ARM) |
401 | #define SHT_RELM SHT_REL | 402 | #define SHT_RELM SHT_REL |
402 | #define Elf32_RelM Elf32_Rel | 403 | #define Elf32_RelM Elf32_Rel |
403 | #ifdef __ARMEB__ | ||
404 | #define ELFDATAM ELFDATA2MSB | ||
405 | #endif | ||
406 | #ifdef __ARMEL__ | ||
407 | #define ELFDATAM ELFDATA2LSB | ||
408 | #endif | ||
409 | 404 | ||
410 | #elif defined(__powerpc__) | 405 | #elif defined(__powerpc__) |
411 | 406 | ||
412 | #define MATCH_MACHINE(x) (x == EM_PPC) | 407 | #define MATCH_MACHINE(x) (x == EM_PPC) |
413 | #define SHT_RELM SHT_RELA | 408 | #define SHT_RELM SHT_RELA |
414 | #define Elf32_RelM Elf32_Rela | 409 | #define Elf32_RelM Elf32_Rela |
415 | #define ELFDATAM ELFDATA2MSB | ||
416 | 410 | ||
417 | #elif defined(__mips__) | 411 | #elif defined(__mips__) |
418 | 412 | ||
@@ -428,12 +422,6 @@ static const int MODUTILS_OBJ_H = 1; | |||
428 | #define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE) | 422 | #define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE) |
429 | #define SHT_RELM SHT_REL | 423 | #define SHT_RELM SHT_REL |
430 | #define Elf32_RelM Elf32_Rel | 424 | #define Elf32_RelM Elf32_Rel |
431 | #ifdef __MIPSEB__ | ||
432 | #define ELFDATAM ELFDATA2MSB | ||
433 | #endif | ||
434 | #ifdef __MIPSEL__ | ||
435 | #define ELFDATAM ELFDATA2LSB | ||
436 | #endif | ||
437 | 425 | ||
438 | #elif defined(__i386__) | 426 | #elif defined(__i386__) |
439 | 427 | ||
@@ -448,7 +436,6 @@ static const int MODUTILS_OBJ_H = 1; | |||
448 | 436 | ||
449 | #define SHT_RELM SHT_REL | 437 | #define SHT_RELM SHT_REL |
450 | #define Elf32_RelM Elf32_Rel | 438 | #define Elf32_RelM Elf32_Rel |
451 | #define ELFDATAM ELFDATA2LSB | ||
452 | 439 | ||
453 | #elif defined(__mc68000__) | 440 | #elif defined(__mc68000__) |
454 | 441 | ||
@@ -465,7 +452,6 @@ static const int MODUTILS_OBJ_H = 1; | |||
465 | #define MATCH_MACHINE(x) ((x) == EM_V850 || (x) == EM_CYGNUS_V850) | 452 | #define MATCH_MACHINE(x) ((x) == EM_V850 || (x) == EM_CYGNUS_V850) |
466 | #define SHT_RELM SHT_RELA | 453 | #define SHT_RELM SHT_RELA |
467 | #define Elf32_RelM Elf32_Rela | 454 | #define Elf32_RelM Elf32_Rela |
468 | #define ELFDATAM ELFDATA2LSB | ||
469 | 455 | ||
470 | #define SYMBOL_PREFIX "_" | 456 | #define SYMBOL_PREFIX "_" |
471 | 457 | ||