Changeset 153c7a29 in mainline
- Timestamp:
- 2016-05-22T17:46:10Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0dc2fec
- Parents:
- 2112a79
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/dlfcn.c
r2112a79 r153c7a29 49 49 module_t *m; 50 50 51 if (runtime_env == NULL) {52 printf("Dynamic linker not set up -- initializing.\n");53 rtld_init_static();54 }55 56 printf("dlopen(\"%s\", %d)\n", path, flag);57 58 printf("module_find('%s')\n", path);59 51 m = module_find(runtime_env, path); 60 52 if (m == NULL) { 61 printf("NULL. module_load('%s')\n", path);62 53 m = module_load(runtime_env, path, mlf_local); 63 printf("module_load_deps(m)\n");64 54 module_load_deps(m, mlf_local); 65 55 /* Now relocate. */ 66 printf("module_process_relocs(m)\n");67 56 module_process_relocs(m); 68 } else {69 printf("not NULL\n");70 57 } 71 58 … … 81 68 module_t *sm; 82 69 83 printf("dlsym(0x%lx, \"%s\")\n", (long)mod, sym_name);84 70 sd = symbol_bfs_find(sym_name, (module_t *) mod, &sm); 85 71 if (sd != NULL) { -
uspace/lib/c/generic/libc.c
r2112a79 r153c7a29 41 41 */ 42 42 43 #include <errno.h> 43 44 #include <libc.h> 44 45 #include <stdlib.h> … … 65 66 void __main(void *pcb_ptr) 66 67 { 68 /* Initialize user task run-time environment */ 69 __malloc_init(); 70 67 71 /* Save the PCB pointer */ 68 72 __pcb = (pcb_t *) pcb_ptr; … … 71 75 if (__pcb != NULL && __pcb->rtld_runtime != NULL) { 72 76 runtime_env = (rtld_t *) __pcb->rtld_runtime; 77 } else { 78 if (rtld_init_static() != EOK) 79 abort(); 73 80 } 74 81 #endif 75 /* Initialize user task run-time environment */76 __malloc_init();77 82 78 83 fibril_t *fibril = fibril_setup(); -
uspace/lib/c/generic/rtld/module.c
r2112a79 r153c7a29 49 49 #include <rtld/rtld_arch.h> 50 50 #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 */ 58 int 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 } 51 84 52 85 /** (Eagerly) process all relocation tables in a module. … … 191 224 m->tls_align = info.tls.tls_align; 192 225 193 printf("tdata at %p size %zu, tbss size %zu\n",226 DPRINTF("tdata at %p size %zu, tbss size %zu\n", 194 227 m->tdata, m->tdata_size, m->tbss_size); 195 228 -
uspace/lib/c/generic/rtld/rtld.c
r2112a79 r153c7a29 45 45 46 46 /** Initialize the runtime linker for use in a statically-linked executable. */ 47 void rtld_init_static(void) 48 { 47 int rtld_init_static(void) 48 { 49 int rc; 50 49 51 runtime_env = &rt_env_static; 50 52 list_initialize(&runtime_env->modules); … … 52 54 runtime_env->next_bias = 0x2000000; 53 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; 54 65 } 55 66 … … 98 109 prog->tls_align = p_info->tls.tls_align; 99 110 100 printf("prog tdata at %p size %zu, tbss size %zu\n",111 DPRINTF("prog tdata at %p size %zu, tbss size %zu\n", 101 112 prog->tdata, prog->tdata_size, prog->tbss_size); 102 113 -
uspace/lib/c/include/rtld/module.h
r2112a79 r153c7a29 42 42 #include <types/rtld/rtld.h> 43 43 44 extern int module_create_static_exec(rtld_t *, module_t **); 44 45 extern void module_process_relocs(module_t *); 45 46 extern module_t *module_find(rtld_t *, const char *); -
uspace/lib/c/include/rtld/rtld.h
r2112a79 r153c7a29 46 46 extern rtld_t *runtime_env; 47 47 48 extern voidrtld_init_static(void);48 extern int rtld_init_static(void); 49 49 extern int rtld_prog_process(elf_finfo_t *, rtld_t **); 50 50 extern tcb_t *rtld_tls_make(rtld_t *); -
uspace/srv/loader/main.c
r2112a79 r153c7a29 269 269 270 270 pcb.filc = filc; 271 printf("dynamic=%p rtld_env=%p\n", pcb.dynamic, pcb.rtld_runtime);272 271 273 272 async_answer_0(rid, rc);
Note:
See TracChangeset
for help on using the changeset viewer.