Beispiel #1
0
static void
cmd_list (const gchar *file,
          const gchar *section,
          const gchar *path,
          gboolean     details)
{
  GResource *resource;

#ifdef HAVE_LIBELF
  Elf *elf;
  int fd;

  if ((elf = get_elf (file, &fd)))
    {
      elf_list_resources (elf, fd, section, path ? path : "", details);
      elf_end (elf);
      close (fd);
    }
  else

#endif

  if ((resource = get_resource (file)))
    {
      list_resource (resource, "/", "", path ? path : "", details);
      g_resource_unref (resource);
    }
  else
    {
      g_printerr ("Don't know how to handle %s\n", file);
#ifndef HAVE_LIBELF
      g_printerr ("gresource is built without elf support\n");
#endif
    }
}
Beispiel #2
0
int crunch_pltmap()
{
   list_t * list;
   elf_t  * elf;
   addr_t curvma;
   char * data;
   size_t nread,
          tread = 0;

   if(!(list = get_pltmap()))
      error_ret("can't get plt_map()",-1);

   if((curvma = get_plt(NULL))<=0)
      error_ret("can't get plt",-1);

   if(!(elf = get_elf()))
      error_ret("can't get elf",-1);

   if(!(data=data_at_addr(elf,curvma)))
      error_ret("can't get data",-1);

   if((nread = crunch_plt_header( data , curvma ))<=0)
      error_ret("bad plt header",-1);
   tread  += nread;

   int reloff;
   while((nread = crunch_plt_entry( data + tread, curvma + tread , 
                                    &reloff , NULL ))>0)
   {
      plt_map_t * map;
      Elf32_Rel * rel_plt;
      char      * str;
      map = new_plt_map();

      if(!(rel_plt=get_rel_plt(elf)))
         error_ret("can't get reloc table",-1);

      map->vaddr = curvma + tread;
      map->off   = reloff;

      rel_plt += (reloff/sizeof(*rel_plt));

      str = dsym_name_by_index( elf , ELF32_R_SYM(rel_plt->r_info));

      map->name = strdup( str ? str : "" );

      add_pltmap( list , map );

      tread  += nread;
   }
   add_pltmap_funcs(list);
   return(tread);
}
Beispiel #3
0
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);
}
Beispiel #4
0
static void
cmd_sections (const gchar *file,
              const gchar *section,
              const gchar *path,
              gboolean     details)
{
  GResource *resource;

#ifdef HAVE_LIBELF

  Elf *elf;
  gint fd;

  if ((elf = get_elf (file, &fd)))
    {
      elf_foreach_resource_section (elf, print_section_name, NULL);
      elf_end (elf);
      close (fd);
    }
  else

#endif

  if ((resource = get_resource (file)))
    {
      /* No sections */
      g_resource_unref (resource);
    }
  else
    {
      g_printerr ("Don't know how to handle %s\n", file);
#ifndef HAVE_LIBELF
      g_printerr ("gresource is built without elf support\n");
#endif
    }
}
Beispiel #5
0
int show_dsymtab( char **argv )
{
   if( *argv ) error_ret("bad args",-1);
   dump_dsymtab( get_elf() );
   return( COMMAND_SUCCESS );
}