Allow loader to load 64-bit ELFv2 PowerPC kernels.

This commit is contained in:
Nathan Whitehorn 2015-12-01 17:01:27 +00:00
parent f19d421ac6
commit b931a53849
3 changed files with 17 additions and 6 deletions

View File

@ -77,7 +77,10 @@ ppc64_ofw_elf_exec(struct preloaded_file *fp)
}
e = (Elf_Ehdr *)&fmp->md_data;
/* Handle function descriptor */
/* Handle function descriptor for ELFv1 kernels */
if ((e->e_flags & 3) == 2)
entry = e->e_entry;
else
entry = *(uint64_t *)e->e_entry;
if ((error = md_load64(fp->f_args, &mdp, &dtbp)) != 0)

View File

@ -78,10 +78,15 @@ ppc64_elf_exec(struct preloaded_file *fp)
/* Figure out where to put it */
trampolinebase = archsw.arch_loadaddr(LOAD_RAW, NULL, 0);
/* Set up interesting values in function descriptor */
/* Set up loader trampoline */
trampoline = malloc(szkerneltramp);
memcpy(trampoline, &kerneltramp, szkerneltramp);
archsw.arch_copyout(e->e_entry + elf64_relocation_offset, &entry, 8);
/* Parse function descriptor for ELFv1 kernels */
if ((e->e_flags & 3) == 2)
entry = e->e_entry;
else
archsw.arch_copyout(e->e_entry + elf64_relocation_offset,
&entry, 8);
trampoline[2] = entry + elf64_relocation_offset;
trampoline[4] = 0; /* Phys. mem offset */
trampoline[5] = 0; /* OF entry point */

View File

@ -75,7 +75,10 @@ ppc64_elf_exec(struct preloaded_file *fp)
}
e = (Elf_Ehdr *)&fmp->md_data;
/* Handle function descriptor */
/* Handle function descriptor for ELFv1 kernels */
if ((e->e_flags & 3) == 2)
entry = e->e_entry;
else
entry = (void *)(uintptr_t)(*(uint64_t *)e->e_entry);
if ((error = md_load64(fp->f_args, &mdp)) != 0)