Remove debugging statement.
[oweals/busybox.git] / insmod.c
index 5e51fcb709d3a163135d3732c1cbab781d425a23..4b00515942fb7d756a239dcef08eec95a308a14e 100644 (file)
--- a/insmod.c
+++ b/insmod.c
 #ifndef MODUTILS_MODULE_H
 static const int MODUTILS_MODULE_H = 1;
 
-#ident "$Id: insmod.c,v 1.64 2001/05/21 16:09:18 andersen Exp $"
+#ident "$Id: insmod.c,v 1.67 2001/06/28 21:36:06 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
@@ -347,7 +347,7 @@ int delete_module(const char *);
 #ifndef MODUTILS_OBJ_H
 static const int MODUTILS_OBJ_H = 1;
 
-#ident "$Id: insmod.c,v 1.64 2001/05/21 16:09:18 andersen Exp $"
+#ident "$Id: insmod.c,v 1.67 2001/06/28 21:36:06 andersen Exp $"
 
 /* The relocatable object is manipulated using elfin types.  */
 
@@ -372,10 +372,8 @@ static const int MODUTILS_OBJ_H = 1;
 
 #define ELFCLASSM      ELFCLASS32
 
-#if (defined(__m68k__))                                        
+#if (defined(__mc68000__))                                     
 #define ELFDATAM       ELFDATA2MSB
-#else
-#define ELFDATAM       ELFDATA2LSB
 #endif
 
 
@@ -399,7 +397,7 @@ static const int MODUTILS_OBJ_H = 1;
 #define MATCH_MACHINE(x) (x == EM_PPC)
 #define SHT_RELM       SHT_RELA
 #define Elf32_RelM     Elf32_Rela
-#define ELFDATAM        ELFDATA2MSB
+#define ELFDATAM    ELFDATA2MSB
 
 #elif defined(__mips__)
 
@@ -437,7 +435,7 @@ static const int MODUTILS_OBJ_H = 1;
 #define Elf32_RelM     Elf32_Rel
 #define ELFDATAM       ELFDATA2LSB
 
-#elif defined(__m68k__) 
+#elif defined(__mc68000__) 
 
 #define MATCH_MACHINE(x)       (x == EM_68K)
 #define SHT_RELM                       SHT_RELA
@@ -815,7 +813,7 @@ arch_apply_relocation(struct obj_file *f,
        case R_ARM_NONE:
 #elif defined(__i386__)
        case R_386_NONE:
-#elif defined(__m68k__) 
+#elif defined(__mc68000__) 
        case R_68K_NONE:
 #elif defined(__powerpc__)
        case R_PPC_NONE:
@@ -830,7 +828,7 @@ arch_apply_relocation(struct obj_file *f,
        case R_ARM_ABS32:
 #elif defined(__i386__)
        case R_386_32:  
-#elif defined(__m68k__) 
+#elif defined(__mc68000__) 
        case R_68K_32:
 #elif defined(__powerpc__)
        case R_PPC_ADDR32:
@@ -839,7 +837,7 @@ arch_apply_relocation(struct obj_file *f,
 #endif
                *loc += v;
                break;
-#if defined(__m68k__)
+#if defined(__mc68000__)
     case R_68K_8:
                if (v > 0xff)
                ret = obj_reloc_overflow;
@@ -850,7 +848,7 @@ arch_apply_relocation(struct obj_file *f,
                ret = obj_reloc_overflow;
                *(short *)loc = v;
                break;
-#endif /* __m68k__   */
+#endif /* __mc68000__   */
 
 #if defined(__powerpc__)
        case R_PPC_ADDR16_HA:
@@ -956,7 +954,7 @@ arch_apply_relocation(struct obj_file *f,
        case R_386_PC32:
                *loc += v - dot;
                break;
-#elif defined(__m68k__)
+#elif defined(__mc68000__)
     case R_68K_PC8:
                v -= dot;
                if ((Elf32_Sword)v > 0x7f || (Elf32_Sword)v < -(Elf32_Sword)0x80)
@@ -1051,7 +1049,7 @@ arch_apply_relocation(struct obj_file *f,
        case R_386_JMP_SLOT:
                *loc = v;
                break;
-#elif defined(__m68k__)
+#elif defined(__mc68000__)
        case R_68K_GLOB_DAT:
        case R_68K_JMP_SLOT:
                *loc = v;
@@ -1067,7 +1065,7 @@ arch_apply_relocation(struct obj_file *f,
         case R_386_RELATIVE:
                *loc += f->baseaddr;
                break;
-#elif defined(__m68k__)
+#elif defined(__mc68000__)
     case R_68K_RELATIVE:
        *(int *)loc += f->baseaddr;
        break;
@@ -1098,7 +1096,7 @@ arch_apply_relocation(struct obj_file *f,
        case R_ARM_GOT32:
 #elif defined(__i386__)
        case R_386_GOT32:
-#elif defined(__m68k__)
+#elif defined(__mc68000__)
        case R_68K_GOT32:
 #endif
                assert(isym != NULL);
@@ -1110,26 +1108,26 @@ arch_apply_relocation(struct obj_file *f,
         /* make the reloc with_respect_to_.got */
 #if defined(__sh__)
                *loc += isym->gotent.offset + rel->r_addend;
-#elif defined(__i386__) || defined(__arm__) || defined(__m68k__)
+#elif defined(__i386__) || defined(__arm__) || defined(__mc68000__)
                *loc += isym->gotent.offset;
 #endif
                break;
 
     /* address relative to the got */
-#if !defined(__m68k__)
+#if !defined(__mc68000__)
 #if defined(__sh__)
        case R_SH_GOTOFF:
 #elif defined(__arm__)
        case R_ARM_GOTOFF:
 #elif defined(__i386__)
        case R_386_GOTOFF:
-#elif defined(__m68k__)
+#elif defined(__mc68000__)
        case R_68K_GOTOFF:
 #endif
                assert(got != 0);
                *loc += v - got;
                break;
-#endif // __m68k__
+#endif // __mc68000__
 
 #endif /* BB_USE_GOT_ENTRIES */
 
@@ -1185,7 +1183,7 @@ int arch_create_got(struct obj_file *f)
 #elif defined(__i386__)
                        case R_386_GOT32:
                                break;
-#elif defined(__m68k__)
+#elif defined(__mc68000__)
                        case R_68K_GOT32:
                                break;
 #endif
@@ -1462,8 +1460,13 @@ struct obj_symbol *obj_add_symbol(struct obj_file *f, const char *name,
        f->symtab[hash] = sym;
        sym->ksymidx = -1;
 
-       if (ELFW(ST_BIND) (info) == STB_LOCAL)
-               f->local_symtab[symidx] = sym;
+       if (ELFW(ST_BIND)(info) == STB_LOCAL && symidx != -1) {
+               if (symidx >= f->local_symtab_size)
+                       error_msg("local symbol %s with index %ld exceeds local_symtab_size %ld",
+                                       name, (long) symidx, (long) f->local_symtab_size);
+               else
+                       f->local_symtab[symidx] = sym;
+       }
 
   found:
        sym->name = name;