Exemple #1
0
static void read_frame_info_section(Context * ctx, ELF_Section * text_section,
                                    U8_T IP, DWARFCache * cache, FrameInfoIndex * index) {
    unsigned l, h;
    ELF_Section * section = index->mSection;
    ELF_File * file = section->file;
    U4_T sec_idx = 0;

    if (text_section != NULL && text_section->file != file) {
        unsigned i;
        assert(get_dwarf_file(text_section->file) == file);
        for (i = 1; i < file->section_cnt; i++) {
            ELF_Section * sec = cache->mFile->sections + i;
            if (sec->name == NULL) continue;
            if (strcmp(sec->name, text_section->name) == 0) {
                text_section = sec;
                break;
            }
        }
    }

    memset(&rules, 0, sizeof(StackFrameRules));
    rules.ctx = ctx;
    rules.section = section;
    rules.text_section = text_section;
    rules.eh_frame = strcmp(section->name, ".eh_frame") == 0;
    rules.reg_id_scope.big_endian = file->big_endian;
    rules.reg_id_scope.machine = file->machine;
    rules.reg_id_scope.os_abi = file->os_abi;
    rules.reg_id_scope.elf64 = file->elf64;
    rules.reg_id_scope.id_type = rules.eh_frame ? REGNUM_EH_FRAME : REGNUM_DWARF;
    rules.cie_pos = ~(U8_T)0;

    if (index->mFrameInfoRanges == NULL) create_search_index(cache, index);
    l = 0;
    h = index->mFrameInfoRangesCnt;
    if (index->mRelocatable && text_section != NULL) sec_idx = text_section->index;
    while (l < h) {
        unsigned k = (l + h) / 2;
        FrameInfoRange * range = index->mFrameInfoRanges + k;
        if (sec_idx < range->mSection) {
            h = k;
        }
        else if (sec_idx > range->mSection) {
            l = k + 1;
        }
        else if (range->mAddr > IP) {
            h = k;
        }
        else if (range->mAddr + range->mSize <= IP) {
            l = k + 1;
        }
        else {
            read_frame_fde(IP, range->mOffset);
            return;
        }
    }
}
Exemple #2
0
/** Command arguments are as follows
 *  - argv[1]: The corpus file
 *  - argv[2]: The search file
 *  - argv[3]: The number of significant terms to display
 */
int main(int argc, char * argv[]){
  // Create an index from the corpus
  create_corpus_index(argv[1]);

  // Create an index from the search file
  create_search_index(argv[2]);

  // Print statistics
  print_statistics(argv[2], (atoi(argv[3])));

  // No errors encountered
  return 0;
}