[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MULTIBOOT2 SPEC PATCH v4 26/27] multiboot2: Generate symbol lists and d
From: |
Hans Ulrich Niedermann |
Subject: |
[MULTIBOOT2 SPEC PATCH v4 26/27] multiboot2: Generate symbol lists and disassembly file |
Date: |
Fri, 15 May 2020 05:43:49 +0200 |
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 <address@hidden>
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
- [MULTIBOOT2 SPEC PATCH v4 17/27] multiboot2: Clean up stack (cdecl calling conventions), (continued)
- [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
- [MULTIBOOT2 SPEC PATCH v4 24/27] multiboot2: Generate a kernel.map map file, Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 25/27] multiboot2: Generate gcc temp files (*.i and *.s), Hans Ulrich Niedermann, 2020/05/14
- [MULTIBOOT2 SPEC PATCH v4 26/27] multiboot2: Generate symbol lists and disassembly file,
Hans Ulrich Niedermann <=
- [MULTIBOOT2 SPEC PATCH v4 27/27] multiboot2: Add labels around the termination tag, Hans Ulrich Niedermann, 2020/05/14