diff options
author | Masahiro Yamada <yamada.m@jp.panasonic.com> | 2014-06-08 22:16:37 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2014-06-10 08:59:33 -0400 |
commit | 18165efa8203a34d82f60a1831ea290e7304c654 (patch) | |
tree | e9efe9cedb1119d94c4708d93cfed23396e6a41d /scripts | |
parent | 1ecc8e489abfdaa6d8d1689f7ff62fdf1adda30c (diff) |
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: Masahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/objdiff | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/scripts/objdiff b/scripts/objdiff index 6e72f9645983..499eb4bc1e8d 100755 --- a/scripts/objdiff +++ b/scripts/objdiff | |||
@@ -25,7 +25,7 @@ | |||
25 | # | 25 | # |
26 | # Note: 'make mrproper' will also remove .tmp_objdiff | 26 | # Note: 'make mrproper' will also remove .tmp_objdiff |
27 | 27 | ||
28 | SRCTREE=$(git rev-parse --show-toplevel 2>/dev/null) | 28 | SRCTREE=$(cd $(git rev-parse --show-toplevel 2>/dev/null); pwd) |
29 | 29 | ||
30 | if [ -z "$SRCTREE" ]; then | 30 | if [ -z "$SRCTREE" ]; then |
31 | echo >&2 "ERROR: Not a git repository." | 31 | echo >&2 "ERROR: Not a git repository." |
@@ -42,6 +42,18 @@ usage() { | |||
42 | exit 1 | 42 | exit 1 |
43 | } | 43 | } |
44 | 44 | ||
45 | get_output_dir() { | ||
46 | dir=${1%/*} | ||
47 | |||
48 | if [ "$dir" = "$1" ]; then | ||
49 | dir=. | ||
50 | fi | ||
51 | |||
52 | dir=$(cd $dir; pwd) | ||
53 | |||
54 | echo $TMPD/$CMT${dir#$SRCTREE} | ||
55 | } | ||
56 | |||
45 | dorecord() { | 57 | dorecord() { |
46 | [ $# -eq 0 ] && usage | 58 | [ $# -eq 0 ] && usage |
47 | 59 | ||
@@ -50,18 +62,16 @@ dorecord() { | |||
50 | CMT="`git rev-parse --short HEAD`" | 62 | CMT="`git rev-parse --short HEAD`" |
51 | 63 | ||
52 | OBJDUMP="${CROSS_COMPILE}objdump" | 64 | OBJDUMP="${CROSS_COMPILE}objdump" |
53 | OBJDIFFD="$TMPD/$CMT" | ||
54 | 65 | ||
55 | for f in $FILES; do | 66 | for f in $FILES; do |
56 | dn="${f%/*}" | 67 | dir=$(get_output_dir $f) |
57 | bn="${f##*/}" | 68 | bn="${f##*/}" |
58 | 69 | ||
59 | [ ! -d "$OBJDIFFD/$dn" ] && mkdir -p "$OBJDIFFD/$dn" | 70 | [ ! -d "$dir" ] && mkdir -p $dir |
60 | 71 | ||
61 | # remove addresses for a more clear diff | 72 | # remove addresses for a more clear diff |
62 | # http://dummdida.tumblr.com/post/60924060451/binary-diff-between-libc-from-scientificlinux-and | 73 | # http://dummdida.tumblr.com/post/60924060451/binary-diff-between-libc-from-scientificlinux-and |
63 | $OBJDUMP -D "$f" | sed "s/^[[:space:]]\+[0-9a-f]\+//" \ | 74 | $OBJDUMP -D $f | sed "s/^[[:space:]]\+[0-9a-f]\+//" > $dir/$bn |
64 | >"$OBJDIFFD/$dn/$bn" | ||
65 | done | 75 | done |
66 | } | 76 | } |
67 | 77 | ||