为什么linux内核原始二进制Image有Windows可执行格式?

问题描述

根据https://ineclabs.com/image-zimage-uimage-vmlinuz-linux-kernel/

Image: The generic Linux kernel binary image file.

我有一个ARM64 编译的 make Image 内核,它被 linux 识别为 Windows 可执行文件。至少它获得了 Windows 图标。

在 Cutter 上,我打开并被 pe64

识别

根据Documentation/arm64/booting.rst,这是未压缩时的内核头

======aarch64 kernel header========
u32 code0;          /* Executable code */
u32 code1;          /* Executable code */
u64 text_offset;        /* Image load offset,little endian */
u64 image_size;     /* Effective Image size,little endian */
u64 flags;          /* kernel flags,little endian */
u64 res2    = 0;        /* reserved */
u64 res3    = 0;        /* reserved */
u64 res4    = 0;        /* reserved */
u32 magic   = 0x644d5241;   /* Magic number,little endian,"ARM\x64" */
u32 res5;           /* reserved (used for PE COFF offset) */
====================================

为了被识别为 PE64,前 2 个字节应该是 4D 5A,但我在内核头文件中没有看到这种情况

解决方法

它不是 PE64;是COFF。由于某种原因,您的工具将任何 COFF 识别为 Windows 可执行文件。 COFF 很少见,但 ARM 仍然在引导固件中使用它,所以这就是你得到的。