Changeset 8b655705 in mainline for uspace/srv/loader
- Timestamp:
- 2011-04-15T19:38:07Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9dd730d1
- Parents:
- 6b9e85b (diff), b2fb47f (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/loader
- Files:
-
- 10 edited
-
arch/abs32le/_link.ld.in (modified) (3 diffs)
-
arch/amd64/_link.ld.in (modified) (7 diffs)
-
arch/arm32/_link.ld.in (modified) (5 diffs)
-
arch/ia32/_link.ld.in (modified) (4 diffs)
-
arch/ia64/_link.ld.in (modified) (5 diffs)
-
arch/mips32/_link.ld.in (modified) (5 diffs)
-
arch/ppc32/_link.ld.in (modified) (6 diffs)
-
arch/sparc64/_link.ld.in (modified) (4 diffs)
-
elf_load.c (modified) (7 diffs)
-
main.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/loader/arch/abs32le/_link.ld.in
r6b9e85b r8b655705 3 3 * is the base address and the special interp section. 4 4 */ 5 5 6 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o) 6 7 ENTRY(__entry) … … 20 21 21 22 .text : { 22 *(.text );23 *(.rodata *);23 *(.text .text.*); 24 *(.rodata .rodata.*); 24 25 } :text 25 26 … … 54 55 } :data 55 56 56 . = ALIGN(0x1000);57 58 _heap = .;59 60 57 /DISCARD/ : { 61 58 *(*); -
uspace/srv/loader/arch/amd64/_link.ld.in
r6b9e85b r8b655705 1 /* 2 * The difference from _link.ld.in for regular statically-linked apps 3 * is the base address and the special interp section. 4 */ 5 1 6 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o) 2 7 ENTRY(__entry) … … 6 11 text PT_LOAD FLAGS(5); 7 12 data PT_LOAD FLAGS(6); 13 debug PT_NOTE; 8 14 } 9 15 … … 11 17 .interp : { 12 18 *(.interp); 13 } : interp14 15 /* . = 0x0000700000001000; */19 } :interp 20 21 /* . = 0x0000700000001000; */ 16 22 . = 0x70001000; 17 23 … … 19 25 *(.init); 20 26 } :text 27 21 28 .text : { 22 *(.text );23 *(.rodata *);29 *(.text .text.*); 30 *(.rodata .rodata.*); 24 31 } :text 25 32 … … 27 34 *(.data); 28 35 } :data 36 29 37 .tdata : { 30 38 _tdata_start = .; … … 32 40 _tdata_end = .; 33 41 } :data 42 34 43 .tbss : { 35 44 _tbss_start = .; … … 37 46 _tbss_end = .; 38 47 } :data 48 39 49 _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)); 50 40 51 .bss : { 41 52 *(COMMON); 42 53 *(.bss); 43 54 } :data 44 45 . = ALIGN(0x1000); 46 _heap = .; 55 56 #ifdef CONFIG_LINE_DEBUG 57 .comment 0 : { *(.comment); } :debug 58 .debug_abbrev 0 : { *(.debug_abbrev); } :debug 59 .debug_aranges 0 : { *(.debug_aranges); } :debug 60 .debug_info 0 : { *(.debug_info); } :debug 61 .debug_line 0 : { *(.debug_line); } :debug 62 .debug_loc 0 : { *(.debug_loc); } :debug 63 .debug_pubnames 0 : { *(.debug_pubnames); } :debug 64 .debug_pubtypes 0 : { *(.debug_pubtypes); } :debug 65 .debug_ranges 0 : { *(.debug_ranges); } :debug 66 .debug_str 0 : { *(.debug_str); } :debug 67 #endif 47 68 48 69 /DISCARD/ : { 49 70 *(*); 50 71 } 51 52 72 } -
uspace/srv/loader/arch/arm32/_link.ld.in
r6b9e85b r8b655705 3 3 * is the base address. 4 4 */ 5 5 6 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o) 6 7 ENTRY(__entry) … … 16 17 *(.interp); 17 18 } : interp 18 19 19 20 . = 0x70001000; 20 21 21 22 .init ALIGN(0x1000): SUBALIGN(0x1000) { 22 23 *(.init); 23 } : text 24 } :text 25 24 26 .text : { 25 *(.text );26 *(.rodata*);27 *(.text .text.*); 28 *(.rodata .rodata.*); 27 29 } :text 28 30 … … 32 34 *(.sdata); 33 35 } :data 36 34 37 .tdata : { 35 38 _tdata_start = .; … … 37 40 _tdata_end = .; 38 41 } :data 42 39 43 .tbss : { 40 44 _tbss_start = .; … … 42 46 _tbss_end = .; 43 47 } :data 48 44 49 _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)); 50 45 51 .bss : { 46 52 *(.sbss); 47 53 *(.scommon); 48 *(COMMON);49 *(.bss);54 *(COMMON); 55 *(.bss); 50 56 } :data 51 52 . = ALIGN(0x1000);53 _heap = .;54 57 55 58 /DISCARD/ : { 56 59 *(*); 57 60 } 58 59 61 } -
uspace/srv/loader/arch/ia32/_link.ld.in
r6b9e85b r8b655705 3 3 * is the base address and the special interp section. 4 4 */ 5 5 6 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o) 6 7 ENTRY(__entry) … … 10 11 text PT_LOAD FILEHDR PHDRS FLAGS(5); 11 12 data PT_LOAD FLAGS(6); 13 debug PT_NOTE; 12 14 } 13 15 … … 24 26 25 27 .text : { 26 *(.text );27 *(.rodata *);28 *(.text .text.*); 29 *(.rodata .rodata.*); 28 30 } :text 29 31 … … 52 54 } :data 53 55 54 . = ALIGN(0x1000); 55 56 _heap = .; 56 #ifdef CONFIG_LINE_DEBUG 57 .comment 0 : { *(.comment); } :debug 58 .debug_abbrev 0 : { *(.debug_abbrev); } :debug 59 .debug_aranges 0 : { *(.debug_aranges); } :debug 60 .debug_info 0 : { *(.debug_info); } :debug 61 .debug_line 0 : { *(.debug_line); } :debug 62 .debug_loc 0 : { *(.debug_loc); } :debug 63 .debug_pubnames 0 : { *(.debug_pubnames); } :debug 64 .debug_pubtypes 0 : { *(.debug_pubtypes); } :debug 65 .debug_ranges 0 : { *(.debug_ranges); } :debug 66 .debug_str 0 : { *(.debug_str); } :debug 67 #endif 57 68 58 69 /DISCARD/ : { -
uspace/srv/loader/arch/ia64/_link.ld.in
r6b9e85b r8b655705 12 12 *(.interp); 13 13 } :interp 14 14 15 15 /* On Itanium code sections must be aligned to 16 bytes. */ 16 16 . = ALIGN(0x800000000 + SIZEOF_HEADERS, 16); 17 17 18 18 .init : { 19 19 *(.init); 20 } : text 20 } :text 21 21 22 .text : { 22 *(.text );23 *(.rodata *);23 *(.text .text.*); 24 *(.rodata .rodata.*); 24 25 } :text 25 26 26 27 . = . + 0x4000; 27 28 28 29 .got : { 29 _gp = .; 30 *(.got*); 31 } :data 30 /* Tell the linker where we expect GP to point. */ 31 __gp = .; 32 *(.got .got.*); 33 } :data 34 32 35 .data : { 33 36 *(.opd); … … 35 38 *(.sdata); 36 39 } :data 40 37 41 .tdata : { 38 42 _tdata_start = .; … … 40 44 _tdata_end = .; 41 45 } :data 46 42 47 .tbss : { 43 48 _tbss_start = .; … … 45 50 _tbss_end = .; 46 51 } :data 52 47 53 _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)); 54 48 55 .bss : { 49 56 *(.sbss); … … 52 59 *(.bss); 53 60 } :data 54 55 . = ALIGN(0x4000); 56 _heap = .; 57 61 58 62 /DISCARD/ : { 59 63 *(*); 60 }64 } 61 65 } -
uspace/srv/loader/arch/mips32/_link.ld.in
r6b9e85b r8b655705 3 3 * is the base address. 4 4 */ 5 5 6 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o) 6 7 ENTRY(__entry) … … 16 17 *(.interp); 17 18 } :interp 18 19 19 20 . = 0x70004000; 20 21 … … 22 23 *(.init); 23 24 } :text 25 24 26 .text : { 25 *(.text);26 *(.rodata *);27 *(.text .text.*); 28 *(.rodata .rodata.*); 27 29 } :text 28 30 31 . = . + 0x4000; 32 29 33 .data : { 30 34 *(.data); 31 35 *(.data.rel*); 32 36 } :data 33 37 34 38 .got : { 35 39 _gp = .; 36 40 *(.got); 37 41 } :data 38 42 39 43 .tdata : { 40 44 _tdata_start = .; … … 42 46 _tdata_end = .; 43 47 } :data 48 44 49 .tbss : { 45 50 _tbss_start = .; … … 47 52 _tbss_end = .; 48 53 } :data 54 49 55 _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)); 50 56 51 57 .sbss : { 52 58 *(.scommon); 53 59 *(.sbss); 54 } 60 } 61 55 62 .bss : { 56 63 *(.bss); 57 64 *(COMMON); 58 65 } :data 59 60 . = ALIGN(0x4000); 61 _heap = .; 62 66 63 67 /DISCARD/ : { 64 68 *(*); -
uspace/srv/loader/arch/ppc32/_link.ld.in
r6b9e85b r8b655705 3 3 * is the base address. 4 4 */ 5 5 6 STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o) 6 7 ENTRY(__entry) … … 16 17 *(.interp); 17 18 } :interp 18 19 19 20 . = 0x70001000; 20 21 21 22 .init ALIGN(0x1000) : SUBALIGN(0x1000) { 22 23 *(.init); 23 24 } :text 25 24 26 .text : { 25 *(.text );26 *(.rodata *);27 *(.text .text.*); 28 *(.rodata .rodata.*); 27 29 } :text 28 30 … … 31 33 *(.sdata); 32 34 } :data 35 33 36 .tdata : { 34 37 _tdata_start = .; … … 36 39 _tdata_end = .; 37 40 } :data 41 38 42 .tbss : { 39 43 _tbss_start = .; … … 41 45 _tbss_end = .; 42 46 } :data 47 43 48 _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)); 49 44 50 .bss : { 45 51 *(.sbss); … … 47 53 *(.bss); 48 54 } :data 49 50 . = ALIGN(0x1000);51 _heap = .;52 55 53 56 /DISCARD/ : { 54 57 *(*); 55 58 } 56 57 59 } -
uspace/srv/loader/arch/sparc64/_link.ld.in
r6b9e85b r8b655705 12 12 *(.interp); 13 13 } :interp 14 14 15 15 . = 0x70004000 + SIZEOF_HEADERS; 16 16 17 17 .init : { 18 18 *(.init); 19 19 } :text 20 20 21 .text : { 21 *(.text );22 *(.rodata *);22 *(.text .text.*); 23 *(.rodata .rodata.*); 23 24 } :text 24 25 25 26 . = . + 0x4000; 26 27 27 28 .got : { 28 29 _gp = .; 29 30 *(.got*); 30 31 } :data 32 31 33 .data : { 32 34 *(.data); 33 35 *(.sdata); 34 36 } :data 37 35 38 .tdata : { 36 39 _tdata_start = .; … … 38 41 _tdata_end = .; 39 42 } :data 43 40 44 .tbss : { 41 45 _tbss_start = .; … … 43 47 _tbss_end = .; 44 48 } :data 49 45 50 _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss)); 51 46 52 .bss : { 47 53 *(.sbss); … … 49 55 *(.bss); 50 56 } :data 51 52 . = ALIGN(0x4000);53 _heap = .;54 57 55 58 /DISCARD/ : { 56 59 *(*); 57 60 } 58 59 61 } -
uspace/srv/loader/elf_load.c
r6b9e85b r8b655705 109 109 int fd; 110 110 int rc; 111 111 112 112 fd = open(file_name, O_RDONLY); 113 113 if (fd < 0) { … … 300 300 case PT_NULL: 301 301 case PT_PHDR: 302 case PT_NOTE: 302 303 break; 303 304 case PT_LOAD: … … 310 311 case PT_DYNAMIC: 311 312 case PT_SHLIB: 312 case PT_NOTE:313 313 case PT_LOPROC: 314 314 case PT_HIPROC: … … 344 344 seg_ptr = (void *) seg_addr; 345 345 346 DPRINTF("Load segment at addr %p, size 0x%x\n", seg_addr,346 DPRINTF("Load segment at addr %p, size 0x%x\n", (void *) seg_addr, 347 347 entry->p_memsz); 348 348 … … 372 372 mem_sz = entry->p_memsz + (entry->p_vaddr - base); 373 373 374 DPRINTF("Map to seg_addr=%p-%p.\n", seg_addr, 375 entry->p_vaddr + bias + ALIGN_UP(entry->p_memsz, PAGE_SIZE)); 374 DPRINTF("Map to seg_addr=%p-%p.\n", (void *) seg_addr, 375 (void *) (entry->p_vaddr + bias + 376 ALIGN_UP(entry->p_memsz, PAGE_SIZE))); 376 377 377 378 /* … … 386 387 } 387 388 388 DPRINTF("as_area_create(%p, 0x%x, %d) -> 0x%lx\n",389 base + bias, mem_sz, flags, (uintptr_t)a);389 DPRINTF("as_area_create(%p, %#zx, %d) -> %p\n", 390 (void *) (base + bias), mem_sz, flags, (void *) a); 390 391 391 392 /* … … 464 465 (void *)((uint8_t *)entry->sh_addr + elf->bias); 465 466 DPRINTF("Dynamic section found at %p.\n", 466 (uintptr_t)elf->info->dynamic);467 (void *) elf->info->dynamic); 467 468 break; 468 469 default: -
uspace/srv/loader/main.c
r6b9e85b r8b655705 50 50 #include <fcntl.h> 51 51 #include <sys/types.h> 52 #include <ipc/ipc.h>53 52 #include <ipc/services.h> 54 53 #include <ipc/loader.h> … … 95 94 96 95 /** Used to limit number of connections to one. */ 97 static bool connected ;96 static bool connected = false; 98 97 99 98 static void ldr_get_taskid(ipc_callid_t rid, ipc_call_t *request) … … 106 105 107 106 if (!async_data_read_receive(&callid, &len)) { 108 ipc_answer_0(callid, EINVAL);109 ipc_answer_0(rid, EINVAL);107 async_answer_0(callid, EINVAL); 108 async_answer_0(rid, EINVAL); 110 109 return; 111 110 } … … 115 114 116 115 async_data_read_finalize(callid, &task_id, len); 117 ipc_answer_0(rid, EOK);116 async_answer_0(rid, EOK); 118 117 } 119 118 … … 135 134 } 136 135 137 ipc_answer_0(rid, rc);136 async_answer_0(rid, rc); 138 137 } 139 138 … … 155 154 } 156 155 157 ipc_answer_0(rid, rc);156 async_answer_0(rid, rc); 158 157 } 159 158 … … 188 187 if (_argv == NULL) { 189 188 free(buf); 190 ipc_answer_0(rid, ENOMEM);189 async_answer_0(rid, ENOMEM); 191 190 return; 192 191 } … … 220 219 } 221 220 222 ipc_answer_0(rid, rc);221 async_answer_0(rid, rc); 223 222 } 224 223 … … 244 243 if (_filv == NULL) { 245 244 free(buf); 246 ipc_answer_0(rid, ENOMEM);245 async_answer_0(rid, ENOMEM); 247 246 return; 248 247 } … … 271 270 } 272 271 273 ipc_answer_0(rid, EOK);272 async_answer_0(rid, EOK); 274 273 } 275 274 … … 287 286 if (rc != EE_OK) { 288 287 DPRINTF("Failed to load executable '%s'.\n", pathname); 289 ipc_answer_0(rid, EINVAL);288 async_answer_0(rid, EINVAL); 290 289 return 1; 291 290 } … … 304 303 /* Statically linked program */ 305 304 is_dyn_linked = false; 306 ipc_answer_0(rid, EOK);305 async_answer_0(rid, EOK); 307 306 return 0; 308 307 } … … 312 311 DPRINTF("Failed to load interpreter '%s.'\n", 313 312 prog_info.interp); 314 ipc_answer_0(rid, EINVAL);313 async_answer_0(rid, EINVAL); 315 314 return 1; 316 315 } 317 316 318 317 is_dyn_linked = true; 319 ipc_answer_0(rid, EOK);318 async_answer_0(rid, EOK); 320 319 321 320 return 0; … … 343 342 DPRINTF("Entry point: %p\n", interp_info.entry); 344 343 345 ipc_answer_0(rid, EOK);344 async_answer_0(rid, EOK); 346 345 elf_run(&interp_info, &pcb); 347 346 } else { 348 347 /* Statically linked program */ 349 ipc_answer_0(rid, EOK);348 async_answer_0(rid, EOK); 350 349 elf_run(&prog_info, &pcb); 351 350 } … … 367 366 /* Already have a connection? */ 368 367 if (connected) { 369 ipc_answer_0(iid, ELIMIT);368 async_answer_0(iid, ELIMIT); 370 369 return; 371 370 } … … 374 373 375 374 /* Accept the connection */ 376 ipc_answer_0(iid, EOK);375 async_answer_0(iid, EOK); 377 376 378 377 /* Ignore parameters, the connection is already open */ … … 408 407 /* Not reached */ 409 408 default: 410 retval = E NOENT;409 retval = EINVAL; 411 410 break; 412 411 } 413 if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP) { 414 DPRINTF("Responding EINVAL to method %d.\n", 415 IPC_GET_IMETHOD(call)); 416 ipc_answer_0(callid, EINVAL); 417 } 412 413 if (IPC_GET_IMETHOD(call) != IPC_M_PHONE_HUNGUP) 414 async_answer_0(callid, retval); 418 415 } 419 416 } … … 423 420 int main(int argc, char *argv[]) 424 421 { 425 sysarg_t phonead; 426 task_id_t id; 427 int rc; 428 429 connected = false; 430 422 /* Set a handler of incomming connections. */ 423 async_set_client_connection(ldr_connection); 424 431 425 /* Introduce this task to the NS (give it our task ID). */ 432 id = task_get_id();433 rc = async_req_2_0(PHONE_NS, NS_ID_INTRO, LOWER32(id), UPPER32(id));426 task_id_t id = task_get_id(); 427 int rc = async_req_2_0(PHONE_NS, NS_ID_INTRO, LOWER32(id), UPPER32(id)); 434 428 if (rc != EOK) 435 429 return -1; 436 437 /* Set a handler of incomming connections. */438 async_set_client_connection(ldr_connection);439 430 440 431 /* Register at naming service. */ 441 if ( ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, &phonead) != 0)432 if (service_register(SERVICE_LOAD) != EOK) 442 433 return -2; 443 434 444 435 async_manager(); 445 436
Note:
See TracChangeset
for help on using the changeset viewer.
