3

What is the purpose of ‘checksum’?

The field ‘checksum’ is a 32-bit unsigned value which, when added to the other magic fields (i.e. ‘magic’ and ‘flags’), must have a 32-bit unsigned sum of zero.

dd 0x100000000 - (0xe85250d6 + 0 + (header_end - header_start))
Fifoernik
  • 9,779
  • 1
  • 21
  • 27

1 Answers1

5

The purpose is to verify that the multiboot header is in fact a multiboot header. The magic number 0xE85250D6 isn't sufficient to verify this because this magic number could appear either by chance or design in non-multiboot executables. For example a program for working with multiboot executables could easily have this magic number somewhere in it.

Its purpose is not to detect errors as it's pointless to only check the multiboot header for corruption. If corruption is a possibility then the entire executable needs to be verified.

Fifoernik
  • 9,779
  • 1
  • 21
  • 27
Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
  • Ross, why do you think that magic is 0xE85250D6? https://www.gnu.org/software/grub/manual/multiboot/multiboot.html https://www.gnu.org/software/grub/manual/multiboot/html_node/Header-magic-fields.html http://alex.dzyoba.com/programming/multiboot.html http://wiki.osdev.org/Higher_Half_x86_Bare_Bones https://lists.gnu.org/archive/html/pupa-devel/2003-11/msg00026.html lists it as 0x1BADB002 (or 0x2BADB002 in PUPA - https://lists.gnu.org/archive/html/pupa-devel/2003-11/msg00026.html). – osgx Mar 27 '17 at 00:36
  • 2
    @osgx Because it's magic number the original poster used. It's the multiboot2 magic number. – Ross Ridge Mar 27 '17 at 01:15
  • Ross, Thanks. Does multiboot scan huge parts of data for this magic? – osgx Mar 27 '17 at 01:22
  • 1
    @osgx For multiboot2 the header needs to be in the first 32k of the OS image. For the original multiboot the header needs to be in first 8k of the image. – Ross Ridge Mar 27 '17 at 01:25