Print this page
4054 dis sometimes decides random symbols are functions


 626  * the offset within that symbol.  If no matching symbol is found, then NULL is
 627  * returned.
 628  *
 629  * If 'cache_result' is specified, then we keep track of the resulting symbol.
 630  * This cached result is consulted first on subsequent lookups in order to avoid
 631  * unecessary lookups.  This flag should be used for resolving the current PC,
 632  * as the majority of addresses stay within the current function.
 633  */
 634 const char *
 635 dis_tgt_lookup(dis_tgt_t *tgt, uint64_t addr, off_t *offset, int cache_result,
 636     size_t *size, int *isfunc)
 637 {
 638         int lo, hi, mid;
 639         sym_entry_t *sym, *osym, *match;
 640         int found;
 641 
 642         if (tgt->dt_symcache != NULL &&
 643             addr >= tgt->dt_symcache->se_sym.st_value &&
 644             addr < tgt->dt_symcache->se_sym.st_value +
 645             tgt->dt_symcache->se_sym.st_size) {
 646                 *offset = addr - tgt->dt_symcache->se_sym.st_value;
 647                 *size = tgt->dt_symcache->se_sym.st_size;
 648                 return (tgt->dt_symcache->se_name);




 649         }
 650 
 651         lo = 0;
 652         hi = (tgt->dt_symcount - 1);
 653         found = 0;
 654         match = osym = NULL;
 655         while (lo <= hi) {
 656                 mid = (lo + hi) / 2;
 657 
 658                 sym = &tgt->dt_symtab[mid];
 659 
 660                 if (addr >= sym->se_sym.st_value &&
 661                     addr < sym->se_sym.st_value + sym->se_sym.st_size &&
 662                     (!found || sym->se_sym.st_value > osym->se_sym.st_value)) {
 663                         osym = sym;
 664                         found = 1;
 665                 } else if (addr == sym->se_sym.st_value) {
 666                         /*
 667                          * Particularly for .plt objects, it's possible to have
 668                          * a zero sized object.  We want to return this, but we




 626  * the offset within that symbol.  If no matching symbol is found, then NULL is
 627  * returned.
 628  *
 629  * If 'cache_result' is specified, then we keep track of the resulting symbol.
 630  * This cached result is consulted first on subsequent lookups in order to avoid
 631  * unecessary lookups.  This flag should be used for resolving the current PC,
 632  * as the majority of addresses stay within the current function.
 633  */
 634 const char *
 635 dis_tgt_lookup(dis_tgt_t *tgt, uint64_t addr, off_t *offset, int cache_result,
 636     size_t *size, int *isfunc)
 637 {
 638         int lo, hi, mid;
 639         sym_entry_t *sym, *osym, *match;
 640         int found;
 641 
 642         if (tgt->dt_symcache != NULL &&
 643             addr >= tgt->dt_symcache->se_sym.st_value &&
 644             addr < tgt->dt_symcache->se_sym.st_value +
 645             tgt->dt_symcache->se_sym.st_size) {
 646                 sym = tgt->dt_symcache;
 647                 *offset = addr - sym->se_sym.st_value;
 648                 *size = sym->se_sym.st_size;
 649                 if (isfunc != NULL)
 650                         *isfunc = (GELF_ST_TYPE(sym->se_sym.st_info) ==
 651                             STT_FUNC);
 652                 return (sym->se_name);
 653         }
 654 
 655         lo = 0;
 656         hi = (tgt->dt_symcount - 1);
 657         found = 0;
 658         match = osym = NULL;
 659         while (lo <= hi) {
 660                 mid = (lo + hi) / 2;
 661 
 662                 sym = &tgt->dt_symtab[mid];
 663 
 664                 if (addr >= sym->se_sym.st_value &&
 665                     addr < sym->se_sym.st_value + sym->se_sym.st_size &&
 666                     (!found || sym->se_sym.st_value > osym->se_sym.st_value)) {
 667                         osym = sym;
 668                         found = 1;
 669                 } else if (addr == sym->se_sym.st_value) {
 670                         /*
 671                          * Particularly for .plt objects, it's possible to have
 672                          * a zero sized object.  We want to return this, but we