Linux 如何将成员添加到任务“要绕过的结构”中;编译时间“断言”;
我需要向Linux内核4.8.0中的task_结构添加成员。但是,当我这样做并尝试构建内核时,错误消息显示:Linux 如何将成员添加到任务“要绕过的结构”中;编译时间“断言”;,linux,linux-kernel,kernel,task,Linux,Linux Kernel,Kernel,Task,我需要向Linux内核4.8.0中的task_结构添加成员。但是,当我这样做并尝试构建内核时,错误消息显示: In file included from linux-hwe-4.8.0/include/uapi/linux/stddef.h:1:0, from linux-hwe-4.8.0/include/linux/stddef.h:4, from linux-hwe-4.8.0/include/uapi/linux/posix_types
In file included from linux-hwe-4.8.0/include/uapi/linux/stddef.h:1:0,
from linux-hwe-4.8.0/include/linux/stddef.h:4,
from linux-hwe-4.8.0/include/uapi/linux/posix_types.h:4,
from linux-hwe-4.8.0/include/uapi/linux/types.h:13,
from linux-hwe-4.8.0/include/linux/types.h:5,
from linux-hwe-4.8.0/include/linux/compat.h:8,
from linux-hwe-4.8.0/arch/x86/include/asm/fpu/internal.h:13,
from linux-hwe-4.8.0/arch/x86/kernel/fpu/init.c:4:
In function ‘fpu__init_task_struct_size’,
inlined from ‘fpu__init_system’ at linux-hwe-4.8.0/arch/x86/kernel/fpu/init.c:390:2:
linux-hwe-4.8.0/include/linux/compiler.h:491:38: error: call to ‘__compiletime_assert_192’ declared with attribute error: BUILD_BUG_ON failed: sizeof(struct task_struct) != ALIGN(offsetofend(struct task_struct, thread), TYPE_ALIGN(struct task_struct))
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
如何消除此类错误并成功构建我的内核?您遇到的断言是由宏(
的CHECK\u MEMBER\u在
)触发的,该宏检查结构任务
的线程
成员是否是其最后一个字段
根据内核源代码,linux/sched.h:
/* CPU-specific state of this task */
struct thread_struct thread;
/*
* WARNING: on x86, 'thread_struct' contains a variable-sized
* structure. It *MUST* be at the end of 'task_struct'.
*
* Do not put anything below here!
只需在其前面添加新字段