Changeset e175d69 in mainline for uspace/srv
- Timestamp:
- 2011-05-01T13:08:18Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 042fbe0
- Parents:
- a41577e (diff), e515a827 (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. - Location:
- uspace/srv
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/rd/Makefile
ra41577e re175d69 30 30 USPACE_PREFIX = ../../.. 31 31 BINARY = rd 32 STATIC_NEEDED = y 32 33 33 34 SOURCES = \ -
uspace/srv/devman/Makefile
ra41577e re175d69 30 30 USPACE_PREFIX = ../.. 31 31 BINARY = devman 32 STATIC_NEEDED = y 32 33 33 34 SOURCES = \ -
uspace/srv/devmap/Makefile
ra41577e re175d69 30 30 USPACE_PREFIX = ../.. 31 31 BINARY = devmap 32 STATIC_NEEDED = y 32 33 33 34 SOURCES = \ -
uspace/srv/fs/devfs/Makefile
ra41577e re175d69 32 32 EXTRA_CFLAGS += -I$(LIBFS_PREFIX) 33 33 BINARY = devfs 34 STATIC_NEEDED = y 34 35 35 36 SOURCES = \ -
uspace/srv/fs/fat/Makefile
ra41577e re175d69 32 32 EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) 33 33 BINARY = fat 34 STATIC_NEEDED = y 34 35 35 36 SOURCES = \ -
uspace/srv/fs/tmpfs/Makefile
ra41577e re175d69 32 32 EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) 33 33 BINARY = tmpfs 34 STATIC_NEEDED = y 34 35 35 36 SOURCES = \ -
uspace/srv/loader/Makefile
ra41577e re175d69 42 42 43 43 BINARY = loader 44 STATIC_ONLY = y 44 45 45 46 GENERIC_SOURCES = \ -
uspace/srv/loader/elf_load.c
ra41577e re175d69 103 103 * 104 104 */ 105 int elf_load_file(const char *file_name, size_t so_bias, elf_info_t *info) 105 int elf_load_file(const char *file_name, size_t so_bias, eld_flags_t flags, 106 elf_info_t *info) 106 107 { 107 108 elf_ld_t elf; … … 118 119 elf.fd = fd; 119 120 elf.info = info; 121 elf.flags = flags; 120 122 121 123 rc = elf_load(&elf, so_bias); … … 124 126 125 127 return rc; 126 }127 128 /** Run an ELF executable.129 *130 * Transfers control to the entry point of an ELF executable loaded131 * earlier with elf_load_file(). This function does not return.132 *133 * @param info Info structure filled earlier by elf_load_file()134 *135 */136 void elf_run(elf_info_t *info, pcb_t *pcb)137 {138 entry_point_jmp(info->entry, pcb);139 140 /* not reached */141 128 } 142 129 … … 153 140 pcb->entry = info->entry; 154 141 pcb->dynamic = info->dynamic; 142 pcb->rtld_runtime = NULL; 155 143 } 156 144 … … 306 294 break; 307 295 case PT_INTERP: 308 /* Assume silently interp == "/ rtld.so" */309 elf->info->interp = "/ rtld.so";296 /* Assume silently interp == "/app/dload" */ 297 elf->info->interp = "/app/dload"; 310 298 break; 311 299 case PT_DYNAMIC: 300 /* Record pointer to dynamic section into info structure */ 301 elf->info->dynamic = 302 (void *)((uint8_t *)entry->p_vaddr + elf->bias); 303 DPRINTF("dynamic section found at 0x%x\n", 304 (uintptr_t)elf->info->dynamic); 305 break; 306 case 0x70000000: 307 /* FIXME: MIPS reginfo */ 308 break; 312 309 case PT_SHLIB: 313 case PT_LOPROC:314 case PT_HIPROC:310 // case PT_LOPROC: 311 // case PT_HIPROC: 315 312 default: 316 313 DPRINTF("Segment p_type %d unknown.\n", entry->p_type); … … 383 380 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE); 384 381 if (a == (void *)(-1)) { 385 DPRINTF("Memory mapping failed.\n"); 382 DPRINTF("memory mapping failed (0x%x, %d)\n", 383 base+bias, mem_sz); 386 384 return EE_MEMORY; 387 385 } … … 425 423 } 426 424 425 /* 426 * The caller wants to modify the segments first. He will then 427 * need to set the right access mode and ensure SMC coherence. 428 */ 429 if ((elf->flags & ELDF_RW) != 0) return EE_OK; 430 431 // printf("set area flags to %d\n", flags); 427 432 rc = as_area_change_flags(seg_ptr, flags); 428 433 if (rc != 0) { -
uspace/srv/loader/include/elf_load.h
ra41577e re175d69 43 43 #include "elf.h" 44 44 45 typedef enum { 46 /** Leave all segments in RW access mode. */ 47 ELDF_RW = 1 48 } eld_flags_t; 49 45 50 /** 46 51 * Some data extracted from the headers are stored here … … 67 72 uintptr_t bias; 68 73 74 /** Flags passed to the ELF loader. */ 75 eld_flags_t flags; 76 69 77 /** A copy of the ELF file header */ 70 78 elf_header_t *header; … … 74 82 } elf_ld_t; 75 83 76 int elf_load_file(const char *file_name, size_t so_bias, el f_info_t *info);77 void elf_run(elf_info_t *info, pcb_t *pcb);84 int elf_load_file(const char *file_name, size_t so_bias, eld_flags_t flags, 85 elf_info_t *info); 78 86 void elf_create_pcb(elf_info_t *info, pcb_t *pcb); 79 87 -
uspace/srv/loader/main.c
ra41577e re175d69 55 55 #include <macros.h> 56 56 #include <loader/pcb.h> 57 #include <entry_point.h> 57 58 #include <errno.h> 58 59 #include <async.h> … … 62 63 #include <elf.h> 63 64 #include <elf_load.h> 65 66 #ifdef CONFIG_RTLD 67 #include <rtld/rtld.h> 68 #include <rtld/dynamic.h> 69 #include <rtld/module.h> 70 71 static int ldr_load_dyn_linked(elf_info_t *p_info); 72 #endif 64 73 65 74 #define DPRINTF(...) … … 89 98 90 99 static elf_info_t prog_info; 91 static elf_info_t interp_info;92 93 static bool is_dyn_linked;94 100 95 101 /** Used to limit number of connections to one. */ 96 102 static bool connected = false; 103 104 #ifdef CONFIG_RTLD 105 /** State structure of the dynamic linker. */ 106 runtime_env_t dload_re; 107 static module_t prog_mod; 108 #endif 97 109 98 110 static void ldr_get_taskid(ipc_callid_t rid, ipc_call_t *request) … … 283 295 int rc; 284 296 285 rc = elf_load_file(pathname, 0, &prog_info);297 rc = elf_load_file(pathname, 0, 0, &prog_info); 286 298 if (rc != EE_OK) { 287 299 DPRINTF("Failed to load executable '%s'.\n", pathname); … … 302 314 if (prog_info.interp == NULL) { 303 315 /* Statically linked program */ 304 is_dyn_linked = false;305 316 async_answer_0(rid, EOK); 306 317 return 0; 307 318 } 308 319 309 rc = elf_load_file(prog_info.interp, 0, &interp_info); 310 if (rc != EE_OK) { 311 DPRINTF("Failed to load interpreter '%s.'\n", 312 prog_info.interp); 313 async_answer_0(rid, EINVAL); 314 return 1; 315 } 316 317 is_dyn_linked = true; 318 async_answer_0(rid, EOK); 319 320 DPRINTF("Binary is dynamically linked.\n"); 321 #ifdef CONFIG_RTLD 322 DPRINTF(" - pcb address: %p\n", &pcb); 323 DPRINTF( "- prog dynamic: %p\n", prog_info.dynamic); 324 325 rc = ldr_load_dyn_linked(&prog_info); 326 #else 327 rc = ENOTSUP; 328 #endif 329 async_answer_0(rid, rc); 320 330 return 0; 321 331 } 322 332 333 #ifdef CONFIG_RTLD 334 335 static int ldr_load_dyn_linked(elf_info_t *p_info) 336 { 337 runtime_env = &dload_re; 338 339 DPRINTF("Load dynamically linked program.\n"); 340 341 /* 342 * First we need to process dynamic sections of the executable 343 * program and insert it into the module graph. 344 */ 345 346 DPRINTF("Parse program .dynamic section at %p\n", p_info->dynamic); 347 dynamic_parse(p_info->dynamic, 0, &prog_mod.dyn); 348 prog_mod.bias = 0; 349 prog_mod.dyn.soname = "[program]"; 350 351 /* Initialize list of loaded modules */ 352 list_initialize(&runtime_env->modules_head); 353 list_append(&prog_mod.modules_link, &runtime_env->modules_head); 354 355 /* Pointer to program module. Used as root of the module graph. */ 356 runtime_env->program = &prog_mod; 357 358 /* Work around non-existent memory space allocation. */ 359 runtime_env->next_bias = 0x1000000; 360 361 /* 362 * Now we can continue with loading all other modules. 363 */ 364 365 DPRINTF("Load all program dependencies\n"); 366 module_load_deps(&prog_mod); 367 368 /* 369 * Now relocate/link all modules together. 370 */ 371 372 /* Process relocations in all modules */ 373 DPRINTF("Relocate all modules\n"); 374 modules_process_relocs(&prog_mod); 375 376 /* Pass runtime evironment pointer through PCB. */ 377 pcb.rtld_runtime = (void *) runtime_env; 378 379 return 0; 380 } 381 #endif 323 382 324 383 /** Run the previously loaded program. … … 332 391 const char *cp; 333 392 393 DPRINTF("Set task name\n"); 394 334 395 /* Set the task name. */ 335 396 cp = str_rchr(pathname, '/'); … … 337 398 task_set_name(cp); 338 399 339 if (is_dyn_linked == true) { 340 /* Dynamically linked program */ 341 DPRINTF("Run ELF interpreter.\n"); 342 DPRINTF("Entry point: %p\n", interp_info.entry); 343 344 async_answer_0(rid, EOK); 345 elf_run(&interp_info, &pcb); 346 } else { 347 /* Statically linked program */ 348 async_answer_0(rid, EOK); 349 elf_run(&prog_info, &pcb); 350 } 400 /* Run program */ 401 DPRINTF("Reply OK\n"); 402 async_answer_0(rid, EOK); 403 DPRINTF("Jump to entry point at %p\n", pcb.entry); 404 entry_point_jmp(prog_info.entry, &pcb); 351 405 352 406 /* Not reached */ -
uspace/srv/net/tl/icmp/Makefile
ra41577e re175d69 32 32 EXTRA_CFLAGS = -I$(LIBNET_PREFIX)/include 33 33 BINARY = icmp 34 STATIC_ONLY = y 34 35 35 36 SOURCES = \ -
uspace/srv/ns/Makefile
ra41577e re175d69 30 30 USPACE_PREFIX = ../.. 31 31 BINARY = ns 32 STATIC_NEEDED = y 32 33 33 34 SOURCES = \ -
uspace/srv/vfs/Makefile
ra41577e re175d69 30 30 USPACE_PREFIX = ../.. 31 31 BINARY = vfs 32 STATIC_NEEDED = y 32 33 33 34 SOURCES = \
Note:
See TracChangeset
for help on using the changeset viewer.