在 linux 内核版本 4.14.41 中,只要对齐的 LOAD 段不是 2MB 的倍数,就会发生错误。但为什么不在 linux 内核版本 3.16.0 中执行相同的检查?另外,为什么不对任何 veriosn 的 32 位配置内核执行此检查?
在 linux-4.9.91 版本中发布了 64 位 2MB 倍数的 LOAD 段对齐检查。以下是 arch/x86/Makefile
的代码片段:
#The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to
#the linker to force 2MB page size regardless of the default page size used
#by the linker.
ifdef CONFIG_X86_64
LDFLAGS += $(call ld-option, -z max-page-size=0x200000)
endif
这种类型的传递在以前的版本中不存在,但 64 位加载部分以 2MB 的倍数对齐。如果不遵循这种对齐方式,那么 4.9.91 及更高版本将产生错误 Alignment of LOAD Segments is not a multiple of 2MB
而其他版本会产生错误 Kernel is not a有效的 ELF 文件
我是一名优秀的程序员,十分优秀!