Make kernel ELF image parsing not crash for kernels running at locations

other than their link address.
This commit is contained in:
Nathan Whitehorn 2015-02-21 23:20:05 +00:00
parent af02586229
commit c6014c739c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=279119

View File

@ -381,6 +381,8 @@ link_elf_link_common_finish(linker_file_t lf)
return (0);
}
extern vm_offset_t __startkernel;
static void
link_elf_init(void* arg)
{
@ -409,7 +411,11 @@ link_elf_init(void* arg)
ef = (elf_file_t) linker_kernel_file;
ef->preloaded = 1;
#ifdef __powerpc64__
ef->address = (caddr_t) (__startkernel - KERNBASE);
#else
ef->address = 0;
#endif
#ifdef SPARSE_MAPPING
ef->object = 0;
#endif
@ -417,7 +423,7 @@ link_elf_init(void* arg)
if (dp != NULL)
parse_dynamic(ef);
linker_kernel_file->address = (caddr_t) KERNBASE;
linker_kernel_file->address += KERNBASE;
linker_kernel_file->size = -(intptr_t)linker_kernel_file->address;
if (modptr != NULL) {