Index: freebsd-utils-jessie/src/usr.bin/kdump/kdump.c
===================================================================
--- freebsd-utils-jessie.orig/src/usr.bin/kdump/kdump.c
+++ freebsd-utils-jessie/src/usr.bin/kdump/kdump.c
@@ -56,6 +56,7 @@ extern int errno;
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
+#include "stat16.h"
 #include <sys/sysent.h>
 #include <sys/un.h>
 #include <sys/queue.h>
@@ -71,6 +72,8 @@ extern int errno;
 #include <netinet/in.h>
 #include <ctype.h>
 #include <dlfcn.h>
+#define RTLD_MODEMASK   0x3
+#define RTLD_TRACE      0x200   /* Trace loaded objects and exit. */
 #include <err.h>
 #include <grp.h>
 #include <inttypes.h>
@@ -106,7 +109,7 @@ void ktruser_rtld(int, unsigned char *);
 void ktruser(int, unsigned char *);
 void ktrcaprights(cap_rights_t *);
 void ktrsockaddr(struct sockaddr *);
-void ktrstat(struct stat *);
+void ktrstat(struct stat16 *);
 void ktrstruct(char *, size_t);
 void ktrcapfail(struct ktr_cap_fail *);
 void ktrfault(struct ktr_fault *);
@@ -1175,6 +1178,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_in
 				ip++;
 				narg--;
 				break;
+#ifdef SYS_procctl
 			case SYS_procctl:
 				putchar('(');
 				idtypename(*ip, decimal);
@@ -1187,6 +1191,7 @@ ktrsyscall(struct ktr_syscall *ktr, u_in
 				ip++;
 				narg--;
 				break;
+#endif
 			}
 		}
 		while (narg > 0) {
@@ -1661,7 +1666,7 @@ ktrsockaddr(struct sockaddr *sa)
 }
 
 void
-ktrstat(struct stat *statp)
+ktrstat(struct stat16 *statp)
 {
 	char mode[12], timestr[PATH_MAX + 4];
 	struct passwd *pwd;
Index: freebsd-utils-jessie/src/usr.bin/kdump/Makefile
===================================================================
--- freebsd-utils-jessie.orig/src/usr.bin/kdump/Makefile
+++ freebsd-utils-jessie/src/usr.bin/kdump/Makefile
@@ -18,6 +18,9 @@ CFLAGS+=	-I${.CURDIR}/../ktrace -I${.CUR
 CFLAGS+=-DPF
 .endif
 
+CFLAGS+=	-Wno-error=implicit-function-declaration
+LDADD+=		-lfreebsd-glue
+
 .if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
 SRCS+=		linux_syscalls.c
 .endif
@@ -28,14 +31,14 @@ CLEANFILES=	ioctl.c kdump_subr.c kdump_s
 
 ioctl.c: mkioctls
 	env MACHINE=${MACHINE} CPP="${CPP}" \
-	    sh ${.CURDIR}/mkioctls print ${DESTDIR}/usr/include > ${.TARGET}
+	    sh ${.CURDIR}/mkioctls print /usr/src/kfreebsd-headers-10.1-0/sys > ${.TARGET}
 
 kdump_subr.h: mksubr
-	sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include | \
+	sh ${.CURDIR}/mksubr /usr/src/kfreebsd-headers-10.1-0/sys | \
 	    sed -n 's/^\([a-z].*)\)$$/void \1;/p' >${.TARGET}
 
 kdump_subr.c: mksubr kdump_subr.h
-	sh ${.CURDIR}/mksubr ${DESTDIR}/usr/include >${.TARGET}
+	sh ${.CURDIR}/mksubr /usr/src/kfreebsd-headers-10.1-0/sys >${.TARGET}
 
 linux_syscalls.c:
 	/bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \
Index: freebsd-utils-jessie/src/usr.bin/kdump/mksubr
===================================================================
--- freebsd-utils-jessie.orig/src/usr.bin/kdump/mksubr
+++ freebsd-utils-jessie/src/usr.bin/kdump/mksubr
@@ -80,7 +80,10 @@ _EOF_
 		if ($i ~ /define/) \
 			break; \
 		++i; \
-		printf "\tif (!((arg > 0) ^ ((%s) > 0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i }'
+		printf "#ifdef %s\n", $i; \
+		printf "\tif (!((arg > 0) ^ ((%s) > 0)))\n\t\tif_print_or(arg, %s, or);\n", $i, $i; \
+		printf "#endif\n" \
+		}'
 cat <<_EOF_
 	printf(">");
 	if (or == 0)
@@ -113,7 +116,10 @@ _EOF_
 		if ($i ~ /define/) \
 			break; \
 		++i; \
-		printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i }'
+		printf "#ifdef %s\n", $i; \
+		printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i; \
+		printf "#endif\n" \
+		}'
 cat <<_EOF_
 	default: /* Should not reach */
 		printf("<invalid=%jd>", arg);
@@ -141,10 +147,14 @@ $name(intmax_t arg)
 _EOF_
 	egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
 		$include_dir/$file | \
