summaryrefslogtreecommitdiffstats
path: root/config/kernel-objtool.m4
blob: f9f9d657d8053e5d67090d92385c0f5d482d103f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
dnl #
dnl # Detect objtool functionality.
dnl #

dnl #
dnl # Kernel 5.10: linux/frame.h was renamed linux/objtool.h
dnl #
AC_DEFUN([ZFS_AC_KERNEL_OBJTOOL_HEADER], [
	AC_MSG_CHECKING([whether objtool header is available])
	ZFS_LINUX_TRY_COMPILE([
		#include <linux/objtool.h>
	],[
	],[
		AC_DEFINE(HAVE_KERNEL_OBJTOOL_HEADER, 1,
		    [kernel has linux/objtool.h])
		AC_MSG_RESULT(linux/objtool.h)
	],[
		AC_MSG_RESULT(linux/frame.h)
	])
])

dnl #
dnl # Check for objtool support.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_OBJTOOL], [

	dnl # 4.6 API for compile-time stack validation
	ZFS_LINUX_TEST_SRC([objtool], [
		#undef __ASSEMBLY__
		#include <asm/ptrace.h>
		#include <asm/frame.h>
	],[
		#if !defined(FRAME_BEGIN)
		#error "FRAME_BEGIN is not defined"
		#endif
	])

	dnl # 4.6 API added STACK_FRAME_NON_STANDARD macro
	ZFS_LINUX_TEST_SRC([stack_frame_non_standard], [
		#ifdef HAVE_KERNEL_OBJTOOL_HEADER
		#include <linux/objtool.h>
		#else
		#include <linux/frame.h>
		#endif
	],[
		#if !defined(STACK_FRAME_NON_STANDARD)
		#error "STACK_FRAME_NON_STANDARD is not defined."
		#endif
	])
])

AC_DEFUN([ZFS_AC_KERNEL_OBJTOOL], [
	AC_MSG_CHECKING(
	    [whether compile-time stack validation (objtool) is available])
	ZFS_LINUX_TEST_RESULT([objtool], [
		AC_MSG_RESULT(yes)
		AC_DEFINE(HAVE_KERNEL_OBJTOOL, 1,
		    [kernel does stack verification])

		AC_MSG_CHECKING([whether STACK_FRAME_NON_STANDARD is defined])
		ZFS_LINUX_TEST_RESULT([stack_frame_non_standard], [
			AC_MSG_RESULT(yes)
			AC_DEFINE(HAVE_STACK_FRAME_NON_STANDARD, 1,
			   [STACK_FRAME_NON_STANDARD is defined])
		],[
			AC_MSG_RESULT(no)
		])
	],[
		AC_MSG_RESULT(no)
	])
])