-+
-+/*
-+ * Big piece of 2.4-specific code
-+ */
-+#if ENABLE_FEATURE_2_4_MODULES
- #if ENABLE_FEATURE_INSMOD_LOADINKMEM
- #define LOADBITS 0
- #else
-@@ -184,7 +280,6 @@
- /* Microblaze */
- #if defined(__microblaze__)
- #define USE_SINGLE
--#include <linux/elf-em.h>
- #define MATCH_MACHINE(x) (x == EM_XILINX_MICROBLAZE)
- #define SHT_RELM SHT_RELA
- #define Elf32_RelM Elf32_Rela
-@@ -452,7 +547,7 @@
- /* The system calls unchanged between 2.0 and 2.1. */
-
- unsigned long create_module(const char *, size_t);
--int delete_module(const char *module, unsigned int flags);
-+int delete_module(const char *);
-
-
- #endif /* module.h */
-@@ -652,7 +747,7 @@
-
- static enum obj_reloc arch_apply_relocation(struct obj_file *f,
- struct obj_section *targsec,
-- /*struct obj_section *symsec,*/
-+ struct obj_section *symsec,
- struct obj_symbol *sym,
- ElfW(RelM) *rel, ElfW(Addr) value);
-
-@@ -673,6 +768,7 @@
- #define SPFX ""
- #endif
-
-+
- enum { STRVERSIONLEN = 64 };
-
- /*======================================================================*/
-@@ -788,28 +884,6 @@
- static char *m_fullName;
-
-
--/*======================================================================*/
--
--
--static int check_module_name_match(const char *filename,
-- struct stat *statbuf ATTRIBUTE_UNUSED,
-- void *userdata, int depth ATTRIBUTE_UNUSED)
--{
-- char *fullname = (char *) userdata;
-- char *tmp;
--
-- if (fullname[0] == '\0')
-- return FALSE;
--
-- tmp = bb_get_last_path_component_nostrip(filename);
-- if (strcmp(tmp, fullname) == 0) {
-- /* Stop searching if we find a match */
-- m_filename = xstrdup(filename);
-- return FALSE;
-- }
-- return TRUE;
--}
--
-
- /*======================================================================*/
-
-@@ -835,27 +909,18 @@
- static enum obj_reloc
- arch_apply_relocation(struct obj_file *f,
- struct obj_section *targsec,
-- /*struct obj_section *symsec,*/
-+ struct obj_section *symsec,
- struct obj_symbol *sym,
- ElfW(RelM) *rel, ElfW(Addr) v)
- {
--#if defined(__arm__) || defined(__i386__) || defined(__mc68000__) \
-- || defined(__sh__) || defined(__s390__) || defined(__x86_64__)
- struct arch_file *ifile = (struct arch_file *) f;
--#endif
- enum obj_reloc ret = obj_reloc_ok;
- ElfW(Addr) *loc = (ElfW(Addr) *) (targsec->contents + rel->r_offset);
--#if defined(__arm__) || defined(__H8300H__) || defined(__H8300S__) \
-- || defined(__i386__) || defined(__mc68000__) || defined(__microblaze__) \
-- || defined(__mips__) || defined(__nios2__) || defined(__powerpc__) \
-- || defined(__s390__) || defined(__sh__) || defined(__x86_64__)
- ElfW(Addr) dot = targsec->header.sh_addr + rel->r_offset;
--#endif
- #if defined(USE_GOT_ENTRIES) || defined(USE_PLT_ENTRIES)
- struct arch_symbol *isym = (struct arch_symbol *) sym;
- #endif
--#if defined(__arm__) || defined(__i386__) || defined(__mc68000__) \
-- || defined(__sh__) || defined(__s390__)
-+#if defined(__arm__) || defined(__i386__) || defined(__mc68000__) || defined(__sh__) || defined(__s390__)
- #if defined(USE_GOT_ENTRIES)
- ElfW(Addr) got = ifile->got ? ifile->got->header.sh_addr : 0;
- #endif
-@@ -953,7 +1018,6 @@
-
- case R_386_PLT32:
- case R_386_PC32:
-- case R_386_GOTOFF:
- *loc += v - dot;
- break;
-
-@@ -972,6 +1036,9 @@
-
- case R_386_GOT32:
- goto bb_use_got;
-+
-+ case R_386_GOTOFF:
-+ *loc += v - got;
- break;
-
- #elif defined(__microblaze__)
-@@ -1758,7 +1825,7 @@
-
- #if defined(USE_SINGLE)
-
--static int arch_single_init(/*ElfW(RelM) *rel,*/ struct arch_single_entry *single,
-+static int arch_single_init(ElfW(RelM) *rel, struct arch_single_entry *single,
- int offset, int size)
- {
- if (single->allocated == 0) {
-@@ -1906,7 +1973,7 @@
- #if defined(USE_GOT_ENTRIES)
- if (got_allocate) {
- got_offset += arch_single_init(
-- /*rel,*/ &intsym->gotent,
-+ rel, &intsym->gotent,
- got_offset, GOT_ENTRY_SIZE);
-
- got_needed = 1;
-@@ -1920,7 +1987,7 @@
- plt_offset, PLT_ENTRY_SIZE);
- #else
- plt_offset += arch_single_init(
-- /*rel,*/ &intsym->pltent,
-+ rel, &intsym->pltent,
- plt_offset, PLT_ENTRY_SIZE);
- #endif
- plt_needed = 1;
-@@ -1958,8 +2025,7 @@
- while (n > 0) {
- ch = *name++;
- h = (h << 4) + ch;
-- g = (h & 0xf0000000);
-- if (g != 0) {
-+ if ((g = (h & 0xf0000000)) != 0) {
- h ^= g >> 24;
- h &= ~g;
- }
-@@ -2038,7 +2104,7 @@
- int n_type = ELF_ST_TYPE(info);
- int n_binding = ELF_ST_BIND(info);
-
-- for (sym = f->symtab[hash]; sym; sym = sym->next) {
-+ for (sym = f->symtab[hash]; sym; sym = sym->next)
- if (f->symbol_cmp(sym->name, name) == 0) {
- int o_secidx = sym->secidx;
- int o_info = sym->info;
-@@ -2097,14 +2163,14 @@
- return sym;
- }
- }
-- }
-
- /* Completely new symbol. */
- sym = arch_new_symbol();
- sym->next = f->symtab[hash];
- f->symtab[hash] = sym;
- sym->ksymidx = -1;
-- if (ELF_ST_BIND(info) == STB_LOCAL && symidx != (unsigned long)(-1)) {
-+
-+ if (ELF_ST_BIND(info) == STB_LOCAL && symidx != -1) {
- if (symidx >= f->local_symtab_size)
- bb_error_msg("local symbol %s with index %ld exceeds local_symtab_size %ld",
- name, (long) symidx, (long) f->local_symtab_size);
-@@ -3227,7 +3293,7 @@
-
- /* Do it! */
- switch (arch_apply_relocation
-- (f, targsec, /*symsec,*/ intsym, rel, value)
-+ (f, targsec, symsec, intsym, rel, value)
- ) {
- case obj_reloc_ok:
- break;
-@@ -3306,11 +3372,11 @@
-
- /*======================================================================*/
-
--static struct obj_file *obj_load(FILE * fp, int loadprogbits ATTRIBUTE_UNUSED)
-+static struct obj_file *obj_load(FILE * fp, int loadprogbits)
- {
- struct obj_file *f;
- ElfW(Shdr) * section_headers;
-- size_t shnum, i;
-+ int shnum, i;
- char *shstrtab;
-
- /* Read the file header. */
-@@ -3582,7 +3648,7 @@
- while (ptr < endptr) {
- value = strchr(ptr, '=');
- if (value && strncmp(ptr, "license", value-ptr) == 0) {
-- unsigned i;
-+ int i;
- if (license)
- *license = value+1;
- for (i = 0; i < ARRAY_SIZE(gpl_licenses); ++i) {
-@@ -3686,9 +3752,6 @@
- * start of some sections. this info is used by ksymoops to do better
- * debugging.
- */
--#if !ENABLE_FEATURE_INSMOD_VERSION_CHECKING
--#define get_module_version(f, str) get_module_version(str)
--#endif
- static int
- get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
- {
-@@ -3721,8 +3784,7 @@
- struct obj_symbol *sym;
- char *name, *absolute_filename;
- char str[STRVERSIONLEN];
-- unsigned i;
-- int l, lm_name, lfilename, use_ksymtab, version;
-+ int i, l, lm_name, lfilename, use_ksymtab, version;
- struct stat statbuf;
-
- /* WARNING: was using realpath, but replaced by readlink to stop using
-@@ -3909,145 +3971,57 @@
- void print_load_map(struct obj_file *f);
- #endif
-
--int insmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
--int insmod_main(int argc, char **argv)
-+int insmod_main_24( int argc, char **argv)
- {
- char *opt_o, *arg1;
-- int len;
- int k_crcs;
-- char *tmp, *tmp1;
- unsigned long m_size;
- ElfW(Addr) m_addr;
- struct obj_file *f;
-- struct stat st;
-- char *m_name = NULL;
-- int exit_status = EXIT_FAILURE;
-+ char *tmp = NULL, *m_name = NULL;
-+ int ret = EINVAL;
- int m_has_modinfo;
- #if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
- struct utsname uts_info;
- char m_strversion[STRVERSIONLEN];
- int m_version, m_crcs;
- #endif
--#if ENABLE_FEATURE_CLEAN_UP
- FILE *fp = NULL;
--#else
-- FILE *fp;
--#endif
-- int k_version = 0;
-+ int k_version;
- struct utsname myuname;
-
-+ /* check the kernel version */
-+ if ((uname(&myuname) != 0) || (myuname.release[0] != '2'))
-+ return EINVAL;
-+
-+ k_version = myuname.release[2] - '0';
-+ if (k_version > 4)
-+ return ENOTSUP;
-+
- /* Parse any options */
- getopt32(argv, OPTION_STR, &opt_o);
- arg1 = argv[optind];
- if (option_mask32 & OPT_o) { // -o /* name the output module */
-- free(m_name);
- m_name = xstrdup(opt_o);
- }