-	awk '{ printf "\t"; \
+	awk '{
+		printf "#ifdef %s\n", $2; \
+		printf "\t"; \
 		if (NR > 1) \
 			printf "else " ; \
-		printf "if (arg == %s) \n\t\tprintf(\"%s\");\n", $2, $2 }'
+		printf "if (arg == %s) \n\t\tprintf(\"%s\");\n", $2, $2;
+		printf "#endif\n" \
+		}'
 cat <<_EOF_
 	else /* Should not reach */
 		printf("<invalid=%jd>", arg);
@@ -161,6 +171,7 @@ cat <<_EOF_
 #include <sys/fcntl.h>
 #include <sys/stat.h>
 #include <sys/unistd.h>
+#include <sys/rfork.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
 #define _KERNEL
@@ -175,11 +186,7 @@ cat <<_EOF_
 #include <sys/reboot.h>
 #include <sched.h>
 #include <sys/linker.h>
-#define _KERNEL
-#include <sys/thr.h>
-#undef _KERNEL
 #include <sys/extattr.h>
-#include <sys/acl.h>
 #include <aio.h>
 #include <sys/sem.h>
 #include <sys/ipc.h>
@@ -193,6 +200,20 @@ cat <<_EOF_
 
 #include "kdump_subr.h"
 
