Files
mirror_zfs/config/kernel-objtool.m4
T

109 lines
2.8 KiB
Plaintext
Raw Normal View History

dnl # SPDX-License-Identifier: CDDL-1.0
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>
],[
],[
2025-06-05 02:40:09 +02:00
objtool_header=$LINUX/include/linux/objtool.h
AC_DEFINE(HAVE_KERNEL_OBJTOOL_HEADER, 1,
[kernel has linux/objtool.h])
AC_MSG_RESULT(linux/objtool.h)
],[
2025-06-05 02:40:09 +02:00
objtool_header=$LINUX/include/linux/frame.h
AC_MSG_RESULT(linux/frame.h)
])
])
2017-03-07 21:59:31 +01:00
dnl #
2019-10-01 12:50:34 -07:00
dnl # Check for objtool support.
2017-03-07 21:59:31 +01:00
dnl #
2019-10-01 12:50:34 -07:00
AC_DEFUN([ZFS_AC_KERNEL_SRC_OBJTOOL], [
dnl # 4.6 API for compile-time stack validation
ZFS_LINUX_TEST_SRC([objtool], [
2017-03-07 21:59:31 +01:00
#undef __ASSEMBLY__
2020-09-28 16:40:50 -07:00
#include <asm/ptrace.h>
2017-03-07 21:59:31 +01:00
#include <asm/frame.h>
],[
#if !defined(FRAME_BEGIN)
2020-09-28 16:40:50 -07:00
#error "FRAME_BEGIN is not defined"
2017-03-07 21:59:31 +01:00
#endif
2017-12-07 10:28:50 -08:00
])
2019-10-01 12:50:34 -07:00
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
2017-12-07 10:28:50 -08:00
#include <linux/frame.h>
#endif
2017-12-07 10:28:50 -08:00
],[
#if !defined(STACK_FRAME_NON_STANDARD)
2020-09-28 16:40:50 -07:00
#error "STACK_FRAME_NON_STANDARD is not defined."
2017-12-07 10:28:50 -08:00
#endif
2019-10-01 12:50:34 -07:00
])
2025-06-16 17:12:09 +02:00
dnl # 6.15 made CONFIG_OBJTOOL_WERROR=y the default. We need to handle
dnl # this or our build will fail.
ZFS_LINUX_TEST_SRC([config_objtool_werror], [
#if !defined(CONFIG_OBJTOOL_WERROR)
#error "CONFIG_OBJTOOL_WERROR is not defined."
#endif
])
2019-10-01 12:50:34 -07:00
])
AC_DEFUN([ZFS_AC_KERNEL_OBJTOOL], [
AC_MSG_CHECKING(
[whether compile-time stack validation (objtool) is available])
ZFS_LINUX_TEST_RESULT([objtool], [
2017-12-07 10:28:50 -08:00
AC_MSG_RESULT(yes)
2019-10-01 12:50:34 -07:00
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])
2025-06-05 02:40:09 +02:00
dnl # Needed for kernels missing the asm macro. We grep
dnl # for it in the header file since there is currently
dnl # no test to check the result of assembling a file.
AC_MSG_CHECKING(
[whether STACK_FRAME_NON_STANDARD asm macro is defined])
dnl # Escape square brackets.
sp='@<:@@<:@:space:@:>@@:>@'
dotmacro='@<:@.@:>@macro'
regexp="^$sp*$dotmacro$sp+STACK_FRAME_NON_STANDARD$sp"
AS_IF([$EGREP -s -q "$regexp" $objtool_header],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_STACK_FRAME_NON_STANDARD_ASM, 1,
[STACK_FRAME_NON_STANDARD asm macro is defined])
],[
AC_MSG_RESULT(no)
])
2019-10-01 12:50:34 -07:00
],[
AC_MSG_RESULT(no)
])
2025-06-16 17:12:09 +02:00
AC_MSG_CHECKING([whether CONFIG_OBJTOOL_WERROR is defined])
ZFS_LINUX_TEST_RESULT([config_objtool_werror],[
AC_MSG_RESULT(yes)
CONFIG_OBJTOOL_WERROR_DEFINED=yes
],[
AC_MSG_RESULT(no)
])
2017-03-07 21:59:31 +01:00
],[
AC_MSG_RESULT(no)
])
])