Changeset f570cdf in mainline for uspace/lib/c/generic/rtld/module.c
- Timestamp:
- 2016-05-24T15:32:57Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c170438
- Parents:
- dcc150cb (diff), 0a981e3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/rtld/module.c
rdcc150cb rf570cdf 37 37 #include <adt/list.h> 38 38 #include <elf/elf_load.h> 39 #include <errno.h> 39 40 #include <fcntl.h> 40 41 #include <loader/pcb.h> … … 48 49 #include <rtld/rtld_arch.h> 49 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 } 50 84 51 85 /** (Eagerly) process all relocation tables in a module. … … 135 169 136 170 m = calloc(1, sizeof(module_t)); 137 if ( !m) {171 if (m == NULL) { 138 172 printf("malloc failed\n"); 139 173 exit(1); … … 141 175 142 176 m->rtld = rtld; 177 m->id = rtld_get_next_id(rtld); 178 143 179 if ((flags & mlf_local) != 0) 144 180 m->local = true; … … 181 217 /* Insert into the list of loaded modules */ 182 218 list_append(&m->modules_link, &rtld->modules); 219 220 /* Copy TLS info */ 221 m->tdata = info.tls.tdata; 222 m->tdata_size = info.tls.tdata_size; 223 m->tbss_size = info.tls.tbss_size; 224 m->tls_align = info.tls.tls_align; 225 226 DPRINTF("tdata at %p size %zu, tbss size %zu\n", 227 m->tdata, m->tdata_size, m->tbss_size); 183 228 184 229 return m; … … 243 288 } 244 289 290 /** Find module structure by ID. */ 291 module_t *module_by_id(rtld_t *rtld, unsigned long id) 292 { 293 list_foreach(rtld->modules, modules_link, module_t, m) { 294 if (m->id == id) 295 return m; 296 } 297 298 return NULL; 299 } 300 245 301 /** Process relocations in modules. 246 302 * … … 260 316 } 261 317 318 void modules_process_tls(rtld_t *rtld) 319 { 320 #ifdef CONFIG_TLS_VARIANT_1 321 list_foreach(rtld->modules, modules_link, module_t, m) { 322 m->ioffs = rtld->tls_size; 323 list_append(&m->imodules_link, &rtmd->imodules); 324 rtld->tls_size += m->tdata_size + m->tbss_size; 325 } 326 #else /* CONFIG_TLS_VARIANT_2 */ 327 size_t offs; 328 329 list_foreach(rtld->modules, modules_link, module_t, m) { 330 rtld->tls_size += m->tdata_size + m->tbss_size; 331 } 332 333 offs = 0; 334 list_foreach(rtld->modules, modules_link, module_t, m) { 335 offs += m->tdata_size + m->tbss_size; 336 m->ioffs = rtld->tls_size - offs; 337 list_append(&m->imodules_link, &rtld->imodules); 338 } 339 #endif 340 } 341 262 342 /** Clear BFS tags of all modules. 263 343 */
Note:
See TracChangeset
for help on using the changeset viewer.