Ignore:
File:
1 edited

Legend:

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

    r17341d4 r9d58539  
    3535 */
    3636
    37 #include <errno.h>
    38 #include <rtld/module.h>
    3937#include <rtld/rtld.h>
    40 #include <rtld/rtld_debug.h>
    41 #include <stdlib.h>
    4238
    43 rtld_t *runtime_env;
    44 static rtld_t rt_env_static;
    45 static module_t prog_mod;
     39runtime_env_t *runtime_env;
     40static runtime_env_t rt_env_static;
    4641
    47 /** Initialize the runtime linker for use in a statically-linked executable. */
     42/** Initialize the loder for use in a statically-linked binary. */
    4843void rtld_init_static(void)
    4944{
     
    5449}
    5550
    56 /** Initialize and process a dynamically linked executable.
    57  *
    58  * @param p_info Program info
    59  * @return EOK on success or non-zero error code
    60  */
    61 int rtld_prog_process(elf_finfo_t *p_info, rtld_t **rre)
    62 {
    63         rtld_t *env;
    64 
    65         DPRINTF("Load dynamically linked program.\n");
    66 
    67         /* Allocate new RTLD environment to pass to the loaded program */
    68         env = calloc(1, sizeof(rtld_t));
    69         if (env == NULL)
    70                 return ENOMEM;
    71 
    72         /*
    73          * First we need to process dynamic sections of the executable
    74          * program and insert it into the module graph.
    75          */
    76 
    77         DPRINTF("Parse program .dynamic section at %p\n", p_info->dynamic);
    78         dynamic_parse(p_info->dynamic, 0, &prog_mod.dyn);
    79         prog_mod.bias = 0;
    80         prog_mod.dyn.soname = "[program]";
    81         prog_mod.rtld = env;
    82 
    83         /* Initialize list of loaded modules */
    84         list_initialize(&env->modules);
    85         list_append(&prog_mod.modules_link, &env->modules);
    86 
    87         /* Pointer to program module. Used as root of the module graph. */
    88         env->program = &prog_mod;
    89 
    90         /* Work around non-existent memory space allocation. */
    91         env->next_bias = 0x1000000;
    92 
    93         /*
    94          * Now we can continue with loading all other modules.
    95          */
    96 
    97         DPRINTF("Load all program dependencies\n");
    98         module_load_deps(&prog_mod);
    99 
    100         /*
    101          * Now relocate/link all modules together.
    102          */
    103 
    104         /* Process relocations in all modules */
    105         DPRINTF("Relocate all modules\n");
    106         modules_process_relocs(env, &prog_mod);
    107 
    108         *rre = env;
    109         return EOK;
    110 }
    111 
    11251/** @}
    11352 */
Note: See TracChangeset for help on using the changeset viewer.