blob: 1471d69bc07cee9189a1354526b366e2758ff6c7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
BEGIN {
# > xxd -d -e -c 4 IMG
# 00004096: 1badb002 ....
#
# Split at colon to easily extract file offset.
FS = ":"
# An OS image must contain an additional header called Multiboot header,
# besides the headers of the format used by the OS image. The Multiboot
# header must be contained completely within the first 8192 bytes of the OS
# image, and must be longword (32-bit) aligned. In general, it should come
# as early as possible, and may be embedded in the beginning of the text
# segment after the real executable header.
#
# https://www.gnu.org/software/grub/manual/multiboot/multiboot.html
MBHDR_LIMIT = 8192;
MBHDR_ALIGN = 4;
MBHDR_SIZE = 3 * 4;
}
/1badb002/ {
print $0" off="$1
if ($1 > MBHDR_LIMIT - MBHDR_SIZE) {
print "FAIL: multiboot header must be in the first "$MBHDR_SIZE" bytes of the image!"
exit 1
}
if ($1 % MBHDR_ALIGN != 0) {
print "FAIL: multiboot header must be 32bit aligned!"
exit 1
}
exit 0
}
|