Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/rtld/symbol.c

    r9d58539 r17341d4  
    3939
    4040#include <elf/elf.h>
     41#include <rtld/module.h>
    4142#include <rtld/rtld.h>
    4243#include <rtld/rtld_debug.h>
     
    111112 * @param name          Name of the symbol to search for.
    112113 * @param start         Module in which to start the search..
     114 * @param flags         @c ssf_none or @c ssf_noroot to not look for the symbol
     115 *                      in @a start
    113116 * @param mod           (output) Will be filled with a pointer to the module
    114117 *                      that contains the symbol.
    115118 */
    116 elf_symbol_t *symbol_bfs_find(const char *name, module_t *start, module_t **mod)
     119elf_symbol_t *symbol_bfs_find(const char *name, module_t *start,
     120    symbol_search_flags_t flags, module_t **mod)
    117121{
    118122        module_t *m, *dm;
     
    129133
    130134        /* Mark all vertices (modules) as unvisited */ 
    131         modules_untag();
     135        modules_untag(start->rtld);
    132136
    133137        /* Insert root (the program) into the queue and tag it */
     
    145149                list_remove(&m->queue_link);
    146150
    147                 s = def_find_in_module(name, m);
    148                 if (s != NULL) {
    149                         /* Symbol found */
    150                         sym = s;
    151                         *mod = m;
    152                         break;
     151                /* If ssf_noroot is specified, do not look in start module */
     152                if (m != start || (flags & ssf_noroot) == 0) {
     153                        s = def_find_in_module(name, m);
     154                        if (s != NULL) {
     155                                /* Symbol found */
     156                                sym = s;
     157                                *mod = m;
     158                                break;
     159                        }
    153160                }
    154161
     
    179186
    180187
    181 /** Find the definition of a symbol..
     188/** Find the definition of a symbol.
    182189 *
    183190 * By definition in System V ABI, if module origin has the flag DT_SYMBOLIC,
     
    188195 * @param name          Name of the symbol to search for.
    189196 * @param origin        Module in which the dependency originates.
     197 * @param flags         @c ssf_none or @c ssf_noroot to not look for the symbol
     198 *                      in the executable program.
    190199 * @param mod           (output) Will be filled with a pointer to the module
    191200 *                      that contains the symbol.
    192201 */
    193 elf_symbol_t *symbol_def_find(const char *name, module_t *origin, module_t **mod)
     202elf_symbol_t *symbol_def_find(const char *name, module_t *origin,
     203    symbol_search_flags_t flags, module_t **mod)
    194204{
    195205        elf_symbol_t *s;
     
    210220        /* Not DT_SYMBOLIC or no match. Now try other locations. */
    211221
    212         if (runtime_env->program) {
     222        if (origin->rtld->program) {
    213223                /* Program is dynamic -- start with program as root. */
    214                 return symbol_bfs_find(name, runtime_env->program, mod);
     224                return symbol_bfs_find(name, origin->rtld->program, flags, mod);
    215225        } else {
    216226                /* Program is static -- start with @a origin as root. */
    217                 return symbol_bfs_find(name, origin, mod);
     227                return symbol_bfs_find(name, origin, ssf_none, mod);
    218228        }
    219229}
Note: See TracChangeset for help on using the changeset viewer.