コード例 #1
0
ファイル: target.c プロジェクト: boz/elfcrunch
int open_target( char * file )
{
   if(!file)
      error_die("null arg",1);

   /* there's only 1 target */
   if( target_elf ) 
      free_elf( target_elf );

   if(!(target_elf = new_elf(file)))
      error_ret("can't open elf",-1);

#ifdef USE_COMMANDS
   /* check for info saved in xml file */
   if( use_info )
      if(open_target_info( target_elf ) < 0 )
         error_ret("problem getting info",-1);
#endif /* USE_COMMANDS */

   disasm_init();
   crunch_pltmap();
   gather_funcs_by_symtab( get_elf() );
   gather_funcs_by_section(NULL);
   get_objs_from_entry(get_elf());
   gather_vars( get_elf() );
   sync_func_map();

#if 0
   if( do_disasm || do_pltmap ||do_disasm_seg ||do_map_dmp){
      crunch_pltmap();
   }

   if( do_dump_funcs || do_disasm || do_disasm_seg || do_map_dmp ){
      gather_funcs_by_symtab( get_elf() );
      gather_funcs_by_section(NULL);
      get_objs_from_entry(get_elf());
   }
   if( do_vars || do_disasm || do_disasm_seg || do_map_dmp || do_map_dmp )
      gather_vars( get_elf() );
   sync_func_map();
#endif

   return(0);
}
コード例 #2
0
static
void dump_vars(const GoughGraph &g, const string &base, const Grey &grey) {
    FILE *f;
    {
        stringstream ss;
        ss << grey.dumpPath << "gough_" << base << "_vars.dot";
        f = fopen(ss.str().c_str(), "w");
    }
    fprintf(f, "digraph NFA {\n");
    fprintf(f, "rankdir=LR;\n");
    fprintf(f, "size=\"11.5,8\"\n");
    fprintf(f, "node [ shape = circle ];\n");
    fprintf(f, "START [style=invis];\n");

    vector<const GoughSSAVar *> vars;
    map<const GoughSSAVar *, string> names;
    map<const GoughSSAVar *, string> src_label;
    set<const GoughSSAVar *> reporters;
    gather_vars(g, &vars, &names, &src_label, &reporters);

    for (const GoughSSAVar *vp : vars) {
        fprintf(f, "%s [ width = 1, fixedsize = true, fontsize = 12, ",
                names[vp].c_str());
        fprintf(f, "label = \"%s\\n", src_label[vp].c_str());

        if (dynamic_cast<const GoughSSAVarMin *>(vp)) {
            fprintf(f, "MIN");
        } else if (dynamic_cast<const GoughSSAVarJoin *>(vp)) {
            fprintf(f, "JOIN");
        } else if (dynamic_cast<const GoughSSAVarNew *>(vp)) {
            fprintf(f, "NEW");
        } else {
            fprintf(f, "???");
        }
        fprintf(f, "\"];\n");
    }

    for (const GoughSSAVar *vp : reporters) {
        if (vp) {
            fprintf(f, "%s [ shape = doublecircle]\n", names[vp].c_str());
        } else {
            fprintf(f, "eps [ label = \"eps\" shape = doublecircle]\n");
        }
    }

    for (const GoughSSAVar *vp : vars) {
        const flat_set<GoughSSAVar *> &inputs = vp->get_inputs();
        for (const GoughSSAVar *v_in : inputs) {
            fprintf(f, "%s -> %s\n", names[v_in].c_str(), names[vp].c_str());
        }
    }

    fprintf(f, "}\n");
    fclose(f);
}