* [MULTIBOOT2 SPEC PATCH v4 01/27] multiboot2: Allow autogen.sh to run with current gnulib
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 02/27] multiboot2: Use .gitignore files Hans Ulrich Niedermann
` (25 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann, Daniel Kiper
Current gnulib's gnulib-tool (which is called by autogen.sh)
only runs if configure.ac contains at least AC_PREREQ(2.63).
Requiring Autoconf 2.63 (release tagged in 2008-09) instead of
Autoconf 2.59 (release 2.59 tagged in 2003-11, 2.59d in 2006-06)
should not affect too many systems in 2020.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
diff --git a/configure.ac b/configure.ac
index 585b37a36..8f21b1852 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,7 +12,7 @@ dnl "AS IS" CONDITION. THE FREE SOFTWARE FOUNDATION DISCLAIMS ANY
dnl LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE
dnl USE OF THIS SOFTWARE.
-AC_PREREQ(2.59)
+AC_PREREQ(2.63)
AC_INIT([Multiboot], [2.0], [bug-grub@gnu.org])
AC_CONFIG_SRCDIR([doc/multiboot.texi])
AC_CONFIG_HEADER([config.h])
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 02/27] multiboot2: Use .gitignore files
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 01/27] multiboot2: Allow autogen.sh to run with current gnulib Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 03/27] multiboot2: Use m4 quoting and AS_HELP_STRING Hans Ulrich Niedermann
` (24 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Add .gitignore file and remove the obsolete .bzrignore file.
As gnulib-tool (called from autogen.sh) insists on creating
doc/.gitignore (if it does not exist) or updating it (if it is
missing some patterns gnulib-tool wants ignored by git), we
add a doc/.gitignore file and the gnulib patterns there.
All other ignore patterns should be in the top-level
.gitignore file.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
delete mode 100644 .bzrignore
create mode 100644 .gitignore
create mode 100644 doc/.gitignore
diff --git a/.bzrignore b/.bzrignore
deleted file mode 100644
index fda459816..000000000
--- a/.bzrignore
+++ /dev/null
@@ -1,30 +0,0 @@
-gendocs.sh
-lib
-m4
-.deps
-Makefile
-autom4te.cache
-config.cache
-config.h
-config.log
-config.status
-stamp-h
-stamp-h1
-doc/Makefile
-doc/*.info*
-doc/.deps
-doc/gendocs_template
-doc/mdate-sh
-doc/Makefile.in
-doc/boot.S.texi
-doc/kernel
-doc/kernel.c.texi
-doc/multiboot.h.texi
-doc/texinfo.tex
-Makefile.in
-aclocal.m4
-config.h.in
-configure
-depcomp
-install-sh
-missing
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..631ff668d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,46 @@
+# Generated by "autogen.sh"
+Makefile.in
+
+/INSTALL
+/NEWS
+/README
+/aclocal.m4
+/autom4te.cache/
+/compile
+/config.h.in
+/configure
+/depcomp
+/doc/mdate-sh
+/doc/texinfo.tex
+/gendocs.sh
+/install-sh
+/lib/
+/m4/
+/missing
+
+# Generated by "configure"
+.deps/
+Makefile
+
+/config.h
+/config.log
+/config.status
+/stamp-h1
+
+# Generated by "make"
+*.o
+
+/doc/*.S.texi
+/doc/*.c.texi
+/doc/*.h.texi
+/doc/kernel
+/doc/multiboot.info*
+/doc/stamp-vti
+/doc/version.texi
+
+# Generated by "make web-manual"
+/doc/manual/
+/doc/multiboot.aux
+/doc/multiboot.cp
+/doc/multiboot.log
+/doc/multiboot.toc
diff --git a/doc/.gitignore b/doc/.gitignore
new file mode 100644
index 000000000..c8f86161e
--- /dev/null
+++ b/doc/.gitignore
@@ -0,0 +1,4 @@
+# gnulib-tool insists on having these ignore patterns in this file.
+# We keep all other ignore patterns in the top-level .gitignore file.
+/gendocs_template
+/gendocs_template_min
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 03/27] multiboot2: Use m4 quoting and AS_HELP_STRING
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 01/27] multiboot2: Allow autogen.sh to run with current gnulib Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 02/27] multiboot2: Use .gitignore files Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 04/27] multiboot2: Remove obsolete compat code for ancient Autoconf Hans Ulrich Niedermann
` (23 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Use proper m4 quoting throughout configure.ac and use AS_HELP_STRING
for the --enable-example-kernel argument.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/configure.ac b/configure.ac
index 8f21b1852..5bfc0ee5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,7 +12,7 @@ dnl "AS IS" CONDITION. THE FREE SOFTWARE FOUNDATION DISCLAIMS ANY
dnl LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE
dnl USE OF THIS SOFTWARE.
-AC_PREREQ(2.63)
+AC_PREREQ([2.63])
AC_INIT([Multiboot], [2.0], [bug-grub@gnu.org])
AC_CONFIG_SRCDIR([doc/multiboot.texi])
AC_CONFIG_HEADER([config.h])
@@ -22,7 +22,7 @@ AM_INIT_AUTOMAKE
# Programs
#
-AC_CHECK_TOOL(CC, gcc)
+AC_CHECK_TOOL([CC], [gcc])
AC_PROG_CC
AM_PROG_AS
# We need this for older versions of Autoconf.
@@ -30,17 +30,19 @@ _AM_DEPENDENCIES(CC)
dnl Because recent automake complains about AS, set it here.
CCAS="$CC"
-AC_SUBST(CCAS)
+AC_SUBST([CCAS])
-dnl Build the example Multiboot kernel.
-AC_ARG_ENABLE(example-kernel,
- [ --enable-example-kernel
- build the example Multiboot kernel])
-AM_CONDITIONAL(BUILD_EXAMPLE_KERNEL, test "x$enable_example_kernel" = xyes)
+dnl Build the example Multiboot2 kernel.
+AC_ARG_ENABLE([example-kernel], [dnl
+AS_HELP_STRING([--enable-example-kernel],
+ [build the example Multiboot2 kernel])])
+
+AM_CONDITIONAL([BUILD_EXAMPLE_KERNEL],
+ [test "x$enable_example_kernel" = xyes])
dnl Because recent automake complains about CCASFLAGS, set it here.
CCASFLAGS='$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)'
-AC_SUBST(CCASFLAGS)
+AC_SUBST([CCASFLAGS])
CFLAGS="-nostdlib $CFLAGS"
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 04/27] multiboot2: Remove obsolete compat code for ancient Autoconf
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (2 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 03/27] multiboot2: Use m4 quoting and AS_HELP_STRING Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 05/27] multiboot2: Remove CCAS workarounds for pre-2005 Automake Hans Ulrich Niedermann
` (22 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
The remark about "older versions of Autoconf" was added in 2001.
We already AC_PREREQ(2.63) which is from 2008, so we need not
worry about pre-2008 versions of Autoconf, much less about
pre-2001 versions.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/configure.ac b/configure.ac
index 5bfc0ee5b..5b5c84d1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,8 +25,6 @@ AM_INIT_AUTOMAKE
AC_CHECK_TOOL([CC], [gcc])
AC_PROG_CC
AM_PROG_AS
-# We need this for older versions of Autoconf.
-_AM_DEPENDENCIES(CC)
dnl Because recent automake complains about AS, set it here.
CCAS="$CC"
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 05/27] multiboot2: Remove CCAS workarounds for pre-2005 Automake
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (3 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 04/27] multiboot2: Remove obsolete compat code for ancient Autoconf Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 06/27] multiboot2: Remove unnecessary definition of CC Hans Ulrich Niedermann
` (21 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
The "recent automake" remark is from 2001, and the AM_PROG_AS
issues with CCAS and CCASFLAGS appear to have been solved in
the first half of the 2000s.
Just to make sure, require Automake 1.10.1 which was tagged
on 2008-08-19 which is a similar vintage as the Autoconf 2.63
version which we already require.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/configure.ac b/configure.ac
index 5b5c84d1e..37b220d0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,7 @@ AC_PREREQ([2.63])
AC_INIT([Multiboot], [2.0], [bug-grub@gnu.org])
AC_CONFIG_SRCDIR([doc/multiboot.texi])
AC_CONFIG_HEADER([config.h])
-AM_INIT_AUTOMAKE
+AM_INIT_AUTOMAKE([1.10.1])
#
# Programs
@@ -26,10 +26,6 @@ AC_CHECK_TOOL([CC], [gcc])
AC_PROG_CC
AM_PROG_AS
-dnl Because recent automake complains about AS, set it here.
-CCAS="$CC"
-AC_SUBST([CCAS])
-
dnl Build the example Multiboot2 kernel.
AC_ARG_ENABLE([example-kernel], [dnl
AS_HELP_STRING([--enable-example-kernel],
@@ -38,10 +34,6 @@ AS_HELP_STRING([--enable-example-kernel],
AM_CONDITIONAL([BUILD_EXAMPLE_KERNEL],
[test "x$enable_example_kernel" = xyes])
-dnl Because recent automake complains about CCASFLAGS, set it here.
-CCASFLAGS='$(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)'
-AC_SUBST([CCASFLAGS])
-
CFLAGS="-nostdlib $CFLAGS"
dnl Output.
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 06/27] multiboot2: Remove unnecessary definition of CC
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (4 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 05/27] multiboot2: Remove CCAS workarounds for pre-2005 Automake Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 07/27] multiboot2: Automake generates dependencies automatically Hans Ulrich Niedermann
` (20 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Remove the unnecessary separate definition of CC by AC_CHECK_TOOL.
AC_CHECK_TOOL(CC, gcc) might have been necessary back in 1999 when
this line has been written, but AC_PROG_CC has since taken over
defining CC so we do not need AC_CHECK_TOOL for this any more.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/configure.ac b/configure.ac
index 37b220d0c..d8e08597d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,6 @@ AM_INIT_AUTOMAKE([1.10.1])
# Programs
#
-AC_CHECK_TOOL([CC], [gcc])
AC_PROG_CC
AM_PROG_AS
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 07/27] multiboot2: Automake generates dependencies automatically
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (5 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 06/27] multiboot2: Remove unnecessary definition of CC Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 08/27] multiboot2: Automake cleans built programs automatically Hans Ulrich Niedermann
` (19 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Remove manual dependency line for boot.o.
This line was written in 2001-01. Some time after that, Automake
has gained the capability of automatically tracking source code
dependencies.
Also, the actual object file Automake builds would be called
kernel-boot.o, so a dependency rule for boot.o is useless anyway.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 2a5afd95d..a65b452cf 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -13,8 +13,6 @@ kernel_SOURCES = $(EXAMPLES)
kernel_CFLAGS = -fno-builtin -nostdinc -O -g -Wall \
-imacros $(top_builddir)/config.h
kernel_LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,80100000 -Wl,--build-id=none
-
-boot.o: multiboot2.h
endif
EXTRA_DIST = $(man_MANS) $(noinst_SCRIPTS) \
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 08/27] multiboot2: Automake cleans built programs automatically
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (6 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 07/27] multiboot2: Automake generates dependencies automatically Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 09/27] multiboot2: Use the constants by their proper names Hans Ulrich Niedermann
` (18 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
The "CLEANFILES = $(noinst_PROGRAMS)" definition is from 2001-01,
and Automake has learned to clean up generated files automatically
since, so we can remove this.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/doc/Makefile.am b/doc/Makefile.am
index a65b452cf..dc7816d9f 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -17,7 +17,6 @@ endif
EXTRA_DIST = $(man_MANS) $(noinst_SCRIPTS) \
$(EXAMPLES) $(multiboot_TEXINFOS)
-CLEANFILES = $(noinst_PROGRAMS)
# Cancel the rule %.texi -> %. This rule may confuse make to determine
# the dependecies.
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 09/27] multiboot2: Use the constants by their proper names
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (7 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 08/27] multiboot2: Automake cleans built programs automatically Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 10/27] multiboot2: Rename boot.S to boot_i386.S Hans Ulrich Niedermann
` (17 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
In the i386 boot.S file, use the constants with the names
multiboot2.h actually defines them as, and which boot_mips.S
has been using already.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/doc/boot.S b/doc/boot.S
index 8f6f66fcc..9ab016612 100644
--- a/doc/boot.S
+++ b/doc/boot.S
@@ -50,11 +50,11 @@ multiboot_header:
/* magic */
.long MULTIBOOT2_HEADER_MAGIC
/* ISA: i386 */
- .long GRUB_MULTIBOOT_ARCHITECTURE_I386
+ .long MULTIBOOT_ARCHITECTURE_I386
/* Header length. */
.long multiboot_header_end - multiboot_header
/* checksum */
- .long -(MULTIBOOT2_HEADER_MAGIC + GRUB_MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header))
+ .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header))
#ifndef __ELF__
address_tag_start:
.short MULTIBOOT_HEADER_TAG_ADDRESS
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 10/27] multiboot2: Rename boot.S to boot_i386.S
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (8 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 09/27] multiboot2: Use the constants by their proper names Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 11/27] multiboot2: Add boot_i386.S to shipped files Hans Ulrich Niedermann
` (16 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
The file boot.S contains only i386 specific code. Rename the file
to boot_i386.S following the pattern of having the mips specific
code in the boot_mips.S file.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
rename doc/{boot.S => boot_i386.S} (100%)
diff --git a/doc/Makefile.am b/doc/Makefile.am
index dc7816d9f..d9efe8116 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,6 +1,6 @@
info_TEXINFOS = multiboot.texi
EXAMPLES = boot_mips.S kernel.c multiboot2.h
-multiboot_TEXINFOS = boot.S.texi kernel.c.texi multiboot2.h.texi
+multiboot_TEXINFOS = boot_i386.S.texi kernel.c.texi multiboot2.h.texi
SRC2TEXI = src2texi
noinst_SCRIPTS = $(SRC2TEXI)
EXTRA_PROGRAMS = kernel
diff --git a/doc/boot.S b/doc/boot_i386.S
similarity index 100%
rename from doc/boot.S
rename to doc/boot_i386.S
diff --git a/doc/multiboot.texi b/doc/multiboot.texi
index df8a0d056..b89b12272 100644
--- a/doc/multiboot.texi
+++ b/doc/multiboot.texi
@@ -1553,9 +1553,9 @@ Multiboot2-compliant boot loader and for reference to how to implement a
Multiboot2 kernel. The source files can be found under the directory
@file{doc} in the Multiboot2 source distribution.
-The kernel @file{kernel} consists of only three files: @file{boot.S},
+The kernel @file{kernel} consists of only three files: @file{boot_i386.S},
@file{kernel.c} and @file{multiboot2.h}. The assembly source
-@file{boot.S} is written in GAS (@pxref{Top, , GNU assembler, as.info,
+@file{boot_i386.S} is written in GAS (@pxref{Top, , GNU assembler, as.info,
The GNU assembler}), and contains the Multiboot2 information structure to
comply with the specification. When a Multiboot2-compliant boot loader
loads and execute it, it initialize the stack pointer and @code{EFLAGS},
@@ -1571,7 +1571,7 @@ information structure.
@menu
* multiboot2.h::
-* boot.S::
+* boot_i386.S::
* kernel.c::
* Other Multiboot2 kernels::
@end menu
@@ -1587,13 +1587,13 @@ This is the source code in the file @file{multiboot2.h}:
@end example
-@node boot.S
-@subsection boot.S
+@node boot_i386.S
+@subsection boot_i386.S
-In the file @file{boot.S}:
+In the file @file{boot_i386.S}:
@example
-@include boot.S.texi
+@include boot_i386.S.texi
@end example
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 11/27] multiboot2: Add boot_i386.S to shipped files
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (9 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 10/27] multiboot2: Rename boot.S to boot_i386.S Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 12/27] multiboot2: Add boot_mips.S example code to docs Hans Ulrich Niedermann
` (15 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Ship the boot_i386.S file in the dist tarball as well, not
just the boot_mips.S file.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/doc/Makefile.am b/doc/Makefile.am
index d9efe8116..e88f4d271 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,5 +1,5 @@
info_TEXINFOS = multiboot.texi
-EXAMPLES = boot_mips.S kernel.c multiboot2.h
+arch_sources = boot_i386.S boot_mips.S
multiboot_TEXINFOS = boot_i386.S.texi kernel.c.texi multiboot2.h.texi
SRC2TEXI = src2texi
noinst_SCRIPTS = $(SRC2TEXI)
@@ -9,14 +9,14 @@ pkginclude_HEADERS = multiboot2.h
# The example kernel is built if you specify --enable-example-kernel.
if BUILD_EXAMPLE_KERNEL
noinst_PROGRAMS = kernel
-kernel_SOURCES = $(EXAMPLES)
+kernel_SOURCES = boot_mips.S kernel.c multiboot2.h
kernel_CFLAGS = -fno-builtin -nostdinc -O -g -Wall \
-imacros $(top_builddir)/config.h
kernel_LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,80100000 -Wl,--build-id=none
endif
EXTRA_DIST = $(man_MANS) $(noinst_SCRIPTS) \
- $(EXAMPLES) $(multiboot_TEXINFOS)
+ $(arch_sources) $(multiboot_TEXINFOS)
# Cancel the rule %.texi -> %. This rule may confuse make to determine
# the dependecies.
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 12/27] multiboot2: Add boot_mips.S example code to docs
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (10 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 11/27] multiboot2: Add boot_i386.S to shipped files Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 13/27] multiboot2: Build arch specific boot code Hans Ulrich Niedermann
` (14 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Add the boot_mips.S file to the example code documentation.
Before this, while boot_mips.S was the boot code always built,
boot_i386.S was the only documented boot code.
Now both boot_i386.S and boot_mips.S are in the docs, with
the build situation remaining unchanged.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/doc/Makefile.am b/doc/Makefile.am
index e88f4d271..08fdbf342 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,6 +1,6 @@
info_TEXINFOS = multiboot.texi
arch_sources = boot_i386.S boot_mips.S
-multiboot_TEXINFOS = boot_i386.S.texi kernel.c.texi multiboot2.h.texi
+multiboot_TEXINFOS = boot_i386.S.texi boot_mips.S.texi kernel.c.texi multiboot2.h.texi
SRC2TEXI = src2texi
noinst_SCRIPTS = $(SRC2TEXI)
EXTRA_PROGRAMS = kernel
diff --git a/doc/multiboot.texi b/doc/multiboot.texi
index b89b12272..67f0abd84 100644
--- a/doc/multiboot.texi
+++ b/doc/multiboot.texi
@@ -1553,25 +1553,30 @@ Multiboot2-compliant boot loader and for reference to how to implement a
Multiboot2 kernel. The source files can be found under the directory
@file{doc} in the Multiboot2 source distribution.
-The kernel @file{kernel} consists of only three files: @file{boot_i386.S},
-@file{kernel.c} and @file{multiboot2.h}. The assembly source
-@file{boot_i386.S} is written in GAS (@pxref{Top, , GNU assembler, as.info,
-The GNU assembler}), and contains the Multiboot2 information structure to
-comply with the specification. When a Multiboot2-compliant boot loader
-loads and execute it, it initialize the stack pointer and @code{EFLAGS},
-and then call the function @code{cmain} defined in @file{kernel.c}. If
-@code{cmain} returns to the callee, then it shows a message to inform
-the user of the halt state and stops forever until you push the reset
-key. The file @file{kernel.c} contains the function @code{cmain},
-which checks if the magic number passed by the boot loader is valid and
-so on, and some functions to print messages on the screen. The file
-@file{multiboot2.h} defines some macros, such as the magic number for the
-Multiboot2 header, the Multiboot2 header structure and the Multiboot2
-information structure.
+The kernel @file{kernel} consists of only three files:
+@file{boot_i386.S} or @file{boot_mips.S} (depending on the kernel
+architecture), @file{kernel.c}, and @file{multiboot2.h}. The assembly
+sources @file{boot_i386.S} and @file{boot_mips.S} are written in GAS
+(@pxref{Top, , GNU assembler, as.info, The GNU assembler}) and
+contain the Multiboot2 information structure to comply with the
+specification. When a Multiboot2-compliant boot loader loads and
+executes @file{boot_*.S}, it initializes the stack pointer and
+@code{EFLAGS}, and then calls the function @code{cmain} defined in
+@file{kernel.c}.
+
+If @code{cmain} returns to the callee, then it shows a message to
+inform the user of the halt state and stops forever until you push the
+system reset button. The file @file{kernel.c} contains the function
+@code{cmain}, which checks if the magic number passed by the boot
+loader is valid and so on, and some functions to print messages on the
+screen. The file @file{multiboot2.h} defines some C preprocessor
+macros, such as the magic number for the Multiboot2 header, the
+Multiboot2 header structure and the Multiboot2 information structure.
@menu
* multiboot2.h::
* boot_i386.S::
+* boot_mips.S::
* kernel.c::
* Other Multiboot2 kernels::
@end menu
@@ -1597,6 +1602,16 @@ In the file @file{boot_i386.S}:
@end example
+@node boot_mips.S
+@subsection boot_mips.S
+
+In the file @file{boot_mips.S}:
+
+@example
+@include boot_mips.S.texi
+@end example
+
+
@node kernel.c
@subsection kernel.c
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 13/27] multiboot2: Build arch specific boot code
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (11 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 12/27] multiboot2: Add boot_mips.S example code to docs Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 14/27] multiboot2: Fix example kernel header tag alignment Hans Ulrich Niedermann
` (13 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Choose the arch specific bootcode for i386 or mips, depending
on what --host is being built for.
Before this, boot_i386.S and boot_mips.S were both in the docs,
but boot_mips.S was the boot code always built regardless of the
actual system being built for.
If the --host system is neither i386 (or x86_64 which is switched
into 32bit mode) or mips, the example kernel build will be skipped.
The mips definitions for kernel_ccasflags and kernel_cflags are
completely untested.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/.gitignore b/.gitignore
index 631ff668d..e27a3e0e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,7 +7,9 @@ Makefile.in
/aclocal.m4
/autom4te.cache/
/compile
+/config.guess
/config.h.in
+/config.sub
/configure
/depcomp
/doc/mdate-sh
diff --git a/configure.ac b/configure.ac
index d8e08597d..830b1f57e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,13 +25,37 @@ AM_INIT_AUTOMAKE([1.10.1])
AC_PROG_CC
AM_PROG_AS
-dnl Build the example Multiboot2 kernel.
+dnl Build the example Multiboot2 kernel (if possible on this host)
+AC_CANONICAL_HOST
+kernel_boot_arch=unsupported
+kernel_ccasflags=
+kernel_cflags=
+case "$host_cpu" in #(
+ i[[3456]]86)
+ kernel_boot_arch=i386
+ ;; #(
+ x86_64)
+ kernel_boot_arch=i386
+ kernel_ccasflags="-m32"
+ kernel_cflags="-m32"
+ ;; #(
+ mips*)
+ kernel_boot_arch=mips
+ kernel_ccasflags="-mabi=32"
+ kernel_cflags="-mabi=32"
+ ;;
+esac
+AC_SUBST([kernel_boot_arch])
+AC_SUBST([kernel_ccasflags])
+AC_SUBST([kernel_cflags])
+
AC_ARG_ENABLE([example-kernel], [dnl
AS_HELP_STRING([--enable-example-kernel],
[build the example Multiboot2 kernel])])
AM_CONDITIONAL([BUILD_EXAMPLE_KERNEL],
- [test "x$enable_example_kernel" = xyes])
+ [test "x$enable_example_kernel" = xyes &&
+ test "x$kernel_boot_arch" != "xunsupported"])
CFLAGS="-nostdlib $CFLAGS"
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 08fdbf342..b19fc24bf 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -9,8 +9,9 @@ pkginclude_HEADERS = multiboot2.h
# The example kernel is built if you specify --enable-example-kernel.
if BUILD_EXAMPLE_KERNEL
noinst_PROGRAMS = kernel
-kernel_SOURCES = boot_mips.S kernel.c multiboot2.h
-kernel_CFLAGS = -fno-builtin -nostdinc -O -g -Wall \
+kernel_SOURCES = boot_$(kernel_boot_arch).S kernel.c multiboot2.h
+kernel_CCASFLAGS = $(kernel_ccasflags)
+kernel_CFLAGS = $(kernel_cflags) -fno-builtin -nostdinc -O -g -Wall \
-imacros $(top_builddir)/config.h
kernel_LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,80100000 -Wl,--build-id=none
endif
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 14/27] multiboot2: Fix example kernel header tag alignment
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (12 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 13/27] multiboot2: Build arch specific boot code Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 15/27] multiboot2: Remove unreferenced AOUT_KLUDGE Hans Ulrich Niedermann
` (12 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
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 <hun@n-dimensional.de>
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
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 15/27] multiboot2: Remove unreferenced AOUT_KLUDGE
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (13 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 14/27] multiboot2: Fix example kernel header tag alignment Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 16/27] multiboot2: Change "Multiboot" in comments to "Multiboot2" Hans Ulrich Niedermann
` (11 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Remove unreferenced AOUT_KLUDGE from both boot_i386.S and
boot_mips.S.
There is no reference in the example kernel to AOUT_KLUDGE or
MULTIBOOT_AOUT_KLUDGE, so this has never had a function in the
Multiboot 2 example kernel.
I presume this was something left over from the Multiboot 1
specification's example kernel.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/doc/boot_i386.S b/doc/boot_i386.S
index 0e8118b2a..c6e7f1382 100644
--- a/doc/boot_i386.S
+++ b/doc/boot_i386.S
@@ -28,13 +28,6 @@
/* The size of our stack (16KB). */
#define STACK_SIZE 0x4000
-/* The flags for the Multiboot header. */
-#ifdef __ELF__
-# define AOUT_KLUDGE 0
-#else
-# define AOUT_KLUDGE MULTIBOOT_AOUT_KLUDGE
-#endif
-
.text
.globl start, _start
diff --git a/doc/boot_mips.S b/doc/boot_mips.S
index a8d3fb0e4..2b9ee0f9c 100644
--- a/doc/boot_mips.S
+++ b/doc/boot_mips.S
@@ -28,13 +28,6 @@
/* The size of our stack (16KB). */
#define STACK_SIZE 0x4000
-/* The flags for the Multiboot header. */
-#ifdef __ELF__
-# define AOUT_KLUDGE 0
-#else
-# define AOUT_KLUDGE MULTIBOOT_AOUT_KLUDGE
-#endif
-
.text
.set noreorder
.set nomacro
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 16/27] multiboot2: Change "Multiboot" in comments to "Multiboot2"
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (14 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 15/27] multiboot2: Remove unreferenced AOUT_KLUDGE Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 17/27] multiboot2: Clean up stack (cdecl calling conventions) Hans Ulrich Niedermann
` (10 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
In source code comments, change "Multiboot" to "Multiboot2".
This forced us to touch the completely wrongly placed comment
on the 'flags' in multiboot2.h, so we have moved that comment
where it belongs and added comments for the groups of macro
definitions which now had no comments at all.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/doc/boot_i386.S b/doc/boot_i386.S
index c6e7f1382..20a600a6e 100644
--- a/doc/boot_i386.S
+++ b/doc/boot_i386.S
@@ -38,7 +38,7 @@ _start:
/* Align 64 bits boundary. */
.balign 8
- /* Multiboot header. */
+ /* Multiboot2 header. */
multiboot_header:
/* magic */
.long MULTIBOOT2_HEADER_MAGIC
@@ -94,7 +94,7 @@ multiboot_entry:
pushl $0
popf
- /* Push the pointer to the Multiboot information structure. */
+ /* Push the pointer to the Multiboot2 information structure. */
pushl %ebx
/* Push the magic value. */
pushl %eax
diff --git a/doc/boot_mips.S b/doc/boot_mips.S
index 2b9ee0f9c..3f99c81a0 100644
--- a/doc/boot_mips.S
+++ b/doc/boot_mips.S
@@ -41,7 +41,7 @@ _start:
/* Align 64 bits boundary. */
.balign 8
- /* Multiboot header. */
+ /* Multiboot2 header. */
multiboot_header:
/* magic */
.long MULTIBOOT2_HEADER_MAGIC
diff --git a/doc/kernel.c b/doc/kernel.c
index c9431e3c0..d555fbe06 100644
--- a/doc/kernel.c
+++ b/doc/kernel.c
@@ -44,7 +44,7 @@ static void itoa (char *buf, int base, int d);
static void putchar (int c);
void printf (const char *format, ...);
-/* Check if MAGIC is valid and print the Multiboot information structure
+/* Check if MAGIC is valid and print the Multiboot2 information structure
pointed by ADDR. */
void
cmain (unsigned long magic, unsigned long addr)
@@ -55,7 +55,7 @@ cmain (unsigned long magic, unsigned long addr)
/* Clear the screen. */
cls ();
- /* Am I booted by a Multiboot-compliant boot loader? */
+ /* Am I booted by a Multiboot2-compliant boot loader? */
if (magic != MULTIBOOT2_BOOTLOADER_MAGIC)
{
printf ("Invalid magic number: 0x%x\n", (unsigned) magic);
diff --git a/doc/multiboot2.h b/doc/multiboot2.h
index b18160707..d3b03d7a1 100644
--- a/doc/multiboot2.h
+++ b/doc/multiboot2.h
@@ -32,14 +32,13 @@
/* This should be in %eax. */
#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36d76289
-/* Alignment of multiboot modules. */
+/* Alignment of multiboot2 modules. */
#define MULTIBOOT_MOD_ALIGN 0x00001000
-/* Alignment of the multiboot info structure. */
+/* Alignment of the multiboot2 info structure. */
#define MULTIBOOT_INFO_ALIGN 0x00000008
-/* Flags set in the 'flags' member of the multiboot header. */
-
+/* Multiboot2 boot information tag types */
#define MULTIBOOT_TAG_ALIGN 8
#define MULTIBOOT_TAG_TYPE_END 0
#define MULTIBOOT_TAG_TYPE_CMDLINE 1
@@ -64,6 +63,7 @@
#define MULTIBOOT_TAG_TYPE_EFI64_IH 20
#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21
+/* Multiboot2 header tag types */
#define MULTIBOOT_HEADER_TAG_END 0
#define MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST 1
#define MULTIBOOT_HEADER_TAG_ADDRESS 2
@@ -76,14 +76,19 @@
#define MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 9
#define MULTIBOOT_HEADER_TAG_RELOCATABLE 10
+/* values for Multiboot2 header architecture field */
#define MULTIBOOT_ARCHITECTURE_I386 0
#define MULTIBOOT_ARCHITECTURE_MIPS32 4
+
+/* Flag set in the 'flags' member of the multiboot2 header tag. */
#define MULTIBOOT_HEADER_TAG_OPTIONAL 1
+/* Values for the Multiboot2 relocateable header tag preference field */
#define MULTIBOOT_LOAD_PREFERENCE_NONE 0
#define MULTIBOOT_LOAD_PREFERENCE_LOW 1
#define MULTIBOOT_LOAD_PREFERENCE_HIGH 2
+/* Flags for the Multiboot2 (console) flags tag */
#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 17/27] multiboot2: Clean up stack (cdecl calling conventions)
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (15 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 16/27] multiboot2: Change "Multiboot" in comments to "Multiboot2" Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 18/27] multiboot2: Use predefined #ifdef __ASSEMBLER__ Hans Ulrich Niedermann
` (9 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Clean up the stack after calling C functions according to the
i386 cdecl calling conventions.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/doc/boot_i386.S b/doc/boot_i386.S
index 20a600a6e..14dc14660 100644
--- a/doc/boot_i386.S
+++ b/doc/boot_i386.S
@@ -101,10 +101,12 @@ multiboot_entry:
/* Now enter the C main function... */
call EXT_C(cmain)
+ addl $8, %esp
/* Halt. */
pushl $halt_message
call EXT_C(printf)
+ addl $4, %esp
loop: hlt
jmp loop
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 18/27] multiboot2: Use predefined #ifdef __ASSEMBLER__
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (16 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 17/27] multiboot2: Clean up stack (cdecl calling conventions) Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 19/27] multiboot2: Set -nostdlib before AC_PROG_CC for x-compile Hans Ulrich Niedermann
` (8 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
GCC already predefines __ASSEMBLER__ for .S files (assembly with C
preprocessor), so we can just use that instead of defining our own
ASM_FILE macro.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/doc/boot_i386.S b/doc/boot_i386.S
index 14dc14660..2aa2a92b6 100644
--- a/doc/boot_i386.S
+++ b/doc/boot_i386.S
@@ -15,7 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define ASM_FILE 1
#include <multiboot2.h>
/* C symbol format. HAVE_ASM_USCORE is defined by configure. */
diff --git a/doc/boot_mips.S b/doc/boot_mips.S
index 3f99c81a0..b59e3fd6a 100644
--- a/doc/boot_mips.S
+++ b/doc/boot_mips.S
@@ -15,7 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#define ASM_FILE 1
#include <multiboot2.h>
/* C symbol format. HAVE_ASM_USCORE is defined by configure. */
diff --git a/doc/multiboot2.h b/doc/multiboot2.h
index d3b03d7a1..f89cd5e77 100644
--- a/doc/multiboot2.h
+++ b/doc/multiboot2.h
@@ -92,7 +92,7 @@
#define MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED 1
#define MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED 2
-#ifndef ASM_FILE
+#ifndef __ASSEMBLER__
typedef unsigned char multiboot_uint8_t;
typedef unsigned short multiboot_uint16_t;
@@ -417,6 +417,6 @@ struct multiboot_tag_load_base_addr
multiboot_uint32_t load_base_addr;
};
-#endif /* ! ASM_FILE */
+#endif /* ! __ASSEMBLER__ */
#endif /* ! MULTIBOOT_HEADER */
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 19/27] multiboot2: Set -nostdlib before AC_PROG_CC for x-compile
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (17 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 18/27] multiboot2: Use predefined #ifdef __ASSEMBLER__ Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 20/27] multiboot2: mips build wants __start symbol Hans Ulrich Niedermann
` (7 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Set -nostdlib in CFLAGS and LDFLAGS before AC_PROG_CC if we
appear to be cross-compiling.
This makes the example kernel build work on my x86_64 system
with both
* native compile to generate i386 example kernel
./configure --enable-example-kernel
* cross-compile to generate mips example kernel
./configure --host=mips64-linux-gnu --enable-example-kernel
It remains to be verified how this works on other systems,
namely native mips systems, and non-x86 systems like arm.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/configure.ac b/configure.ac
index 830b1f57e..6b0718451 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,11 +22,18 @@ AM_INIT_AUTOMAKE([1.10.1])
# Programs
#
+AC_CANONICAL_BUILD
+AC_CANONICAL_HOST
+
+AS_IF([test "x$host" != "x$build"], [dnl
+ CFLAGS="-nostdlib $CFLAGS"
+ LDFLAGS="-nostdlib $LDFLAGS"
+])
+
AC_PROG_CC
AM_PROG_AS
dnl Build the example Multiboot2 kernel (if possible on this host)
-AC_CANONICAL_HOST
kernel_boot_arch=unsupported
kernel_ccasflags=
kernel_cflags=
@@ -57,8 +64,6 @@ AM_CONDITIONAL([BUILD_EXAMPLE_KERNEL],
[test "x$enable_example_kernel" = xyes &&
test "x$kernel_boot_arch" != "xunsupported"])
-CFLAGS="-nostdlib $CFLAGS"
-
dnl Output.
AC_CONFIG_FILES([Makefile doc/Makefile])
AC_OUTPUT
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 20/27] multiboot2: mips build wants __start symbol
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (18 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 19/27] multiboot2: Set -nostdlib before AC_PROG_CC for x-compile Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 21/27] multiboot2: "make distcheck" with example kernel enabled Hans Ulrich Niedermann
` (6 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
When building the example kernel for mips, there is a warning
about __start being undefined and some default address being
chosen as start address.
As this does not inspire confidence, we add a __start symbol
at the same place where start and _start are already defined.
Now the mips build builds nicely.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/doc/boot_mips.S b/doc/boot_mips.S
index b59e3fd6a..a6881528f 100644
--- a/doc/boot_mips.S
+++ b/doc/boot_mips.S
@@ -31,9 +31,10 @@
.set noreorder
.set nomacro
- .globl start, _start
+ .globl start, _start, __start
start:
_start:
+__start:
b multiboot_entry
nop
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 21/27] multiboot2: "make distcheck" with example kernel enabled
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (19 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 20/27] multiboot2: mips build wants __start symbol Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 22/27] multiboot2: Always define the kernel_* vars Hans Ulrich Niedermann
` (5 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Even if no one ever does a tarball release of the Multiboot2 spec,
"make distcheck" is a good way of checking the build system's
integrity.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/Makefile.am b/Makefile.am
index 70eec9cd0..38e797aa7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,5 @@
+AM_DISTCHECK_CONFIGURE_FLAGS = --enable-example-kernel
+
# Do not change this order if you don't know what you are doing.
AUTOMAKE_OPTIONS = 1.7 gnu
SUBDIRS = doc
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 22/27] multiboot2: Always define the kernel_* vars
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (20 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 21/27] multiboot2: "make distcheck" with example kernel enabled Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 23/27] multiboot2: Generate per object file listings Hans Ulrich Niedermann
` (4 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Always define the kernel_* vars independent of the
BUILD_EXAMPLE_KERNEL conditional. This should make
sure that we actually distribute the kernel sources
even when we are not building the example kernel.
Note that this does not mean we always *build* the
example kernel. EXTRA_PROGRAMS are *not* built when
running "make all".
We still only build "if BUILD_EXAMPLE_KERNEL", which
is when noinst_PROGRAMS is set.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/doc/Makefile.am b/doc/Makefile.am
index b19fc24bf..cb290a0cb 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -9,12 +9,13 @@ pkginclude_HEADERS = multiboot2.h
# The example kernel is built if you specify --enable-example-kernel.
if BUILD_EXAMPLE_KERNEL
noinst_PROGRAMS = kernel
+endif
+
kernel_SOURCES = boot_$(kernel_boot_arch).S kernel.c multiboot2.h
kernel_CCASFLAGS = $(kernel_ccasflags)
kernel_CFLAGS = $(kernel_cflags) -fno-builtin -nostdinc -O -g -Wall \
-imacros $(top_builddir)/config.h
kernel_LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,80100000 -Wl,--build-id=none
-endif
EXTRA_DIST = $(man_MANS) $(noinst_SCRIPTS) \
$(arch_sources) $(multiboot_TEXINFOS)
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 23/27] multiboot2: Generate per object file listings
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (21 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 22/27] multiboot2: Always define the kernel_* vars Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 15:14 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 24/27] multiboot2: Generate a kernel.map map file Hans Ulrich Niedermann
` (3 subsequent siblings)
26 siblings, 1 reply; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Generate one listing file *.lst per object file *.o.
This allows easy examination of the generated machine code,
making the example kernel more educational.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/.gitignore b/.gitignore
index e27a3e0e2..7a035c267 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,7 @@ Makefile
/stamp-h1
# Generated by "make"
+*.lst
*.o
/doc/*.S.texi
diff --git a/doc/Makefile.am b/doc/Makefile.am
index cb290a0cb..cc07ceec8 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,3 +1,4 @@
+CLEANFILES =
info_TEXINFOS = multiboot.texi
arch_sources = boot_i386.S boot_mips.S
multiboot_TEXINFOS = boot_i386.S.texi boot_mips.S.texi kernel.c.texi multiboot2.h.texi
@@ -17,6 +18,10 @@ kernel_CFLAGS = $(kernel_cflags) -fno-builtin -nostdinc -O -g -Wall \
-imacros $(top_builddir)/config.h
kernel_LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,80100000 -Wl,--build-id=none
+CLEANFILES += *.lst
+kernel_CCASFLAGS += -Wa,-adhlns=$(@:.o=.lst)
+kernel_CFLAGS += -Wa,-adhlns=$(@:.o=.lst)
+
EXTRA_DIST = $(man_MANS) $(noinst_SCRIPTS) \
$(arch_sources) $(multiboot_TEXINFOS)
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [MULTIBOOT2 SPEC PATCH v4 23/27] multiboot2: Generate per object file listings
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 23/27] multiboot2: Generate per object file listings Hans Ulrich Niedermann
@ 2020-05-15 15:14 ` Hans Ulrich Niedermann
0 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 15:14 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 1903 bytes --]
I have just noticed that when running the multiboot2 build with "configure CC=clang" instead of going with the default gcc, clang10 will not recognize the "-Wa,-adhlns=$(@:.o=.lst)" argument and abort.
Ist clang support for the multiboot2 example kernel important? If so, I could either comment out those parameter additions, or guard them with a check for adhlns support and an AM_CONDITIONAL in configure.ac.
Am 15. Mai 2020 05:43:46 MESZ schrieb Hans Ulrich Niedermann <hun@n-dimensional.de>:
>Generate one listing file *.lst per object file *.o.
>
>This allows easy examination of the generated machine code,
>making the example kernel more educational.
>
>Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
>
>diff --git a/.gitignore b/.gitignore
>index e27a3e0e2..7a035c267 100644
>--- a/.gitignore
>+++ b/.gitignore
>@@ -30,6 +30,7 @@ Makefile
> /stamp-h1
>
> # Generated by "make"
>+*.lst
> *.o
>
> /doc/*.S.texi
>diff --git a/doc/Makefile.am b/doc/Makefile.am
>index cb290a0cb..cc07ceec8 100644
>--- a/doc/Makefile.am
>+++ b/doc/Makefile.am
>@@ -1,3 +1,4 @@
>+CLEANFILES =
> info_TEXINFOS = multiboot.texi
> arch_sources = boot_i386.S boot_mips.S
>multiboot_TEXINFOS = boot_i386.S.texi boot_mips.S.texi kernel.c.texi
>multiboot2.h.texi
>@@ -17,6 +18,10 @@ kernel_CFLAGS = $(kernel_cflags) -fno-builtin
>-nostdinc -O -g -Wall \
> -imacros $(top_builddir)/config.h
>kernel_LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,80100000
>-Wl,--build-id=none
>
>+CLEANFILES += *.lst
>+kernel_CCASFLAGS += -Wa,-adhlns=$(@:.o=.lst)
>+kernel_CFLAGS += -Wa,-adhlns=$(@:.o=.lst)
>+
> EXTRA_DIST = $(man_MANS) $(noinst_SCRIPTS) \
> $(arch_sources) $(multiboot_TEXINFOS)
>
>--
>2.26.2
>
>
>_______________________________________________
>Grub-devel mailing list
>Grub-devel@gnu.org
>https://lists.gnu.org/mailman/listinfo/grub-devel
[-- Attachment #2: Type: text/html, Size: 2022 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 24/27] multiboot2: Generate a kernel.map map file
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (22 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 23/27] multiboot2: Generate per object file listings Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 25/27] multiboot2: Generate gcc temp files (*.i and *.s) Hans Ulrich Niedermann
` (2 subsequent siblings)
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Generate a kernel.map map file for the example kernel.
This helps with examining the generated machine code, making
the example kernel more educational.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/.gitignore b/.gitignore
index 7a035c267..889e17f69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,6 +37,7 @@ Makefile
/doc/*.c.texi
/doc/*.h.texi
/doc/kernel
+/doc/kernel.map
/doc/multiboot.info*
/doc/stamp-vti
/doc/version.texi
diff --git a/doc/Makefile.am b/doc/Makefile.am
index cc07ceec8..21cdff0b2 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -18,6 +18,9 @@ kernel_CFLAGS = $(kernel_cflags) -fno-builtin -nostdinc -O -g -Wall \
-imacros $(top_builddir)/config.h
kernel_LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,80100000 -Wl,--build-id=none
+CLEANFILES += kernel.map
+kernel_LDFLAGS += -Wl,-Map,kernel.map
+
CLEANFILES += *.lst
kernel_CCASFLAGS += -Wa,-adhlns=$(@:.o=.lst)
kernel_CFLAGS += -Wa,-adhlns=$(@:.o=.lst)
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 25/27] multiboot2: Generate gcc temp files (*.i and *.s)
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (23 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 24/27] multiboot2: Generate a kernel.map map file Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 26/27] multiboot2: Generate symbol lists and disassembly file Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 27/27] multiboot2: Add labels around the termination tag Hans Ulrich Niedermann
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Generate gcc temporary files for each object file, showing
the intermediate steps after the C preprocessor and immediately
before assembly.
This helps with examining how the example kernel code is
generated, making the example kernel more educational.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/.gitignore b/.gitignore
index 889e17f69..f6a1b7736 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,7 +31,9 @@ Makefile
# Generated by "make"
*.lst
+*.i
*.o
+*.s
/doc/*.S.texi
/doc/*.c.texi
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 21cdff0b2..fe1e473c9 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -25,6 +25,10 @@ CLEANFILES += *.lst
kernel_CCASFLAGS += -Wa,-adhlns=$(@:.o=.lst)
kernel_CFLAGS += -Wa,-adhlns=$(@:.o=.lst)
+CLEANFILES += *.i *.s
+kernel_CCASFLAGS += -save-temps=obj
+kernel_CFLAGS += -save-temps=obj
+
EXTRA_DIST = $(man_MANS) $(noinst_SCRIPTS) \
$(arch_sources) $(multiboot_TEXINFOS)
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 26/27] multiboot2: Generate symbol lists and disassembly file
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (24 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 25/27] multiboot2: Generate gcc temp files (*.i and *.s) Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 27/27] multiboot2: Add labels around the termination tag Hans Ulrich Niedermann
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
Generate symbol lists (kernel.sym with nm and kernel.vsym
with objdump) and a complete disassembly of the finished
kernel image.
This helps with examining how the built kernel image is
actually linked and what parts of the code and data have
ended up where.
This makes the example kernel more educational.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/.gitignore b/.gitignore
index f6a1b7736..ba08c2911 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,7 +39,10 @@ Makefile
/doc/*.c.texi
/doc/*.h.texi
/doc/kernel
+/doc/kernel.lss
/doc/kernel.map
+/doc/kernel.sym
+/doc/kernel.vsym
/doc/multiboot.info*
/doc/stamp-vti
/doc/version.texi
diff --git a/configure.ac b/configure.ac
index 6b0718451..e70da14d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -31,8 +31,28 @@ AS_IF([test "x$host" != "x$build"], [dnl
])
AC_PROG_CC
+AC_PROG_GREP
AM_PROG_AS
+AC_ARG_VAR([NM], [nm tool])
+AC_CHECK_TOOL([NM], [nm])
+
+AC_ARG_VAR([OBJDUMP], [objdump tool])
+AC_CHECK_TOOL([OBJDUMP], [objdump])
+
+AC_ARG_VAR([SORT], [sort program])
+AC_PATH_PROG([SORT], [sort])
+
+AC_ARG_VAR([UNIQ], [uniq program])
+AC_PATH_PROG([UNIQ], [uniq])
+
+AC_ARG_VAR([SORT_U], [working sort -u program])
+# we are too lazy to figure out whether 'sort -u' works
+SORT_U="\${SORT} | \${UNIQ}"
+AC_SUBST([SORT_U])
+AC_MSG_CHECKING([for sort -u])
+AC_MSG_RESULT([${SORT_U} (lazy)])
+
dnl Build the example Multiboot2 kernel (if possible on this host)
kernel_boot_arch=unsupported
kernel_ccasflags=
diff --git a/doc/Makefile.am b/doc/Makefile.am
index fe1e473c9..a382b62be 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -32,6 +32,26 @@ kernel_CFLAGS += -save-temps=obj
EXTRA_DIST = $(man_MANS) $(noinst_SCRIPTS) \
$(arch_sources) $(multiboot_TEXINFOS)
+noinst_DATA =
+
+CLEANFILES += kernel.lss
+noinst_DATA += kernel.lss
+kernel.lss: kernel$(EXEEXT)
+ $(OBJDUMP) -h -S kernel$(EXEEXT) > kernel.lss.new
+ mv -f kernel.lss.new kernel.lss
+
+CLEANFILES += kernel.sym
+noinst_DATA += kernel.sym
+kernel.sym: kernel$(EXEEXT)
+ $(NM) -n kernel$(EXEEXT) | $(SORT_U) > kernel.sym.new
+ mv -f kernel.sym.new kernel.sym
+
+CLEANFILES += kernel.vsym
+noinst_DATA += kernel.vsym
+kernel.vsym: kernel$(EXEEXT)
+ $(OBJDUMP) --syms kernel$(EXEEXT) | $(GREP) '^[0-9a-f]\{4,16\} ' | $(SORT_U) > kernel.vsym.new
+ mv -f kernel.vsym.new kernel.vsym
+
# Cancel the rule %.texi -> %. This rule may confuse make to determine
# the dependecies.
.texi:
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [MULTIBOOT2 SPEC PATCH v4 27/27] multiboot2: Add labels around the termination tag
2020-05-15 3:43 [MULTIBOOT2 SPEC PATCH v4 00/27] multiboot2: Clean up the example kernel Hans Ulrich Niedermann
` (25 preceding siblings ...)
2020-05-15 3:43 ` [MULTIBOOT2 SPEC PATCH v4 26/27] multiboot2: Generate symbol lists and disassembly file Hans Ulrich Niedermann
@ 2020-05-15 3:43 ` Hans Ulrich Niedermann
26 siblings, 0 replies; 29+ messages in thread
From: Hans Ulrich Niedermann @ 2020-05-15 3:43 UTC (permalink / raw)
To: grub-devel; +Cc: Hans Ulrich Niedermann
For code consistency and more clarity as to what these .short
and .long values actually are, use the same system for labeling
the terminator header tag as for labeling all other header tags.
This improves the readability of the code, without changing
the actual output.
Signed-off-by: Hans Ulrich Niedermann <hun@n-dimensional.de>
diff --git a/doc/boot_i386.S b/doc/boot_i386.S
index 2aa2a92b6..67411b968 100644
--- a/doc/boot_i386.S
+++ b/doc/boot_i386.S
@@ -81,9 +81,11 @@ framebuffer_tag_start:
.long 32
framebuffer_tag_end:
.balign 8
+terminator_tag_start:
.short MULTIBOOT_HEADER_TAG_END
.short 0
- .long 8
+ .long terminator_tag_end - terminator_tag_start
+terminator_tag_end:
multiboot_header_end:
multiboot_entry:
/* Initialize the stack pointer. */
diff --git a/doc/boot_mips.S b/doc/boot_mips.S
index a6881528f..4d6ac1f67 100644
--- a/doc/boot_mips.S
+++ b/doc/boot_mips.S
@@ -85,9 +85,11 @@ framebuffer_tag_start:
.long 32
framebuffer_tag_end:
.balign 8
+terminator_tag_start:
.short MULTIBOOT_HEADER_TAG_END
.short 0
- .long 8
+ .long terminator_tag_end - terminator_tag_start
+terminator_tag_end:
multiboot_header_end:
multiboot_entry:
/* Initialize the stack pointer. */
--
2.26.2
^ permalink raw reply related [flat|nested] 29+ messages in thread