DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>,
	Ferruh Yigit <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH v2] devtools: check orphan symbols in map files
Date: Sun, 27 May 2018 23:54:47 +0200	[thread overview]
Message-ID: <20180527215447.2841-1-thomas@monjalon.net> (raw)
In-Reply-To: <4156041.IfarTdeXU8@xps>

The script check-symbol-maps.sh finds the symbols exported
in a map file but not referenced in the codebase.

Suggested-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
v2:
    - rewrite Python script from Pavan in a smaller shell script
    - check symbol as whole word (-w)
    - print one symbol per line
---
 MAINTAINERS                   |  1 +
 devtools/check-symbol-maps.sh | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100755 devtools/check-symbol-maps.sh

diff --git a/MAINTAINERS b/MAINTAINERS
index e56c72687..437777a22 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -81,6 +81,7 @@ F: devtools/check-dup-includes.sh
 F: devtools/check-maintainers.sh
 F: devtools/check-git-log.sh
 F: devtools/check-includes.sh
+F: devtools/check-symbol-maps.sh
 F: devtools/checkpatches.sh
 F: devtools/get-maintainer.sh
 F: devtools/git-log-fixes.sh
diff --git a/devtools/check-symbol-maps.sh b/devtools/check-symbol-maps.sh
new file mode 100755
index 000000000..e137d48a4
--- /dev/null
+++ b/devtools/check-symbol-maps.sh
@@ -0,0 +1,30 @@
+#! /bin/sh -e
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2018 Mellanox Technologies, Ltd
+
+cd $(dirname $0)/..
+
+# speed up by ignoring Unicode details
+export LC_ALL=C
+
+find_orphan_symbols ()
+{
+    for map in $(find lib drivers -name '*.map') ; do
+        for sym in $(sed -rn 's,^([^}]*_.*);,\1,p' $map) ; do
+            if echo $sym | grep -q '^per_lcore_' ; then
+                continue
+            fi
+            if ! grep -q -r --exclude=$(basename $map) \
+                    -w $sym $(dirname $map) ; then
+                echo "$map: $sym"
+            fi
+        done
+    done
+}
+
+orphan_symbols=$(find_orphan_symbols)
+if [ -n "$orphan_symbols" ] ; then
+    echo "Found only in symbol map file:"
+    echo "$orphan_symbols" | sed 's,^,\t,'
+    exit 1
+fi
-- 
2.16.2

  reply	other threads:[~2018-05-27 21:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-12 16:13 [dpdk-dev] [PATCH] devtools: add script to verify " Pavan Nikhilesh
2018-02-13 10:48 ` Ferruh Yigit
2018-05-27 20:50   ` Thomas Monjalon
2018-05-27 21:54     ` Thomas Monjalon [this message]
2018-05-29 15:56       ` [dpdk-dev] [PATCH v2] devtools: check orphan symbols in " Thomas Monjalon
2018-05-28  9:21     ` [dpdk-dev] [PATCH] devtools: add script to verify " Bruce Richardson
2018-05-28  9:31       ` Thomas Monjalon
2018-05-28 13:17         ` Bruce Richardson

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=20180527215447.2841-1-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=pbhagavatula@caviumnetworks.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;
as well as URLs for NNTP newsgroup(s).