static void elf_file_read_symbol_table(struct elf_file_t *elf_file) { struct elf_section_t *section; int i; /* Create symbol table */ elf_file->symbol_table = list_create(); /* Load symbols from sections */ for (i = 0; i < list_count(elf_file->section_list); i++) { section = list_get(elf_file->section_list, i); if (section->header->sh_type == 2 || section->header->sh_type == 11) elf_file_read_symbol_section(elf_file, section); } /* Sort symbol table */ list_sort(elf_file->symbol_table, elf_symbol_compare); }
static void elf_file_read_symbol_table(struct elf_file_t *elf_file) { struct elf_section_t *section; struct elf_symbol_t *symbol; int i; /* Create symbol table */ elf_file->symbol_table = list_create(); /* Load symbols from sections */ elf_debug("Symbol table:\n"); for (i = 0; i < list_count(elf_file->section_list); i++) { section = list_get(elf_file->section_list, i); if (section->header->sh_type == 2 || section->header->sh_type == 11) elf_file_read_symbol_section(elf_file, section); } /* Sort symbol table */ list_sort(elf_file->symbol_table, elf_symbol_compare); /* Dump */ elf_debug("\n"); elf_debug("%-40s %-15s %-12s %-12s\n", "name", "section", "value", "size"); for (i = 0; i < 80; i++) elf_debug("-"); elf_debug("\n"); for (i = 0; i < list_count(elf_file->symbol_table); i++) { char section_name[15]; symbol = list_get(elf_file->symbol_table, i); section = list_get(elf_file->section_list, symbol->section); if (section) snprintf(section_name, sizeof(section_name), "%s", section->name); else snprintf(section_name, sizeof(section_name), "%d", symbol->section); elf_debug("%-40s %-15s 0x%-10x %-12d\n", symbol->name, section_name, symbol->value, symbol->size); } elf_debug("\n"); }