aboutsummaryrefslogtreecommitdiff
path: root/modutils/insmod.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-03-15 08:29:22 +0000
committerEric Andersen <andersen@codepoet.org>2004-03-15 08:29:22 +0000
commitc7bda1ce659294d6e22c06e087f6f265983c7578 (patch)
tree4c6d2217f4d8306c59cf1096f8664e1cfd167213 /modutils/insmod.c
parent8854004b41065b3d081af7f3df13a100b0c8bfbe (diff)
downloadbusybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.gz
busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.bz2
busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.zip
Remove trailing whitespace. Update copyright to include 2004.
Diffstat (limited to 'modutils/insmod.c')
-rw-r--r--modutils/insmod.c67
1 files changed, 33 insertions, 34 deletions
diff --git a/modutils/insmod.c b/modutils/insmod.c
index 73259131b..eaa425f5d 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -2,11 +2,10 @@
2/* 2/*
3 * Mini insmod implementation for busybox 3 * Mini insmod implementation for busybox
4 * 4 *
5 * This version of insmod supports x86, ARM, SH3/4/5, powerpc, m68k, 5 * This version of insmod supports x86, ARM, SH3/4/5, powerpc, m68k,
6 * MIPS, and v850e. 6 * MIPS, and v850e.
7 * 7 *
8 * Copyright (C) 1999,2000 by Lineo, inc. and Erik Andersen 8 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
9 * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
10 * and Ron Alder <alder@lineo.com> 9 * and Ron Alder <alder@lineo.com>
11 * 10 *
12 * Miles Bader <miles@gnu.org> added NEC V850E support. 11 * Miles Bader <miles@gnu.org> added NEC V850E support.
@@ -32,7 +31,7 @@
32 * These blocks should be easy maintain and sync with obj_xxx.c in modutils. 31 * These blocks should be easy maintain and sync with obj_xxx.c in modutils.
33 * 32 *
34 * Magnus Damm <damm@opensource.se> added PowerPC support 20-Feb-2001. 33 * Magnus Damm <damm@opensource.se> added PowerPC support 20-Feb-2001.
35 * PowerPC specific code stolen from modutils-2.3.16, 34 * PowerPC specific code stolen from modutils-2.3.16,
36 * written by Paul Mackerras, Copyright 1996, 1997 Linux International. 35 * written by Paul Mackerras, Copyright 1996, 1997 Linux International.
37 * I've only tested the code on mpc8xx platforms in big-endian mode. 36 * I've only tested the code on mpc8xx platforms in big-endian mode.
38 * Did some cleanup and added CONFIG_USE_xxx_ENTRIES... 37 * Did some cleanup and added CONFIG_USE_xxx_ENTRIES...
@@ -104,7 +103,7 @@ extern int insmod_ng_main( int argc, char **argv);
104#endif 103#endif
105 104
106#ifdef CONFIG_FEATURE_INSMOD_LOADINKMEM 105#ifdef CONFIG_FEATURE_INSMOD_LOADINKMEM
107#define LOADBITS 0 106#define LOADBITS 0
108#else 107#else
109#define LOADBITS 1 108#define LOADBITS 1
110#endif 109#endif
@@ -152,7 +151,7 @@ extern int insmod_ng_main( int argc, char **argv);
152#define ELFCLASSM ELFCLASS32 151#define ELFCLASSM ELFCLASS32
153#endif 152#endif
154 153
155#if defined(__mc68000__) 154#if defined(__mc68000__)
156#define CONFIG_USE_GOT_ENTRIES 155#define CONFIG_USE_GOT_ENTRIES
157#define CONFIG_GOT_ENTRY_SIZE 4 156#define CONFIG_GOT_ENTRY_SIZE 4
158#define CONFIG_USE_SINGLE 157#define CONFIG_USE_SINGLE
@@ -183,7 +182,7 @@ extern int insmod_ng_main( int argc, char **argv);
183#define CONFIG_USE_PLT_ENTRIES 182#define CONFIG_USE_PLT_ENTRIES
184#define CONFIG_PLT_ENTRY_SIZE 16 183#define CONFIG_PLT_ENTRY_SIZE 16
185#define CONFIG_USE_PLT_LIST 184#define CONFIG_USE_PLT_LIST
186#define CONFIG_LIST_ARCHTYPE ElfW(Addr) 185#define CONFIG_LIST_ARCHTYPE ElfW(Addr)
187#define CONFIG_USE_LIST 186#define CONFIG_USE_LIST
188 187
189#define MATCH_MACHINE(x) (x == EM_PPC) 188#define MATCH_MACHINE(x) (x == EM_PPC)
@@ -282,7 +281,7 @@ extern int insmod_ng_main( int argc, char **argv);
282#ifndef MODUTILS_MODULE_H 281#ifndef MODUTILS_MODULE_H
283static const int MODUTILS_MODULE_H = 1; 282static const int MODUTILS_MODULE_H = 1;
284 283
285#ident "$Id: insmod.c,v 1.112 2004/02/18 10:14:17 mjn3 Exp $" 284#ident "$Id: insmod.c,v 1.113 2004/03/15 08:28:47 andersen Exp $"
286 285
287/* This file contains the structures used by the 2.0 and 2.1 kernels. 286/* This file contains the structures used by the 2.0 and 2.1 kernels.
288 We do not use the kernel headers directly because we do not wish 287 We do not use the kernel headers directly because we do not wish
@@ -503,7 +502,7 @@ int delete_module(const char *);
503#ifndef MODUTILS_OBJ_H 502#ifndef MODUTILS_OBJ_H
504static const int MODUTILS_OBJ_H = 1; 503static const int MODUTILS_OBJ_H = 1;
505 504
506#ident "$Id: insmod.c,v 1.112 2004/02/18 10:14:17 mjn3 Exp $" 505#ident "$Id: insmod.c,v 1.113 2004/03/15 08:28:47 andersen Exp $"
507 506
508/* The relocatable object is manipulated using elfin types. */ 507/* The relocatable object is manipulated using elfin types. */
509 508
@@ -680,7 +679,7 @@ static enum obj_reloc arch_apply_relocation (struct obj_file *f,
680static void arch_create_got (struct obj_file *f); 679static void arch_create_got (struct obj_file *f);
681 680
682static int obj_gpl_license(struct obj_file *f, const char **license); 681static int obj_gpl_license(struct obj_file *f, const char **license);
683 682
684#ifdef CONFIG_FEATURE_2_4_MODULES 683#ifdef CONFIG_FEATURE_2_4_MODULES
685static int arch_init_module (struct obj_file *f, struct new_module *); 684static int arch_init_module (struct obj_file *f, struct new_module *);
686#endif 685#endif
@@ -888,8 +887,8 @@ arch_apply_relocation(struct obj_file *f,
888 goto bb_use_got; 887 goto bb_use_got;
889 888
890 case R_ARM_GOTPC: 889 case R_ARM_GOTPC:
891 /* relative reloc, always to _GLOBAL_OFFSET_TABLE_ 890 /* relative reloc, always to _GLOBAL_OFFSET_TABLE_
892 * (which is .got) similar to branch, 891 * (which is .got) similar to branch,
893 * but is full 32 bits relative */ 892 * but is full 32 bits relative */
894 893
895 assert(got); 894 assert(got);
@@ -922,7 +921,7 @@ arch_apply_relocation(struct obj_file *f,
922 case R_390_PC16DBL: 921 case R_390_PC16DBL:
923 *(unsigned short *) loc += (v - dot) >> 1; 922 *(unsigned short *) loc += (v - dot) >> 1;
924 break; 923 break;
925 case R_390_PC16: 924 case R_390_PC16:
926 *(unsigned short *) loc += v - dot; 925 *(unsigned short *) loc += v - dot;
927 break; 926 break;
928 927
@@ -933,7 +932,7 @@ arch_apply_relocation(struct obj_file *f,
933 pe = (struct arch_single_entry *) &isym->pltent; 932 pe = (struct arch_single_entry *) &isym->pltent;
934 assert(pe->allocated); 933 assert(pe->allocated);
935 if (pe->inited == 0) { 934 if (pe->inited == 0) {
936 ip = (unsigned long *)(ifile->plt->contents + pe->offset); 935 ip = (unsigned long *)(ifile->plt->contents + pe->offset);
937 ip[0] = 0x0d105810; /* basr 1,0; lg 1,10(1); br 1 */ 936 ip[0] = 0x0d105810; /* basr 1,0; lg 1,10(1); br 1 */
938 ip[1] = 0x100607f1; 937 ip[1] = 0x100607f1;
939 if (ELF32_R_TYPE(rel->r_info) == R_390_PLT16DBL) 938 if (ELF32_R_TYPE(rel->r_info) == R_390_PLT16DBL)
@@ -984,7 +983,7 @@ arch_apply_relocation(struct obj_file *f,
984 break; 983 break;
985 984
986#ifndef R_390_GOTOFF32 985#ifndef R_390_GOTOFF32
987#define R_390_GOTOFF32 R_390_GOTOFF 986#define R_390_GOTOFF32 R_390_GOTOFF
988#endif 987#endif
989 case R_390_GOTOFF32: 988 case R_390_GOTOFF32:
990 assert(got != 0); 989 assert(got != 0);
@@ -1052,7 +1051,7 @@ arch_apply_relocation(struct obj_file *f,
1052 1051
1053 case R_68K_PC8: 1052 case R_68K_PC8:
1054 v -= dot; 1053 v -= dot;
1055 if ((Elf32_Sword)v > 0x7f || 1054 if ((Elf32_Sword)v > 0x7f ||
1056 (Elf32_Sword)v < -(Elf32_Sword)0x80) { 1055 (Elf32_Sword)v < -(Elf32_Sword)0x80) {
1057 ret = obj_reloc_overflow; 1056 ret = obj_reloc_overflow;
1058 } 1057 }
@@ -1061,7 +1060,7 @@ arch_apply_relocation(struct obj_file *f,
1061 1060
1062 case R_68K_PC16: 1061 case R_68K_PC16:
1063 v -= dot; 1062 v -= dot;
1064 if ((Elf32_Sword)v > 0x7fff || 1063 if ((Elf32_Sword)v > 0x7fff ||
1065 (Elf32_Sword)v < -(Elf32_Sword)0x8000) { 1064 (Elf32_Sword)v < -(Elf32_Sword)0x8000) {
1066 ret = obj_reloc_overflow; 1065 ret = obj_reloc_overflow;
1067 } 1066 }
@@ -1365,7 +1364,7 @@ bb_use_plt:
1365 v -= dot; 1364 v -= dot;
1366 /* if the target is too far away.... */ 1365 /* if the target is too far away.... */
1367#if defined (__arm__) || defined (__powerpc__) 1366#if defined (__arm__) || defined (__powerpc__)
1368 if ((int)v < -0x02000000 || (int)v >= 0x02000000) 1367 if ((int)v < -0x02000000 || (int)v >= 0x02000000)
1369#elif defined (__v850e__) 1368#elif defined (__v850e__)
1370 if ((Elf32_Sword)v > 0x1fffff || (Elf32_Sword)v < (Elf32_Sword)-0x200000) 1369 if ((Elf32_Sword)v > 0x1fffff || (Elf32_Sword)v < (Elf32_Sword)-0x200000)
1371#endif 1370#endif
@@ -1426,7 +1425,7 @@ bb_use_got:
1426} 1425}
1427 1426
1428 1427
1429#if defined(CONFIG_USE_LIST) 1428#if defined(CONFIG_USE_LIST)
1430 1429
1431static int arch_list_add(ElfW(RelM) *rel, struct arch_list_entry **list, 1430static int arch_list_add(ElfW(RelM) *rel, struct arch_list_entry **list,
1432 int offset, int size) 1431 int offset, int size)
@@ -1453,7 +1452,7 @@ static int arch_list_add(ElfW(RelM) *rel, struct arch_list_entry **list,
1453 1452
1454#endif 1453#endif
1455 1454
1456#if defined(CONFIG_USE_SINGLE) 1455#if defined(CONFIG_USE_SINGLE)
1457 1456
1458static int arch_single_init(ElfW(RelM) *rel, struct arch_single_entry *single, 1457static int arch_single_init(ElfW(RelM) *rel, struct arch_single_entry *single,
1459 int offset, int size) 1458 int offset, int size)
@@ -1471,7 +1470,7 @@ static int arch_single_init(ElfW(RelM) *rel, struct arch_single_entry *single,
1471 1470
1472#if defined(CONFIG_USE_GOT_ENTRIES) || defined(CONFIG_USE_PLT_ENTRIES) 1471#if defined(CONFIG_USE_GOT_ENTRIES) || defined(CONFIG_USE_PLT_ENTRIES)
1473 1472
1474static struct obj_section *arch_xsect_init(struct obj_file *f, char *name, 1473static struct obj_section *arch_xsect_init(struct obj_file *f, char *name,
1475 int offset, int size) 1474 int offset, int size)
1476{ 1475{
1477 struct obj_section *myrelsec = obj_find_section(f, name); 1476 struct obj_section *myrelsec = obj_find_section(f, name);
@@ -1483,7 +1482,7 @@ static struct obj_section *arch_xsect_init(struct obj_file *f, char *name,
1483 if (myrelsec) { 1482 if (myrelsec) {
1484 obj_extend_section(myrelsec, offset); 1483 obj_extend_section(myrelsec, offset);
1485 } else { 1484 } else {
1486 myrelsec = obj_create_alloced_section(f, name, 1485 myrelsec = obj_create_alloced_section(f, name,
1487 size, offset); 1486 size, offset);
1488 assert(myrelsec); 1487 assert(myrelsec);
1489 } 1488 }
@@ -1575,7 +1574,7 @@ static void arch_create_got(struct obj_file *f)
1575 1574
1576#elif defined(__sh__) 1575#elif defined(__sh__)
1577 case R_SH_GOT32: 1576 case R_SH_GOT32:
1578 got_allocate = 1; 1577 got_allocate = 1;
1579 break; 1578 break;
1580 1579
1581 case R_SH_GOTPC: 1580 case R_SH_GOTPC:
@@ -1602,7 +1601,7 @@ static void arch_create_got(struct obj_file *f)
1602#if defined(CONFIG_USE_GOT_ENTRIES) 1601#if defined(CONFIG_USE_GOT_ENTRIES)
1603 if (got_allocate) { 1602 if (got_allocate) {
1604 got_offset += arch_single_init( 1603 got_offset += arch_single_init(
1605 rel, &intsym->gotent, 1604 rel, &intsym->gotent,
1606 got_offset, CONFIG_GOT_ENTRY_SIZE); 1605 got_offset, CONFIG_GOT_ENTRY_SIZE);
1607 1606
1608 got_needed = 1; 1607 got_needed = 1;
@@ -1610,13 +1609,13 @@ static void arch_create_got(struct obj_file *f)
1610#endif 1609#endif
1611#if defined(CONFIG_USE_PLT_ENTRIES) 1610#if defined(CONFIG_USE_PLT_ENTRIES)
1612 if (plt_allocate) { 1611 if (plt_allocate) {
1613#if defined(CONFIG_USE_PLT_LIST) 1612#if defined(CONFIG_USE_PLT_LIST)
1614 plt_offset += arch_list_add( 1613 plt_offset += arch_list_add(
1615 rel, &intsym->pltent, 1614 rel, &intsym->pltent,
1616 plt_offset, CONFIG_PLT_ENTRY_SIZE); 1615 plt_offset, CONFIG_PLT_ENTRY_SIZE);
1617#else 1616#else
1618 plt_offset += arch_single_init( 1617 plt_offset += arch_single_init(
1619 rel, &intsym->pltent, 1618 rel, &intsym->pltent,
1620 plt_offset, CONFIG_PLT_ENTRY_SIZE); 1619 plt_offset, CONFIG_PLT_ENTRY_SIZE);
1621#endif 1620#endif
1622 plt_needed = 1; 1621 plt_needed = 1;
@@ -1954,7 +1953,7 @@ static struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
1954static void *obj_extend_section(struct obj_section *sec, unsigned long more) 1953static void *obj_extend_section(struct obj_section *sec, unsigned long more)
1955{ 1954{
1956 unsigned long oldsize = sec->header.sh_size; 1955 unsigned long oldsize = sec->header.sh_size;
1957 if (more) { 1956 if (more) {
1958 sec->contents = xrealloc(sec->contents, sec->header.sh_size += more); 1957 sec->contents = xrealloc(sec->contents, sec->header.sh_size += more);
1959 } 1958 }
1960 return sec->contents + oldsize; 1959 return sec->contents + oldsize;
@@ -2363,7 +2362,7 @@ old_init_module(const char *m_name, struct obj_file *f,
2363 struct obj_symbol *sym; 2362 struct obj_symbol *sym;
2364 for (sym = f->symtab[i]; sym; sym = sym->next) 2363 for (sym = f->symtab[i]; sym; sym = sym->next)
2365 if (ELFW(ST_BIND) (sym->info) != STB_LOCAL 2364 if (ELFW(ST_BIND) (sym->info) != STB_LOCAL
2366 && sym->secidx <= SHN_HIRESERVE) 2365 && sym->secidx <= SHN_HIRESERVE)
2367 { 2366 {
2368 sym->ksymidx = nsyms++; 2367 sym->ksymidx = nsyms++;
2369 strsize += strlen(sym->name) + 1; 2368 strsize += strlen(sym->name) + 1;
@@ -2977,7 +2976,7 @@ new_init_module(const char *m_name, struct obj_file *f,
2977 tgt_long m_addr; 2976 tgt_long m_addr;
2978 2977
2979 sec = obj_find_section(f, ".this"); 2978 sec = obj_find_section(f, ".this");
2980 if (!sec || !sec->contents) { 2979 if (!sec || !sec->contents) {
2981 bb_perror_msg_and_die("corrupt module %s?",m_name); 2980 bb_perror_msg_and_die("corrupt module %s?",m_name);
2982 } 2981 }
2983 module = (struct new_module *) sec->contents; 2982 module = (struct new_module *) sec->contents;
@@ -3499,7 +3498,7 @@ static struct obj_file *obj_load(FILE * fp, int loadprogbits)
3499 sec->contents = NULL; 3498 sec->contents = NULL;
3500 break; 3499 break;
3501 } 3500 }
3502#endif 3501#endif
3503 case SHT_SYMTAB: 3502 case SHT_SYMTAB:
3504 case SHT_STRTAB: 3503 case SHT_STRTAB:
3505 case SHT_RELM: 3504 case SHT_RELM:
@@ -3726,7 +3725,7 @@ static int obj_gpl_license(struct obj_file *f, const char **license)
3726#define TAINT_UNSAFE_SMP (1<<2) 3725#define TAINT_UNSAFE_SMP (1<<2)
3727#define TAINT_URL "http://www.tux.org/lkml/#export-tainted" 3726#define TAINT_URL "http://www.tux.org/lkml/#export-tainted"
3728 3727
3729static void set_tainted(struct obj_file *f, int fd, char *m_name, 3728static void set_tainted(struct obj_file *f, int fd, char *m_name,
3730 int kernel_has_tainted, int taint, const char *text1, const char *text2) 3729 int kernel_has_tainted, int taint, const char *text1, const char *text2)
3731{ 3730{
3732 char buf[80]; 3731 char buf[80];
@@ -3819,7 +3818,7 @@ get_module_version(struct obj_file *f, char str[STRVERSIONLEN])
3819 * start of some sections. this info is used by ksymoops to do better 3818 * start of some sections. this info is used by ksymoops to do better
3820 * debugging. 3819 * debugging.
3821 */ 3820 */
3822static void 3821static void
3823add_ksymoops_symbols(struct obj_file *f, const char *filename, 3822add_ksymoops_symbols(struct obj_file *f, const char *filename,
3824 const char *m_name) 3823 const char *m_name)
3825{ 3824{
@@ -4059,7 +4058,7 @@ extern int insmod_main( int argc, char **argv)
4059#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP 4058#ifdef CONFIG_FEATURE_INSMOD_LOAD_MAP
4060 while ((opt = getopt(argc, argv, "fkqsvxmLo:")) > 0) 4059 while ((opt = getopt(argc, argv, "fkqsvxmLo:")) > 0)
4061#else 4060#else
4062 while ((opt = getopt(argc, argv, "fkqsvxLo:")) > 0) 4061 while ((opt = getopt(argc, argv, "fkqsvxLo:")) > 0)
4063#endif 4062#endif
4064 { 4063 {
4065 switch (opt) { 4064 switch (opt) {