+#ifndef S_IFWHT
+#define S_IFWHT __S_IFWHT
+#endif
+
+#ifndef PT_LWPINFO
+#define PT_LWPINFO      13      /* Info about the LWP that stopped. */
+#endif
+#ifndef PT_GETNUMLWPS
+#define PT_GETNUMLWPS   14      /* get total number of threads */
+#endif
+#ifndef PT_GETLWPLIST
+#define PT_GETLWPLIST   15      /* get thread list */
+#endif
+
 /*
  * These are simple support macros. print_or utilizes a variable
  * defined in the calling function to track whether or not it should
@@ -336,6 +357,7 @@ idtypename(idtype_t idtype, int decimal)
 	case P_PID:
 		printf("P_PID");
 		break;
+#if 0
 	case P_PPID:
 		printf("P_PPID");
 		break;
@@ -381,6 +403,7 @@ idtypename(idtype_t idtype, int decimal)
 	case P_PSETID:
 		printf("P_PSETID");
 		break;
+#endif
 	default:
 		if (decimal) {
 			printf("%d", idtype);
@@ -438,10 +461,14 @@ vmprotname (int type)
 void
 socktypenamewithflags(int type)
 {
+#ifdef SOCK_CLOEXEC
 	if (type & SOCK_CLOEXEC)
 		printf("SOCK_CLOEXEC|"), type &= ~SOCK_CLOEXEC;
+#endif
+#ifdef SOCK_NONBLOCK
 	if (type & SOCK_NONBLOCK)
 		printf("SOCK_NONBLOCK|"), type &= ~SOCK_NONBLOCK;
+#endif
 	socktypename(type);
 }
 _EOF_
@@ -456,7 +483,7 @@ auto_or_type     "flockname"           "
 auto_or_type     "getfsstatflagsname"  "MNT_[A-Z]+[[:space:]]+[1-9][0-9]*"            "sys/mount.h"
 auto_switch_type "kldsymcmdname"       "KLDSYM_[A-Z]+[[:space:]]+[0-9]+"              "sys/linker.h"
 auto_switch_type "kldunloadfflagsname" "LINKER_UNLOAD_[A-Z]+[[:space:]]+[0-9]+"       "sys/linker.h"
-auto_switch_type "lio_listioname"      "LIO_(NO)?WAIT[[:space:]]+[0-9]+"              "aio.h"
+auto_switch_type "lio_listioname"      "LIO_(NO)?WAIT[[:space:]]+[0-9]+"              "sys/aio.h"
 auto_switch_type "madvisebehavname"    "_?MADV_[A-Z]+[[:space:]]+[0-9]+"              "sys/mman.h"
 auto_switch_type "minheritname"        "INHERIT_[A-Z]+[[:space:]]+[0-9]+"             "sys/mman.h"
 auto_or_type     "mlockallname"        "MCL_[A-Z]+[[:space:]]+0x[0-9]+"               "sys/mman.h"
@@ -472,7 +499,7 @@ auto_switch_type "quotactlname"        "
 auto_or_type     "rebootoptname"       "RB_[A-Z]+[[:space:]]+0x[0-9]+"                "sys/reboot.h"
 auto_or_type     "rforkname"           "RF[A-Z]+[[:space:]]+\([0-9]+<<[0-9]+\)"       "sys/unistd.h"
 auto_switch_type "rlimitname"          "RLIMIT_[A-Z]+[[:space:]]+[0-9]+"              "sys/resource.h"
-auto_switch_type "schedpolicyname"     "SCHED_[A-Z]+[[:space:]]+[0-9]+"               "sched.h"
+auto_switch_type "schedpolicyname"     "SCHED_[A-Z]+[[:space:]]+[0-9]+"               "sys/sched.h"
 auto_switch_type "sendfileflagsname"   "SF_[A-Z]+[[:space:]]+[0-9]+"                  "sys/socket.h"
 auto_or_type     "shmatname"           "SHM_[A-Z]+[[:space:]]+[0-9]{6}+"              "sys/shm.h"
 auto_switch_type "shutdownhowname"     "SHUT_[A-Z]+[[:space:]]+[0-9]+"                "sys/socket.h"
@@ -511,7 +538,11 @@ egrep "^#[[:space:]]*define[[:space:]]+F
 			break; \
 		++i; \
 		if (o <= $(i+1)) \
+			{ \
+			printf "#ifdef %s\n", $i; \
 			printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i; \
+			printf "#endif\n";
+			} \
 		else \
 			exit; \
 		o = $(i+1) }'
@@ -549,7 +580,6 @@ cat <<_EOF_
 void
 mmapflagsname(int flags)
 {
-	int align;
 	int or = 0;
 	printf("%#x<", flags);
 _EOF_
@@ -559,13 +589,17 @@ egrep "^#[[:space:]]*define[[:space:]]+M
 		if ($i ~ /define/) \
 			break; \
 		++i; \
-		printf "\tif (!((flags > 0) ^ ((%s) > 0)))\n\t\tif_print_or(flags, %s, or);\n", $i, $i }'
+		printf "#ifdef %s\n", $i; \
+		printf "\tif (!((flags > 0) ^ ((%s) > 0)))\n\t\tif_print_or(flags, %s, or);\n", $i, $i; \
+		printf "#endif\n" \
+		}'
 cat <<_EOF_
 #ifdef MAP_32BIT
 	if (!((flags > 0) ^ ((MAP_32BIT) > 0)))
 		if_print_or(flags, MAP_32BIT, or);
 #endif
-	align = flags & MAP_ALIGNMENT_MASK;
+#ifdef MAP_ALIGNMENT_MASK
+	int align = flags & MAP_ALIGNMENT_MASK;
 	if (align != 0) {
 		if (align == MAP_ALIGNED_SUPER)
 			print_or("MAP_ALIGNED_SUPER", or);
@@ -577,6 +611,7 @@ cat <<_EOF_
 	printf(">");
 	if (or == 0)
 		printf("<invalid>%d", flags);
+#endif
 }
 
 /*
@@ -628,7 +663,10 @@ egrep "^#[[:space:]]*define[[:space:]]+M
 		if ($i ~ /define/) \
 			break; \
 		++i; \
-		printf "\tif(!((flags>0)^((%s)>0)))\n\t\tif_print_or(flags, %s, or);\n", $i, $i }'
+		printf "#ifdef %s\n", $i; \
+		printf "\tif(!((flags>0)^((%s)>0)))\n\t\tif_print_or(flags, %s, or);\n", $i, $i; \
+		printf "#endif\n" \
+		}'
 cat <<_EOF_
 	printf(">");
 }
@@ -649,7 +687,10 @@ egrep "^#[[:space:]]*define[[:space:]]+S
 		if ($i ~ /define/) \
 			break; \
 		++i; \
-		printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i }'
+		printf "#ifdef %s\n", $i; \
+		printf "\tcase %s:\n\t\tprintf(\"%s\");\n\t\tbreak;\n", $i, $i; \
+		printf "#endif\n" \
+		}'
 cat <<_EOF_
 	default:
 		switch (sig) {
Index: freebsd-utils-jessie/src/usr.bin/kdump/stat16.h
===================================================================
--- /dev/null
+++ freebsd-utils-jessie/src/usr.bin/kdump/stat16.h
@@ -0,0 +1,55 @@
+/* Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This structure corresponds to the standard FreeBSD 'struct stat'
+   (i.e. _STAT_VER_stat), and is used by the stat() system call family. */
+
+struct stat16
+  {
+    __dev_t st_dev;		/* Device containing the file.  */
+    __ino_t st_ino;		/* File serial number.  */
+
+    __uint16_t st_mode;		/* File mode.  */
+    __uint16_t st_nlink;	/* Link count.  */
+
+    __uid_t st_uid;		/* User ID of the file's owner.  */
+    __gid_t st_gid;		/* Group ID of the file's group.  */
+
+    __dev_t st_rdev;		/* Device number, if device.  */
+
+    struct  timespec st_atim;  /* time of last access */
+    struct  timespec st_mtim;  /* time of last data modification */
+    struct  timespec st_ctim;  /* time of last file status change */
+
+    __off_t st_size;		/* Size of file, in bytes.  */
+
+    __blkcnt_t st_blocks;	/* Number of 512-byte blocks allocated.  */
+
+    __blksize_t st_blksize;	/* Optimal block size for I/O.  */
+
+    __uint32_t st_flags;	/* User defined flags.  */
+
+    __uint32_t st_gen;		/* Generation number.  */
+
+    __uint32_t __dummy1;
+
+    struct timespec st_birthtim; /* time of file creation */
+
+#define _BIRTH_PADSIZE     (2*(8 - sizeof (long)))
+    char __birth_padding[_BIRTH_PADSIZE];
+  };
