Based on patches from Mike Frysinger, add insmod support for

sparc and ia64 (itanium).

Also, reorganize the insmod architecture support code to be
alphasorted and less messy.

Update the readme to list current insmod arch support.
This commit is contained in:
Eric Andersen 2004-09-02 23:03:25 +00:00
parent 192c35f6eb
commit 45a0513a64
2 changed files with 95 additions and 86 deletions

17
README
View File

@ -33,23 +33,24 @@ Supported architectures:
BusyBox in general will build on any architecture supported by gcc. It has BusyBox in general will build on any architecture supported by gcc. It has
a few specialized features added for __sparc__ and __alpha__. insmod a few specialized features added for __sparc__ and __alpha__. insmod
functionality is currently limited to x86, ARM, SH3/4, powerpc, m68k, functionality is currently limited to ARM, CRIS, H8/300, x86, ia64,
MIPS, cris, and v850e. x86_64, m68k, MIPS, PowerPC, S390, SH3/4/5, Sparc, v850e, and x86_64
for 2.4.x kernels. For 2.6.x kernels
Supported C Libraries: Supported C Libraries:
glibc-2.0.x, glibc-2.1.x, glibc-2.2.x, glibc-2.3.x, uClibc. People uClibc and glibc are supported. People have been looking at newlib and
are looking at newlib and diet-libc, but consider them unsupported, diet-libc, but they are currently considered unsupported, untested, or
untested, or worse. Linux-libc5 is no longer supported -- you worse. Linux-libc5 is no longer supported -- you should probably use uClibc
should probably use uClibc instead if you want a small C library. instead if you want a small C library.
Supported kernels: Supported kernels:
Full functionality requires Linux 2.2.x or better. A large fraction of the Full functionality requires Linux 2.2.x or better. A large fraction of the
code should run on just about anything. While the current code is fairly code should run on just about anything. While the current code is fairly
Linux specific, it should be fairly easy to port the majority of the code Linux specific, it should be fairly easy to port the majority of the code
to, say, FreeBSD or Solaris, or Mac OS X, or even Windows (if you are into to support, say, FreeBSD or Solaris, or Mac OS X, or even Windows (if you
that sort of thing). are into that sort of thing).
---------------- ----------------

View File

