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 <h...@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 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel