Changeset 8b655705 in mainline for uspace/srv/loader


Ignore:
Timestamp:
2011-04-15T19:38:07Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
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.
Message:

Merge mainline changes.

Location:
uspace/srv/loader
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/loader/arch/abs32le/_link.ld.in

    r6b9e85b r8b655705  
    33 * is the base address and the special interp section.
    44 */
     5
    56STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
    67ENTRY(__entry)
     
    2021       
    2122        .text : {
    22                 *(.text);
    23                 *(.rodata*);
     23                *(.text .text.*);
     24                *(.rodata .rodata.*);
    2425        } :text
    2526       
     
    5455        } :data
    5556       
    56         . = ALIGN(0x1000);
    57        
    58         _heap = .;
    59        
    6057        /DISCARD/ : {
    6158                *(*);
  • 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
    16STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
    27ENTRY(__entry)
     
    611        text PT_LOAD FLAGS(5);
    712        data PT_LOAD FLAGS(6);
     13        debug PT_NOTE;
    814}
    915
     
    1117        .interp : {
    1218                *(.interp);
    13         } : interp
    14 
    15         /* . = 0x0000700000001000;*/
     19        } :interp
     20       
     21        /* . = 0x0000700000001000; */
    1622        . = 0x70001000;
    1723       
     
    1925                *(.init);
    2026        } :text
     27       
    2128        .text : {
    22                 *(.text);
    23                 *(.rodata*);
     29                *(.text .text.*);
     30                *(.rodata .rodata.*);
    2431        } :text
    2532       
     
    2734                *(.data);
    2835        } :data
     36       
    2937        .tdata : {
    3038                _tdata_start = .;
     
    3240                _tdata_end = .;
    3341        } :data
     42       
    3443        .tbss : {
    3544                _tbss_start = .;
     
    3746                _tbss_end = .;
    3847        } :data
     48       
    3949        _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
     50       
    4051        .bss : {
    4152                *(COMMON);
    4253                *(.bss);
    4354        } :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
    4768       
    4869        /DISCARD/ : {
    4970                *(*);
    5071        }
    51 
    5272}
  • uspace/srv/loader/arch/arm32/_link.ld.in

    r6b9e85b r8b655705  
    33 * is the base address.
    44 */
     5
    56STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
    67ENTRY(__entry)
     
    1617                *(.interp);
    1718        } : interp
    18 
     19       
    1920        . = 0x70001000;
    20 
     21       
    2122        .init ALIGN(0x1000): SUBALIGN(0x1000) {
    2223                *(.init);
    23         } : text
     24        } :text
     25       
    2426        .text : {
    25                 *(.text);
    26         *(.rodata*);
     27                *(.text .text.*);
     28                *(.rodata .rodata.*);
    2729        } :text
    2830       
     
    3234                *(.sdata);
    3335        } :data
     36       
    3437        .tdata : {
    3538                _tdata_start = .;
     
    3740                _tdata_end = .;
    3841        } :data
     42       
    3943        .tbss : {
    4044                _tbss_start = .;
     
    4246                _tbss_end = .;
    4347        } :data
     48       
    4449        _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
     50       
    4551        .bss : {
    4652                *(.sbss);
    4753                *(.scommon);
    48         *(COMMON);
    49         *(.bss);
     54                *(COMMON);
     55                *(.bss);
    5056        } :data
    51        
    52         . = ALIGN(0x1000);
    53         _heap = .;
    5457       
    5558        /DISCARD/ : {
    5659                *(*);
    5760        }
    58 
    5961}
  • uspace/srv/loader/arch/ia32/_link.ld.in

    r6b9e85b r8b655705  
    33 * is the base address and the special interp section.
    44 */
     5
    56STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
    67ENTRY(__entry)
     
    1011        text PT_LOAD FILEHDR PHDRS FLAGS(5);
    1112        data PT_LOAD FLAGS(6);
     13        debug PT_NOTE;
    1214}
    1315
     
    2426       
    2527        .text : {
    26                 *(.text);
    27                 *(.rodata*);
     28                *(.text .text.*);
     29                *(.rodata .rodata.*);
    2830        } :text
    2931       
     
    5254        } :data
    5355       
    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
    5768       
    5869        /DISCARD/ : {
  • uspace/srv/loader/arch/ia64/_link.ld.in

    r6b9e85b r8b655705  
    1212                *(.interp);
    1313        } :interp
    14 
     14       
    1515        /* On Itanium code sections must be aligned to 16 bytes. */
    1616        . = ALIGN(0x800000000 + SIZEOF_HEADERS, 16);
    17 
     17       
    1818        .init : {
    1919                *(.init);
    20         } : text
     20        } :text
     21       
    2122        .text : {
    22                 *(.text);
    23                 *(.rodata*);
     23                *(.text .text.*);
     24                *(.rodata .rodata.*);
    2425        } :text
    25 
     26       
    2627        . = . + 0x4000;
    27 
     28       
    2829        .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       
    3235        .data : {
    3336                *(.opd);
     
    3538                *(.sdata);
    3639        } :data
     40       
    3741        .tdata : {
    3842                _tdata_start = .;
     
    4044                _tdata_end = .;
    4145        } :data
     46       
    4247        .tbss : {
    4348                _tbss_start = .;
     
    4550                _tbss_end = .;
    4651        } :data
     52       
    4753        _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
     54       
    4855        .bss : {
    4956                *(.sbss);
     
    5259                *(.bss);
    5360        } :data
    54 
    55         . = ALIGN(0x4000);
    56         _heap = .;
    57  
     61       
    5862        /DISCARD/ : {
    5963                *(*);
    60         }
     64        }
    6165}
  • uspace/srv/loader/arch/mips32/_link.ld.in

    r6b9e85b r8b655705  
    33 * is the base address.
    44 */
     5
    56STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
    67ENTRY(__entry)
     
    1617                *(.interp);
    1718        } :interp
    18 
     19       
    1920        . = 0x70004000;
    2021       
     
    2223                *(.init);
    2324        } :text
     25       
    2426        .text : {
    25                 *(.text);
    26                 *(.rodata*);
     27                *(.text .text.*);
     28                *(.rodata .rodata.*);
    2729        } :text
    28 
     30       
     31        . = . + 0x4000;
     32       
    2933        .data : {
    3034                *(.data);
    3135                *(.data.rel*);
    3236        } :data
    33 
     37       
    3438        .got : {
    3539                _gp = .;
    3640                *(.got);
    3741        } :data
    38 
     42       
    3943        .tdata : {
    4044                _tdata_start = .;
     
    4246                _tdata_end = .;
    4347        } :data
     48       
    4449        .tbss : {
    4550                _tbss_start = .;
     
    4752                _tbss_end = .;
    4853        } :data
     54       
    4955        _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
    50 
     56       
    5157        .sbss : {
    5258                *(.scommon);
    5359                *(.sbss);
    54         }       
     60        }
     61       
    5562        .bss : {
    5663                *(.bss);
    5764                *(COMMON);
    5865        } :data
    59 
    60         . = ALIGN(0x4000);
    61         _heap = .;
    62 
     66       
    6367        /DISCARD/ : {
    6468                *(*);
  • uspace/srv/loader/arch/ppc32/_link.ld.in

    r6b9e85b r8b655705  
    33 * is the base address.
    44 */
     5
    56STARTUP(LIBC_PREFIX/arch/UARCH/src/entry.o)
    67ENTRY(__entry)
     
    1617                *(.interp);
    1718        } :interp
    18 
     19       
    1920        . = 0x70001000;
    20 
     21       
    2122        .init ALIGN(0x1000) : SUBALIGN(0x1000) {
    2223                *(.init);
    2324        } :text
     25       
    2426        .text : {
    25                 *(.text);
    26                 *(.rodata*);
     27                *(.text .text.*);
     28                *(.rodata .rodata.*);
    2729        } :text
    2830       
     
    3133                *(.sdata);
    3234        } :data
     35       
    3336        .tdata : {
    3437                _tdata_start = .;
     
    3639                _tdata_end = .;
    3740        } :data
     41       
    3842        .tbss : {
    3943                _tbss_start = .;
     
    4145                _tbss_end = .;
    4246        } :data
     47       
    4348        _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
     49       
    4450        .bss : {
    4551                *(.sbss);
     
    4753                *(.bss);
    4854        } :data
    49 
    50         . = ALIGN(0x1000);
    51         _heap = .;
    5255       
    5356        /DISCARD/ : {
    5457                *(*);
    5558        }
    56 
    5759}
  • uspace/srv/loader/arch/sparc64/_link.ld.in

    r6b9e85b r8b655705  
    1212                *(.interp);
    1313        } :interp
    14 
     14       
    1515        . = 0x70004000 + SIZEOF_HEADERS;
    16 
     16       
    1717        .init : {
    1818                *(.init);
    1919        } :text
     20       
    2021        .text : {
    21                 *(.text);
    22                 *(.rodata*);
     22                *(.text .text.*);
     23                *(.rodata .rodata.*);
    2324        } :text
    24 
     25       
    2526        . = . + 0x4000;
    26 
     27       
    2728        .got : {
    2829                 _gp = .;
    2930                 *(.got*);
    3031        } :data
     32       
    3133        .data : {
    3234                *(.data);
    3335                *(.sdata);
    3436        } :data
     37       
    3538        .tdata : {
    3639                _tdata_start = .;
     
    3841                _tdata_end = .;
    3942        } :data
     43       
    4044        .tbss : {
    4145                _tbss_start = .;
     
    4347                _tbss_end = .;
    4448        } :data
     49       
    4550        _tls_alignment = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
     51       
    4652        .bss : {
    4753                *(.sbss);
     
    4955                *(.bss);
    5056        } :data
    51 
    52         . = ALIGN(0x4000);
    53         _heap = .;
    5457       
    5558        /DISCARD/ : {
    5659                *(*);
    5760        }
    58 
    5961}
  • uspace/srv/loader/elf_load.c

    r6b9e85b r8b655705  
    109109        int fd;
    110110        int rc;
    111 
     111       
    112112        fd = open(file_name, O_RDONLY);
    113113        if (fd < 0) {
     
    300300        case PT_NULL:
    301301        case PT_PHDR:
     302        case PT_NOTE:
    302303                break;
    303304        case PT_LOAD:
     
    310311        case PT_DYNAMIC:
    311312        case PT_SHLIB:
    312         case PT_NOTE:
    313313        case PT_LOPROC:
    314314        case PT_HIPROC:
     
    344344        seg_ptr = (void *) seg_addr;
    345345
    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,
    347347                entry->p_memsz);
    348348
     
    372372        mem_sz = entry->p_memsz + (entry->p_vaddr - base);
    373373
    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)));
    376377
    377378        /*
     
    386387        }
    387388
    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);
    390391
    391392        /*
     
    464465                    (void *)((uint8_t *)entry->sh_addr + elf->bias);
    465466                DPRINTF("Dynamic section found at %p.\n",
    466                         (uintptr_t)elf->info->dynamic);
     467                    (void *) elf->info->dynamic);
    467468                break;
    468469        default:
  • uspace/srv/loader/main.c

    r6b9e85b r8b655705  
    5050#include <fcntl.h>
    5151#include <sys/types.h>
    52 #include <ipc/ipc.h>
    5352#include <ipc/services.h>
    5453#include <ipc/loader.h>
     
    9594
    9695/** Used to limit number of connections to one. */
    97 static bool connected;
     96static bool connected = false;
    9897
    9998static void ldr_get_taskid(ipc_callid_t rid, ipc_call_t *request)
     
    106105       
    107106        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);
    110109                return;
    111110        }
     
    115114       
    116115        async_data_read_finalize(callid, &task_id, len);
    117         ipc_answer_0(rid, EOK);
     116        async_answer_0(rid, EOK);
    118117}
    119118
     
    135134        }
    136135       
    137         ipc_answer_0(rid, rc);
     136        async_answer_0(rid, rc);
    138137}
    139138
     
    155154        }
    156155       
    157         ipc_answer_0(rid, rc);
     156        async_answer_0(rid, rc);
    158157}
    159158
     
    188187                if (_argv == NULL) {
    189188                        free(buf);
    190                         ipc_answer_0(rid, ENOMEM);
     189                        async_answer_0(rid, ENOMEM);
    191190                        return;
    192191                }
     
    220219        }
    221220       
    222         ipc_answer_0(rid, rc);
     221        async_answer_0(rid, rc);
    223222}
    224223
     
    244243                if (_filv == NULL) {
    245244                        free(buf);
    246                         ipc_answer_0(rid, ENOMEM);
     245                        async_answer_0(rid, ENOMEM);
    247246                        return;
    248247                }
     
    271270        }
    272271       
    273         ipc_answer_0(rid, EOK);
     272        async_answer_0(rid, EOK);
    274273}
    275274
     
    287286        if (rc != EE_OK) {
    288287                DPRINTF("Failed to load executable '%s'.\n", pathname);
    289                 ipc_answer_0(rid, EINVAL);
     288                async_answer_0(rid, EINVAL);
    290289                return 1;
    291290        }
     
    304303                /* Statically linked program */
    305304                is_dyn_linked = false;
    306                 ipc_answer_0(rid, EOK);
     305                async_answer_0(rid, EOK);
    307306                return 0;
    308307        }
     
    312311                DPRINTF("Failed to load interpreter '%s.'\n",
    313312                    prog_info.interp);
    314                 ipc_answer_0(rid, EINVAL);
     313                async_answer_0(rid, EINVAL);
    315314                return 1;
    316315        }
    317316       
    318317        is_dyn_linked = true;
    319         ipc_answer_0(rid, EOK);
     318        async_answer_0(rid, EOK);
    320319       
    321320        return 0;
     
    343342                DPRINTF("Entry point: %p\n", interp_info.entry);
    344343               
    345                 ipc_answer_0(rid, EOK);
     344                async_answer_0(rid, EOK);
    346345                elf_run(&interp_info, &pcb);
    347346        } else {
    348347                /* Statically linked program */
    349                 ipc_answer_0(rid, EOK);
     348                async_answer_0(rid, EOK);
    350349                elf_run(&prog_info, &pcb);
    351350        }
     
    367366        /* Already have a connection? */
    368367        if (connected) {
    369                 ipc_answer_0(iid, ELIMIT);
     368                async_answer_0(iid, ELIMIT);
    370369                return;
    371370        }
     
    374373       
    375374        /* Accept the connection */
    376         ipc_answer_0(iid, EOK);
     375        async_answer_0(iid, EOK);
    377376       
    378377        /* Ignore parameters, the connection is already open */
     
    408407                        /* Not reached */
    409408                default:
    410                         retval = ENOENT;
     409                        retval = EINVAL;
    411410                        break;
    412411                }
    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);
    418415        }
    419416}
     
    423420int main(int argc, char *argv[])
    424421{
    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       
    431425        /* 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));
    434428        if (rc != EOK)
    435429                return -1;
    436 
    437         /* Set a handler of incomming connections. */
    438         async_set_client_connection(ldr_connection);
    439430       
    440431        /* 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)
    442433                return -2;
    443 
     434       
    444435        async_manager();
    445436       
Note: See TracChangeset for help on using the changeset viewer.