@ -2,8 +2,8 @@
/* /*
* Mini insmod implementation for busybox * Mini insmod implementation for busybox
* *
* This version of insmod supports x86, x86_64, ARM, SH3/4/5, powerpc, m68k, * This version of insmod supports ARM, CRIS, H8/300, x86, ia64, x86_64,
* MIPS, v850e, and H8/300. * m68k, MIPS, PowerPC, S390, SH3/4/5, Sparc, v850e, and x86_64.
* *
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
* and Ron Alder <alder@lineo.com> * and Ron Alder <alder@lineo.com>
@ -109,67 +109,82 @@ extern int insmod_ng_main( int argc, char **argv);
#endif #endif
/* ARM support */
#if defined(__arm__) #if defined(__arm__)
#define CONFIG_USE_PLT_ENTRIES
#define CONFIG_PLT_ENTRY_SIZE 8
#define CONFIG_USE_GOT_ENTRIES
#define CONFIG_GOT_ENTRY_SIZE 8
#define CONFIG_USE_SINGLE
#define MATCH_MACHINE(x) (x == EM_ARM) #define MATCH_MACHINE(x) (x == EM_ARM)
#define SHT_RELM SHT_REL #define SHT_RELM SHT_REL
#define Elf32_RelM Elf32_Rel #define Elf32_RelM Elf32_Rel
#define ELFCLASSM ELFCLASS32 #define ELFCLASSM ELFCLASS32
#endif
#if defined(__s390__)
#define CONFIG_USE_PLT_ENTRIES #define CONFIG_USE_PLT_ENTRIES
#define CONFIG_PLT_ENTRY_SIZE 8 #define CONFIG_PLT_ENTRY_SIZE 8
#define CONFIG_USE_GOT_ENTRIES #define CONFIG_USE_GOT_ENTRIES
#define CONFIG_GOT_ENTRY_SIZE 8 #define CONFIG_GOT_ENTRY_SIZE 8
#define CONFIG_USE_SINGLE #define CONFIG_USE_SINGLE
#endif
#define MATCH_MACHINE(x) (x == EM_S390) /* CRIS */
#if defined(__cris__)
#define MATCH_MACHINE(x) (x == EM_CRIS)
#define SHT_RELM SHT_RELA #define SHT_RELM SHT_RELA
#define Elf32_RelM Elf32_Rela #define Elf32_RelM Elf32_Rela
#define ELFCLASSM ELFCLASS32 #define ELFCLASSM ELFCLASS32
#ifndef EM_CRIS
#define EM_CRIS 76
#define R_CRIS_NONE 0
#define R_CRIS_32 3
#endif
#endif #endif
#if defined(__i386__) /* H8/300 */
#define CONFIG_USE_GOT_ENTRIES #if defined(__H8300H__) || defined(__H8300S__)
#define CONFIG_GOT_ENTRY_SIZE 4 #define MATCH_MACHINE(x) (x == EM_H8_300)
#define SHT_RELM SHT_RELA
#define Elf32_RelM Elf32_Rela
#define ELFCLASSM ELFCLASS32
#define CONFIG_USE_SINGLE #define CONFIG_USE_SINGLE
#define SYMBOL_PREFIX "_"
#endif
/* x86 */
#if defined(__i386__)
#ifndef EM_486 #ifndef EM_486
#define MATCH_MACHINE(x) (x == EM_386) #define MATCH_MACHINE(x) (x == EM_386)
#else #else
#define MATCH_MACHINE(x) (x == EM_386 || x == EM_486) #define MATCH_MACHINE(x) (x == EM_386 || x == EM_486)
#endif #endif
#define SHT_RELM SHT_REL #define SHT_RELM SHT_REL
#define Elf32_RelM Elf32_Rel #define Elf32_RelM Elf32_Rel
#define ELFCLASSM ELFCLASS32 #define ELFCLASSM ELFCLASS32
#endif
#if defined(__x86_64__)
#define MATCH_MACHINE(x) (x == EM_X86_64)
#define SHT_RELM SHT_REL
#define Elf64_RelM Elf64_Rel
#define ELFCLASSM ELFCLASS64
#endif
#if defined(__mc68000__)
#define CONFIG_USE_GOT_ENTRIES #define CONFIG_USE_GOT_ENTRIES
#define CONFIG_GOT_ENTRY_SIZE 4 #define CONFIG_GOT_ENTRY_SIZE 4
#define CONFIG_USE_SINGLE #define CONFIG_USE_SINGLE
#endif
/* IA64, aka Itanium */
#if defined(__ia64__)
#define MATCH_MACHINE(x) (x == EM_IA_64)
#define SHT_RELM SHT_RELA
#define Elf64_RelM Elf64_Rela
#define ELFCLASSM ELFCLASS64
#endif
/* m68k */
#if defined(__mc68000__)
#define MATCH_MACHINE(x) (x == EM_68K) #define MATCH_MACHINE(x) (x == EM_68K)
#define SHT_RELM SHT_RELA #define SHT_RELM SHT_RELA
#define Elf32_RelM Elf32_Rela #define Elf32_RelM Elf32_Rela
#define ELFCLASSM ELFCLASS32 #define ELFCLASSM ELFCLASS32
#define CONFIG_USE_GOT_ENTRIES
#define CONFIG_GOT_ENTRY_SIZE 4
#define CONFIG_USE_SINGLE
#endif #endif
/* MIPS */
#if defined(__mips__) #if defined(__mips__)
#define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE)
#define SHT_RELM SHT_REL
#define Elf32_RelM Elf32_Rel
#define ELFCLASSM ELFCLASS32
/* Account for ELF spec changes. */ /* Account for ELF spec changes. */
#ifndef EM_MIPS_RS3_LE #ifndef EM_MIPS_RS3_LE
#ifdef EM_MIPS_RS4_BE #ifdef EM_MIPS_RS4_BE
@ -178,94 +193,87 @@ extern int insmod_ng_main( int argc, char **argv);
#define EM_MIPS_RS3_LE 10 #define EM_MIPS_RS3_LE 10
#endif #endif
#endif /* !EM_MIPS_RS3_LE */ #endif /* !EM_MIPS_RS3_LE */
#define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE)
#define SHT_RELM SHT_REL
#define Elf32_RelM Elf32_Rel
#define ELFCLASSM ELFCLASS32
#define ARCHDATAM "__dbe_table" #define ARCHDATAM "__dbe_table"
#endif #endif
/* PowerPC */
#if defined(__powerpc__) #if defined(__powerpc__)
#define MATCH_MACHINE(x) (x == EM_PPC)
#define SHT_RELM SHT_RELA
#define Elf32_RelM Elf32_Rela
#define ELFCLASSM ELFCLASS32
#define CONFIG_USE_PLT_ENTRIES #define CONFIG_USE_PLT_ENTRIES
#define CONFIG_PLT_ENTRY_SIZE 16 #define CONFIG_PLT_ENTRY_SIZE 16
#define CONFIG_USE_PLT_LIST #define CONFIG_USE_PLT_LIST
#define CONFIG_LIST_ARCHTYPE ElfW(Addr) #define CONFIG_LIST_ARCHTYPE ElfW(Addr)
#define CONFIG_USE_LIST #define CONFIG_USE_LIST
#define MATCH_MACHINE(x) (x == EM_PPC)
#define SHT_RELM SHT_RELA
#define Elf32_RelM Elf32_Rela
#define ELFCLASSM ELFCLASS32
#define ARCHDATAM "__ftr_fixup" #define ARCHDATAM "__ftr_fixup"
#endif #endif
#if defined(__sh__) /* S390 */
#if defined(__s390__)
#define MATCH_MACHINE(x) (x == EM_S390)
#define SHT_RELM SHT_RELA
#define Elf32_RelM Elf32_Rela
#define ELFCLASSM ELFCLASS32
#define CONFIG_USE_PLT_ENTRIES
#define CONFIG_PLT_ENTRY_SIZE 8
#define CONFIG_USE_GOT_ENTRIES #define CONFIG_USE_GOT_ENTRIES
#define CONFIG_GOT_ENTRY_SIZE 4 #define CONFIG_GOT_ENTRY_SIZE 8
#define CONFIG_USE_SINGLE #define CONFIG_USE_SINGLE
#endif
/* SuperH */
#if defined(__sh__)
#define MATCH_MACHINE(x) (x == EM_SH) #define MATCH_MACHINE(x) (x == EM_SH)
#define SHT_RELM SHT_RELA #define SHT_RELM SHT_RELA
#define Elf32_RelM Elf32_Rela #define Elf32_RelM Elf32_Rela
#define ELFCLASSM ELFCLASS32 #define ELFCLASSM ELFCLASS32
#define CONFIG_USE_GOT_ENTRIES
#define CONFIG_GOT_ENTRY_SIZE 4
#define CONFIG_USE_SINGLE
/* the SH changes have only been tested in =little endian= mode */ /* the SH changes have only been tested in =little endian= mode */
/* I'm not sure about big endian, so let's warn: */ /* I'm not sure about big endian, so let's warn: */
#if defined(__sh__) && defined(__BIG_ENDIAN__) #if defined(__sh__) && defined(__BIG_ENDIAN__)
#error insmod.c may require changes for use on big endian SH #error insmod.c may require changes for use on big endian SH
#endif #endif
/* it may or may not work on the SH1/SH2... Error on those also */
/* it may or may not work on the SH1/SH2... So let's error on those #if ((!(defined(__SH3__) || defined(__SH4__) || defined(__SH5__)))) && (defined(__sh__))
also */
#if ((!(defined(__SH3__) || defined(__SH4__) || defined(__SH5__)))) && \
(defined(__sh__))
#error insmod.c may require changes for SH1 or SH2 use #error insmod.c may require changes for SH1 or SH2 use
#endif #endif
#endif #endif
#if defined (__v850e__) /* Sparc */
#define CONFIG_USE_PLT_ENTRIES #if defined(__sparc__)
#define CONFIG_PLT_ENTRY_SIZE 8 #define MATCH_MACHINE(x) (x == EM_SPARC)
#define CONFIG_USE_SINGLE #define SHT_RELM SHT_RELA
#define Elf32_RelM Elf32_Rela
#ifndef EM_CYGNUS_V850 /* grumble */ #define ELFCLASSM ELFCLASS32
#define EM_CYGNUS_V850 0x9080
#endif #endif
/* v850e */
#if defined (__v850e__)
#define MATCH_MACHINE(x) ((x) == EM_V850 || (x) == EM_CYGNUS_V850) #define MATCH_MACHINE(x) ((x) == EM_V850 || (x) == EM_CYGNUS_V850)
#define SHT_RELM SHT_RELA #define SHT_RELM SHT_RELA
#define Elf32_RelM Elf32_Rela #define Elf32_RelM Elf32_Rela
#define ELFCLASSM ELFCLASS32 #define ELFCLASSM ELFCLASS32
#define CONFIG_USE_PLT_ENTRIES
#define SYMBOL_PREFIX "_" #define CONFIG_PLT_ENTRY_SIZE 8
#endif
#if defined(__cris__)
#ifndef EM_CRIS
#define EM_CRIS 76
#define R_CRIS_NONE 0
#define R_CRIS_32 3
#endif
#define MATCH_MACHINE(x) (x == EM_CRIS)
#define SHT_RELM SHT_RELA
#define Elf32_RelM Elf32_Rela
#define ELFCLASSM ELFCLASS32
#endif
#if defined(__H8300H__) || defined(__H8300S__)
#define CONFIG_USE_SINGLE #define CONFIG_USE_SINGLE
#ifndef EM_CYGNUS_V850 /* grumble */
#define MATCH_MACHINE(x) (x == EM_H8_300) #define EM_CYGNUS_V850 0x9080
#define SHT_RELM SHT_RELA #endif
#define Elf32_RelM Elf32_Rela
#define ELFCLASSM ELFCLASS32
#define SYMBOL_PREFIX "_" #define SYMBOL_PREFIX "_"
#endif #endif
/* X86_64 */
#if defined(__x86_64__)
#define MATCH_MACHINE(x) (x == EM_X86_64)
#define SHT_RELM SHT_REL
#define Elf64_RelM Elf64_Rel
#define ELFCLASSM ELFCLASS64
#endif
#ifndef SHT_RELM #ifndef SHT_RELM
#error Sorry, but insmod.c does not yet support this architecture... #error Sorry, but insmod.c does not yet support this architecture...
#endif #endif
@ -300,7 +308,7 @@ extern int insmod_ng_main( int argc, char **argv);
#ifndef MODUTILS_MODULE_H #ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1; static const int MODUTILS_MODULE_H = 1;
#ident "$Id: insmod.c,v 1.124 2004/08/28 00:43:06 andersen Exp $" #ident "$Id: insmod.c,v 1.125 2004/09/02 23:03:25 andersen Exp $"
/*======================================================================*/ /*======================================================================*/
/* For sizeof() which are related to the module platform and not to the /* For sizeof() which are related to the module platform and not to the
@ -458,7 +466,7 @@ int delete_module(const char *);
#ifndef MODUTILS_OBJ_H #ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1; static const int MODUTILS_OBJ_H = 1;
#ident "$Id: insmod.c,v 1.124 2004/08/28 00:43:06 andersen Exp $" #ident "$Id: insmod.c,v 1.125 2004/09/02 23:03:25 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */ /* The relocatable object is manipulated using elfin types. */