Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18165efa authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Michal Marek
Browse files

scripts: objdiff: improve path flexibility for record command



Prior to this commit, scripts/objdiff expected to be run at the top
directory and only the relative path of objects.

This commit provides more flexibility in terms of object path:

[1] scripts/objdiff can be run in any directory

For example,

  $ scripts/objdiff record init/main.o

and

  $ cd init; ../scripts/objdiff record main.o

produce the same result.

[2] Support absolute path for objects

  $ scripts/objdiff record /home/foo/bar/linux/init/main.o

work as well.

Signed-off-by: default avatarMasahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: default avatarJason Cooper <jason@lakedaemon.net>
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
parent 1ecc8e48
Loading
Loading
Loading
Loading
+16 −6
Original line number Original line Diff line number Diff line
@@ -25,7 +25,7 @@
#
#
# Note: 'make mrproper' will also remove .tmp_objdiff
# Note: 'make mrproper' will also remove .tmp_objdiff


SRCTREE=$(git rev-parse --show-toplevel 2>/dev/null)
SRCTREE=$(cd $(git rev-parse --show-toplevel 2>/dev/null); pwd)


if [ -z "$SRCTREE" ]; then
if [ -z "$SRCTREE" ]; then
	echo >&2 "ERROR: Not a git repository."
	echo >&2 "ERROR: Not a git repository."
@@ -42,6 +42,18 @@ usage() {
	exit 1
	exit 1
}
}


get_output_dir() {
	dir=${1%/*}

	if [ "$dir" = "$1" ]; then
		dir=.
	fi

	dir=$(cd $dir; pwd)

	echo $TMPD/$CMT${dir#$SRCTREE}
}

dorecord() {
dorecord() {
	[ $# -eq 0 ] && usage
	[ $# -eq 0 ] && usage


@@ -50,18 +62,16 @@ dorecord() {
	CMT="`git rev-parse --short HEAD`"
	CMT="`git rev-parse --short HEAD`"


	OBJDUMP="${CROSS_COMPILE}objdump"
	OBJDUMP="${CROSS_COMPILE}objdump"
	OBJDIFFD="$TMPD/$CMT"


	for f in $FILES; do
	for f in $FILES; do
		dn="${f%/*}"
		dir=$(get_output_dir $f)
		bn="${f##*/}"
		bn="${f##*/}"


		[ ! -d "$OBJDIFFD/$dn" ] && mkdir -p "$OBJDIFFD/$dn"
		[ ! -d "$dir" ] && mkdir -p $dir


		# remove addresses for a more clear diff
		# remove addresses for a more clear diff
		# http://dummdida.tumblr.com/post/60924060451/binary-diff-between-libc-from-scientificlinux-and
		# http://dummdida.tumblr.com/post/60924060451/binary-diff-between-libc-from-scientificlinux-and
		$OBJDUMP -D "$f" | sed "s/^[[:space:]]\+[0-9a-f]\+//" \
		$OBJDUMP -D $f | sed "s/^[[:space:]]\+[0-9a-f]\+//" > $dir/$bn
			>"$OBJDIFFD/$dn/$bn"
	done
	done
}
}