svn commit: r279119 - head/sys/kern

Nathan Whitehorn nwhitehorn at FreeBSD.org
Sat Feb 21 23:20:06 UTC 2015


Author: nwhitehorn
Date: Sat Feb 21 23:20:05 2015
New Revision: 279119
URL: https://svnweb.freebsd.org/changeset/base/279119

Log:
  Make kernel ELF image parsing not crash for kernels running at locations
  other than their link address.

Modified:
  head/sys/kern/link_elf.c

Modified: head/sys/kern/link_elf.c
==============================================================================
--- head/sys/kern/link_elf.c	Sat Feb 21 23:04:18 2015	(r279118)
+++ head/sys/kern/link_elf.c	Sat Feb 21 23:20:05 2015	(r279119)
@@ -381,6 +381,8 @@ link_elf_link_common_finish(linker_file_
 	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) {


More information about the svn-src-all mailing list