insmod: set STRVERSIONLEN = 64, convert #ifdef CONFIG to #if ENABLE,

stop using CONFIG_ prefix for non-config-system variables
This commit is contained in:
Denis Vlasenko 2006-11-21 14:12:53 +00:00
parent 9229794ab3
commit 3aa2d51cd6

View File

@ -40,7 +40,7 @@
* PowerPC specific code stolen from modutils-2.3.16, * PowerPC specific code stolen from modutils-2.3.16,
* written by Paul Mackerras, Copyright 1996, 1997 Linux International. * written by Paul Mackerras, Copyright 1996, 1997 Linux International.
* I've only tested the code on mpc8xx platforms in big-endian mode. * I've only tested the code on mpc8xx platforms in big-endian mode.
* Did some cleanup and added CONFIG_USE_xxx_ENTRIES... * Did some cleanup and added USE_xxx_ENTRIES...
* *
* Quinn Jensen <jensenq@lineo.com> added MIPS support 23-Feb-2001. * Quinn Jensen <jensenq@lineo.com> added MIPS support 23-Feb-2001.
* based on modutils-2.4.2 * based on modutils-2.4.2
@ -62,24 +62,23 @@
#include <libgen.h> #include <libgen.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#if !defined(CONFIG_FEATURE_2_4_MODULES) && \ #if !ENABLE_FEATURE_2_4_MODULES && !ENABLE_FEATURE_2_6_MODULES
!defined(CONFIG_FEATURE_2_6_MODULES) #define ENABLE_FEATURE_2_4_MODULES 1
#define CONFIG_FEATURE_2_4_MODULES
#endif #endif
#if !defined(CONFIG_FEATURE_2_4_MODULES) #if !ENABLE_FEATURE_2_4_MODULES
#define insmod_ng_main insmod_main #define insmod_ng_main insmod_main
#endif #endif
#if defined(CONFIG_FEATURE_2_6_MODULES) #if ENABLE_FEATURE_2_6_MODULES
extern int insmod_ng_main( int argc, char **argv); extern int insmod_ng_main( int argc, char **argv);
#endif #endif
#if defined(CONFIG_FEATURE_2_4_MODULES) #if ENABLE_FEATURE_2_4_MODULES
#ifdef CONFIG_FEATURE_INSMOD_LOADINKMEM #if ENABLE_FEATURE_INSMOD_LOADINKMEM
#define LOADBITS 0 #define LOADBITS 0
#else #else
#define LOADBITS 1 #define LOADBITS 1
@ -100,11 +99,11 @@ extern int insmod_ng_main( int argc, char **argv);
#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
#define CONFIG_USE_PLT_ENTRIES #define USE_PLT_ENTRIES
#define CONFIG_PLT_ENTRY_SIZE 8 #define PLT_ENTRY_SIZE 8
#define CONFIG_USE_GOT_ENTRIES #define USE_GOT_ENTRIES
#define CONFIG_GOT_ENTRY_SIZE 8 #define GOT_ENTRY_SIZE 8
#define CONFIG_USE_SINGLE #define USE_SINGLE
#endif #endif
/* blackfin */ /* blackfin */
@ -134,7 +133,7 @@ extern int insmod_ng_main( int argc, char **argv);
#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_SINGLE #define USE_SINGLE
#define SYMBOL_PREFIX "_" #define SYMBOL_PREFIX "_"
#endif #endif
@ -161,9 +160,9 @@ extern int insmod_ng_main( int argc, char **argv);
#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
#define CONFIG_USE_GOT_ENTRIES #define USE_GOT_ENTRIES
#define CONFIG_GOT_ENTRY_SIZE 4 #define GOT_ENTRY_SIZE 4
#define CONFIG_USE_SINGLE #define USE_SINGLE
#endif #endif
/* IA64, aka Itanium */ /* IA64, aka Itanium */
@ -180,14 +179,14 @@ extern int insmod_ng_main( int argc, char **argv);
#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 USE_GOT_ENTRIES
#define CONFIG_GOT_ENTRY_SIZE 4 #define GOT_ENTRY_SIZE 4
#define CONFIG_USE_SINGLE #define USE_SINGLE
#endif #endif
/* Microblaze */ /* Microblaze */
#if defined(__microblaze__) #if defined(__microblaze__)
#define CONFIG_USE_SINGLE #define USE_SINGLE
#define MATCH_MACHINE(x) (x == EM_XILINX_MICROBLAZE) #define MATCH_MACHINE(x) (x == EM_XILINX_MICROBLAZE)
#define SHT_RELM SHT_RELA #define SHT_RELM SHT_RELA
#define Elf32_RelM Elf32_Rela #define Elf32_RelM Elf32_Rela
@ -230,11 +229,11 @@ extern int insmod_ng_main( int argc, char **argv);
#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 USE_PLT_ENTRIES
#define CONFIG_PLT_ENTRY_SIZE 16 #define PLT_ENTRY_SIZE 16
#define CONFIG_USE_PLT_LIST #define USE_PLT_LIST
#define CONFIG_LIST_ARCHTYPE ElfW(Addr) #define LIST_ARCHTYPE ElfW(Addr)
#define CONFIG_USE_LIST #define USE_LIST
#define ARCHDATAM "__ftr_fixup" #define ARCHDATAM "__ftr_fixup"
#endif #endif
@ -244,11 +243,11 @@ extern int insmod_ng_main( int argc, char **argv);
#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 USE_PLT_ENTRIES
#define CONFIG_PLT_ENTRY_SIZE 8 #define PLT_ENTRY_SIZE 8
#define CONFIG_USE_GOT_ENTRIES #define USE_GOT_ENTRIES
#define CONFIG_GOT_ENTRY_SIZE 8 #define GOT_ENTRY_SIZE 8
#define CONFIG_USE_SINGLE #define USE_SINGLE
#endif #endif
/* SuperH */ /* SuperH */
@ -257,9 +256,9 @@ extern int insmod_ng_main( int argc, char **argv);
#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 USE_GOT_ENTRIES
#define CONFIG_GOT_ENTRY_SIZE 4 #define GOT_ENTRY_SIZE 4
#define CONFIG_USE_SINGLE #define 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__) && BB_BIG_ENDIAN #if defined(__sh__) && BB_BIG_ENDIAN
@ -285,9 +284,9 @@ extern int insmod_ng_main( int argc, char **argv);
#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 USE_PLT_ENTRIES
#define CONFIG_PLT_ENTRY_SIZE 8 #define PLT_ENTRY_SIZE 8
#define CONFIG_USE_SINGLE #define USE_SINGLE
#ifndef EM_CYGNUS_V850 /* grumble */ #ifndef EM_CYGNUS_V850 /* grumble */
#define EM_CYGNUS_V850 0x9080 #define EM_CYGNUS_V850 0x9080
#endif #endif
@ -298,9 +297,9 @@ extern int insmod_ng_main( int argc, char **argv);
#if defined(__x86_64__) #if defined(__x86_64__)
#define MATCH_MACHINE(x) (x == EM_X86_64) #define MATCH_MACHINE(x) (x == EM_X86_64)
#define SHT_RELM SHT_RELA #define SHT_RELM SHT_RELA
#define CONFIG_USE_GOT_ENTRIES #define USE_GOT_ENTRIES
#define CONFIG_GOT_ENTRY_SIZE 8 #define GOT_ENTRY_SIZE 8
#define CONFIG_USE_SINGLE #define USE_SINGLE
#define Elf64_RelM Elf64_Rela #define Elf64_RelM Elf64_Rela
#define ELFCLASSM ELFCLASS64 #define ELFCLASSM ELFCLASS64
#endif #endif
@ -606,7 +605,7 @@ static struct obj_symbol *obj_find_symbol (struct obj_file *f,
static ElfW(Addr) obj_symbol_final_value(struct obj_file *f, static ElfW(Addr) obj_symbol_final_value(struct obj_file *f,
struct obj_symbol *sym); struct obj_symbol *sym);
#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING #if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
static void obj_set_symbol_compare(struct obj_file *f, static void obj_set_symbol_compare(struct obj_file *f,
int (*cmp)(const char *, const char *), int (*cmp)(const char *, const char *),
unsigned long (*hash)(const char *)); unsigned long (*hash)(const char *));
@ -665,7 +664,7 @@ static enum obj_reloc arch_apply_relocation (struct obj_file *f,
static void arch_create_got (struct obj_file *f); static void arch_create_got (struct obj_file *f);
#if ENABLE_FEATURE_CHECK_TAINTED_MODULE #if ENABLE_FEATURE_CHECK_TAINTED_MODULE
static int obj_gpl_license(struct obj_file *f, const char **license); static int obj_gpl_license(struct obj_file *f, const char **license);
#endif /* ENABLE_FEATURE_CHECK_TAINTED_MODULE */ #endif /* FEATURE_CHECK_TAINTED_MODULE */
#endif /* obj.h */ #endif /* obj.h */
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
//--------end of modutils obj.h //--------end of modutils obj.h
@ -681,7 +680,7 @@ static int obj_gpl_license(struct obj_file *f, const char **license);
#define _PATH_MODULES "/lib/modules" #define _PATH_MODULES "/lib/modules"
enum { STRVERSIONLEN = 32 }; enum { STRVERSIONLEN = 64 };
/*======================================================================*/ /*======================================================================*/
@ -709,7 +708,7 @@ enum {
#define flag_verbose (option_mask32 & OPT_v) #define flag_verbose (option_mask32 & OPT_v)
#define flag_quiet (option_mask32 & OPT_q) #define flag_quiet (option_mask32 & OPT_q)
#define flag_noexport (option_mask32 & OPT_x) #define flag_noexport (option_mask32 & OPT_x)
#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP #if ENABLE_FEATURE_INSMOD_LOAD_MAP
#define flag_print_load_map (option_mask32 & OPT_m) #define flag_print_load_map (option_mask32 & OPT_m)
#else #else
#define flag_print_load_map 0 #define flag_print_load_map 0
@ -717,19 +716,19 @@ enum {
/*======================================================================*/ /*======================================================================*/
#if defined(CONFIG_USE_LIST) #if defined(USE_LIST)
struct arch_list_entry struct arch_list_entry
{ {
struct arch_list_entry *next; struct arch_list_entry *next;
CONFIG_LIST_ARCHTYPE addend; LIST_ARCHTYPE addend;
int offset; int offset;
int inited : 1; int inited : 1;
}; };
#endif #endif
#if defined(CONFIG_USE_SINGLE) #if defined(USE_SINGLE)
struct arch_single_entry struct arch_single_entry
{ {
@ -751,10 +750,10 @@ struct mips_hi16
struct arch_file { struct arch_file {
struct obj_file root; struct obj_file root;
#if defined(CONFIG_USE_PLT_ENTRIES) #if defined(USE_PLT_ENTRIES)
struct obj_section *plt; struct obj_section *plt;
#endif #endif
#if defined(CONFIG_USE_GOT_ENTRIES) #if defined(USE_GOT_ENTRIES)
struct obj_section *got; struct obj_section *got;
#endif #endif
#if defined(__mips__) #if defined(__mips__)
@ -764,14 +763,14 @@ struct arch_file {
struct arch_symbol { struct arch_symbol {
struct obj_symbol root; struct obj_symbol root;
#if defined(CONFIG_USE_PLT_ENTRIES) #if defined(USE_PLT_ENTRIES)
#if defined(CONFIG_USE_PLT_LIST) #if defined(USE_PLT_LIST)
struct arch_list_entry *pltent; struct arch_list_entry *pltent;
#else #else
struct arch_single_entry pltent; struct arch_single_entry pltent;
#endif #endif
#endif #endif
#if defined(CONFIG_USE_GOT_ENTRIES) #if defined(USE_GOT_ENTRIES)
struct arch_single_entry gotent; struct arch_single_entry gotent;
#endif #endif
}; };
@ -860,18 +859,18 @@ arch_apply_relocation(struct obj_file *f,
enum obj_reloc ret = obj_reloc_ok; enum obj_reloc ret = obj_reloc_ok;
ElfW(Addr) *loc = (ElfW(Addr) *) (targsec->contents + rel->r_offset); ElfW(Addr) *loc = (ElfW(Addr) *) (targsec->contents + rel->r_offset);
ElfW(Addr) dot = targsec->header.sh_addr + rel->r_offset; ElfW(Addr) dot = targsec->header.sh_addr + rel->r_offset;
#if defined(CONFIG_USE_GOT_ENTRIES) || defined(CONFIG_USE_PLT_ENTRIES) #if defined(USE_GOT_ENTRIES) || defined(USE_PLT_ENTRIES)
struct arch_symbol *isym = (struct arch_symbol *) sym; struct arch_symbol *isym = (struct arch_symbol *) sym;
#endif #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(CONFIG_USE_GOT_ENTRIES) #if defined(USE_GOT_ENTRIES)
ElfW(Addr) got = ifile->got ? ifile->got->header.sh_addr : 0; ElfW(Addr) got = ifile->got ? ifile->got->header.sh_addr : 0;
#endif #endif
#endif #endif
#if defined(CONFIG_USE_PLT_ENTRIES) #if defined(USE_PLT_ENTRIES)
ElfW(Addr) plt = ifile->plt ? ifile->plt->header.sh_addr : 0; ElfW(Addr) plt = ifile->plt ? ifile->plt->header.sh_addr : 0;
unsigned long *ip; unsigned long *ip;
# if defined(CONFIG_USE_PLT_LIST) # if defined(USE_PLT_LIST)
struct arch_list_entry *pe; struct arch_list_entry *pe;
# else # else
struct arch_single_entry *pe; struct arch_single_entry *pe;
@ -1637,13 +1636,13 @@ arch_apply_relocation(struct obj_file *f,
ret = obj_reloc_unhandled; ret = obj_reloc_unhandled;
break; break;
#if defined(CONFIG_USE_PLT_ENTRIES) #if defined(USE_PLT_ENTRIES)
bb_use_plt: bb_use_plt:
/* find the plt entry and initialize it if necessary */ /* find the plt entry and initialize it if necessary */
#if defined(CONFIG_USE_PLT_LIST) #if defined(USE_PLT_LIST)
for (pe = isym->pltent; pe != NULL && pe->addend != rel->r_addend;) for (pe = isym->pltent; pe != NULL && pe->addend != rel->r_addend;)
pe = pe->next; pe = pe->next;
#else #else
@ -1714,9 +1713,9 @@ bb_use_plt:
(v & 0xffff); /* offs low part */ (v & 0xffff); /* offs low part */
#endif #endif
break; break;
#endif /* CONFIG_USE_PLT_ENTRIES */ #endif /* USE_PLT_ENTRIES */
#if defined(CONFIG_USE_GOT_ENTRIES) #if defined(USE_GOT_ENTRIES)
bb_use_got: bb_use_got:
/* needs an entry in the .got: set it, once */ /* needs an entry in the .got: set it, once */
@ -1732,14 +1731,14 @@ bb_use_got:
#endif #endif
break; break;
#endif /* CONFIG_USE_GOT_ENTRIES */ #endif /* USE_GOT_ENTRIES */
} }
return ret; return ret;
} }
#if defined(CONFIG_USE_LIST) #if defined(USE_LIST)
static int arch_list_add(ElfW(RelM) *rel, struct arch_list_entry **list, static int arch_list_add(ElfW(RelM) *rel, struct arch_list_entry **list,
int offset, int size) int offset, int size)
@ -1766,7 +1765,7 @@ static int arch_list_add(ElfW(RelM) *rel, struct arch_list_entry **list,
#endif #endif
#if defined(CONFIG_USE_SINGLE) #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) int offset, int size)
@ -1782,7 +1781,7 @@ static int arch_single_init(ElfW(RelM) *rel, struct arch_single_entry *single,
#endif #endif
#if defined(CONFIG_USE_GOT_ENTRIES) || defined(CONFIG_USE_PLT_ENTRIES) #if defined(USE_GOT_ENTRIES) || defined(USE_PLT_ENTRIES)
static struct obj_section *arch_xsect_init(struct obj_file *f, char *name, static struct obj_section *arch_xsect_init(struct obj_file *f, char *name,
int offset, int size) int offset, int size)
@ -1807,13 +1806,13 @@ static struct obj_section *arch_xsect_init(struct obj_file *f, char *name,
static void arch_create_got(struct obj_file *f) static void arch_create_got(struct obj_file *f)
{ {
#if defined(CONFIG_USE_GOT_ENTRIES) || defined(CONFIG_USE_PLT_ENTRIES) #if defined(USE_GOT_ENTRIES) || defined(USE_PLT_ENTRIES)
struct arch_file *ifile = (struct arch_file *) f; struct arch_file *ifile = (struct arch_file *) f;
int i; int i;
#if defined(CONFIG_USE_GOT_ENTRIES) #if defined(USE_GOT_ENTRIES)
int got_offset = 0, got_needed = 0, got_allocate; int got_offset = 0, got_needed = 0, got_allocate;
#endif #endif
#if defined(CONFIG_USE_PLT_ENTRIES) #if defined(USE_PLT_ENTRIES)
int plt_offset = 0, plt_needed = 0, plt_allocate; int plt_offset = 0, plt_needed = 0, plt_allocate;
#endif #endif
struct obj_section *relsec, *symsec, *strsec; struct obj_section *relsec, *symsec, *strsec;
@ -1838,10 +1837,10 @@ static void arch_create_got(struct obj_file *f)
for (; rel < relend; ++rel) { for (; rel < relend; ++rel) {
extsym = &symtab[ELF_R_SYM(rel->r_info)]; extsym = &symtab[ELF_R_SYM(rel->r_info)];
#if defined(CONFIG_USE_GOT_ENTRIES) #if defined(USE_GOT_ENTRIES)
got_allocate = 0; got_allocate = 0;
#endif #endif
#if defined(CONFIG_USE_PLT_ENTRIES) #if defined(USE_PLT_ENTRIES)
plt_allocate = 0; plt_allocate = 0;
#endif #endif
@ -1913,25 +1912,25 @@ static void arch_create_got(struct obj_file *f)
name = f->sections[extsym->st_shndx]->name; name = f->sections[extsym->st_shndx]->name;
} }
intsym = (struct arch_symbol *) obj_find_symbol(f, name); intsym = (struct arch_symbol *) obj_find_symbol(f, name);
#if defined(CONFIG_USE_GOT_ENTRIES) #if defined(USE_GOT_ENTRIES)
if (got_allocate) { if (got_allocate) {
got_offset += arch_single_init( got_offset += arch_single_init(
rel, &intsym->gotent, rel, &intsym->gotent,
got_offset, CONFIG_GOT_ENTRY_SIZE); got_offset, GOT_ENTRY_SIZE);
got_needed = 1; got_needed = 1;
} }
#endif #endif
#if defined(CONFIG_USE_PLT_ENTRIES) #if defined(USE_PLT_ENTRIES)
if (plt_allocate) { if (plt_allocate) {
#if defined(CONFIG_USE_PLT_LIST) #if defined(USE_PLT_LIST)
plt_offset += arch_list_add( plt_offset += arch_list_add(
rel, &intsym->pltent, rel, &intsym->pltent,
plt_offset, CONFIG_PLT_ENTRY_SIZE); plt_offset, PLT_ENTRY_SIZE);
#else #else
plt_offset += arch_single_init( plt_offset += arch_single_init(
rel, &intsym->pltent, rel, &intsym->pltent,
plt_offset, CONFIG_PLT_ENTRY_SIZE); plt_offset, PLT_ENTRY_SIZE);
#endif #endif
plt_needed = 1; plt_needed = 1;
} }
@ -1939,21 +1938,21 @@ static void arch_create_got(struct obj_file *f)
} }
} }
#if defined(CONFIG_USE_GOT_ENTRIES) #if defined(USE_GOT_ENTRIES)
if (got_needed) { if (got_needed) {
ifile->got = arch_xsect_init(f, ".got", got_offset, ifile->got = arch_xsect_init(f, ".got", got_offset,
CONFIG_GOT_ENTRY_SIZE); GOT_ENTRY_SIZE);
} }
#endif #endif
#if defined(CONFIG_USE_PLT_ENTRIES) #if defined(USE_PLT_ENTRIES)
if (plt_needed) { if (plt_needed) {
ifile->plt = arch_xsect_init(f, ".plt", plt_offset, ifile->plt = arch_xsect_init(f, ".plt", plt_offset,
CONFIG_PLT_ENTRY_SIZE); PLT_ENTRY_SIZE);
} }
#endif #endif
#endif /* defined(CONFIG_USE_GOT_ENTRIES) || defined(CONFIG_USE_PLT_ENTRIES) */ #endif /* defined(USE_GOT_ENTRIES) || defined(USE_PLT_ENTRIES) */
} }
/*======================================================================*/ /*======================================================================*/
@ -1982,7 +1981,7 @@ static unsigned long obj_elf_hash(const char *name)
return obj_elf_hash_n(name, strlen(name)); return obj_elf_hash_n(name, strlen(name));
} }
#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING #if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
/* String comparison for non-co-versioned kernel and module. */ /* String comparison for non-co-versioned kernel and module. */
static int ncv_strcmp(const char *a, const char *b) static int ncv_strcmp(const char *a, const char *b)
@ -2034,7 +2033,7 @@ obj_set_symbol_compare(struct obj_file *f,
} }
} }
#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */ #endif /* FEATURE_INSMOD_VERSION_CHECKING */
static struct obj_symbol * static struct obj_symbol *
obj_add_symbol(struct obj_file *f, const char *name, obj_add_symbol(struct obj_file *f, const char *name,
@ -2281,7 +2280,7 @@ add_symbols_from( struct obj_file *f,
char *name_buf = 0; char *name_buf = 0;
size_t name_alloced_size = 0; size_t name_alloced_size = 0;
#endif #endif
#ifdef CONFIG_FEATURE_CHECK_TAINTED_MODULE #if ENABLE_FEATURE_CHECK_TAINTED_MODULE
int gpl; int gpl;
gpl = obj_gpl_license(f, NULL) == 0; gpl = obj_gpl_license(f, NULL) == 0;
@ -2301,7 +2300,7 @@ add_symbols_from( struct obj_file *f,
* their references. * their references.
*/ */
if (strncmp((char *)s->name, "GPLONLY_", 8) == 0) { if (strncmp((char *)s->name, "GPLONLY_", 8) == 0) {
#ifdef CONFIG_FEATURE_CHECK_TAINTED_MODULE #if ENABLE_FEATURE_CHECK_TAINTED_MODULE
if (gpl) if (gpl)
s->name += 8; s->name += 8;
else else
@ -2637,7 +2636,7 @@ end_of_arg:
return 1; return 1;
} }
#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING #if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
static int new_is_module_checksummed(struct obj_file *f) static int new_is_module_checksummed(struct obj_file *f)
{ {
const char *p = get_modinfo_value(f, "using_checksums"); const char *p = get_modinfo_value(f, "using_checksums");
@ -2673,7 +2672,7 @@ new_get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
return a << 16 | b << 8 | c; return a << 16 | b << 8 | c;
} }
#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */ #endif /* FEATURE_INSMOD_VERSION_CHECKING */
/* Fetch the loaded modules, and all currently exported symbols. */ /* Fetch the loaded modules, and all currently exported symbols. */
@ -2803,7 +2802,7 @@ static int new_create_this_module(struct obj_file *f, const char *m_name)
return 1; return 1;
} }
#ifdef CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS #if ENABLE_FEATURE_INSMOD_KSYMOOPS_SYMBOLS
/* add an entry to the __ksymtab section, creating it if necessary */ /* add an entry to the __ksymtab section, creating it if necessary */
static void new_add_ksymtab(struct obj_file *f, struct obj_symbol *sym) static void new_add_ksymtab(struct obj_file *f, struct obj_symbol *sym)
{ {
@ -2826,14 +2825,14 @@ static void new_add_ksymtab(struct obj_file *f, struct obj_symbol *sym)
if (!sec) if (!sec)
return; return;
sec->header.sh_flags |= SHF_ALLOC; sec->header.sh_flags |= SHF_ALLOC;
sec->header.sh_addralign = tgt_sizeof_void_p; /* Empty section might /* Empty section might be byte-aligned */
be byte-aligned */ sec->header.sh_addralign = tgt_sizeof_void_p;
ofs = sec->header.sh_size; ofs = sec->header.sh_size;
obj_symbol_patch(f, sec->idx, ofs, sym); obj_symbol_patch(f, sec->idx, ofs, sym);
obj_string_patch(f, sec->idx, ofs + tgt_sizeof_void_p, sym->name); obj_string_patch(f, sec->idx, ofs + tgt_sizeof_void_p, sym->name);
obj_extend_section(sec, 2 * tgt_sizeof_char_p); obj_extend_section(sec, 2 * tgt_sizeof_char_p);
} }
#endif /* CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS */ #endif /* FEATURE_INSMOD_KSYMOOPS_SYMBOLS */
static int new_create_module_ksymtab(struct obj_file *f) static int new_create_module_ksymtab(struct obj_file *f)
{ {
@ -3552,7 +3551,7 @@ static struct obj_file *obj_load(FILE * fp, int loadprogbits)
return f; return f;
} }
#ifdef CONFIG_FEATURE_INSMOD_LOADINKMEM #if ENABLE_FEATURE_INSMOD_LOADINKMEM
/* /*
* load the unloaded sections directly into the memory allocated by * load the unloaded sections directly into the memory allocated by
* kernel for the module * kernel for the module
@ -3604,7 +3603,7 @@ static void hide_special_symbols(struct obj_file *f)
} }
#ifdef CONFIG_FEATURE_CHECK_TAINTED_MODULE #if ENABLE_FEATURE_CHECK_TAINTED_MODULE
static int obj_gpl_license(struct obj_file *f, const char **license) static int obj_gpl_license(struct obj_file *f, const char **license)
{ {
struct obj_section *sec; struct obj_section *sec;
@ -3719,11 +3718,11 @@ static void check_tainted_module(struct obj_file *f, char *m_name)
if (fd >= 0) if (fd >= 0)
close(fd); close(fd);
} }
#else /* CONFIG_FEATURE_CHECK_TAINTED_MODULE */ #else /* FEATURE_CHECK_TAINTED_MODULE */
#define check_tainted_module(x, y) do { } while(0); #define check_tainted_module(x, y) do { } while(0);
#endif /* CONFIG_FEATURE_CHECK_TAINTED_MODULE */ #endif /* FEATURE_CHECK_TAINTED_MODULE */
#ifdef CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS #if ENABLE_FEATURE_INSMOD_KSYMOOPS_SYMBOLS
/* add module source, timestamp, kernel version and a symbol for the /* add module source, timestamp, kernel version and a symbol for the
* start of some sections. this info is used by ksymoops to do better * start of some sections. this info is used by ksymoops to do better
* debugging. * debugging.
@ -3731,12 +3730,12 @@ static void check_tainted_module(struct obj_file *f, char *m_name)
static int static int
get_module_version(struct obj_file *f, char str[STRVERSIONLEN]) get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
{ {
#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING #if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
return new_get_module_version(f, str); return new_get_module_version(f, str);
#else /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */ #else /* FEATURE_INSMOD_VERSION_CHECKING */
strncpy(str, "???", sizeof(str)); strncpy(str, "???", sizeof(str));
return -1; return -1;
#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */ #endif /* FEATURE_INSMOD_VERSION_CHECKING */
} }
/* add module source, timestamp, kernel version and a symbol for the /* add module source, timestamp, kernel version and a symbol for the
@ -3854,9 +3853,9 @@ add_ksymoops_symbols(struct obj_file *f, const char *filename,
} }
} }
} }
#endif /* CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS */ #endif /* FEATURE_INSMOD_KSYMOOPS_SYMBOLS */
#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP #if ENABLE_FEATURE_INSMOD_LOAD_MAP
static void print_load_map(struct obj_file *f) static void print_load_map(struct obj_file *f)
{ {
struct obj_symbol *sym; struct obj_symbol *sym;
@ -3885,7 +3884,7 @@ static void print_load_map(struct obj_file *f)
(long)sec->header.sh_addr, (long)sec->header.sh_addr,
a); a);
} }
#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL #if ENABLE_FEATURE_INSMOD_LOAD_MAP_FULL
/* Quick reference which section indicies are loaded. */ /* Quick reference which section indicies are loaded. */
loaded = alloca(sizeof(int) * (i = f->header.e_shnum)); loaded = alloca(sizeof(int) * (i = f->header.e_shnum));
@ -3945,7 +3944,7 @@ static void print_load_map(struct obj_file *f)
} }
#endif #endif
} }
#else /* !CONFIG_FEATURE_INSMOD_LOAD_MAP */ #else /* !FEATURE_INSMOD_LOAD_MAP */
void print_load_map(struct obj_file *f); void print_load_map(struct obj_file *f);
#endif #endif
@ -3962,12 +3961,12 @@ int insmod_main( int argc, char **argv)
char *m_name = 0; char *m_name = 0;
int exit_status = EXIT_FAILURE; int exit_status = EXIT_FAILURE;
int m_has_modinfo; int m_has_modinfo;
#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING #if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
struct utsname uts_info; struct utsname uts_info;
char m_strversion[STRVERSIONLEN]; char m_strversion[STRVERSIONLEN];
int m_version, m_crcs; int m_version, m_crcs;
#endif #endif
#ifdef CONFIG_FEATURE_CLEAN_UP #if ENABLE_FEATURE_CLEAN_UP
FILE *fp = 0; FILE *fp = 0;
#else #else
FILE *fp; FILE *fp;
@ -3998,7 +3997,7 @@ int insmod_main( int argc, char **argv)
} }
} }
#if defined(CONFIG_FEATURE_2_6_MODULES) #if ENABLE_FEATURE_2_6_MODULES
if (k_version > 4 && len > 3 && tmp[len - 3] == '.' if (k_version > 4 && len > 3 && tmp[len - 3] == '.'
&& tmp[len - 2] == 'k' && tmp[len - 1] == 'o' && tmp[len - 2] == 'k' && tmp[len - 1] == 'o'
) { ) {
@ -4012,7 +4011,7 @@ int insmod_main( int argc, char **argv)
} }
#if defined(CONFIG_FEATURE_2_6_MODULES) #if ENABLE_FEATURE_2_6_MODULES
if (k_version > 4) if (k_version > 4)
m_fullName = xasprintf("%s.ko", tmp); m_fullName = xasprintf("%s.ko", tmp);
else else
@ -4080,7 +4079,7 @@ int insmod_main( int argc, char **argv)
if (flag_verbose) if (flag_verbose)
printf("Using %s\n", m_filename); printf("Using %s\n", m_filename);
#ifdef CONFIG_FEATURE_2_6_MODULES #if ENABLE_FEATURE_2_6_MODULES
if (k_version > 4) { if (k_version > 4) {
argv[optind] = m_filename; argv[optind] = m_filename;
optind--; optind--;
@ -4097,7 +4096,7 @@ int insmod_main( int argc, char **argv)
else else
m_has_modinfo = 1; m_has_modinfo = 1;
#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING #if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
/* Version correspondence? */ /* Version correspondence? */
if (!flag_quiet) { if (!flag_quiet) {
if (uname(&uts_info) < 0) if (uname(&uts_info) < 0)
@ -4127,7 +4126,7 @@ int insmod_main( int argc, char **argv)
} }
} }
k_crcs = 0; k_crcs = 0;
#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */ #endif /* FEATURE_INSMOD_VERSION_CHECKING */
if (!query_module(NULL, 0, NULL, 0, NULL)) { if (!query_module(NULL, 0, NULL, 0, NULL)) {
if (!new_get_kernel_symbols()) if (!new_get_kernel_symbols())
@ -4138,14 +4137,14 @@ int insmod_main( int argc, char **argv)
goto out; goto out;
} }
#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING #if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
m_crcs = 0; m_crcs = 0;
if (m_has_modinfo) if (m_has_modinfo)
m_crcs = new_is_module_checksummed(f); m_crcs = new_is_module_checksummed(f);
if (m_crcs != k_crcs) if (m_crcs != k_crcs)
obj_set_symbol_compare(f, ncv_strcmp, ncv_symbol_hash); obj_set_symbol_compare(f, ncv_strcmp, ncv_symbol_hash);
#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */ #endif /* FEATURE_INSMOD_VERSION_CHECKING */
/* Let the module know about the kernel symbols. */ /* Let the module know about the kernel symbols. */
add_kernel_symbols(f); add_kernel_symbols(f);
@ -4173,9 +4172,9 @@ int insmod_main( int argc, char **argv)
arch_create_got(f); arch_create_got(f);
hide_special_symbols(f); hide_special_symbols(f);
#ifdef CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS #if ENABLE_FEATURE_INSMOD_KSYMOOPS_SYMBOLS
add_ksymoops_symbols(f, m_filename, m_name); add_ksymoops_symbols(f, m_filename, m_name);
#endif /* CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS */ #endif /* FEATURE_INSMOD_KSYMOOPS_SYMBOLS */
new_create_module_ksymtab(f); new_create_module_ksymtab(f);
@ -4224,7 +4223,7 @@ int insmod_main( int argc, char **argv)
exit_status = EXIT_SUCCESS; exit_status = EXIT_SUCCESS;
out: out:
#ifdef CONFIG_FEATURE_CLEAN_UP #if ENABLE_FEATURE_CLEAN_UP
if(fp) if(fp)
fclose(fp); fclose(fp);
free(tmp1); free(tmp1);
@ -4240,7 +4239,7 @@ out:
#endif #endif
#ifdef CONFIG_FEATURE_2_6_MODULES #if ENABLE_FEATURE_2_6_MODULES
#include <sys/mman.h> #include <sys/mman.h>
#include <asm/unistd.h> #include <asm/unistd.h>