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

int revm_load_dep ( elfshobj_t parent,
char *  name,
eresi_Addr  base,
elfshlinkmap_t lm,
hash_t dephash 
)

Load a dependence which is different from a normal file.

Parameters:
parent 
name 
base 
lm 
dephash 
Returns:

Definition at line 405 of file deps.c.

References ASPECT_TYPE_UNKNOW, s_obj::child_hash, elfsh_get_arch(), elfsh_init_symbol_hashtables(), elfsh_map_obj(), s_obj::hdr, s_obj::lastchildid, s_hash::name, s_obj::name, revm_output(), and revm_update_depinfo().

Referenced by revm_load_enumdep_rec().

{
  elfshobj_t      *new;
  char            logbuf[BUFSIZ];

  PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);  
  if (!parent || !name)
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
                  "Invalid argument", -1);

  /* Map the standard ELF object */
  new = elfsh_map_obj(name);
  if (NULL == new)
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
                  "Cannot load object", -1);
  if (elfsh_get_arch(new->hdr) != elfsh_get_arch(parent->hdr))
    {
      snprintf(logbuf, sizeof (logbuf) - 1, "Parent file and dependance %s"
             " architecture unmatched", name);
      PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,
                  logbuf, -1);
    }
  
  /* Print a msg if not in quiet mode */
  new->loadtime = time(&new->loadtime);
  if (!world.state.revm_quiet)
    {
      snprintf(logbuf, BUFSIZ - 1, " [*] New object dependences loaded : %s\n",
            name);
      revm_output(logbuf);
    }

  /* Set base address and linkmap addr */
  new->rhdr.base = base;
  new->linkmap = lm;

  /* Add the object of child objects */
  if (parent->lastchildid >= ELFSH_CHILD_MAX)
    PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
                  "Cannot create more child", -1);    

  /* Generate a child id */
  new->id = ELFSH_CHILD_NEW(parent);

  /* Init search hash tables */
  elfsh_init_symbol_hashtables(new);

  /* Parse debugging informations */
  revm_edfmt_parse(new);

  /* Initialize hash tables */
  snprintf(logbuf, sizeof(logbuf), "%s_children", name);
  hash_init(&new->child_hash, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW);
 
  snprintf(logbuf, sizeof(logbuf), "%s_parents", name);
  hash_init(&new->parent_hash, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW);  
 
  snprintf(logbuf, sizeof(logbuf), "%s_roots", name);
  hash_init(&new->root_hash, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW);  
 

  /* Link with its parent */
  /* Link with all the additional root files of its parent */
  /* Add reference to the private (or shared) list */
  hash_add(&new->parent_hash, parent->name, parent);
  hash_add(&parent->child_hash, new->name, new);
  if (world.state.revm_shared)
    hash_add(&world.shared_hash, new->name, new);
  else
    hash_add(&world.curjob->loaded, new->name, new);
  hash_add(&file_hash, new->name, new);
  revm_update_depinfo(new, parent, dephash, REVM_HASH_MERGE);
    
  PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0);
}


Generated by  Doxygen 1.6.0   Back to index