Major rework of the directory structure and the entire build system.
-Erik
diff --git a/modutils/Makefile b/modutils/Makefile
new file mode 100644
index 0000000..7a8d466
--- /dev/null
+++ b/modutils/Makefile
@@ -0,0 +1,39 @@
+# Makefile for busybox
+#
+# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+TOPDIR :=..
+L_TARGET := modutils.a
+
+obj-y :=
+obj-n :=
+obj- :=
+
+
+obj-$(CONFIG_INSMOD) += insmod.o
+obj-$(CONFIG_LSMOD) += lsmod.o
+obj-$(CONFIG_MODPROBE) += modprobe.o
+obj-$(CONFIG_RMMOD) += rmmod.o
+
+
+# Hand off to toplevel Rules.mak
+include $(TOPDIR)/Rules.mak
+
+clean:
+ rm -f $(L_TARGET) *.o core
+
diff --git a/modutils/config.in b/modutils/config.in
new file mode 100644
index 0000000..fc00e33
--- /dev/null
+++ b/modutils/config.in
@@ -0,0 +1,22 @@
+#
+# For a description of the syntax of this configuration file,
+# see scripts/kbuild/config-language.txt.
+#
+
+mainmenu_option next_comment
+comment 'Module Utilities'
+
+
+bool 'insmod' CONFIG_INSMOD
+bool 'lsmod' CONFIG_LSMOD
+bool 'modprobe' CONFIG_MODPROBE
+bool 'rmmod' CONFIG_RMMOD
+
+if [ "$CONFIG_INSMOD" = "y" ]; then
+ bool 'Support insmod/lsmod/rmmod for post 2.1 kernels' CONFIG_FEATURE_NEW_MODULE_INTERFACE
+ bool 'Support insmod/lsmod/rmmod for pre 2.1 kernels' CONFIG_FEATURE_OLD_MODULE_INTERFACE
+ bool 'Support module version checking' CONFIG_FEATURE_INSMOD_VERSION_CHECKING
+fi
+
+endmenu
+
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 6b81ca7..c21f22b 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -5,9 +5,8 @@
* This version of insmod supports x86, ARM, SH3/4, powerpc, m68k,
* and MIPS.
*
- *
- * Copyright (C) 1999,2000,2001 by Lineo, inc.
- * Written by Erik Andersen <andersen@lineo.com>
+ * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
* and Ron Alder <alder@lineo.com>
*
* Modified by Bryan Rittmeyer <bryan@ixiacom.com> to support SH4
@@ -22,7 +21,7 @@
* PowerPC specific code stolen from modutils-2.3.16,
* written by Paul Mackerras, Copyright 1996, 1997 Linux International.
* I've only tested the code on mpc8xx platforms in big-endian mode.
- * Did some cleanup and added BB_USE_xxx_ENTRIES...
+ * Did some cleanup and added CONFIG_USE_xxx_ENTRIES...
*
* Quinn Jensen <jensenq@lineo.com> added MIPS support 23-Feb-2001.
* based on modutils-2.4.2
@@ -66,39 +65,39 @@
#include <sys/utsname.h>
#include "busybox.h"
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
-# undef BB_FEATURE_OLD_MODULE_INTERFACE
+#ifdef CONFIG_FEATURE_NEW_MODULE_INTERFACE
+# undef CONFIG_FEATURE_OLD_MODULE_INTERFACE
# define new_sys_init_module init_module
#else
# define old_sys_init_module init_module
#endif
-#ifdef BB_FEATURE_INSMOD_LOADINKMEM
+#ifdef CONFIG_FEATURE_INSMOD_LOADINKMEM
#define LOADBITS 0
#else
#define LOADBITS 1
#endif
#if defined(__powerpc__)
-#define BB_USE_PLT_ENTRIES
-#define BB_PLT_ENTRY_SIZE 16
+#define CONFIG_USE_PLT_ENTRIES
+#define CONFIG_PLT_ENTRY_SIZE 16
#endif
#if defined(__arm__)
-#define BB_USE_PLT_ENTRIES
-#define BB_PLT_ENTRY_SIZE 8
-#define BB_USE_GOT_ENTRIES
-#define BB_GOT_ENTRY_SIZE 8
+#define CONFIG_USE_PLT_ENTRIES
+#define CONFIG_PLT_ENTRY_SIZE 8
+#define CONFIG_USE_GOT_ENTRIES
+#define CONFIG_GOT_ENTRY_SIZE 8
#endif
#if defined(__sh__)
-#define BB_USE_GOT_ENTRIES
-#define BB_GOT_ENTRY_SIZE 4
+#define CONFIG_USE_GOT_ENTRIES
+#define CONFIG_GOT_ENTRY_SIZE 4
#endif
#if defined(__i386__)
-#define BB_USE_GOT_ENTRIES
-#define BB_GOT_ENTRY_SIZE 4
+#define CONFIG_USE_GOT_ENTRIES
+#define CONFIG_GOT_ENTRY_SIZE 4
#endif
#if defined(__mips__)
@@ -134,7 +133,7 @@
#ifndef MODUTILS_MODULE_H
static const int MODUTILS_MODULE_H = 1;
-#ident "$Id: insmod.c,v 1.73 2001/08/22 05:41:57 andersen Exp $"
+#ident "$Id: insmod.c,v 1.74 2001/10/24 04:59:54 andersen Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
@@ -267,7 +266,7 @@
unsigned tgt_long persist_end;
unsigned tgt_long can_unload;
unsigned tgt_long runsize;
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
+#ifdef CONFIG_FEATURE_NEW_MODULE_INTERFACE
const char *kallsyms_start; /* All symbols for kernel debugging */
const char *kallsyms_end;
const char *archdata_start; /* arch specific data for module */
@@ -351,7 +350,7 @@
#ifndef MODUTILS_OBJ_H
static const int MODUTILS_OBJ_H = 1;
-#ident "$Id: insmod.c,v 1.73 2001/08/22 05:41:57 andersen Exp $"
+#ident "$Id: insmod.c,v 1.74 2001/10/24 04:59:54 andersen Exp $"
/* The relocatable object is manipulated using elfin types. */
@@ -551,7 +550,7 @@
static ElfW(Addr) obj_symbol_final_value(struct obj_file *f,
struct obj_symbol *sym);
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
+#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING
static void obj_set_symbol_compare(struct obj_file *f,
int (*cmp)(const char *, const char *),
unsigned long (*hash)(const char *));
@@ -643,7 +642,7 @@
-#if defined(BB_USE_PLT_ENTRIES)
+#if defined(CONFIG_USE_PLT_ENTRIES)
struct arch_plt_entry
{
int offset;
@@ -652,7 +651,7 @@
};
#endif
-#if defined(BB_USE_GOT_ENTRIES)
+#if defined(CONFIG_USE_GOT_ENTRIES)
struct arch_got_entry {
int offset;
unsigned offset_done:1;
@@ -671,10 +670,10 @@
struct arch_file {
struct obj_file root;
-#if defined(BB_USE_PLT_ENTRIES)
+#if defined(CONFIG_USE_PLT_ENTRIES)
struct obj_section *plt;
#endif
-#if defined(BB_USE_GOT_ENTRIES)
+#if defined(CONFIG_USE_GOT_ENTRIES)
struct obj_section *got;
#endif
#if defined(__mips__)
@@ -684,10 +683,10 @@
struct arch_symbol {
struct obj_symbol root;
-#if defined(BB_USE_PLT_ENTRIES)
+#if defined(CONFIG_USE_PLT_ENTRIES)
struct arch_plt_entry pltent;
#endif
-#if defined(BB_USE_GOT_ENTRIES)
+#if defined(CONFIG_USE_GOT_ENTRIES)
struct arch_got_entry gotent;
#endif
};
@@ -746,10 +745,10 @@
struct arch_file *f;
f = xmalloc(sizeof(*f));
-#if defined(BB_USE_PLT_ENTRIES)
+#if defined(CONFIG_USE_PLT_ENTRIES)
f->plt = NULL;
#endif
-#if defined(BB_USE_GOT_ENTRIES)
+#if defined(CONFIG_USE_GOT_ENTRIES)
f->got = NULL;
#endif
#if defined(__mips__)
@@ -769,10 +768,10 @@
struct arch_symbol *sym;
sym = xmalloc(sizeof(*sym));
-#if defined(BB_USE_PLT_ENTRIES)
+#if defined(CONFIG_USE_PLT_ENTRIES)
memset(&sym->pltent, 0, sizeof(sym->pltent));
#endif
-#if defined(BB_USE_GOT_ENTRIES)
+#if defined(CONFIG_USE_GOT_ENTRIES)
memset(&sym->gotent, 0, sizeof(sym->gotent));
#endif
@@ -793,10 +792,10 @@
ElfW(Addr) *loc = (ElfW(Addr) *) (targsec->contents + rel->r_offset);
ElfW(Addr) dot = targsec->header.sh_addr + rel->r_offset;
-#if defined(BB_USE_GOT_ENTRIES)
+#if defined(CONFIG_USE_GOT_ENTRIES)
ElfW(Addr) got = ifile->got ? ifile->got->header.sh_addr : 0;
#endif
-#if defined(BB_USE_PLT_ENTRIES)
+#if defined(CONFIG_USE_PLT_ENTRIES)
ElfW(Addr) plt = ifile->plt ? ifile->plt->header.sh_addr : 0;
struct arch_plt_entry *pe;
unsigned long *ip;
@@ -984,7 +983,7 @@
#elif defined(__i386__)
#endif
-#if defined(BB_USE_PLT_ENTRIES)
+#if defined(CONFIG_USE_PLT_ENTRIES)
#if defined(__arm__)
case R_ARM_PC24:
@@ -1037,7 +1036,7 @@
*loc = (*loc & ~0x03fffffc) | (v & 0x03fffffc);
#endif
break;
-#endif /* BB_USE_PLT_ENTRIES */
+#endif /* CONFIG_USE_PLT_ENTRIES */
#if defined(__arm__)
#elif defined(__sh__)
@@ -1072,7 +1071,7 @@
break;
#endif
-#if defined(BB_USE_GOT_ENTRIES)
+#if defined(CONFIG_USE_GOT_ENTRIES)
#if !defined(__68k__)
#if defined(__sh__)
@@ -1130,7 +1129,7 @@
break;
#endif // __mc68000__
-#endif /* BB_USE_GOT_ENTRIES */
+#endif /* CONFIG_USE_GOT_ENTRIES */
default:
printf("Warning: unhandled reloc %d\n",(int)ELF32_R_TYPE(rel->r_info));
@@ -1143,13 +1142,13 @@
static int arch_create_got(struct obj_file *f)
{
-#if defined(BB_USE_GOT_ENTRIES) || defined(BB_USE_PLT_ENTRIES)
+#if defined(CONFIG_USE_GOT_ENTRIES) || defined(CONFIG_USE_PLT_ENTRIES)
struct arch_file *ifile = (struct arch_file *) f;
int i;
-#if defined(BB_USE_GOT_ENTRIES)
+#if defined(CONFIG_USE_GOT_ENTRIES)
int got_offset = 0, gotneeded = 0;
#endif
-#if defined(BB_USE_PLT_ENTRIES)
+#if defined(CONFIG_USE_PLT_ENTRIES)
int plt_offset = 0, pltneeded = 0;
#endif
struct obj_section *relsec, *symsec, *strsec;
@@ -1226,18 +1225,18 @@
name = f->sections[extsym->st_shndx]->name;
}
intsym = (struct arch_symbol *) obj_find_symbol(f, name);
-#if defined(BB_USE_GOT_ENTRIES)
+#if defined(CONFIG_USE_GOT_ENTRIES)
if (!intsym->gotent.offset_done) {
intsym->gotent.offset_done = 1;
intsym->gotent.offset = got_offset;
- got_offset += BB_GOT_ENTRY_SIZE;
+ got_offset += CONFIG_GOT_ENTRY_SIZE;
}
#endif
-#if defined(BB_USE_PLT_ENTRIES)
+#if defined(CONFIG_USE_PLT_ENTRIES)
if (pltneeded && intsym->pltent.allocated == 0) {
intsym->pltent.allocated = 1;
intsym->pltent.offset = plt_offset;
- plt_offset += BB_PLT_ENTRY_SIZE;
+ plt_offset += CONFIG_PLT_ENTRY_SIZE;
intsym->pltent.inited = 0;
pltneeded = 0;
}
@@ -1245,7 +1244,7 @@
}
}
-#if defined(BB_USE_GOT_ENTRIES)
+#if defined(CONFIG_USE_GOT_ENTRIES)
if (got_offset) {
struct obj_section* myrelsec = obj_find_section(f, ".got");
@@ -1253,7 +1252,7 @@
obj_extend_section(myrelsec, got_offset);
} else {
myrelsec = obj_create_alloced_section(f, ".got",
- BB_GOT_ENTRY_SIZE,
+ CONFIG_GOT_ENTRY_SIZE,
got_offset);
assert(myrelsec);
}
@@ -1262,10 +1261,10 @@
}
#endif
-#if defined(BB_USE_PLT_ENTRIES)
+#if defined(CONFIG_USE_PLT_ENTRIES)
if (plt_offset)
ifile->plt = obj_create_alloced_section(f, ".plt",
- BB_PLT_ENTRY_SIZE,
+ CONFIG_PLT_ENTRY_SIZE,
plt_offset);
#endif
#endif
@@ -1304,7 +1303,7 @@
return obj_elf_hash_n(name, strlen(name));
}
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
+#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING
/* String comparison for non-co-versioned kernel and module. */
static int ncv_strcmp(const char *a, const char *b)
@@ -1356,7 +1355,7 @@
}
}
-#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
+#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */
static struct obj_symbol *
obj_add_symbol(struct obj_file *f, const char *name,
@@ -1787,7 +1786,7 @@
return 1;
}
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
+#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING
static int old_is_module_checksummed(struct obj_file *f)
{
return obj_find_symbol(f, "Using_Versions") != NULL;
@@ -1821,9 +1820,9 @@
return a << 16 | b << 8 | c;
}
-#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
+#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */
-#ifdef BB_FEATURE_OLD_MODULE_INTERFACE
+#ifdef CONFIG_FEATURE_OLD_MODULE_INTERFACE
/* Fetch all the symbols and divvy them up as appropriate for the modules. */
@@ -2033,7 +2032,7 @@
#define old_create_mod_use_count(x) TRUE
#define old_init_module(x, y, z) TRUE
-#endif /* BB_FEATURE_OLD_MODULE_INTERFACE */
+#endif /* CONFIG_FEATURE_OLD_MODULE_INTERFACE */
@@ -2273,7 +2272,7 @@
return 1;
}
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
+#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING
static int new_is_module_checksummed(struct obj_file *f)
{
const char *p = get_modinfo_value(f, "using_checksums");
@@ -2309,10 +2308,10 @@
return a << 16 | b << 8 | c;
}
-#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
+#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
+#ifdef CONFIG_FEATURE_NEW_MODULE_INTERFACE
/* Fetch the loaded modules, and all currently exported symbols. */
@@ -2601,7 +2600,7 @@
#define new_create_module_ksymtab(x)
#define query_module(v, w, x, y, z) -1
-#endif /* BB_FEATURE_NEW_MODULE_INTERFACE */
+#endif /* CONFIG_FEATURE_NEW_MODULE_INTERFACE */
/*======================================================================*/
@@ -3155,7 +3154,7 @@
return f;
}
-#ifdef BB_FEATURE_INSMOD_LOADINKMEM
+#ifdef CONFIG_FEATURE_INSMOD_LOADINKMEM
/*
* load the unloaded sections directly into the memory allocated by
* kernel for the module
@@ -3222,7 +3221,7 @@
char m_name[FILENAME_MAX + 1] = "\0";
int exit_status = EXIT_FAILURE;
int m_has_modinfo;
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
+#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING
struct utsname uts_info;
char m_strversion[STRVERSIONLEN];
int m_version;
@@ -3335,7 +3334,7 @@
else
m_has_modinfo = 1;
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
+#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING
/* Version correspondence? */
if (uname(&uts_info) < 0)
@@ -3366,12 +3365,12 @@
}
}
k_crcs = 0;
-#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
+#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */
k_new_syscalls = !query_module(NULL, 0, NULL, 0, NULL);
if (k_new_syscalls) {
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
+#ifdef CONFIG_FEATURE_NEW_MODULE_INTERFACE
if (!new_get_kernel_symbols())
goto out;
k_crcs = new_is_kernel_checksummed();
@@ -3380,7 +3379,7 @@
goto out;
#endif
} else {
-#ifdef BB_FEATURE_OLD_MODULE_INTERFACE
+#ifdef CONFIG_FEATURE_OLD_MODULE_INTERFACE
if (!old_get_kernel_symbols(m_name))
goto out;
k_crcs = old_is_kernel_checksummed();
@@ -3390,7 +3389,7 @@
#endif
}
-#ifdef BB_FEATURE_INSMOD_VERSION_CHECKING
+#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING
if (m_has_modinfo)
m_crcs = new_is_module_checksummed(f);
else
@@ -3398,7 +3397,7 @@
if (m_crcs != k_crcs)
obj_set_symbol_compare(f, ncv_strcmp, ncv_symbol_hash);
-#endif /* BB_FEATURE_INSMOD_VERSION_CHECKING */
+#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */
/* Let the module know about the kernel symbols. */
add_kernel_symbols(f);
diff --git a/modutils/lsmod.c b/modutils/lsmod.c
index 76ed2fd..7b6ad14 100644
--- a/modutils/lsmod.c
+++ b/modutils/lsmod.c
@@ -2,8 +2,8 @@
/*
* Mini lsmod implementation for busybox
*
- * Copyright (C) 1999,2000,2001 by Lineo, inc.
- * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+ * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* Modified by Alcove, Julien Gaulmin <julien.gaulmin@alcove.fr> and
* Nicolas Ferre <nicolas.ferre@alcove.fr> to support pre 2.1 kernels
@@ -41,7 +41,7 @@
-#ifdef BB_FEATURE_NEW_MODULE_INTERFACE
+#ifdef CONFIG_FEATURE_NEW_MODULE_INTERFACE
struct module_info
{
@@ -142,7 +142,7 @@
return( 0);
}
-#else /*BB_FEATURE_OLD_MODULE_INTERFACE*/
+#else /*CONFIG_FEATURE_OLD_MODULE_INTERFACE*/
extern int lsmod_main(int argc, char **argv)
{
@@ -163,4 +163,4 @@
return 1;
}
-#endif /*BB_FEATURE_OLD_MODULE_INTERFACE*/
+#endif /*CONFIG_FEATURE_OLD_MODULE_INTERFACE*/
diff --git a/modutils/rmmod.c b/modutils/rmmod.c
index 7596d02..affe975 100644
--- a/modutils/rmmod.c
+++ b/modutils/rmmod.c
@@ -2,8 +2,8 @@
/*
* Mini rmmod implementation for busybox
*
- * Copyright (C) 1999,2000,2001 by Lineo, inc.
- * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+ * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by