X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=insmod.c;h=0a7cb1e4ab3156fd43d177fbca75a3b176e9e173;hb=3a6da8c183142a2681a2382b63e970f457cf807b;hp=50f272edb4602b67bfd90d0f9abfb548d1998a35;hpb=2bf658d5cd4460a0e0a8a8f3c8dc3b71be05d1ba;p=oweals%2Fbusybox.git diff --git a/insmod.c b/insmod.c index 50f272edb..0a7cb1e4a 100644 --- a/insmod.c +++ b/insmod.c @@ -119,7 +119,7 @@ #ifndef MODUTILS_MODULE_H static const int MODUTILS_MODULE_H = 1; -#ident "$Id: insmod.c,v 1.50 2001/02/24 20:01:53 andersen Exp $" +#ident "$Id: insmod.c,v 1.53 2001/03/22 19:01:16 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 @@ -325,7 +325,7 @@ int delete_module(const char *); #ifndef MODUTILS_OBJ_H static const int MODUTILS_OBJ_H = 1; -#ident "$Id: insmod.c,v 1.50 2001/02/24 20:01:53 andersen Exp $" +#ident "$Id: insmod.c,v 1.53 2001/03/22 19:01:16 andersen Exp $" /* The relocatable object is manipulated using elfin types. */ @@ -373,6 +373,15 @@ static const int MODUTILS_OBJ_H = 1; #elif defined(__mips__) +/* Account for ELF spec changes. */ +#ifndef EM_MIPS_RS3_LE +#ifdef EM_MIPS_RS4_BE +#define EM_MIPS_RS3_LE EM_MIPS_RS4_BE +#else +#define EM_MIPS_RS3_LE 10 +#endif +#endif /* !EM_MIPS_RS3_LE */ + #define MATCH_MACHINE(x) (x == EM_MIPS || x == EM_MIPS_RS3_LE) #define SHT_RELM SHT_REL #define Elf32_RelM Elf32_Rel @@ -714,8 +723,8 @@ unsigned long create_module(const char *name, size_t size) #else _syscall2(unsigned long, create_module, const char *, name, size_t, size) #endif -static char m_filename[BUFSIZ + 1] = "\0"; -static char m_fullName[BUFSIZ + 1] = "\0"; +static char m_filename[BUFSIZ + 1]; +static char m_fullName[BUFSIZ + 1]; /*======================================================================*/ @@ -793,7 +802,9 @@ arch_apply_relocation(struct obj_file *f, ElfW(RelM) *rel, ElfW(Addr) v) { struct arch_file *ifile = (struct arch_file *) f; +#if !(defined(__mips__)) struct arch_symbol *isym = (struct arch_symbol *) sym; +#endif ElfW(Addr) *loc = (ElfW(Addr) *) (targsec->contents + rel->r_offset); ElfW(Addr) dot = targsec->header.sh_addr + rel->r_offset; @@ -2306,48 +2317,50 @@ static int new_get_kernel_symbols(void) } n_ext_modules = nmod = ret; - ext_modules = modules = xmalloc(nmod * sizeof(*modules)); - memset(modules, 0, nmod * sizeof(*modules)); /* Collect the modules' symbols. */ - for (i = 0, mn = module_names, m = modules; - i < nmod; ++i, ++m, mn += strlen(mn) + 1) { - struct new_module_info info; - - if (query_module(mn, QM_INFO, &info, sizeof(info), &ret)) { - if (errno == ENOENT) { - /* The module was removed out from underneath us. */ - continue; - } - perror_msg("query_module: QM_INFO: %s", mn); - return 0; - } - - syms = xmalloc(bufsize = 1024); - retry_mod_sym_load: - if (query_module(mn, QM_SYMBOLS, syms, bufsize, &ret)) { - switch (errno) { - case ENOSPC: - syms = xrealloc(syms, bufsize = ret); - goto retry_mod_sym_load; - case ENOENT: - /* The module was removed out from underneath us. */ - continue; - default: - perror_msg("query_module: QM_SYMBOLS: %s", mn); + if (nmod){ + ext_modules = modules = xmalloc(nmod * sizeof(*modules)); + memset(modules, 0, nmod * sizeof(*modules)); + for (i = 0, mn = module_names, m = modules; + i < nmod; ++i, ++m, mn += strlen(mn) + 1) { + struct new_module_info info; + + if (query_module(mn, QM_INFO, &info, sizeof(info), &ret)) { + if (errno == ENOENT) { + /* The module was removed out from underneath us. */ + continue; + } + perror_msg("query_module: QM_INFO: %s", mn); return 0; } - } - nsyms = ret; - - m->name = mn; - m->addr = info.addr; - m->nsyms = nsyms; - m->syms = syms; - - for (j = 0, s = syms; j < nsyms; ++j, ++s) { - s->name += (unsigned long) syms; + + syms = xmalloc(bufsize = 1024); + retry_mod_sym_load: + if (query_module(mn, QM_SYMBOLS, syms, bufsize, &ret)) { + switch (errno) { + case ENOSPC: + syms = xrealloc(syms, bufsize = ret); + goto retry_mod_sym_load; + case ENOENT: + /* The module was removed out from underneath us. */ + continue; + default: + perror_msg("query_module: QM_SYMBOLS: %s", mn); + return 0; + } + } + nsyms = ret; + + m->name = mn; + m->addr = info.addr; + m->nsyms = nsyms; + m->syms = syms; + + for (j = 0, s = syms; j < nsyms; ++j, ++s) { + s->name += (unsigned long) syms; + } } }