Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3688 → Rev 3689

/branches/dynload/uspace/lib/rtld/symbol.c
70,7 → 70,7
elf_word bucket;
 
// module_name = m->dyn.soname;
// DPRINTF("def_find_in_module('%s', %s)\n", name, module_name);
DPRINTF("def_find_in_module('%s', %s)\n", name, module_name);
 
sym_table = m->dyn.sym_tab;
nbucket = m->dyn.hash[0];
103,19 → 103,18
return sym; /* Found */
}
 
/** Find the definition of a symbol.
/** Find the definition of a symbol in a module and its deps.
*
* By definition in System V ABI, if module origin has the flag DT_SYMBOLIC,
* origin is searched first. Otherwise, or if the symbol hasn't been found,
* the module dependency graph is searched breadth-first, beginning
* from the executable program.
* Search the module dependency graph is breadth-first, beginning
* from the module @a start. Thus, @start and all its dependencies
* get searched.
*
* @param name Name of the symbol to search for.
* @param origin Module in which the dependency originates.
* @param start Module in which to start the search..
* @param mod (output) Will be filled with a pointer to the module
* that contains the symbol.
*/
elf_symbol_t *symbol_def_find(char *name, module_t *origin, module_t **mod)
elf_symbol_t *symbol_bfs_find(char *name, module_t *start, module_t **mod)
{
module_t *m, *dm;
elf_symbol_t *sym, *s;
122,21 → 121,6
link_t queue_head;
size_t i;
 
if (origin->dyn.symbolic) {
/*
* Origin module has a DT_SYMBOLIC flag.
* Try this module first
*/
s = def_find_in_module(name, origin);
if (s != NULL) {
/* Found */
*mod = origin;
return s;
}
}
 
/* Otherwise start in the executable program */
 
/*
* Do a BFS using the queue_link and bfs_tag fields.
* Vertices (modules) are tagged the moment they are inserted
149,8 → 133,8
 
/* Insert root (the program) into the queue and tag it */
list_initialize(&queue_head);
runtime_env->program->bfs_tag = true;
list_append(&runtime_env->program->queue_link, &queue_head);
start->bfs_tag = true;
list_append(&start->queue_link, &queue_head);
 
/* If the symbol is found, it will be stored in 'sym' */
sym = NULL;
196,6 → 180,43
return sym; /* Symbol found */
}
 
 
/** Find the definition of a symbol..
*
* By definition in System V ABI, if module origin has the flag DT_SYMBOLIC,
* origin is searched first. Otherwise, or if the symbol hasn't been found,
* the module dependency graph is searched breadth-first, beginning
* from the executable program.
*
* @param name Name of the symbol to search for.
* @param origin Module in which the dependency originates.
* @param mod (output) Will be filled with a pointer to the module
* that contains the symbol.
*/
elf_symbol_t *symbol_def_find(char *name, module_t *origin, module_t **mod)
{
module_t *m, *dm;
elf_symbol_t *sym, *s;
link_t queue_head;
size_t i;
 
if (origin->dyn.symbolic) {
/*
* Origin module has a DT_SYMBOLIC flag.
* Try this module first
*/
s = def_find_in_module(name, origin);
if (s != NULL) {
/* Found */
*mod = origin;
return s;
}
}
 
/* Otherwise start in the executable program */
return symbol_bfs_find(name, runtime_env->program, mod);
}
 
uintptr_t symbol_get_addr(elf_symbol_t *sym, module_t *m)
{
if (sym->st_shndx == SHN_ABS) {