[5510] * Use function pointers for symbol lookup ( currently for elf32 and elf64,
Revision: 5510
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5510 Author: pbrook Date: 2008-10-22 15:11:31 +0000 (Wed, 22 Oct 2008)
Log Message:
-----------
* Use function pointers for symbol lookup (currently for elf32 and elf64, could be expanded). This also fixes the bug with mips elf64 symbols in current Qemu trunk.
* Use quicksort and binary search for symbol lookup.
* Remove unneeded entries from symbol table. This reduced a typical table size (linux mips kernel) from 1764487 to 11656 entries.
Modified Paths:
--------------
trunk/disas.c
trunk/disas.h
trunk/elf_ops.h
trunk/linux-user/elfload.c
Modified: trunk/disas.c
===================================================================
disas.c +7 -23
@@ -303,33 +303,17 @@/* Look up symbol for debugging purpose. Returns "" if unknown. */ const char *lookup_symbol (target_ulong orig_addr) { -unsigned int i; -/* Hack, because we know this is x86. */ -Elf32_Sym *sym; +const char *symbol ="" ;struct syminfo *s; -target_ulong addr;for (s = syminfos; s; s = s->next) { - sym = s->disas_symtab; -for (i =0 ; i < s->disas_num_syms; i++) { -if (sym[i].st_shndx ==SHN_UNDEF - || sym[i].st_shndx >=SHN_LORESERVE ) -continue ; - -if (ELF_ST_TYPE (sym[i].st_info) !=STT_FUNC ) -continue ; - - addr = sym[i].st_value; -#if defined(TARGET_ARM ) || defined (TARGET_MIPS ) -/* The bottom address bit marks a Thumb or MIPS16 symbol. */ - addr &= ~(target_ulong )1 ; -#endif -if (orig_addr >= addr - && orig_addr < addr + sym[i].st_size) -return s->disas_strtab + sym[i].st_name; - } + symbol = s->lookup_symbol (s, orig_addr); +if (symbol[0 ] !='\0' ) { +break ; + } } -return "" ; + +return symbol; }#if !defined(CONFIG_USER_ONLY )
Modified: trunk/disas.h
===================================================================
disas.h +16 -4
@@ -10,12 +10,24 @@/* Look up symbol for debugging purpose. Returns "" if unknown. */ const char *lookup_symbol (target_ulong orig_addr); -/* Filled in by elfload.c. Simplistic, but will do for now. */ -extern struct syminfo { +struct syminfo ; +struct elf32_sym ; +struct elf64_sym ; + +typedef const char *(*lookup_symbol_t )(struct syminfo *s,target_ulong orig_addr); + +struct syminfo { +lookup_symbol_t lookup_symbol;unsigned int disas_num_syms; -void *disas_symtab; +union { +struct elf32_sym *elf32; +struct elf64_sym *elf64; + } disas_symtab;const char *disas_strtab;struct syminfo *next; -} *syminfos; +}; +/* Filled in by elfload.c. Simplistic, but will do for now. */ +extern struct syminfo *syminfos; +#endif /* _QEMU_DISAS_H */
Modified: trunk/elf_ops.h
===================================================================
elf_ops.h +63 -24
122 lines not on this page · raw message
Modified: trunk/linux-user/elfload.c
===================================================================
linux-user/elfload.c +98 -44
178 lines not on this page · raw message