Changeset 17341d4 in mainline for uspace/lib/c/generic/rtld/module.c


Ignore:
Timestamp:
2016-04-20T17:25:48Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dc0d8b52
Parents:
13dfa3f9
Message:

Move rtld internals out of loader. Stop misusing rtld instance from current environment for loading dynamically linked executables.

File:
1 edited

Legend:

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

    r13dfa3f9 r17341d4  
    9191 * path components are ignored.
    9292 */
    93 module_t *module_find(const char *name)
     93module_t *module_find(rtld_t *rtld, const char *name)
    9494{
    9595        const char *p, *soname;
     
    106106
    107107        /* Traverse list of all modules. Not extremely fast, but simple */
    108         list_foreach(runtime_env->modules, modules_link, module_t, m) {
     108        list_foreach(rtld->modules, modules_link, module_t, m) {
    109109                DPRINTF("m = %p\n", m);
    110110                if (str_cmp(m->dyn.soname, soname) == 0) {
     
    122122 * Currently this trivially tries to load '/<name>'.
    123123 */
    124 module_t *module_load(const char *name)
    125 {
    126         elf_info_t info;
     124module_t *module_load(rtld_t *rtld, const char *name)
     125{
     126        elf_finfo_t info;
    127127        char name_buf[NAME_BUF_SIZE];
    128128        module_t *m;
     
    135135        }
    136136
     137        m->rtld = rtld;
     138
    137139        if (str_size(name) > NAME_BUF_SIZE - 2) {
    138140                printf("soname too long. increase NAME_BUF_SIZE\n");
     
    145147
    146148        /* FIXME: need to real allocation of address space */
    147         m->bias = runtime_env->next_bias;
    148         runtime_env->next_bias += 0x100000;
     149        m->bias = rtld->next_bias;
     150        rtld->next_bias += 0x100000;
    149151
    150152        DPRINTF("filename:'%s'\n", name_buf);
     
    171173
    172174        /* Insert into the list of loaded modules */
    173         list_append(&m->modules_link, &runtime_env->modules);
     175        list_append(&m->modules_link, &rtld->modules);
    174176
    175177        return m;
     
    221223
    222224                        DPRINTF("%s needs %s\n", m->dyn.soname, dep_name);
    223                         dm = module_find(dep_name);
     225                        dm = module_find(m->rtld, dep_name);
    224226                        if (!dm) {
    225                                 dm = module_load(dep_name);
     227                                dm = module_load(m->rtld, dep_name);
    226228                                module_load_deps(dm);
    227229                        }
     
    241243 * @param       start   The module where to start from.
    242244 */
    243 void modules_process_relocs(module_t *start)
    244 {
    245         list_foreach(runtime_env->modules, modules_link, module_t, m) {
    246                 /* Skip rtld, since it has already been processed */
    247                 if (m != &runtime_env->rtld) {
     245void modules_process_relocs(rtld_t *rtld, module_t *start)
     246{
     247        list_foreach(rtld->modules, modules_link, module_t, m) {
     248                /* Skip rtld module, since it has already been processed */
     249                if (m != &rtld->rtld) {
    248250                        module_process_relocs(m);
    249251                }
     
    253255/** Clear BFS tags of all modules.
    254256 */
    255 void modules_untag(void)
    256 {
    257         list_foreach(runtime_env->modules, modules_link, module_t, m) {
     257void modules_untag(rtld_t *rtld)
     258{
     259        list_foreach(rtld->modules, modules_link, module_t, m) {
    258260                m->bfs_tag = false;
    259261        }
Note: See TracChangeset for help on using the changeset viewer.