All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Cooper <jason@lakedaemon.net>
To: Greg KH <gregkh@linuxfoundation.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>
Cc: devel@driverdev.osuosl.org, linux-crypto@vger.kernel.org,
	Jason Cooper <jason@lakedaemon.net>
Subject: [RFC PATCH 01/22] scripts: objdiff: detect object code changes between two commits
Date: Tue, 11 Mar 2014 21:32:33 +0000	[thread overview]
Message-ID: <cc773270b6481ffe69516d994fbe98c13bcfdb5a.1394570067.git.jason@lakedaemon.net> (raw)
In-Reply-To: <cover.1394570067.git.jason@lakedaemon.net>
In-Reply-To: <cover.1394570067.git.jason@lakedaemon.net>

objdiff is useful when doing large code cleanups.  For example, when
removing checkpatch warnings and errors from new drivers in the staging
tree.

objdiff can be used in conjunction with a git rebase to confirm that
each commit made no changes to the resulting object code.  It has the
same return values as diff(1).

This was written specifically to support adding the skein and threefish
cryto drivers to the staging tree.  I needed a programmatic way to
confirm that commits changing >90% of the lines didn't inadvertently
change the code.

Signed-off-by: Jason Cooper <jason@lakedaemon.net>
---
 scripts/objdiff | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100755 scripts/objdiff

