Module Name: src
Committed By: maxv
Date: Thu Dec 21 14:28:39 UTC 2017
Modified Files:
src/sys/lib/libsa: loadfile_elf32.c
Log Message:
Make sure we're loading a relocatable binary, to give the user a chance to
correct the kernel name if he mistakenly typed pkboot on a static kernel,
without having to reboot the machine (currently the prekern sees it's a
static kernel and panics).
To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/lib/libsa/loadfile_elf32.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/lib/libsa/loadfile_elf32.c
diff -u src/sys/lib/libsa/loadfile_elf32.c:1.51 src/sys/lib/libsa/loadfile_elf32.c:1.52
--- src/sys/lib/libsa/loadfile_elf32.c:1.51 Wed Nov 15 18:02:37 2017
+++ src/sys/lib/libsa/loadfile_elf32.c Thu Dec 21 14:28:39 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: loadfile_elf32.c,v 1.51 2017/11/15 18:02:37 maxv Exp $ */
+/* $NetBSD: loadfile_elf32.c,v 1.52 2017/12/21 14:28:39 maxv Exp $ */
/*
* Copyright (c) 1997, 2008, 2017 The NetBSD Foundation, Inc.
@@ -352,6 +352,11 @@ ELFNAMEEND(loadfile_dynamic)(int fd, Elf
internalize_ehdr(elf->e_ident[EI_DATA], elf);
+ if (elf->e_type != ET_REL) {
+ errno = EINVAL;
+ return 1;
+ }
+
/* Create a local copy of the SECTION HEADERS. */
shdrsz = elf->e_shnum * sizeof(Elf_Shdr);
shdr = ALLOC(shdrsz);