module: Fixed the upper limit in symbol table walk through
authorChandramouli Narayanan <chandramouli.narayanan@intel.com>
Wed, 5 Sep 2012 06:49:49 +0000 (07:49 +0100)
committerMatt Fleming <matt.fleming@intel.com>
Wed, 5 Sep 2012 06:49:49 +0000 (07:49 +0100)
Number of entries in symbol table should be sized by the table entry
size. Without this, the loading of modules takes forever due to
walking all over the memory.

Signed-off-by: Chandramouli Narayanan <chandramouli.narayanan@intel.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
com32/lib/sys/module/common.c

index 6e63907..30c57b4 100644 (file)
@@ -47,7 +47,7 @@ void print_elf_symbols(struct elf_module *module) {
        unsigned int i;
        Elf32_Sym *crt_sym;
 
-       for (i = 1; i < module->symtable_size; i++)
+       for (i = 1; i < module->symtable_size/module->syment_size; i++)
        {
                crt_sym = (Elf32_Sym*)(module->sym_table + i*module->syment_size);
 
@@ -315,7 +315,7 @@ int check_symbols(struct elf_module *module)
        int strong_count;
        int weak_count;
 
-       for(i = 1; i < module->symtable_size; i++)
+       for (i = 1; i < module->symtable_size/module->syment_size; i++)
        {
                crt_sym = symbol_get_entry(module, i);
                crt_name = module->str_table + crt_sym->st_name;
@@ -535,7 +535,7 @@ static Elf32_Sym *module_find_symbol_iterate(const char *name,struct elf_module
        unsigned int i;
        Elf32_Sym *crt_sym;
 
-       for (i=1; i < module->symtable_size; i++)
+       for (i = 1; i < module->symtable_size/module->syment_size; i++)
        {
                crt_sym = symbol_get_entry(module, i);
                if (strcmp(name, module->str_table + crt_sym->st_name) == 0)