702 tgt->dt_symcache = sym;
703
704 *offset = addr - sym->se_sym.st_value;
705 *size = sym->se_sym.st_size;
706 if (isfunc)
707 *isfunc = (GELF_ST_TYPE(sym->se_sym.st_info) == STT_FUNC);
708
709 return (sym->se_name);
710 }
711
712 #if !defined(__sparc)
713 /*
714 * Given an address, return the starting offset of the next symbol in the file.
715 * Only needed on variable length instruction architectures.
716 */
717 off_t
718 dis_tgt_next_symbol(dis_tgt_t *tgt, uint64_t addr)
719 {
720 sym_entry_t *sym;
721
722 for (sym = tgt->dt_symcache;
723 sym != tgt->dt_symtab + tgt->dt_symcount;
724 sym++) {
725 if (sym->se_sym.st_value >= addr)
726 return (sym->se_sym.st_value - addr);
727 }
728
729 return (0);
730 }
731 #endif
732
733 /*
734 * Iterate over all sections in the target, executing the given callback for
735 * each.
736 */
737 void
738 dis_tgt_section_iter(dis_tgt_t *tgt, section_iter_f func, void *data)
739 {
740 dis_scn_t sdata;
741 Elf_Scn *scn;
742 int idx;
743
744 for (scn = elf_nextscn(tgt->dt_elf, NULL), idx = 1; scn != NULL;
745 scn = elf_nextscn(tgt->dt_elf, scn), idx++) {
746
|
702 tgt->dt_symcache = sym;
703
704 *offset = addr - sym->se_sym.st_value;
705 *size = sym->se_sym.st_size;
706 if (isfunc)
707 *isfunc = (GELF_ST_TYPE(sym->se_sym.st_info) == STT_FUNC);
708
709 return (sym->se_name);
710 }
711
712 #if !defined(__sparc)
713 /*
714 * Given an address, return the starting offset of the next symbol in the file.
715 * Only needed on variable length instruction architectures.
716 */
717 off_t
718 dis_tgt_next_symbol(dis_tgt_t *tgt, uint64_t addr)
719 {
720 sym_entry_t *sym;
721
722 sym = (tgt->dt_symcache != NULL) ? tgt->dt_symcache : tgt->dt_symtab;
723
724 while (sym != (tgt->dt_symtab + tgt->dt_symcount)) {
725 if (sym->se_sym.st_value >= addr)
726 return (sym->se_sym.st_value - addr);
727 sym++;
728 }
729
730 return (0);
731 }
732 #endif
733
734 /*
735 * Iterate over all sections in the target, executing the given callback for
736 * each.
737 */
738 void
739 dis_tgt_section_iter(dis_tgt_t *tgt, section_iter_f func, void *data)
740 {
741 dis_scn_t sdata;
742 Elf_Scn *scn;
743 int idx;
744
745 for (scn = elf_nextscn(tgt->dt_elf, NULL), idx = 1; scn != NULL;
746 scn = elf_nextscn(tgt->dt_elf, scn), idx++) {
747
|