Changeset 153c7a29 in mainline for uspace/lib/c/generic/rtld/module.c


Ignore:
Timestamp:
2016-05-22T17:46:10Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0dc2fec
Parents:
2112a79
Message:

Since dlopen() sets up runtime_env, we would no longer use the static TLS. Thus set up runtime_env right away and convert static TLS to dynamic TLS.

File:
1 edited

Legend:

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

    r2112a79 r153c7a29  
    4949#include <rtld/rtld_arch.h>
    5050#include <rtld/module.h>
     51
     52/** Create module for static executable.
     53 *
     54 * @param rtld Run-time dynamic linker
     55 * @param rmodule Place to store pointer to new module or @c NULL
     56 * @return EOK on success, ENOMEM if out of memory
     57 */
     58int module_create_static_exec(rtld_t *rtld, module_t **rmodule)
     59{
     60        module_t *module;
     61
     62        module = calloc(1, sizeof(module_t));
     63        if (module == NULL)
     64                return ENOMEM;
     65
     66        module->id = rtld_get_next_id(rtld);
     67        module->dyn.soname = "[program]";
     68
     69        module->rtld = rtld;
     70        module->exec = true;
     71        module->local = true;
     72
     73        module->tdata = &_tdata_start;
     74        module->tdata_size = &_tdata_end - &_tdata_start;
     75        module->tbss_size = &_tbss_end - &_tbss_start;
     76        module->tls_align = (uintptr_t)&_tls_alignment;
     77
     78        list_append(&module->modules_link, &rtld->modules);
     79
     80        if (rmodule != NULL)
     81                *rmodule = module;
     82        return EOK;
     83}
    5184
    5285/** (Eagerly) process all relocation tables in a module.
     
    191224        m->tls_align = info.tls.tls_align;
    192225
    193         printf("tdata at %p size %zu, tbss size %zu\n",
     226        DPRINTF("tdata at %p size %zu, tbss size %zu\n",
    194227            m->tdata, m->tdata_size, m->tbss_size);
    195228
Note: See TracChangeset for help on using the changeset viewer.