Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/loader/elf_load.c

    r1ea99cc r08c9f7d  
    102102 * @return EOK on success or negative error code.
    103103 */
    104 int elf_load_file(char *file_name, size_t so_bias, eld_flags_t flags,
    105     elf_info_t *info)
     104int elf_load_file(char *file_name, size_t so_bias, elf_info_t *info)
    106105{
    107106        elf_ld_t elf;
     
    118117        elf.fd = fd;
    119118        elf.info = info;
    120         elf.flags = flags;
    121119
    122120        rc = elf_load(&elf, so_bias);
     
    125123
    126124        return rc;
     125}
     126
     127/** Run an ELF executable.
     128 *
     129 * Transfers control to the entry point of an ELF executable loaded
     130 * earlier with elf_load_file(). This function does not return.
     131 *
     132 * @param info  Info structure filled earlier by elf_load_file()
     133 */
     134void elf_run(elf_info_t *info, pcb_t *pcb)
     135{
     136        program_run(info->entry, pcb);
     137
     138        /* not reached */
    127139}
    128140
     
    139151        pcb->entry = info->entry;
    140152        pcb->dynamic = info->dynamic;
    141         pcb->rtld_runtime = NULL;
    142153}
    143154
     
    292303                break;
    293304        case PT_INTERP:
    294                 /* Assume silently interp == "/app/dload" */
    295                 elf->info->interp = "/app/dload";
     305                /* Assume silently interp == "/rtld.so" */
     306                elf->info->interp = "/rtld.so";
    296307                break;
    297308        case PT_DYNAMIC:
    298                 /* Record pointer to dynamic section into info structure */
    299                 elf->info->dynamic =
    300                     (void *)((uint8_t *)entry->p_vaddr + elf->bias);
    301                 DPRINTF("dynamic section found at 0x%x\n",
    302                         (uintptr_t)elf->info->dynamic);
    303                 break;
    304         case 0x70000000:
    305                 /* FIXME: MIPS reginfo */
    306                 break;
    307309        case PT_SHLIB:
    308310        case PT_NOTE:
    309 //      case PT_LOPROC:
    310 //      case PT_HIPROC:
     311        case PT_LOPROC:
     312        case PT_HIPROC:
    311313        default:
    312314                DPRINTF("Segment p_type %d unknown.\n", entry->p_type);
     
    378380            AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE);
    379381        if (a == (void *)(-1)) {
    380                 DPRINTF("memory mapping failed (0x%x, %d)\n",
    381                         base+bias, mem_sz);
     382                DPRINTF("Memory mapping failed.\n");
    382383                return EE_MEMORY;
    383384        }
     
    421422        }
    422423
    423         /*
    424          * The caller wants to modify the segments first. He will then
    425          * need to set the right access mode and ensure SMC coherence.
    426          */
    427         if ((elf->flags & ELDF_RW) != 0) return EE_OK;
    428 
    429 //      printf("set area flags to %d\n", flags);
    430424        rc = as_area_change_flags(seg_ptr, flags);
    431425        if (rc != 0) {
     
    464458                break;
    465459        case SHT_DYNAMIC:
     460                /* Record pointer to dynamic section into info structure */
     461                elf->info->dynamic =
     462                    (void *)((uint8_t *)entry->sh_addr + elf->bias);
     463                DPRINTF("Dynamic section found at 0x%x.\n",
     464                        (uintptr_t)elf->info->dynamic);
    466465                break;
    467466        default:
Note: See TracChangeset for help on using the changeset viewer.