Changes in uspace/lib/c/generic/rtld/rtld.c [b83c5e4:32254d6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/rtld/rtld.c
rb83c5e4 r32254d6 43 43 44 44 rtld_t *runtime_env; 45 static rtld_t rt_env_static; 46 47 /** Initialize the runtime linker for use in a statically-linked executable. */ 48 errno_t rtld_init_static(void) 49 { 50 errno_t rc; 51 52 runtime_env = &rt_env_static; 53 list_initialize(&runtime_env->modules); 54 list_initialize(&runtime_env->imodules); 55 runtime_env->program = NULL; 56 runtime_env->next_id = 1; 57 58 rc = module_create_static_exec(runtime_env, NULL); 59 if (rc != EOK) 60 return rc; 61 62 modules_process_tls(runtime_env); 63 64 return EOK; 65 } 66 67 /** Initialize and process a dynamically linked executable. 45 46 /** Initialize and process an executable. 68 47 * 69 48 * @param p_info Program info … … 73 52 { 74 53 rtld_t *env; 75 module_t *prog; 76 77 DPRINTF("Load dynamically linked program.\n"); 54 bool is_dynamic = p_info->dynamic != NULL; 55 DPRINTF("rtld_prog_process\n"); 78 56 79 57 /* Allocate new RTLD environment to pass to the loaded program */ … … 82 60 return ENOMEM; 83 61 84 env->next_id = 1;85 86 prog = calloc(1, sizeof(module_t));87 if (prog == NULL) {88 free(env);89 return ENOMEM;90 }91 92 /*93 * First we need to process dynamic sections of the executable94 * program and insert it into the module graph.95 */96 97 DPRINTF("Parse program .dynamic section at %p\n", p_info->dynamic);98 dynamic_parse(p_info->dynamic, 0, &prog->dyn);99 prog->bias = 0;100 prog->dyn.soname = "[program]";101 prog->rtld = env;102 prog->id = rtld_get_next_id(env);103 prog->exec = true;104 prog->local = false;105 106 prog->tdata = p_info->tls.tdata;107 prog->tdata_size = p_info->tls.tdata_size;108 prog->tbss_size = p_info->tls.tbss_size;109 prog->tls_align = p_info->tls.tls_align;110 111 DPRINTF("prog tdata at %p size %zu, tbss size %zu\n",112 prog->tdata, prog->tdata_size, prog->tbss_size);113 114 /* Initialize list of loaded modules */115 62 list_initialize(&env->modules); 116 63 list_initialize(&env->imodules); 117 list_append(&prog->modules_link, &env->modules); 64 env->next_id = 1; 65 66 module_t *module; 67 errno_t rc = module_create_entrypoint(p_info, env, &module); 68 if (rc != EOK) { 69 free(env); 70 return rc; 71 } 118 72 119 73 /* Pointer to program module. Used as root of the module graph. */ 120 env->program = prog;74 env->program = module; 121 75 122 76 /* … … 124 78 */ 125 79 126 DPRINTF("Load all program dependencies\n"); 127 errno_t rc = module_load_deps(prog, 0); 128 if (rc != EOK) { 129 return rc; 80 if (is_dynamic) { 81 DPRINTF("Load all program dependencies\n"); 82 rc = module_load_deps(module, 0); 83 if (rc != EOK) { 84 free(module); 85 free(env); 86 return rc; 87 } 130 88 } 131 89 … … 137 95 */ 138 96 139 /* Process relocations in all modules */ 140 DPRINTF("Relocate all modules\n"); 141 modules_process_relocs(env, prog); 142 143 *rre = env; 97 if (is_dynamic) { 98 /* Process relocations in all modules */ 99 DPRINTF("Relocate all modules\n"); 100 modules_process_relocs(env, module); 101 } 102 103 if (rre != NULL) 104 *rre = env; 144 105 return EOK; 145 106 }
Note:
See TracChangeset
for help on using the changeset viewer.