diff --git a/scripts/objdiff b/scripts/objdiff
new file mode 100755
index 000000000000..9e1ad8df2d07
--- /dev/null
+++ b/scripts/objdiff
@@ -0,0 +1,126 @@
+#!/bin/bash
+
+# objdiff - a small script for validating that a commit or series of commits
+# didn't change object code.
+#
+# Copyright 2014, Jason Cooper <jason@lakedaemon.net>
+#
+# Licensed under the terms of the GNU GPL version 2
+
+# usage example:
+#
+# $ git checkout COMMIT_A
+# $ <your fancy build command here>
+# $ ./scripts/objdiff record path/to/*.o
+#
+# $ git checkout COMMIT_B
+# $ <your fancy build command here>
+# $ ./scripts/objdiff record path/to/*.o
+#
+# $ ./scripts/objdiff diff COMMIT_A COMMIT_B
+# $
+
+# And to clean up (everything is in /tmp/objdiff-*)
+# $ ./scripts/objdiff clean all
+
+usage() {
+	echo "Usage: $0 <command> <args>"
+	echo "  record    <list of object files>"
+	echo "  diff      <commitA> <commitB>"
+	echo "  clean     all | <commit>"
+	exit 1
+}
+
+dorecord() {
+	[ $# -eq 0 ] && usage
+
+	FILES="$*"
+
+	CMT="`git rev-parse --short HEAD`"
+
+	OBJDUMP="${CROSS_COMPILE}objdump"
+	OBJDIFFD="/tmp/objdiff-$CMT"
+
+	[ ! -d "$OBJDIFFD" ] && mkdir -p "$OBJDIFFD"
+
+	for f in $FILES; do
+		dn="${f%/*}"
+		bn="${f##*/}"
+
+		[ ! -d "$OBJDIFFD/$dn" ] && mkdir -p "$OBJDIFFD/$dn"
+
+		# remove addresses for a more clear diff
+		# http://dummdida.tumblr.com/post/60924060451/binary-diff-between-libc-from-scientificlinux-and
+		$OBJDUMP -D "$f" | sed "s/^[[:space:]]\+[0-9a-f]\+//" \
+			>"$OBJDIFFD/$dn/$bn"
+
+		# force rebuild
+		rm -f "$f"
+	done
+}
+
+dodiff() {
+	[ $# -ne 2 ] && usage
+
+	SRC="`git rev-parse --short $1`"
+	DST="`git rev-parse --short $2`"
+
+	DIFF="`which colordiff`"
+
+	if [ ${#DIFF} -eq 0 ] || [ ! -x "$DIFF" ]; then
+		DIFF="`which diff`"
+	fi
+
+	SRCD="/tmp/objdiff-$SRC"
+	DSTD="/tmp/objdiff-$DST"
+
+	if [ ! -d "$SRCD" ]; then
+		echo "ERROR: $SRCD doesn't exist"
+		exit 1
+	fi
+
+	if [ ! -d "$DSTD" ]; then
+		echo "ERROR: $DSTD doesn't exist"
+		exit 1
+	fi
+
+	$DIFF -Nurd $SRCD $DSTD
+}
+
+doclean() {
+	[ $# -eq 0 ] && usage
+	[ $# -gt 1 ] && usage
+
+	if [ "x$1" = "xall" ]; then
+		rm -rf /tmp/objdiff-*
+	else
+		CMT="`git rev-parse --short $1`"
+
+		if [ -d "/tmp/objdiff-$CMT" ]; then
+			rm -rf /tmp/objdiff-$CMT
+		else
+			echo "$CMT not found"
+		fi
+	fi
+}
+
+[ $# -eq 0 ] &&	usage
+
+case "$1" in
+	record)
+		shift
+		dorecord $*
+		;;
+	diff)
+		shift
+		dodiff $*
+		;;
+	clean)
+		shift
+		doclean $*
+		;;
+	*)
+		echo "Unrecognized command '$1'"
+		exit 1
+		;;
+esac
-- 
1.9.0

  reply	other threads:[~2014-03-11 21:55 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-11 21:32 [RFC PATCH 00/22] staging: add skein/threefish crypto algos Jason Cooper
2014-03-11 21:32 ` Jason Cooper [this message]
2014-03-11 21:32 ` [RFC PATCH 02/22] staging: crypto: skein: import code from Skein3Fish.git Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 03/22] staging: crypto: skein: allow building statically Jason Cooper
2014-03-17 21:52   ` Greg KH
2014-03-18 12:58     ` Jason Cooper
2014-03-18 14:28       ` Greg KH
2014-03-24  2:22         ` Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 04/22] staging: crypto: skein: remove brg_*.h includes Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 05/22] staging: crypto: skein: remove skein_port.h Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 06/22] staging: crypto: skein: remove __cplusplus and an unneeded stddef.h Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 07/22] staging: crypto: skein: remove unneeded typedefs Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 08/22] staging: crypto: skein: remove all typedef {struct,enum} Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 09/22] staging: crypto: skein: use u8, u64 vice uint*_t Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 10/22] staging: crypto: skein: fixup pointer whitespace Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 11/22] staging: crypto: skein: cleanup whitespace around operators/punc Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 12/22] staging: crypto: skein: dos2unix, remove executable perms Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 13/22] staging: crypto: skein: fix leading whitespace Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 14/22] staging: crypto: skein: remove trailing whitespace Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 15/22] staging: crypto: skein: cleanup >80 character lines Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 16/22] staging: crypto: skein: fix do/while brace formatting Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 17/22] staging: crypto: skein: fix brace placement errors Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 18/22] staging: crypto: skein: wrap multi-line macros in do-while loops Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 19/22] staging: crypto: skein: remove externs from .c files Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 20/22] staging: crypto: skein: remove braces from single-statement block Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 21/22] staging: crypto: skein: remove unnecessary line continuation Jason Cooper
2014-03-11 21:32 ` [RFC PATCH 22/22] staging: crypto: skein: add TODO file Jason Cooper
2014-03-12 16:55 ` [RFC PATCH 00/22] staging: add skein/threefish crypto algos Jason Cooper
2014-03-24  1:48 ` [PATCH V2 00/21] " Jason Cooper
2014-03-24  1:48   ` [PATCH V2 01/21] staging: crypto: skein: import code from Skein3Fish.git Jason Cooper
2014-03-24  1:48   ` [PATCH V2 02/21] staging: crypto: skein: allow building statically Jason Cooper
2014-03-24  2:32     ` [PATCH V3 " Jason Cooper
2014-03-24  1:49   ` [PATCH V2 03/21] staging: crypto: skein: remove brg_*.h includes Jason Cooper
2014-03-24  1:49   ` [PATCH V2 04/21] staging: crypto: skein: remove skein_port.h Jason Cooper
2014-03-24  1:49   ` [PATCH V2 05/21] staging: crypto: skein: remove __cplusplus and an unneeded stddef.h Jason Cooper
2014-03-24  1:49   ` [PATCH V2 06/21] staging: crypto: skein: remove unneeded typedefs Jason Cooper
2014-03-24  1:49   ` [PATCH V2 07/21] staging: crypto: skein: remove all typedef {struct,enum} Jason Cooper
2014-03-24  1:49   ` [PATCH V2 08/21] staging: crypto: skein: use u8, u64 vice uint*_t Jason Cooper
2014-03-24  1:49   ` [PATCH V2 09/21] staging: crypto: skein: fixup pointer whitespace Jason Cooper
2014-03-24  1:49   ` [PATCH V2 10/21] staging: crypto: skein: cleanup whitespace around operators/punc Jason Cooper
2014-03-24  1:49   ` [PATCH V2 11/21] staging: crypto: skein: dos2unix, remove executable perms Jason Cooper
2014-03-24  1:49   ` [PATCH V2 12/21] staging: crypto: skein: fix leading whitespace Jason Cooper
2014-03-24  1:49   ` [PATCH V2 13/21] staging: crypto: skein: remove trailing whitespace Jason Cooper
2014-03-24  1:49   ` [PATCH V2 14/21] staging: crypto: skein: cleanup >80 character lines Jason Cooper
2014-03-24  1:49   ` [PATCH V2 15/21] staging: crypto: skein: fix do/while brace formatting Jason Cooper
2014-03-24  1:49   ` [PATCH V2 16/21] staging: crypto: skein: fix brace placement errors Jason Cooper
2014-03-24  1:49   ` [PATCH V2 17/21] staging: crypto: skein: wrap multi-line macros in do-while loops Jason Cooper
2014-03-24  1:49   ` [PATCH V2 18/21] staging: crypto: skein: remove externs from .c files Jason Cooper
2014-03-24  1:49   ` [PATCH V2 19/21] staging: crypto: skein: remove braces from single-statement block Jason Cooper
2014-03-24  1:49   ` [PATCH V2 20/21] staging: crypto: skein: remove unnecessary line continuation Jason Cooper
2014-03-24  1:49   ` [PATCH V2 21/21] staging: crypto: skein: add TODO file Jason Cooper

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=cc773270b6481ffe69516d994fbe98c13bcfdb5a.1394570067.git.jason@lakedaemon.net \
    --to=jason@lakedaemon.net \
    --cc=davem@davemloft.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.