Changeset 31ea2a7 in mainline for uspace/lib/c/generic/rtld


Ignore:
Timestamp:
2025-01-26T17:53:49Z (14 months ago)
Author:
Matěj Volf <git@…>
Children:
f215c6ef
Parents:
eff458d
git-author:
Matěj Volf <git@…> (2025-01-25 21:36:13)
git-committer:
Matěj Volf <git@…> (2025-01-26 17:53:49)
Message:

init RTLD runtime at load time even for statically linked binaries

before this, main_fibril of a statically linked binary had wrong thread-local storage

please see PR description for an elaborate explanation of what and why was wrong

File:
1 edited

Legend:

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

    reff458d r31ea2a7  
    4545static rtld_t rt_env_static;
    4646
    47 /** Initialize the runtime linker for use in a statically-linked executable. */
     47/** Initialize a minimal runtime linker environment for use in executables loaded directly by kernel. */
    4848errno_t rtld_init_static(void)
    4949{
     
    6565}
    6666
    67 /** Initialize and process a dynamically linked executable.
     67/** Initialize and process an executable, static or dynamic.
    6868 *
    6969 * @param p_info Program info
     
    7575        module_t *prog;
    7676
    77         DPRINTF("Load dynamically linked program.\n");
     77        DPRINTF("Load program with rtld.\n");
    7878
    7979        /* Allocate new RTLD environment to pass to the loaded program */
     
    9595         */
    9696
    97         DPRINTF("Parse program .dynamic section at %p\n", p_info->dynamic);
    98         dynamic_parse(p_info->dynamic, 0, &prog->dyn);
     97        if (p_info->dynamic) {
     98                DPRINTF("Parse program .dynamic section at %p\n", p_info->dynamic);
     99                dynamic_parse(p_info->dynamic, 0, &prog->dyn);
     100        } else {
     101                DPRINTF("Program is statically linked\n");
     102        }
    99103        prog->bias = 0;
    100104        prog->dyn.soname = "[program]";
     
    124128         */
    125129
    126         DPRINTF("Load all program dependencies\n");
    127         errno_t rc = module_load_deps(prog, 0);
    128         if (rc != EOK) {
    129                 return rc;
     130        if (p_info->dynamic) {
     131                DPRINTF("Load all program dependencies\n");
     132                errno_t rc = module_load_deps(prog, 0);
     133                if (rc != EOK) {
     134                        free(prog);
     135                        free(env);
     136                        return rc;
     137                }
    130138        }
    131139
Note: See TracChangeset for help on using the changeset viewer.