Parse an executable image in the kernel memory. * * If the image belongs to a program loader, it is registered as such, * (and *task is set to NULL). Otherwise a task is created from the * executable image. The task is returned in *task. * * @param[in] image_addr Address of an executable program image. * @param[in] name Name to set for the program's task. * @param[out] prg B
| 142 | * |
| 143 | */ |
| 144 | errno_t program_create_from_image(void *image_addr, char *name, program_t *prg) |
| 145 | { |
| 146 | as_t *as = as_create(0); |
| 147 | if (!as) |
| 148 | return ENOMEM; |
| 149 | |
| 150 | prg->loader_status = elf_load((elf_header_t *) image_addr, as); |
| 151 | if (prg->loader_status != EOK) { |
| 152 | as_release(as); |
| 153 | prg->task = NULL; |
| 154 | prg->main_thread = NULL; |
| 155 | return ENOTSUP; |
| 156 | } |
| 157 | |
| 158 | return program_create(as, ((elf_header_t *) image_addr)->e_entry, |
| 159 | name, prg); |
| 160 | } |
| 161 | |
| 162 | /** Create a task from the program loader image. |
| 163 | * |
no test coverage detected