[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MULTIBOOT2 SPEC PATCH v4 14/27] multiboot2: Fix example kernel header t
From: |
Hans Ulrich Niedermann |
Subject: |
[MULTIBOOT2 SPEC PATCH v4 14/27] multiboot2: Fix example kernel header tag alignment |
Date: |
Fri, 15 May 2020 05:43:37 +0200 |
Properly align all Multiboot2 header tags to 8 byte
boundaries as per the Multiboot2 specification.
Note that the assembler directive ".align 8" is machine
dependent: On i386, it means "align to 8 byte boundary".
On mips, it means that the lower 8 bits of address must
be zero, i.e. ".align 8" aligns to a 256 byte boundary!
Therefore, this changes boot_mips.S to use ".balign 8"
where it had mistakenly used ".align 8" before, and
boot_i386.S to use ".balign 8" as well for consistency.
Note also that the Multiboot2 header termination tag
(not labeled in the source) actually needs that explicit
alignment to an 8 byte boundary in the example kernel,
as the preceding tag (framebuffer_tag_start) is 20 bytes
long which is not a multiple of 8 bytes.
You can add "-Wa,-adhlns=$(@:.o=.lst)" to kernel_CCASFLAGS
to generate a listing file which shows the offsets of the
labels in the boot_*.S files to verify the alignment issues.
Note also that you cannot detect the wrong header tag
alignment using the "grub-file --is-x86-multiboot2" utility.
It only considers the Multiboot2 header magic fields while
completely ignoring the Multiboot2 header tags.
Signed-off-by: Hans Ulrich Niedermann <address@hidden>
diff --git a/doc/boot_i386.S b/doc/boot_i386.S
index 9ab016612..0e8118b2a 100644
--- a/doc/boot_i386.S
+++ b/doc/boot_i386.S
@@ -43,7 +43,7 @@ _start:
jmp multiboot_entry
/* Align 64 bits boundary. */
- .align 8
+ .balign 8
/* Multiboot header. */
multiboot_header:
@@ -56,6 +56,7 @@ multiboot_header:
/* checksum */
.long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 +
(multiboot_header_end - multiboot_header))
#ifndef __ELF__
+ .balign 8
address_tag_start:
.short MULTIBOOT_HEADER_TAG_ADDRESS
.short MULTIBOOT_HEADER_TAG_OPTIONAL
@@ -69,6 +70,7 @@ address_tag_start:
/* bss_end_addr */
.long _end
address_tag_end:
+ .balign 8
entry_address_tag_start:
.short MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS
.short MULTIBOOT_HEADER_TAG_OPTIONAL
@@ -77,6 +79,7 @@ entry_address_tag_start:
.long multiboot_entry
entry_address_tag_end:
#endif /* __ELF__ */
+ .balign 8
framebuffer_tag_start:
.short MULTIBOOT_HEADER_TAG_FRAMEBUFFER
.short MULTIBOOT_HEADER_TAG_OPTIONAL
@@ -85,6 +88,7 @@ framebuffer_tag_start:
.long 768
.long 32
framebuffer_tag_end:
+ .balign 8
.short MULTIBOOT_HEADER_TAG_END
.short 0
.long 8
diff --git a/doc/boot_mips.S b/doc/boot_mips.S
index ed604214d..a8d3fb0e4 100644
--- a/doc/boot_mips.S
+++ b/doc/boot_mips.S
@@ -46,7 +46,7 @@ _start:
nop
/* Align 64 bits boundary. */
- .align 8
+ .balign 8
/* Multiboot header. */
multiboot_header:
@@ -59,6 +59,7 @@ multiboot_header:
/* checksum */
.long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_MIPS32 +
(multiboot_header_end - multiboot_header))
#ifndef __ELF__
+ .balign 8
address_tag_start:
.short MULTIBOOT_HEADER_TAG_ADDRESS
.short MULTIBOOT_HEADER_TAG_OPTIONAL
@@ -72,6 +73,7 @@ address_tag_start:
/* bss_end_addr */
.long _end
address_tag_end:
+ .balign 8
entry_address_tag_start:
.short MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS
.short MULTIBOOT_HEADER_TAG_OPTIONAL
@@ -80,6 +82,7 @@ entry_address_tag_start:
.long multiboot_entry
entry_address_tag_end:
#endif /* __ELF__ */
+ .balign 8
framebuffer_tag_start:
.short MULTIBOOT_HEADER_TAG_FRAMEBUFFER
.short MULTIBOOT_HEADER_TAG_OPTIONAL
@@ -88,6 +91,7 @@ framebuffer_tag_start:
.long 768
.long 32
framebuffer_tag_end:
+ .balign 8
.short MULTIBOOT_HEADER_TAG_END
.short 0
.long 8
@@ -114,6 +118,6 @@ loop: nop
halt_message:
.asciz "Halted."
- .align 8
+ .balign 8
/* Our stack area. */
.comm stack, STACK_SIZE
--
2.26.2
- [MULTIBOOT2 SPEC PATCH v4 04/27] multiboot2: Remove obsolete compat code for ancient Autoconf, (continued)
- [MULTIBOOT2 SPEC PATCH v4 04/27] multiboot2: Remove obsolete compat code for ancient Autoconf, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 05/27] multiboot2: Remove CCAS workarounds for pre-2005 Automake, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 06/27] multiboot2: Remove unnecessary definition of CC, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 07/27] multiboot2: Automake generates dependencies automatically, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 08/27] multiboot2: Automake cleans built programs automatically, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 09/27] multiboot2: Use the constants by their proper names, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 10/27] multiboot2: Rename boot.S to boot_i386.S, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 11/27] multiboot2: Add boot_i386.S to shipped files, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 12/27] multiboot2: Add boot_mips.S example code to docs, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 13/27] multiboot2: Build arch specific boot code, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 14/27] multiboot2: Fix example kernel header tag alignment,
Hans Ulrich Niedermann <=
- [MULTIBOOT2 SPEC PATCH v4 15/27] multiboot2: Remove unreferenced AOUT_KLUDGE, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 16/27] multiboot2: Change "Multiboot" in comments to "Multiboot2", Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 17/27] multiboot2: Clean up stack (cdecl calling conventions), Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 18/27] multiboot2: Use predefined #ifdef __ASSEMBLER__, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 19/27] multiboot2: Set -nostdlib before AC_PROG_CC for x-compile, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 20/27] multiboot2: mips build wants __start symbol, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 21/27] multiboot2: "make distcheck" with example kernel enabled, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 22/27] multiboot2: Always define the kernel_* vars, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 23/27] multiboot2: Generate per object file listings, Hans Ulrich Niedermann, 2020/05/14