Changeset 31ea2a7 in mainline
- Timestamp:
- 2025-01-26T17:53:49Z (3 weeks ago)
- 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)
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/elf/elf_load.c
reff458d r31ea2a7 57 57 errno_t elf_load(int file, elf_info_t *info) 58 58 { 59 #ifdef CONFIG_RTLD 60 rtld_t *env; 61 #endif 62 errno_t rc; 59 errno_t rc = EOK; 63 60 64 61 rc = elf_load_file(file, 0, &info->finfo); … … 68 65 } 69 66 70 if (info->finfo.dynamic == NULL) {71 /* Statically linked program */72 DPRINTF("Binary is statically linked.\n");73 info->env = NULL;74 return EOK;75 }76 77 DPRINTF("Binary is dynamically linked.\n");78 67 #ifdef CONFIG_RTLD 79 DPRINTF("- prog dynamic: %p\n", info->finfo.dynamic); 80 68 rtld_t *env; 81 69 rc = rtld_prog_process(&info->finfo, &env); 82 70 info->env = env; -
uspace/lib/c/generic/libc.c
reff458d r31ea2a7 96 96 97 97 #ifdef CONFIG_RTLD 98 if (__pcb != NULL && __pcb->rtld_runtime != NULL) { 98 if (__pcb == NULL) { 99 /* 100 * A binary loaded by kernel, not the loader. 101 * Init some rudimentary rtld runtime environment. 102 */ 103 errno_t rtld_init_result = rtld_init_static(); 104 assert(rtld_init_result == EOK); 105 } else { 106 assert(__pcb->rtld_runtime != NULL); 99 107 runtime_env = (rtld_t *) __pcb->rtld_runtime; 100 } else {101 if (rtld_init_static() != EOK)102 abort();103 108 } 104 109 #endif -
uspace/lib/c/generic/rtld/rtld.c
reff458d r31ea2a7 45 45 static rtld_t rt_env_static; 46 46 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. */ 48 48 errno_t rtld_init_static(void) 49 49 { … … 65 65 } 66 66 67 /** Initialize and process a dynamically linked executable.67 /** Initialize and process an executable, static or dynamic. 68 68 * 69 69 * @param p_info Program info … … 75 75 module_t *prog; 76 76 77 DPRINTF("Load dynamically linked program.\n");77 DPRINTF("Load program with rtld.\n"); 78 78 79 79 /* Allocate new RTLD environment to pass to the loaded program */ … … 95 95 */ 96 96 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 } 99 103 prog->bias = 0; 100 104 prog->dyn.soname = "[program]"; … … 124 128 */ 125 129 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 } 130 138 } 131 139 -
uspace/lib/c/generic/thread/tls.c
reff458d r31ea2a7 74 74 } 75 75 76 /** Get address of static TLS block */76 /** Get address of static TLS block - only when RTLD is not initialized */ 77 77 void *tls_get(void) 78 78 { -
uspace/srv/loader/main.c
reff458d r31ea2a7 300 300 301 301 #ifdef CONFIG_RTLD 302 if (prog_info.env) { 303 pcb.tcb = rtld_tls_make(prog_info.env); 304 } else { 305 pcb.tcb = tls_make(prog_info.finfo.base); 306 } 302 assert(prog_info.env != NULL); 303 pcb.tcb = rtld_tls_make(prog_info.env); 307 304 #else 308 305 pcb.tcb = tls_make(prog_info.finfo.base);
Note:
See TracChangeset
for help on using the changeset viewer.