Print this page
remove crap I didnt end up using
take to dis and libdisasm with an axe; does not yet compile


 692 
 693                 if (osym == tgt->dt_symtab)
 694                         break;
 695 
 696                 osym = osym - 1;
 697         } while ((sym->se_sym.st_value == osym->se_sym.st_value) &&
 698             (addr >= osym->se_sym.st_value) &&
 699             (addr < osym->se_sym.st_value + osym->se_sym.st_size));
 700 
 701         if (cache_result)
 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 
 747                 if (gelf_getshdr(scn, &sdata.ds_shdr) == NULL) {
 748                         warn("%s: failed to get section %d header",
 749                             tgt->dt_filename, idx);
 750                         continue;
 751                 }




 692 
 693                 if (osym == tgt->dt_symtab)
 694                         break;
 695 
 696                 osym = osym - 1;
 697         } while ((sym->se_sym.st_value == osym->se_sym.st_value) &&
 698             (addr >= osym->se_sym.st_value) &&
 699             (addr < osym->se_sym.st_value + osym->se_sym.st_size));
 700 
 701         if (cache_result)
 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 /*
 713  * Given an address, return the starting offset of the next symbol in the file.
 714  * Only needed on variable length instruction architectures.
 715  */
 716 off_t
 717 dis_tgt_next_symbol(dis_tgt_t *tgt, uint64_t addr)
 718 {
 719         sym_entry_t *sym;
 720 
 721         for (sym = tgt->dt_symcache;
 722             sym != tgt->dt_symtab + tgt->dt_symcount;
 723             sym++) {
 724                 if (sym->se_sym.st_value >= addr)
 725                         return (sym->se_sym.st_value - addr);
 726         }
 727 
 728         return (0);
 729 }

 730 
 731 /*
 732  * Iterate over all sections in the target, executing the given callback for
 733  * each.
 734  */
 735 void
 736 dis_tgt_section_iter(dis_tgt_t *tgt, section_iter_f func, void *data)
 737 {
 738         dis_scn_t sdata;
 739         Elf_Scn *scn;
 740         int idx;
 741 
 742         for (scn = elf_nextscn(tgt->dt_elf, NULL), idx = 1; scn != NULL;
 743             scn = elf_nextscn(tgt->dt_elf, scn), idx++) {
 744 
 745                 if (gelf_getshdr(scn, &sdata.ds_shdr) == NULL) {
 746                         warn("%s: failed to get section %d header",
 747                             tgt->dt_filename, idx);
 748                         continue;
 749                 }