summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/insmod-modutils/obj/obj_load.c
diff options
context:
space:
mode:
Diffstat (limited to 'mdk-stage1/insmod-modutils/obj/obj_load.c')
-rw-r--r--mdk-stage1/insmod-modutils/obj/obj_load.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/mdk-stage1/insmod-modutils/obj/obj_load.c b/mdk-stage1/insmod-modutils/obj/obj_load.c
index 4db20a998..62977acb7 100644
--- a/mdk-stage1/insmod-modutils/obj/obj_load.c
+++ b/mdk-stage1/insmod-modutils/obj/obj_load.c
@@ -21,8 +21,6 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-#ident "$Id$"
-
#include <alloca.h>
#include <string.h>
#include <stdlib.h>
@@ -52,7 +50,7 @@ obj_load (int fp, Elf32_Half e_type, const char *filename)
gzf_lseek(fp, 0, SEEK_SET);
if (gzf_read(fp, &f->header, sizeof(f->header)) != sizeof(f->header))
{
- error("error reading ELF header %s: %m", filename);
+ error("cannot read ELF header from %s", filename);
return NULL;
}
@@ -257,7 +255,7 @@ obj_load (int fp, Elf32_Half e_type, const char *filename)
{
case SHT_RELM:
{
- unsigned long nrel, j;
+ unsigned long nrel, j, nsyms;
ElfW(RelM) *rel;
struct obj_section *symtab;
char *strtab;
@@ -273,34 +271,25 @@ obj_load (int fp, Elf32_Half e_type, const char *filename)
nrel = sec->header.sh_size / sizeof(ElfW(RelM));
rel = (ElfW(RelM) *) sec->contents;
symtab = f->sections[sec->header.sh_link];
+ nsyms = symtab->header.sh_size / symtab->header.sh_entsize;
strtab = f->sections[symtab->header.sh_link]->contents;
/* Save the relocate type in each symbol entry. */
for (j = 0; j < nrel; ++j, ++rel)
{
- ElfW(Sym) *extsym;
struct obj_symbol *intsym;
unsigned long symndx;
symndx = ELFW(R_SYM)(rel->r_info);
if (symndx)
{
- extsym = ((ElfW(Sym) *) symtab->contents) + symndx;
- if (ELFW(ST_BIND)(extsym->st_info) == STB_LOCAL)
- {
- /* Local symbols we look up in the local table to be sure
- we get the one that is really intended. */
- intsym = f->local_symtab[symndx];
- }
- else
+ if (symndx >= nsyms)
{
- /* Others we look up in the hash table. */
- const char *name;
- if (extsym->st_name)
- name = strtab + extsym->st_name;
- else
- name = f->sections[extsym->st_shndx]->name;
- intsym = obj_find_symbol(f, name);
+ error("%s: Bad symbol index: %08lx >= %08lx",
+ filename, symndx, nsyms);
+ continue;
}
+
+ obj_find_relsym(intsym, f, f, rel, (ElfW(Sym) *)(symtab->contents), strtab);
intsym->r_type = ELFW(R_TYPE)(rel->r_info);
}
}