Changeset eb522e8 in mainline for uspace/srv/loader/elf_load.c
- Timestamp:
- 2011-06-01T08:43:42Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8d6c1f1
- Parents:
- 9e2e715 (diff), e51a514 (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/srv/loader/elf_load.c
r9e2e715 reb522e8 2 2 * Copyright (c) 2006 Sergey Bondari 3 3 * Copyright (c) 2006 Jakub Jermar 4 * Copyright (c) 20 08Jiri Svoboda4 * Copyright (c) 2011 Jiri Svoboda 5 5 * All rights reserved. 6 6 * … … 53 53 #include <smc.h> 54 54 #include <loader/pcb.h> 55 #include <entry_point.h> 55 56 56 57 #include "elf.h" 57 58 #include "elf_load.h" 58 #include "arch.h"59 59 60 60 #define DPRINTF(...) … … 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; … … 109 110 int fd; 110 111 int rc; 111 112 112 113 fd = open(file_name, O_RDONLY); 113 114 if (fd < 0) { … … 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 program_run(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 … … 300 288 case PT_NULL: 301 289 case PT_PHDR: 290 case PT_NOTE: 302 291 break; 303 292 case PT_LOAD: … … 305 294 break; 306 295 case PT_INTERP: 307 /* Assume silently interp == "/ rtld.so" */308 elf->info->interp = "/ rtld.so";296 /* Assume silently interp == "/app/dload" */ 297 elf->info->interp = "/app/dload"; 309 298 break; 310 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; 311 309 case PT_SHLIB: 312 case PT_NOTE: 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); … … 344 341 seg_ptr = (void *) seg_addr; 345 342 346 DPRINTF("Load segment at addr %p, size 0x%x\n", seg_addr,343 DPRINTF("Load segment at addr %p, size 0x%x\n", (void *) seg_addr, 347 344 entry->p_memsz); 348 345 … … 372 369 mem_sz = entry->p_memsz + (entry->p_vaddr - base); 373 370 374 DPRINTF("Map to seg_addr=%p-%p.\n", seg_addr, 375 entry->p_vaddr + bias + ALIGN_UP(entry->p_memsz, PAGE_SIZE)); 371 DPRINTF("Map to seg_addr=%p-%p.\n", (void *) seg_addr, 372 (void *) (entry->p_vaddr + bias + 373 ALIGN_UP(entry->p_memsz, PAGE_SIZE))); 376 374 377 375 /* … … 382 380 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE); 383 381 if (a == (void *)(-1)) { 384 DPRINTF("Memory mapping failed.\n"); 382 DPRINTF("memory mapping failed (0x%x, %d)\n", 383 base+bias, mem_sz); 385 384 return EE_MEMORY; 386 385 } 387 386 388 DPRINTF("as_area_create(%p, 0x%x, %d) -> 0x%lx\n",389 base + bias, mem_sz, flags, (uintptr_t)a);387 DPRINTF("as_area_create(%p, %#zx, %d) -> %p\n", 388 (void *) (base + bias), mem_sz, flags, (void *) a); 390 389 391 390 /* … … 424 423 } 425 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); 426 432 rc = as_area_change_flags(seg_ptr, flags); 427 433 if (rc != 0) { … … 464 470 (void *)((uint8_t *)entry->sh_addr + elf->bias); 465 471 DPRINTF("Dynamic section found at %p.\n", 466 (uintptr_t)elf->info->dynamic);472 (void *) elf->info->dynamic); 467 473 break; 468 474 default:
Note:
See TracChangeset
for help on using the changeset viewer.