From: Domenico Andreoli <domenico.andreoli@linux.com>
To: Masahiro Yamada <yamada.masahiro@socionext.com>,
Michal Marek <michal.lkml@markovi.net>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH v2] Improve diagnosis when "Inconsistent kallsyms data" happens
Date: Fri, 24 May 2019 09:55:32 +0200 [thread overview]
Message-ID: <20190524075532.zzya47562tgejgn4@dumbo> (raw)
Hi,
linking kallsyms into the kernel occasionally triggers edge conditions
of the linker heuristic and results in inconsistent System.map generation.
This patch adds a first-aid analysis of such inconsistency in form of
unified diff between the two generated symbol maps, where every symbol's
address is replaced by the offset from the previous symbol.
Becomes then trivial to spot symbols reordering without incurring in
the noise of other symbols shifting, as shown below.
$ make
...
LD vmlinux.o
MODPOST vmlinux.o
KSYM .tmp_kallsyms1.o
KSYM .tmp_kallsyms2.o
KSYM .tmp_kallsyms3.o
LD vmlinux
SORTEX vmlinux
SYSMAP System.map
SYSMAP .tmp_System.map.relative
SYSMAP System.map.relative
Inconsistent kallsyms data
Try "make KALLSYMS_EXTRA_PASS=1" as a workaround
----- .tmp_System.map.relative 2019-05-24 09:43:45.249819728 +0200
+++++ System.map.relative 2019-05-24 09:43:42.196968172 +0200
@@ -7,10 +7,10 @@
0000000000013cf78 A __rela_size
0000000000012da88 A __pecoff_data_rawsize
0000000000004e600 A __pecoff_data_size
-000000000004b7000 A __efistub_stext_offset
+000000000004a7000 A __efistub_stext_offset
000000000001719d8 A __rela_offset
0000000000026b628 A _kernel_size_le_lo32
-0ffff00000f4b3000 t __efistub__text
+0ffff00000f4c3000 t __efistub__text
00000000000000000 t _head
00000000000000000 T _text
00000000000000040 t pe_header
@@ -28619,10 +28619,10 @@
00000000000000008 r bus_spec.64271
00000000000000008 r str_spec.64272
00000000000000008 R kallsyms_offsets
-00000000000019bd0 R kallsyms_relative_base
+00000000000019bc8 R kallsyms_relative_base
00000000000000008 R kallsyms_num_syms
00000000000000008 R kallsyms_names
-0000000000004c468 R kallsyms_markers
+0000000000004c460 R kallsyms_markers
000000000000001a0 R kallsyms_token_table
00000000000000368 R kallsyms_token_index
000000000000838c8 R __start_ro_after_init
...
Changes in v2:
- *.relative files are generated by a separate function and only when
needed, this saves time and does not leave unused files around in
case of successful build
Signed-off-by: Domenico Andreoli <domenico.andreoli@linux.com>
---
scripts/link-vmlinux.sh | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
Index: b/scripts/link-vmlinux.sh
===================================================================
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -126,6 +126,28 @@ mksysmap()
${CONFIG_SHELL} "${srctree}/scripts/mksysmap" ${1} ${2}
}
+# Replace the symbol's address with the offset from the previous so
+# that in case of "Inconsistent kallsyms data" it's easier to spot
+# symbols moving around
+mksysmap_relative()
+{
+ local addr
+ local addr_size
+ local addr_prev
+ local remainder
+
+ info SYSMAP ${2}
+ while read addr remainder; do
+ if [ -z "${addr_prev}" ]; then
+ addr_size=`echo ${addr} | wc -c`
+ addr_prev=${addr}
+ fi
+ printf "%0${addr_size}x " $(( 0x${addr} - 0x${addr_prev} ))
+ echo ${remainder}
+ addr_prev=${addr}
+ done <${1} >${2}
+}
+
sortextable()
{
${objtree}/scripts/sortextable ${1}
@@ -134,10 +156,10 @@ sortextable()
# Delete output files in case of error
cleanup()
{
- rm -f .tmp_System.map
+ rm -f .tmp_System.map*
rm -f .tmp_kallsyms*
rm -f .tmp_vmlinux*
- rm -f System.map
+ rm -f System.map*
rm -f vmlinux
rm -f vmlinux.o
}
@@ -261,8 +283,13 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
mksysmap ${kallsyms_vmlinux} .tmp_System.map
if ! cmp -s System.map .tmp_System.map; then
+ mksysmap_relative .tmp_System.map .tmp_System.map.relative
+ mksysmap_relative System.map System.map.relative
+
echo >&2 Inconsistent kallsyms data
- echo >&2 Try "make KALLSYMS_EXTRA_PASS=1" as a workaround
+ echo >&2 Try \"make KALLSYMS_EXTRA_PASS=1\" as a workaround
+ diff >&2 -u .tmp_System.map.relative System.map.relative
+
exit 1
fi
fi
reply other threads:[~2019-05-24 7:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190524075532.zzya47562tgejgn4@dumbo \
--to=domenico.andreoli@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.lkml@markovi.net \
--cc=yamada.masahiro@socionext.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®