summaryrefslogtreecommitdiffstats
path: root/scripts/objdiff
blob: b3e4f10bfc3edac5a5119d31f432371f8e75feee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/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
#
# Note: 'make mrproper' will also remove .tmp_objdiff

GIT_DIR="`git rev-parse --git-dir`"

if [ -d "$GIT_DIR" ]; then
	TMPD="${GIT_DIR%git}tmp_objdiff"

	[ -d "$TMPD" ] || mkdir "$TMPD"
else
	echo "ERROR: git directory not found."
	exit 1
fi

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="$TMPD/$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"
	done
}

dodiff() {
	[ $# -ne 2 ] && [ $# -ne 0 ] && usage

	if [ $# -eq 0 ]; then
		SRC="`git rev-parse --short HEAD^`"
		DST="`git rev-parse --short HEAD`"
	else
		SRC="`git rev-parse --short $1`"
		DST="`git rev-parse --short $2`"
	fi

	DIFF="`which colordiff`"

	if [ ${#DIFF} -eq 0 ] || [ ! -x "$DIFF" ]; then
		DIFF="`which diff`"
	fi

	SRCD="$TMPD/$SRC"
	DSTD="$TMPD/$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 $TMPD/*
	else
		CMT="`git rev-parse --short $1`"

		if [ -d "$TMPD/$CMT" ]; then
			rm -rf $TMPD/$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
hl opt">; /* 0x2C: Automatic Polling Timer Control Register */ uint32_t dblac; /* 0x30: DMA Burst Length&Arbitration Control */ uint32_t revr; /* 0x34: Revision Register */ uint32_t fear; /* 0x38: Feature Register */ uint32_t rsvd[19]; uint32_t maccr; /* 0x88: MAC Control Register */ uint32_t macsr; /* 0x8C: MAC Status Register */ uint32_t phycr; /* 0x90: PHY Control Register */ uint32_t phydr; /* 0x94: PHY Data Register */ uint32_t fcr; /* 0x98: Flow Control Register */ uint32_t bpr; /* 0x9C: Back Pressure Register */ }; /* * Interrupt status/mask register(ISR/IMR) bits */ #define ISR_ALL 0x3ff #define ISR_PHYSTCHG (1 << 9) /* phy status change */ #define ISR_AHBERR (1 << 8) /* bus error */ #define ISR_RXLOST (1 << 7) /* rx lost */ #define ISR_RXFIFO (1 << 6) /* rx to fifo */ #define ISR_TXLOST (1 << 5) /* tx lost */ #define ISR_TXOK (1 << 4) /* tx to ethernet */ #define ISR_NOTXBUF (1 << 3) /* out of tx buffer */ #define ISR_TXFIFO (1 << 2) /* tx to fifo */ #define ISR_NORXBUF (1 << 1) /* out of rx buffer */ #define ISR_RXOK (1 << 0) /* rx to buffer */ /* * MACCR control bits */ #define MACCR_100M (1 << 18) /* 100Mbps mode */ #define MACCR_RXBCST (1 << 17) /* rx broadcast packet */ #define MACCR_RXMCST (1 << 16) /* rx multicast packet */ #define MACCR_FD (1 << 15) /* full duplex */ #define MACCR_CRCAPD (1 << 14) /* tx crc append */ #define MACCR_RXALL (1 << 12) /* rx all packets */ #define MACCR_RXFTL (1 << 11) /* rx packet even it's > 1518 byte */ #define MACCR_RXRUNT (1 << 10) /* rx packet even it's < 64 byte */ #define MACCR_RXMCSTHT (1 << 9) /* rx multicast hash table */ #define MACCR_RXEN (1 << 8) /* rx enable */ #define MACCR_RXINHDTX (1 << 6) /* rx in half duplex tx */ #define MACCR_TXEN (1 << 5) /* tx enable */ #define MACCR_CRCDIS (1 << 4) /* tx packet even it's crc error */ #define MACCR_LOOPBACK (1 << 3) /* loop-back */ #define MACCR_RESET (1 << 2) /* reset */ #define MACCR_RXDMAEN (1 << 1) /* rx dma enable */ #define MACCR_TXDMAEN (1 << 0) /* tx dma enable */ /* * PHYCR control bits */ #define PHYCR_READ (1 << 26) #define PHYCR_WRITE (1 << 27) #define PHYCR_REG_SHIFT 21 #define PHYCR_ADDR_SHIFT 16 /* * ITC control bits */ /* Tx Cycle Length */ #define ITC_TX_CYCLONG (1 << 15) /* 100Mbps=81.92us; 10Mbps=819.2us */ #define ITC_TX_CYCNORM (0 << 15) /* 100Mbps=5.12us; 10Mbps=51.2us */ /* Tx Threshold: Aggregate n interrupts as 1 interrupt */ #define ITC_TX_THR(n) (((n) & 0x7) << 12) /* Tx Interrupt Timeout = n * Tx Cycle */ #define ITC_TX_ITMO(n) (((n) & 0xf) << 8) /* Rx Cycle Length */ #define ITC_RX_CYCLONG (1 << 7) /* 100Mbps=81.92us; 10Mbps=819.2us */ #define ITC_RX_CYCNORM (0 << 7) /* 100Mbps=5.12us; 10Mbps=51.2us */ /* Rx Threshold: Aggregate n interrupts as 1 interrupt */ #define ITC_RX_THR(n) (((n) & 0x7) << 4) /* Rx Interrupt Timeout = n * Rx Cycle */ #define ITC_RX_ITMO(n) (((n) & 0xf) << 0) #define ITC_DEFAULT \ (ITC_TX_THR(1) | ITC_TX_ITMO(0) | ITC_RX_THR(1) | ITC_RX_ITMO(0)) /* * APTC contrl bits */ /* Tx Cycle Length */ #define APTC_TX_CYCLONG (1 << 12) /* 100Mbps=81.92us; 10Mbps=819.2us */ #define APTC_TX_CYCNORM (0 << 12) /* 100Mbps=5.12us; 10Mbps=51.2us */ /* Tx Poll Timeout = n * Tx Cycle, 0=No auto polling */ #define APTC_TX_PTMO(n) (((n) & 0xf) << 8) /* Rx Cycle Length */