[PATCH v1 1/1] scripts/decodecode: Decode 32-bit code correctly on x86_64

From: Andy Shevchenko
Date: Fri Mar 05 2021 - 13:40:51 EST


On x86_64 host the objdump uses current architecture which is 64-bit
and hence decodecode shows wrong instructions.

Fix it by supplying '-M i386' in case of ARCH i?86 or x86.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
scripts/decodecode | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/scripts/decodecode b/scripts/decodecode
index 31d884e35f2f..020a84982249 100755
--- a/scripts/decodecode
+++ b/scripts/decodecode
@@ -75,21 +75,25 @@ disas() {

${CROSS_COMPILE}as $AFLAGS -o $t.o $t.s > /dev/null 2>&1

- if [ "$ARCH" = "arm" ]; then
+ case "$ARCH" in
+ arm)
if [ $width -eq 2 ]; then
OBJDUMPFLAGS="-M force-thumb"
fi

${CROSS_COMPILE}strip $t.o
- fi
-
- if [ "$ARCH" = "arm64" ]; then
+ ;;
+ arm64)
if [ $width -eq 4 ]; then
type=inst
fi

${CROSS_COMPILE}strip $t.o
- fi
+ ;;
+ i?86|x86)
+ OBJDUMPFLAGS="-M i386"
+ ;;
+ esac

if [ $pc_sub -ne 0 ]; then
if [ $PC ]; then
--
2.30.1