Logo Search packages:      
Sourcecode: eresi version File versions  Download package

revmobj_t* parse_lookup5_index ( char *  param,
char *  fmt,
u_int  sep 

Lookup a parameter with 5 fields, 3rd and 5th field beeing indexes Used for Relocation tables and GOT tables

Definition at line 578 of file grammar.c.

References aspect_type_get_by_id(), ASPECT_TYPE_UNKNOW, elfsh_get_raw(), elfsh_setrel(), s_L1handler::get_entptr, s_revm_object::get_obj, s_L2handler::get_obj, s_L1handler::get_obj_idx, s_revm_object::immed, s_L1handler::l2list, s_revm_object::otype, s_revm_object::parent, parse_lookup_varlist(), revm_check_object(), revm_create_IMMED(), revm_lookup_file(), revm_lookup_index(), revm_output(), s_revm_object::set_obj, s_L2handler::set_obj, strcmp(), and s_L2handler::type.

  revmL1_t        *l1;
  revmL2_t        *l2;
  void                  *robj;
  void                  *o1;
  int             real_index;
  int             real_index2;
  u_int                 size;
  int             isversion;
  revmobj_t       *pobj;
  elfshsect_t           *sect;
  char                  obj[ELFSH_MEANING];
  char                  L1field[ELFSH_MEANING];
  char                  L2field[ELFSH_MEANING];
  char                  index[ELFSH_MEANING];
  char                  index2[ELFSH_MEANING];
  int             ret;

#if 0
  char                  logbuf[BUFSIZ];

  if (sep != 2)

  // Check if this handler is the correct one 
  ret = parse_lookup_varlist(param, fmt, obj, L1field, index, index2, L2field);
  if (ret != 5)
                  "Parser handling failed", NULL);

  // Let's ask the hash table for the current working file 
  robj = revm_lookup_file(obj);
  if (robj == NULL)
                  "Cannot find requested file object", 

  // Then, we ask the Level 1 object 
  l1 = hash_get(&L1_hash, L1field);
  if (l1 == NULL)
                  "Cannot find requested L1 object", NULL);
  else if (l1->get_entptr == NULL || l1->get_obj_idx == NULL)
                  "This object needs 2 indexes", NULL);

  // Then the Level 2 object 
  l2 = hash_get(l1->l2list, L2field);
  if (l2 == NULL)
                  "Cannot find requested L2 object", NULL);
  else if (l2->get_obj == NULL || l2->set_obj == NULL)
                  "Child object is invalid", NULL);

  // Not clean .. need to ve virtualized 
  isversion = (!strcmp(L1field, "version") ||
             !strcmp(L1field, "verdef") ||
             !strcmp(L1field, "verneed"));

  // Get indexes 
  real_index  = (int) revm_lookup_index(index);
  real_index2 = (int) revm_lookup_index(index2);

#if 0
 snprintf(logbuf, BUFSIZ - 1, 
        "[DEBUG_MODEL] Lookup5_index : index(" UFMT ") rindex(" UFMT ") \n", 
        real_index, real_index2);

  // Do index sanity 
  o1 = l1->get_obj_idx(robj, real_index, (u_int *) &size);
  if (!isversion && size <= real_index2)
                  "Second index too big", NULL);

  if (isversion && o1 == NULL)
                  "Invalid L1 index", NULL);    
  // printf("[DEBUG_RELOCS_IDX2] o1 = %p, o1->data = %p (%s) \n", 
  // o1, ((elfshsect_t*)o1)->data, ((elfshsect_t*)o1)->name);

  // This elfsh_get_reloc() returns a elfshsect_t *, 
  // and we need to grab the ->data pointer, to avoid rewriting a 
  // new handler (its not fair but it works .. ;) and its acceptable
  // since only relocation tables use this rule.
  sect = (elfshsect_t *) o1;
  o1 = elfsh_get_raw(sect);

  // Finally we fill the intermediate object format for the guessed object 
  pobj = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 0, 0);
  pobj->immed = 0;
  pobj->get_obj = (void *) l2->get_obj;
  pobj->set_obj = (void *) l2->set_obj;
  pobj->otype   = aspect_type_get_by_id(l2->type);

  // ugly flag to put for dynamic Rel vs Rela information 
  pobj->parent  = l1->get_entptr(o1, real_index2);

  if (isversion && pobj->parent == NULL)
                  "Unknown L2 object or Invalid L2 index", 

  // Error checking 
  pobj = revm_check_object(pobj);
  if (!pobj)
                  "Invalid REVM object", NULL);
  PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, pobj);

Generated by  Doxygen 1.6.0   Back to index