flash: jtagspi: fix clang build warning
[openocd.git] / tools / disassemble_inc.sh
blobd4b5f80dce76eca5623061ba5be88a564ff41849
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0-or-later
4 # Simple script to disassemble a file .inc generated by
5 # src/helper/bin2char.sh
6 # Can be useful to check the correctness of the file .inc
8 # By default it decodes ARM thumb little-endian, e.g. cortex-m.
9 # Set CROSS_COMPILE for other toolchains.
10 # Set OBJDUMP_FLAGS for different objdump flags.
12 # Usage:
13 # contrib/loaders/disassemble_inc.sh file.inc
15 default_CROSS_COMPILE="arm-none-eabi-"
16 default_OBJDUMP_FLAGS="-m arm -EL -M force-thumb"
18 if [ $# != 1 -o ! -f "$1" ]; then
19 echo "Usage:"
20 echo " $0 path/to/file.inc"
21 echo ""
22 echo "Set CROSS_COMPILE and/or OBJDUMP_FLAGS to override current default:"
23 echo " export CROSS_COMPILE=\"${default_CROSS_COMPILE}\""
24 echo " export OBJDUMP_FLAGS=\"${default_OBJDUMP_FLAGS}\""
25 exit 1
28 if [ -z "${CROSS_COMPILE}" ]; then
29 CROSS_COMPILE="${default_CROSS_COMPILE}"
32 if [ -z "${OBJDUMP_FLAGS}" ]; then
33 OBJDUMP_FLAGS="${default_OBJDUMP_FLAGS}"
36 perl -v > /dev/null 2>&1
37 if [ $? != 0 ]; then
38 echo "Error: 'perl' interpreter not available."
39 exit 1
42 tmpfile=$(mktemp --suffix=.bin)
44 echo "Disassemble $1:"
45 echo "${CROSS_COMPILE}objdump ${OBJDUMP_FLAGS} -b binary -D ${tmpfile}"
47 perl -e 'while (<>){while ($_=~/(0x..)/g){print chr(hex($1));}}' $1 > ${tmpfile}
48 ${CROSS_COMPILE}objdump ${OBJDUMP_FLAGS} -b binary -D ${tmpfile}
50 rm ${tmpfile}