aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-11-21 14:12:53 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-11-21 14:12:53 +0000
commit3aa2d51cd6649911a84e943845237009f03efed6 (patch)
tree308d2926bfee763b548088e420e7e35456859ab9
parent9229794ab33fa510a5896784958b90f87bef6876 (diff)
downloadbusybox-w32-3aa2d51cd6649911a84e943845237009f03efed6.tar.gz
busybox-w32-3aa2d51cd6649911a84e943845237009f03efed6.tar.bz2
busybox-w32-3aa2d51cd6649911a84e943845237009f03efed6.zip
insmod: set STRVERSIONLEN = 64, convert #ifdef CONFIG to #if ENABLE,
stop using CONFIG_ prefix for non-config-system variables
-rw-r--r--modutils/insmod.c229
1 files changed, 114 insertions, 115 deletions
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 11ba26344..f6ab44309 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -40,7 +40,7 @@
40 * PowerPC specific code stolen from modutils-2.3.16, 40 * PowerPC specific code stolen from modutils-2.3.16,
41 * written by Paul Mackerras, Copyright 1996, 1997 Linux International. 41 * written by Paul Mackerras, Copyright 1996, 1997 Linux International.
42 * I've only tested the code on mpc8xx platforms in big-endian mode. 42 * I've only tested the code on mpc8xx platforms in big-endian mode.
43 * Did some cleanup and added CONFIG_USE_xxx_ENTRIES... 43 * Did some cleanup and added USE_xxx_ENTRIES...
44 * 44 *
45 * Quinn Jensen <jensenq@lineo.com> added MIPS support 23-Feb-2001. 45 * Quinn Jensen <jensenq@lineo.com> added MIPS support 23-Feb-2001.
46 * based on modutils-2.4.2 46 * based on modutils-2.4.2
@@ -62,24 +62,23 @@
62#include <libgen.h> 62#include <libgen.h>
63#include <sys/utsname.h> 63#include <sys/utsname.h>
64 64
65#if !defined(CONFIG_FEATURE_2_4_MODULES) && \ 65#if !ENABLE_FEATURE_2_4_MODULES && !ENABLE_FEATURE_2_6_MODULES
66 !defined(CONFIG_FEATURE_2_6_MODULES) 66#define ENABLE_FEATURE_2_4_MODULES 1
67#define CONFIG_FEATURE_2_4_MODULES
68#endif 67#endif
69 68
70#if !defined(CONFIG_FEATURE_2_4_MODULES) 69#if !ENABLE_FEATURE_2_4_MODULES
71#define insmod_ng_main insmod_main 70#define insmod_ng_main insmod_main
72#endif 71#endif
73 72
74#if defined(CONFIG_FEATURE_2_6_MODULES) 73#if ENABLE_FEATURE_2_6_MODULES
75extern int insmod_ng_main( int argc, char **argv); 74extern int insmod_ng_main( int argc, char **argv);
76#endif 75#endif
77 76
78 77
79#if defined(CONFIG_FEATURE_2_4_MODULES) 78#if ENABLE_FEATURE_2_4_MODULES
80 79
81 80
82#ifdef CONFIG_FEATURE_INSMOD_LOADINKMEM 81#if ENABLE_FEATURE_INSMOD_LOADINKMEM
83#define LOADBITS 0 82#define LOADBITS 0
84#else 83#else
85#define LOADBITS 1 84#define LOADBITS 1
@@ -100,11 +99,11 @@ extern int insmod_ng_main( int argc, char **argv);
100#define SHT_RELM SHT_REL 99#define SHT_RELM SHT_REL
101#define Elf32_RelM Elf32_Rel 100#define Elf32_RelM Elf32_Rel
102#define ELFCLASSM ELFCLASS32 101#define ELFCLASSM ELFCLASS32
103#define CONFIG_USE_PLT_ENTRIES 102#define USE_PLT_ENTRIES
104#define CONFIG_PLT_ENTRY_SIZE 8 103#define PLT_ENTRY_SIZE 8
105#define CONFIG_USE_GOT_ENTRIES 104#define USE_GOT_ENTRIES
106#define CONFIG_GOT_ENTRY_SIZE 8 105#define GOT_ENTRY_SIZE 8
107#define CONFIG_USE_SINGLE 106#define USE_SINGLE
108#endif 107#endif
109 108
110/* blackfin */ 109/* blackfin */
@@ -134,7 +133,7 @@ extern int insmod_ng_main( int argc, char **argv);
134#define SHT_RELM SHT_RELA 133#define SHT_RELM SHT_RELA
135#define Elf32_RelM Elf32_Rela 134#define Elf32_RelM Elf32_Rela
136#define ELFCLASSM ELFCLASS32 135#define ELFCLASSM ELFCLASS32
137#define CONFIG_USE_SINGLE 136#define USE_SINGLE
138#define SYMBOL_PREFIX "_" 137#define SYMBOL_PREFIX "_"
139#endif 138#endif
140 139
@@ -161,9 +160,9 @@ extern int insmod_ng_main( int argc, char **argv);
161#define SHT_RELM SHT_REL 160#define SHT_RELM SHT_REL
162#define Elf32_RelM Elf32_Rel 161#define Elf32_RelM Elf32_Rel
163#define ELFCLASSM ELFCLASS32 162#define ELFCLASSM ELFCLASS32
164#define CONFIG_USE_GOT_ENTRIES 163#define USE_GOT_ENTRIES
165#define CONFIG_GOT_ENTRY_SIZE 4 164#define GOT_ENTRY_SIZE 4
166#define CONFIG_USE_SINGLE 165#define USE_SINGLE
167#endif 166#endif
168 167
169/* IA64, aka Itanium */ 168/* IA64, aka Itanium */
@@ -180,14 +179,14 @@ extern int insmod_ng_main( int argc, char **argv);
180#define SHT_RELM SHT_RELA 179#define SHT_RELM SHT_RELA
181#define Elf32_RelM Elf32_Rela 180#define Elf32_RelM Elf32_Rela
182#define ELFCLASSM ELFCLASS32 181#define ELFCLASSM ELFCLASS32
183#define CONFIG_USE_GOT_ENTRIES 182#define USE_GOT_ENTRIES
184#define CONFIG_GOT_ENTRY_SIZE 4 183#define GOT_ENTRY_SIZE 4
185#define CONFIG_USE_SINGLE 184#define USE_SINGLE
186#endif 185#endif
187 186
188/* Microblaze */ 187/* Microblaze */
189#if defined(__microblaze__) 188#if defined(__microblaze__)
190#define CONFIG_USE_SINGLE 189#define USE_SINGLE
191#define MATCH_MACHINE(x) (x == EM_XILINX_MICROBLAZE) 190#define MATCH_MACHINE(x) (x == EM_XILINX_MICROBLAZE)
192#define SHT_RELM SHT_RELA 191#define SHT_RELM SHT_RELA
193#define Elf32_RelM Elf32_Rela 192#define Elf32_RelM Elf32_Rela
@@ -230,11 +229,11 @@ extern int insmod_ng_main( int argc, char **argv);
230#define SHT_RELM SHT_RELA 229#define SHT_RELM SHT_RELA
231#define Elf32_RelM Elf32_Rela 230#define Elf32_RelM Elf32_Rela
232#define ELFCLASSM ELFCLASS32 231#define ELFCLASSM ELFCLASS32
233#define CONFIG_USE_PLT_ENTRIES 232#define USE_PLT_ENTRIES
234#define CONFIG_PLT_ENTRY_SIZE 16 233#define PLT_ENTRY_SIZE 16
235#define CONFIG_USE_PLT_LIST 234#define USE_PLT_LIST
236#define CONFIG_LIST_ARCHTYPE ElfW(Addr) 235#define LIST_ARCHTYPE ElfW(Addr)
237#define CONFIG_USE_LIST 236#define USE_LIST
238#define ARCHDATAM "__ftr_fixup" 237#define ARCHDATAM "__ftr_fixup"
239#endif 238#endif
240 239
@@ -244,11 +243,11 @@ extern int insmod_ng_main( int argc, char **argv);
244#define SHT_RELM SHT_RELA 243#define SHT_RELM SHT_RELA
245#define Elf32_RelM Elf32_Rela 244#define Elf32_RelM Elf32_Rela
246#define ELFCLASSM ELFCLASS32 245#define ELFCLASSM ELFCLASS32
247#define CONFIG_USE_PLT_ENTRIES 246#define USE_PLT_ENTRIES
248#define CONFIG_PLT_ENTRY_SIZE 8 247#define PLT_ENTRY_SIZE 8
249#define CONFIG_USE_GOT_ENTRIES 248#define USE_GOT_ENTRIES
250#define CONFIG_GOT_ENTRY_SIZE 8 249#define GOT_ENTRY_SIZE 8
251#define CONFIG_USE_SINGLE 250#define USE_SINGLE
252#endif 251#endif
253 252
254/* SuperH */ 253/* SuperH */
@@ -257,9 +256,9 @@ extern int insmod_ng_main( int argc, char **argv);
257#define SHT_RELM SHT_RELA 256#define SHT_RELM SHT_RELA
258#define Elf32_RelM Elf32_Rela 257#define Elf32_RelM Elf32_Rela
259#define ELFCLASSM ELFCLASS32 258#define ELFCLASSM ELFCLASS32
260#define CONFIG_USE_GOT_ENTRIES 259#define USE_GOT_ENTRIES
261#define CONFIG_GOT_ENTRY_SIZE 4 260#define GOT_ENTRY_SIZE 4
262#define CONFIG_USE_SINGLE 261#define USE_SINGLE
263/* the SH changes have only been tested in =little endian= mode */ 262/* the SH changes have only been tested in =little endian= mode */
264/* I'm not sure about big endian, so let's warn: */ 263/* I'm not sure about big endian, so let's warn: */
265#if defined(__sh__) && BB_BIG_ENDIAN 264#if defined(__sh__) && BB_BIG_ENDIAN
@@ -285,9 +284,9 @@ extern int insmod_ng_main( int argc, char **argv);
285#define SHT_RELM SHT_RELA 284#define SHT_RELM SHT_RELA
286#define Elf32_RelM Elf32_Rela 285#define Elf32_RelM Elf32_Rela
287#define ELFCLASSM ELFCLASS32 286#define ELFCLASSM ELFCLASS32
288#define CONFIG_USE_PLT_ENTRIES 287#define USE_PLT_ENTRIES
289#define CONFIG_PLT_ENTRY_SIZE 8 288#define PLT_ENTRY_SIZE 8
290#define CONFIG_USE_SINGLE 289#define USE_SINGLE
291#ifndef EM_CYGNUS_V850 /* grumble */ 290#ifndef EM_CYGNUS_V850 /* grumble */
292#define EM_CYGNUS_V850 0x9080 291#define EM_CYGNUS_V850 0x9080
293#endif 292#endif
@@ -298,9 +297,9 @@ extern int insmod_ng_main( int argc, char **argv);
298#if defined(__x86_64__) 297#if defined(__x86_64__)
299#define MATCH_MACHINE(x) (x == EM_X86_64) 298#define MATCH_MACHINE(x) (x == EM_X86_64)
300#define SHT_RELM SHT_RELA 299#define SHT_RELM SHT_RELA
301#define CONFIG_USE_GOT_ENTRIES 300#define USE_GOT_ENTRIES
302#define CONFIG_GOT_ENTRY_SIZE 8 301#define GOT_ENTRY_SIZE 8
303#define CONFIG_USE_SINGLE 302#define USE_SINGLE
304#define Elf64_RelM Elf64_Rela 303#define Elf64_RelM Elf64_Rela
305#define ELFCLASSM ELFCLASS64 304#define ELFCLASSM ELFCLASS64
306#endif 305#endif
@@ -606,7 +605,7 @@ static struct obj_symbol *obj_find_symbol (struct obj_file *f,
606static ElfW(Addr) obj_symbol_final_value(struct obj_file *f, 605static ElfW(Addr) obj_symbol_final_value(struct obj_file *f,
607 struct obj_symbol *sym); 606 struct obj_symbol *sym);
608 607
609#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING 608#if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
610static void obj_set_symbol_compare(struct obj_file *f, 609static void obj_set_symbol_compare(struct obj_file *f,
611 int (*cmp)(const char *, const char *), 610 int (*cmp)(const char *, const char *),
612 unsigned long (*hash)(const char *)); 611 unsigned long (*hash)(const char *));
@@ -665,7 +664,7 @@ static enum obj_reloc arch_apply_relocation (struct obj_file *f,
665static void arch_create_got (struct obj_file *f); 664static void arch_create_got (struct obj_file *f);
666#if ENABLE_FEATURE_CHECK_TAINTED_MODULE 665#if ENABLE_FEATURE_CHECK_TAINTED_MODULE
667static int obj_gpl_license(struct obj_file *f, const char **license); 666static int obj_gpl_license(struct obj_file *f, const char **license);
668#endif /* ENABLE_FEATURE_CHECK_TAINTED_MODULE */ 667#endif /* FEATURE_CHECK_TAINTED_MODULE */
669#endif /* obj.h */ 668#endif /* obj.h */
670//---------------------------------------------------------------------------- 669//----------------------------------------------------------------------------
671//--------end of modutils obj.h 670//--------end of modutils obj.h
@@ -681,7 +680,7 @@ static int obj_gpl_license(struct obj_file *f, const char **license);
681 680
682 681
683#define _PATH_MODULES "/lib/modules" 682#define _PATH_MODULES "/lib/modules"
684enum { STRVERSIONLEN = 32 }; 683enum { STRVERSIONLEN = 64 };
685 684
686/*======================================================================*/ 685/*======================================================================*/
687 686
@@ -709,7 +708,7 @@ enum {
709#define flag_verbose (option_mask32 & OPT_v) 708#define flag_verbose (option_mask32 & OPT_v)
710#define flag_quiet (option_mask32 & OPT_q) 709#define flag_quiet (option_mask32 & OPT_q)
711#define flag_noexport (option_mask32 & OPT_x) 710#define flag_noexport (option_mask32 & OPT_x)
712#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP 711#if ENABLE_FEATURE_INSMOD_LOAD_MAP
713#define flag_print_load_map (option_mask32 & OPT_m) 712#define flag_print_load_map (option_mask32 & OPT_m)
714#else 713#else
715#define flag_print_load_map 0 714#define flag_print_load_map 0
@@ -717,19 +716,19 @@ enum {
717 716
718/*======================================================================*/ 717/*======================================================================*/
719 718
720#if defined(CONFIG_USE_LIST) 719#if defined(USE_LIST)
721 720
722struct arch_list_entry 721struct arch_list_entry
723{ 722{
724 struct arch_list_entry *next; 723 struct arch_list_entry *next;
725 CONFIG_LIST_ARCHTYPE addend; 724 LIST_ARCHTYPE addend;
726 int offset; 725 int offset;
727 int inited : 1; 726 int inited : 1;
728}; 727};
729 728
730#endif 729#endif
731 730
732#if defined(CONFIG_USE_SINGLE) 731#if defined(USE_SINGLE)
733 732
734struct arch_single_entry 733struct arch_single_entry
735{ 734{
@@ -751,10 +750,10 @@ struct mips_hi16
751 750
752struct arch_file { 751struct arch_file {
753 struct obj_file root; 752 struct obj_file root;
754#if defined(CONFIG_USE_PLT_ENTRIES) 753#if defined(USE_PLT_ENTRIES)
755 struct obj_section *plt; 754 struct obj_section *plt;
756#endif 755#endif
757#if defined(CONFIG_USE_GOT_ENTRIES) 756#if defined(USE_GOT_ENTRIES)
758 struct obj_section *got; 757 struct obj_section *got;
759#endif 758#endif
760#if defined(__mips__) 759#if defined(__mips__)
@@ -764,14 +763,14 @@ struct arch_file {
764 763
765struct arch_symbol { 764struct arch_symbol {
766 struct obj_symbol root; 765 struct obj_symbol root;
767#if defined(CONFIG_USE_PLT_ENTRIES) 766#if defined(USE_PLT_ENTRIES)
768#if defined(CONFIG_USE_PLT_LIST) 767#if defined(USE_PLT_LIST)
769 struct arch_list_entry *pltent; 768 struct arch_list_entry *pltent;
770#else 769#else
771 struct arch_single_entry pltent; 770 struct arch_single_entry pltent;
772#endif 771#endif
773#endif 772#endif
774#if defined(CONFIG_USE_GOT_ENTRIES) 773#if defined(USE_GOT_ENTRIES)
775 struct arch_single_entry gotent; 774 struct arch_single_entry gotent;
776#endif 775#endif
777}; 776};
@@ -860,18 +859,18 @@ arch_apply_relocation(struct obj_file *f,
860 enum obj_reloc ret = obj_reloc_ok; 859 enum obj_reloc ret = obj_reloc_ok;
861 ElfW(Addr) *loc = (ElfW(Addr) *) (targsec->contents + rel->r_offset); 860 ElfW(Addr) *loc = (ElfW(Addr) *) (targsec->contents + rel->r_offset);
862 ElfW(Addr) dot = targsec->header.sh_addr + rel->r_offset; 861 ElfW(Addr) dot = targsec->header.sh_addr + rel->r_offset;
863#if defined(CONFIG_USE_GOT_ENTRIES) || defined(CONFIG_USE_PLT_ENTRIES) 862#if defined(USE_GOT_ENTRIES) || defined(USE_PLT_ENTRIES)
864 struct arch_symbol *isym = (struct arch_symbol *) sym; 863 struct arch_symbol *isym = (struct arch_symbol *) sym;
865#endif 864#endif
866#if defined(__arm__) || defined(__i386__) || defined(__mc68000__) || defined(__sh__) || defined(__s390__) 865#if defined(__arm__) || defined(__i386__) || defined(__mc68000__) || defined(__sh__) || defined(__s390__)
867#if defined(CONFIG_USE_GOT_ENTRIES) 866#if defined(USE_GOT_ENTRIES)
868 ElfW(Addr) got = ifile->got ? ifile->got->header.sh_addr : 0; 867 ElfW(Addr) got = ifile->got ? ifile->got->header.sh_addr : 0;
869#endif 868#endif
870#endif 869#endif
871#if defined(CONFIG_USE_PLT_ENTRIES) 870#if defined(USE_PLT_ENTRIES)
872 ElfW(Addr) plt = ifile->plt ? ifile->plt->header.sh_addr : 0; 871 ElfW(Addr) plt = ifile->plt ? ifile->plt->header.sh_addr : 0;
873 unsigned long *ip; 872 unsigned long *ip;
874# if defined(CONFIG_USE_PLT_LIST) 873# if defined(USE_PLT_LIST)
875 struct arch_list_entry *pe; 874 struct arch_list_entry *pe;
876# else 875# else
877 struct arch_single_entry *pe; 876 struct arch_single_entry *pe;
@@ -1637,13 +1636,13 @@ arch_apply_relocation(struct obj_file *f,
1637 ret = obj_reloc_unhandled; 1636 ret = obj_reloc_unhandled;
1638 break; 1637 break;
1639 1638
1640#if defined(CONFIG_USE_PLT_ENTRIES) 1639#if defined(USE_PLT_ENTRIES)
1641 1640
1642bb_use_plt: 1641bb_use_plt:
1643 1642
1644 /* find the plt entry and initialize it if necessary */ 1643 /* find the plt entry and initialize it if necessary */
1645 1644
1646#if defined(CONFIG_USE_PLT_LIST) 1645#if defined(USE_PLT_LIST)
1647 for (pe = isym->pltent; pe != NULL && pe->addend != rel->r_addend;) 1646 for (pe = isym->pltent; pe != NULL && pe->addend != rel->r_addend;)
1648 pe = pe->next; 1647 pe = pe->next;
1649#else 1648#else
@@ -1714,9 +1713,9 @@ bb_use_plt:
1714 (v & 0xffff); /* offs low part */ 1713 (v & 0xffff); /* offs low part */
1715#endif 1714#endif
1716 break; 1715 break;
1717#endif /* CONFIG_USE_PLT_ENTRIES */ 1716#endif /* USE_PLT_ENTRIES */
1718 1717
1719#if defined(CONFIG_USE_GOT_ENTRIES) 1718#if defined(USE_GOT_ENTRIES)
1720bb_use_got: 1719bb_use_got:
1721 1720
1722 /* needs an entry in the .got: set it, once */ 1721 /* needs an entry in the .got: set it, once */
@@ -1732,14 +1731,14 @@ bb_use_got:
1732#endif 1731#endif
1733 break; 1732 break;
1734 1733
1735#endif /* CONFIG_USE_GOT_ENTRIES */ 1734#endif /* USE_GOT_ENTRIES */
1736 } 1735 }
1737 1736
1738 return ret; 1737 return ret;
1739} 1738}
1740 1739
1741 1740
1742#if defined(CONFIG_USE_LIST) 1741#if defined(USE_LIST)
1743 1742
1744static int arch_list_add(ElfW(RelM) *rel, struct arch_list_entry **list, 1743static int arch_list_add(ElfW(RelM) *rel, struct arch_list_entry **list,
1745 int offset, int size) 1744 int offset, int size)
@@ -1766,7 +1765,7 @@ static int arch_list_add(ElfW(RelM) *rel, struct arch_list_entry **list,
1766 1765
1767#endif 1766#endif
1768 1767
1769#if defined(CONFIG_USE_SINGLE) 1768#if defined(USE_SINGLE)
1770 1769
1771static int arch_single_init(ElfW(RelM) *rel, struct arch_single_entry *single, 1770static int arch_single_init(ElfW(RelM) *rel, struct arch_single_entry *single,
1772 int offset, int size) 1771 int offset, int size)
@@ -1782,7 +1781,7 @@ static int arch_single_init(ElfW(RelM) *rel, struct arch_single_entry *single,
1782 1781
1783#endif 1782#endif
1784 1783
1785#if defined(CONFIG_USE_GOT_ENTRIES) || defined(CONFIG_USE_PLT_ENTRIES) 1784#if defined(USE_GOT_ENTRIES) || defined(USE_PLT_ENTRIES)
1786 1785
1787static struct obj_section *arch_xsect_init(struct obj_file *f, char *name, 1786static struct obj_section *arch_xsect_init(struct obj_file *f, char *name,
1788 int offset, int size) 1787 int offset, int size)
@@ -1807,13 +1806,13 @@ static struct obj_section *arch_xsect_init(struct obj_file *f, char *name,
1807 1806
1808static void arch_create_got(struct obj_file *f) 1807static void arch_create_got(struct obj_file *f)
1809{ 1808{
1810#if defined(CONFIG_USE_GOT_ENTRIES) || defined(CONFIG_USE_PLT_ENTRIES) 1809#if defined(USE_GOT_ENTRIES) || defined(USE_PLT_ENTRIES)
1811 struct arch_file *ifile = (struct arch_file *) f; 1810 struct arch_file *ifile = (struct arch_file *) f;
1812 int i; 1811 int i;
1813#if defined(CONFIG_USE_GOT_ENTRIES) 1812#if defined(USE_GOT_ENTRIES)
1814 int got_offset = 0, got_needed = 0, got_allocate; 1813 int got_offset = 0, got_needed = 0, got_allocate;
1815#endif 1814#endif
1816#if defined(CONFIG_USE_PLT_ENTRIES) 1815#if defined(USE_PLT_ENTRIES)
1817 int plt_offset = 0, plt_needed = 0, plt_allocate; 1816 int plt_offset = 0, plt_needed = 0, plt_allocate;
1818#endif 1817#endif
1819 struct obj_section *relsec, *symsec, *strsec; 1818 struct obj_section *relsec, *symsec, *strsec;
@@ -1838,10 +1837,10 @@ static void arch_create_got(struct obj_file *f)
1838 for (; rel < relend; ++rel) { 1837 for (; rel < relend; ++rel) {
1839 extsym = &symtab[ELF_R_SYM(rel->r_info)]; 1838 extsym = &symtab[ELF_R_SYM(rel->r_info)];
1840 1839
1841#if defined(CONFIG_USE_GOT_ENTRIES) 1840#if defined(USE_GOT_ENTRIES)
1842 got_allocate = 0; 1841 got_allocate = 0;
1843#endif 1842#endif
1844#if defined(CONFIG_USE_PLT_ENTRIES) 1843#if defined(USE_PLT_ENTRIES)
1845 plt_allocate = 0; 1844 plt_allocate = 0;
1846#endif 1845#endif
1847 1846
@@ -1913,25 +1912,25 @@ static void arch_create_got(struct obj_file *f)
1913 name = f->sections[extsym->st_shndx]->name; 1912 name = f->sections[extsym->st_shndx]->name;
1914 } 1913 }
1915 intsym = (struct arch_symbol *) obj_find_symbol(f, name); 1914 intsym = (struct arch_symbol *) obj_find_symbol(f, name);
1916#if defined(CONFIG_USE_GOT_ENTRIES) 1915#if defined(USE_GOT_ENTRIES)
1917 if (got_allocate) { 1916 if (got_allocate) {
1918 got_offset += arch_single_init( 1917 got_offset += arch_single_init(
1919 rel, &intsym->gotent, 1918 rel, &intsym->gotent,
1920 got_offset, CONFIG_GOT_ENTRY_SIZE); 1919 got_offset, GOT_ENTRY_SIZE);
1921 1920
1922 got_needed = 1; 1921 got_needed = 1;
1923 } 1922 }
1924#endif 1923#endif
1925#if defined(CONFIG_USE_PLT_ENTRIES) 1924#if defined(USE_PLT_ENTRIES)
1926 if (plt_allocate) { 1925 if (plt_allocate) {
1927#if defined(CONFIG_USE_PLT_LIST) 1926#if defined(USE_PLT_LIST)
1928 plt_offset += arch_list_add( 1927 plt_offset += arch_list_add(
1929 rel, &intsym->pltent, 1928 rel, &intsym->pltent,
1930 plt_offset, CONFIG_PLT_ENTRY_SIZE); 1929 plt_offset, PLT_ENTRY_SIZE);
1931#else 1930#else
1932 plt_offset += arch_single_init( 1931 plt_offset += arch_single_init(
1933 rel, &intsym->pltent, 1932 rel, &intsym->pltent,
1934 plt_offset, CONFIG_PLT_ENTRY_SIZE); 1933 plt_offset, PLT_ENTRY_SIZE);
1935#endif 1934#endif
1936 plt_needed = 1; 1935 plt_needed = 1;
1937 } 1936 }
@@ -1939,21 +1938,21 @@ static void arch_create_got(struct obj_file *f)
1939 } 1938 }
1940 } 1939 }
1941 1940
1942#if defined(CONFIG_USE_GOT_ENTRIES) 1941#if defined(USE_GOT_ENTRIES)
1943 if (got_needed) { 1942 if (got_needed) {
1944 ifile->got = arch_xsect_init(f, ".got", got_offset, 1943 ifile->got = arch_xsect_init(f, ".got", got_offset,
1945 CONFIG_GOT_ENTRY_SIZE); 1944 GOT_ENTRY_SIZE);
1946 } 1945 }
1947#endif 1946#endif
1948 1947
1949#if defined(CONFIG_USE_PLT_ENTRIES) 1948#if defined(USE_PLT_ENTRIES)
1950 if (plt_needed) { 1949 if (plt_needed) {
1951 ifile->plt = arch_xsect_init(f, ".plt", plt_offset, 1950 ifile->plt = arch_xsect_init(f, ".plt", plt_offset,
1952 CONFIG_PLT_ENTRY_SIZE); 1951 PLT_ENTRY_SIZE);
1953 } 1952 }
1954#endif 1953#endif
1955 1954
1956#endif /* defined(CONFIG_USE_GOT_ENTRIES) || defined(CONFIG_USE_PLT_ENTRIES) */ 1955#endif /* defined(USE_GOT_ENTRIES) || defined(USE_PLT_ENTRIES) */
1957} 1956}
1958 1957
1959/*======================================================================*/ 1958/*======================================================================*/
@@ -1982,7 +1981,7 @@ static unsigned long obj_elf_hash(const char *name)
1982 return obj_elf_hash_n(name, strlen(name)); 1981 return obj_elf_hash_n(name, strlen(name));
1983} 1982}
1984 1983
1985#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING 1984#if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
1986/* String comparison for non-co-versioned kernel and module. */ 1985/* String comparison for non-co-versioned kernel and module. */
1987 1986
1988static int ncv_strcmp(const char *a, const char *b) 1987static int ncv_strcmp(const char *a, const char *b)
@@ -2034,7 +2033,7 @@ obj_set_symbol_compare(struct obj_file *f,
2034 } 2033 }
2035} 2034}
2036 2035
2037#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */ 2036#endif /* FEATURE_INSMOD_VERSION_CHECKING */
2038 2037
2039static struct obj_symbol * 2038static struct obj_symbol *
2040obj_add_symbol(struct obj_file *f, const char *name, 2039obj_add_symbol(struct obj_file *f, const char *name,
@@ -2281,7 +2280,7 @@ add_symbols_from( struct obj_file *f,
2281 char *name_buf = 0; 2280 char *name_buf = 0;
2282 size_t name_alloced_size = 0; 2281 size_t name_alloced_size = 0;
2283#endif 2282#endif
2284#ifdef CONFIG_FEATURE_CHECK_TAINTED_MODULE 2283#if ENABLE_FEATURE_CHECK_TAINTED_MODULE
2285 int gpl; 2284 int gpl;
2286 2285
2287 gpl = obj_gpl_license(f, NULL) == 0; 2286 gpl = obj_gpl_license(f, NULL) == 0;
@@ -2301,7 +2300,7 @@ add_symbols_from( struct obj_file *f,
2301 * their references. 2300 * their references.
2302 */ 2301 */
2303 if (strncmp((char *)s->name, "GPLONLY_", 8) == 0) { 2302 if (strncmp((char *)s->name, "GPLONLY_", 8) == 0) {
2304#ifdef CONFIG_FEATURE_CHECK_TAINTED_MODULE 2303#if ENABLE_FEATURE_CHECK_TAINTED_MODULE
2305 if (gpl) 2304 if (gpl)
2306 s->name += 8; 2305 s->name += 8;
2307 else 2306 else
@@ -2637,7 +2636,7 @@ end_of_arg:
2637 return 1; 2636 return 1;
2638} 2637}
2639 2638
2640#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING 2639#if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
2641static int new_is_module_checksummed(struct obj_file *f) 2640static int new_is_module_checksummed(struct obj_file *f)
2642{ 2641{
2643 const char *p = get_modinfo_value(f, "using_checksums"); 2642 const char *p = get_modinfo_value(f, "using_checksums");
@@ -2673,7 +2672,7 @@ new_get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
2673 return a << 16 | b << 8 | c; 2672 return a << 16 | b << 8 | c;
2674} 2673}
2675 2674
2676#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */ 2675#endif /* FEATURE_INSMOD_VERSION_CHECKING */
2677 2676
2678 2677
2679/* Fetch the loaded modules, and all currently exported symbols. */ 2678/* 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)
2803 return 1; 2802 return 1;
2804} 2803}
2805 2804
2806#ifdef CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS 2805#if ENABLE_FEATURE_INSMOD_KSYMOOPS_SYMBOLS
2807/* add an entry to the __ksymtab section, creating it if necessary */ 2806/* add an entry to the __ksymtab section, creating it if necessary */
2808static void new_add_ksymtab(struct obj_file *f, struct obj_symbol *sym) 2807static void new_add_ksymtab(struct obj_file *f, struct obj_symbol *sym)
2809{ 2808{
@@ -2826,14 +2825,14 @@ static void new_add_ksymtab(struct obj_file *f, struct obj_symbol *sym)
2826 if (!sec) 2825 if (!sec)
2827 return; 2826 return;
2828 sec->header.sh_flags |= SHF_ALLOC; 2827 sec->header.sh_flags |= SHF_ALLOC;
2829 sec->header.sh_addralign = tgt_sizeof_void_p; /* Empty section might 2828 /* Empty section might be byte-aligned */
2830 be byte-aligned */ 2829 sec->header.sh_addralign = tgt_sizeof_void_p;
2831 ofs = sec->header.sh_size; 2830 ofs = sec->header.sh_size;
2832 obj_symbol_patch(f, sec->idx, ofs, sym); 2831 obj_symbol_patch(f, sec->idx, ofs, sym);
2833 obj_string_patch(f, sec->idx, ofs + tgt_sizeof_void_p, sym->name); 2832 obj_string_patch(f, sec->idx, ofs + tgt_sizeof_void_p, sym->name);
2834 obj_extend_section(sec, 2 * tgt_sizeof_char_p); 2833 obj_extend_section(sec, 2 * tgt_sizeof_char_p);
2835} 2834}
2836#endif /* CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS */ 2835#endif /* FEATURE_INSMOD_KSYMOOPS_SYMBOLS */
2837 2836
2838static int new_create_module_ksymtab(struct obj_file *f) 2837static int new_create_module_ksymtab(struct obj_file *f)
2839{ 2838{
@@ -3552,7 +3551,7 @@ static struct obj_file *obj_load(FILE * fp, int loadprogbits)
3552 return f; 3551 return f;
3553} 3552}
3554 3553
3555#ifdef CONFIG_FEATURE_INSMOD_LOADINKMEM 3554#if ENABLE_FEATURE_INSMOD_LOADINKMEM
3556/* 3555/*
3557 * load the unloaded sections directly into the memory allocated by 3556 * load the unloaded sections directly into the memory allocated by
3558 * kernel for the module 3557 * kernel for the module
@@ -3604,7 +3603,7 @@ static void hide_special_symbols(struct obj_file *f)
3604} 3603}
3605 3604
3606 3605
3607#ifdef CONFIG_FEATURE_CHECK_TAINTED_MODULE 3606#if ENABLE_FEATURE_CHECK_TAINTED_MODULE
3608static int obj_gpl_license(struct obj_file *f, const char **license) 3607static int obj_gpl_license(struct obj_file *f, const char **license)
3609{ 3608{
3610 struct obj_section *sec; 3609 struct obj_section *sec;
@@ -3719,11 +3718,11 @@ static void check_tainted_module(struct obj_file *f, char *m_name)
3719 if (fd >= 0) 3718 if (fd >= 0)
3720 close(fd); 3719 close(fd);
3721} 3720}
3722#else /* CONFIG_FEATURE_CHECK_TAINTED_MODULE */ 3721#else /* FEATURE_CHECK_TAINTED_MODULE */
3723#define check_tainted_module(x, y) do { } while(0); 3722#define check_tainted_module(x, y) do { } while(0);
3724#endif /* CONFIG_FEATURE_CHECK_TAINTED_MODULE */ 3723#endif /* FEATURE_CHECK_TAINTED_MODULE */
3725 3724
3726#ifdef CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS 3725#if ENABLE_FEATURE_INSMOD_KSYMOOPS_SYMBOLS
3727/* add module source, timestamp, kernel version and a symbol for the 3726/* add module source, timestamp, kernel version and a symbol for the
3728 * start of some sections. this info is used by ksymoops to do better 3727 * start of some sections. this info is used by ksymoops to do better
3729 * debugging. 3728 * debugging.
@@ -3731,12 +3730,12 @@ static void check_tainted_module(struct obj_file *f, char *m_name)
3731static int 3730static int
3732get_module_version(struct obj_file *f, char str[STRVERSIONLEN]) 3731get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
3733{ 3732{
3734#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING 3733#if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
3735 return new_get_module_version(f, str); 3734 return new_get_module_version(f, str);
3736#else /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */ 3735#else /* FEATURE_INSMOD_VERSION_CHECKING */
3737 strncpy(str, "???", sizeof(str)); 3736 strncpy(str, "???", sizeof(str));
3738 return -1; 3737 return -1;
3739#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */ 3738#endif /* FEATURE_INSMOD_VERSION_CHECKING */
3740} 3739}
3741 3740
3742/* add module source, timestamp, kernel version and a symbol for the 3741/* 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,
3854 } 3853 }
3855 } 3854 }
3856} 3855}
3857#endif /* CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS */ 3856#endif /* FEATURE_INSMOD_KSYMOOPS_SYMBOLS */
3858 3857
3859#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP 3858#if ENABLE_FEATURE_INSMOD_LOAD_MAP
3860static void print_load_map(struct obj_file *f) 3859static void print_load_map(struct obj_file *f)
3861{ 3860{
3862 struct obj_symbol *sym; 3861 struct obj_symbol *sym;
@@ -3885,7 +3884,7 @@ static void print_load_map(struct obj_file *f)
3885 (long)sec->header.sh_addr, 3884 (long)sec->header.sh_addr,
3886 a); 3885 a);
3887 } 3886 }
3888#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL 3887#if ENABLE_FEATURE_INSMOD_LOAD_MAP_FULL
3889 /* Quick reference which section indicies are loaded. */ 3888 /* Quick reference which section indicies are loaded. */
3890 3889
3891 loaded = alloca(sizeof(int) * (i = f->header.e_shnum)); 3890 loaded = alloca(sizeof(int) * (i = f->header.e_shnum));
@@ -3945,7 +3944,7 @@ static void print_load_map(struct obj_file *f)
3945 } 3944 }
3946#endif 3945#endif
3947} 3946}
3948#else /* !CONFIG_FEATURE_INSMOD_LOAD_MAP */ 3947#else /* !FEATURE_INSMOD_LOAD_MAP */
3949void print_load_map(struct obj_file *f); 3948void print_load_map(struct obj_file *f);
3950#endif 3949#endif
3951 3950
@@ -3962,12 +3961,12 @@ int insmod_main( int argc, char **argv)
3962 char *m_name = 0; 3961 char *m_name = 0;
3963 int exit_status = EXIT_FAILURE; 3962 int exit_status = EXIT_FAILURE;
3964 int m_has_modinfo; 3963 int m_has_modinfo;
3965#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING 3964#if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
3966 struct utsname uts_info; 3965 struct utsname uts_info;
3967 char m_strversion[STRVERSIONLEN]; 3966 char m_strversion[STRVERSIONLEN];
3968 int m_version, m_crcs; 3967 int m_version, m_crcs;
3969#endif 3968#endif
3970#ifdef CONFIG_FEATURE_CLEAN_UP 3969#if ENABLE_FEATURE_CLEAN_UP
3971 FILE *fp = 0; 3970 FILE *fp = 0;
3972#else 3971#else
3973 FILE *fp; 3972 FILE *fp;
@@ -3998,7 +3997,7 @@ int insmod_main( int argc, char **argv)
3998 } 3997 }
3999 } 3998 }
4000 3999
4001#if defined(CONFIG_FEATURE_2_6_MODULES) 4000#if ENABLE_FEATURE_2_6_MODULES
4002 if (k_version > 4 && len > 3 && tmp[len - 3] == '.' 4001 if (k_version > 4 && len > 3 && tmp[len - 3] == '.'
4003 && tmp[len - 2] == 'k' && tmp[len - 1] == 'o' 4002 && tmp[len - 2] == 'k' && tmp[len - 1] == 'o'
4004 ) { 4003 ) {
@@ -4012,7 +4011,7 @@ int insmod_main( int argc, char **argv)
4012 } 4011 }
4013 4012
4014 4013
4015#if defined(CONFIG_FEATURE_2_6_MODULES) 4014#if ENABLE_FEATURE_2_6_MODULES
4016 if (k_version > 4) 4015 if (k_version > 4)
4017 m_fullName = xasprintf("%s.ko", tmp); 4016 m_fullName = xasprintf("%s.ko", tmp);
4018 else 4017 else
@@ -4080,7 +4079,7 @@ int insmod_main( int argc, char **argv)
4080 if (flag_verbose) 4079 if (flag_verbose)
4081 printf("Using %s\n", m_filename); 4080 printf("Using %s\n", m_filename);
4082 4081
4083#ifdef CONFIG_FEATURE_2_6_MODULES 4082#if ENABLE_FEATURE_2_6_MODULES
4084 if (k_version > 4) { 4083 if (k_version > 4) {
4085 argv[optind] = m_filename; 4084 argv[optind] = m_filename;
4086 optind--; 4085 optind--;
@@ -4097,7 +4096,7 @@ int insmod_main( int argc, char **argv)
4097 else 4096 else
4098 m_has_modinfo = 1; 4097 m_has_modinfo = 1;
4099 4098
4100#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING 4099#if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
4101 /* Version correspondence? */ 4100 /* Version correspondence? */
4102 if (!flag_quiet) { 4101 if (!flag_quiet) {
4103 if (uname(&uts_info) < 0) 4102 if (uname(&uts_info) < 0)
@@ -4127,7 +4126,7 @@ int insmod_main( int argc, char **argv)
4127 } 4126 }
4128 } 4127 }
4129 k_crcs = 0; 4128 k_crcs = 0;
4130#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */ 4129#endif /* FEATURE_INSMOD_VERSION_CHECKING */
4131 4130
4132 if (!query_module(NULL, 0, NULL, 0, NULL)) { 4131 if (!query_module(NULL, 0, NULL, 0, NULL)) {
4133 if (!new_get_kernel_symbols()) 4132 if (!new_get_kernel_symbols())
@@ -4138,14 +4137,14 @@ int insmod_main( int argc, char **argv)
4138 goto out; 4137 goto out;
4139 } 4138 }
4140 4139
4141#ifdef CONFIG_FEATURE_INSMOD_VERSION_CHECKING 4140#if ENABLE_FEATURE_INSMOD_VERSION_CHECKING
4142 m_crcs = 0; 4141 m_crcs = 0;
4143 if (m_has_modinfo) 4142 if (m_has_modinfo)
4144 m_crcs = new_is_module_checksummed(f); 4143 m_crcs = new_is_module_checksummed(f);
4145 4144
4146 if (m_crcs != k_crcs) 4145 if (m_crcs != k_crcs)
4147 obj_set_symbol_compare(f, ncv_strcmp, ncv_symbol_hash); 4146 obj_set_symbol_compare(f, ncv_strcmp, ncv_symbol_hash);
4148#endif /* CONFIG_FEATURE_INSMOD_VERSION_CHECKING */ 4147#endif /* FEATURE_INSMOD_VERSION_CHECKING */
4149 4148
4150 /* Let the module know about the kernel symbols. */ 4149 /* Let the module know about the kernel symbols. */
4151 add_kernel_symbols(f); 4150 add_kernel_symbols(f);
@@ -4173,9 +4172,9 @@ int insmod_main( int argc, char **argv)
4173 arch_create_got(f); 4172 arch_create_got(f);
4174 hide_special_symbols(f); 4173 hide_special_symbols(f);
4175 4174
4176#ifdef CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS 4175#if ENABLE_FEATURE_INSMOD_KSYMOOPS_SYMBOLS
4177 add_ksymoops_symbols(f, m_filename, m_name); 4176 add_ksymoops_symbols(f, m_filename, m_name);
4178#endif /* CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS */ 4177#endif /* FEATURE_INSMOD_KSYMOOPS_SYMBOLS */
4179 4178
4180 new_create_module_ksymtab(f); 4179 new_create_module_ksymtab(f);
4181 4180
@@ -4224,7 +4223,7 @@ int insmod_main( int argc, char **argv)
4224 exit_status = EXIT_SUCCESS; 4223 exit_status = EXIT_SUCCESS;
4225 4224
4226out: 4225out:
4227#ifdef CONFIG_FEATURE_CLEAN_UP 4226#if ENABLE_FEATURE_CLEAN_UP
4228 if(fp) 4227 if(fp)
4229 fclose(fp); 4228 fclose(fp);
4230 free(tmp1); 4229 free(tmp1);
@@ -4240,7 +4239,7 @@ out:
4240#endif 4239#endif
4241 4240
4242 4241
4243#ifdef CONFIG_FEATURE_2_6_MODULES 4242#if ENABLE_FEATURE_2_6_MODULES
4244 4243
4245#include <sys/mman.h> 4244#include <sys/mman.h>
4246#include <asm/unistd.h> 4245#include <asm/unistd.h>