我正在尝试编写基于它的ELF头文件来计算Linux核心转储文件大小的C代码。这是需要的,因为我将它传递给STDIN并需要传递它,首先指定它的大小,而不实际将它写入文件。将整个文件读入内存也不是一种选择。从头文件计算linux核心文件大小
首先,我寻找到核心转储头:
ELF Header:
Magic: 7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, big endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: CORE (Core file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x0
Start of program headers: 64 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 257
Size of section headers: 0 (bytes)
Number of section headers: 0
Section header string table index: 0
There are no sections in this file.
There are no sections to group in this file.
接下来,我读的程序头在一个循环,并采取一切FileSiz领域的总和。 我的假设是(ELF头大小)+(程序头大小)*(程序头数)+(所有大小的总和)将给我整个文件大小。然而,这种情况并非如此。在我的情况下,我得到的大小为729088000字节的实际文件,而上面的数学给我729054616字节。我错过了什么?