xref: /freebsd/sys/contrib/openzfs/config/kernel-objtool.m4 (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1dnl #
2dnl # Detect objtool functionality.
3dnl #
4
5dnl #
6dnl # Kernel 5.10: linux/frame.h was renamed linux/objtool.h
7dnl #
8AC_DEFUN([ZFS_AC_KERNEL_OBJTOOL_HEADER], [
9	AC_MSG_CHECKING([whether objtool header is available])
10	ZFS_LINUX_TRY_COMPILE([
11		#include <linux/objtool.h>
12	],[
13	],[
14		AC_DEFINE(HAVE_KERNEL_OBJTOOL_HEADER, 1,
15		    [kernel has linux/objtool.h])
16		AC_MSG_RESULT(linux/objtool.h)
17	],[
18		AC_MSG_RESULT(linux/frame.h)
19	])
20])
21
22dnl #
23dnl # Check for objtool support.
24dnl #
25AC_DEFUN([ZFS_AC_KERNEL_SRC_OBJTOOL], [
26
27	dnl # 4.6 API for compile-time stack validation
28	ZFS_LINUX_TEST_SRC([objtool], [
29		#undef __ASSEMBLY__
30		#include <asm/ptrace.h>
31		#include <asm/frame.h>
32	],[
33		#if !defined(FRAME_BEGIN)
34		#error "FRAME_BEGIN is not defined"
35		#endif
36	])
37
38	dnl # 4.6 API added STACK_FRAME_NON_STANDARD macro
39	ZFS_LINUX_TEST_SRC([stack_frame_non_standard], [
40		#ifdef HAVE_KERNEL_OBJTOOL_HEADER
41		#include <linux/objtool.h>
42		#else
43		#include <linux/frame.h>
44		#endif
45	],[
46		#if !defined(STACK_FRAME_NON_STANDARD)
47		#error "STACK_FRAME_NON_STANDARD is not defined."
48		#endif
49	])
50])
51
52AC_DEFUN([ZFS_AC_KERNEL_OBJTOOL], [
53	AC_MSG_CHECKING(
54	    [whether compile-time stack validation (objtool) is available])
55	ZFS_LINUX_TEST_RESULT([objtool], [
56		AC_MSG_RESULT(yes)
57		AC_DEFINE(HAVE_KERNEL_OBJTOOL, 1,
58		    [kernel does stack verification])
59
60		AC_MSG_CHECKING([whether STACK_FRAME_NON_STANDARD is defined])
61		ZFS_LINUX_TEST_RESULT([stack_frame_non_standard], [
62			AC_MSG_RESULT(yes)
63			AC_DEFINE(HAVE_STACK_FRAME_NON_STANDARD, 1,
64			   [STACK_FRAME_NON_STANDARD is defined])
65		],[
66			AC_MSG_RESULT(no)
67		])
68	],[
69		AC_MSG_RESULT(no)
70	])
71])
72