Skip to content

Commit

Permalink
scripts: objdiff: support directories for the augument of record command
Browse files Browse the repository at this point in the history
For example,

  $ scripts/objdiff record init drivers/usb

disassembles all the objects under init and drivers/usb directories.

This feature would be useful when we change various files under the
specific directory.

Signed-off-by: Masahiro Yamada <[email protected]>
Acked-by: Jason Cooper <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
masahir0y authored and michal42 committed Jun 10, 2014
1 parent 8ac28be commit 7fa0e6d
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions scripts/objdiff
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TMPD=$SRCTREE/.tmp_objdiff

usage() {
echo >&2 "Usage: $0 <command> <args>"
echo >&2 " record <list of object files>"
echo >&2 " record <list of object files or directories>"
echo >&2 " diff <commitA> <commitB>"
echo >&2 " clean all | <commit>"
exit 1
Expand All @@ -54,6 +54,18 @@ get_output_dir() {
echo $TMPD/$CMT${dir#$SRCTREE}
}

do_objdump() {
dir=$(get_output_dir $1)
base=${1##*/}
dis=$dir/${base%.o}.dis

[ ! -d "$dir" ] && mkdir -p $dir

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

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

Expand All @@ -63,16 +75,15 @@ dorecord() {

OBJDUMP="${CROSS_COMPILE}objdump"

for f in $FILES; do
dir=$(get_output_dir $f)
base=${f##*/}
dis=$dir/${base%.o}.dis

[ ! -d "$dir" ] && mkdir -p $dir

# remove addresses for a cleaner diff
# http://dummdida.tumblr.com/post/60924060451/binary-diff-between-libc-from-scientificlinux-and
$OBJDUMP -D $f | sed "s/^[[:space:]]\+[0-9a-f]\+//" > $dis
for d in $FILES; do
if [ -d "$d" ]; then
for f in $(find $d -name '*.o')
do
do_objdump $f
done
else
do_objdump $d
fi
done
}

Expand Down

0 comments on commit 7fa0e6d

Please sign in to comment.