2 # SPDX-License-Identifier: GPL-2.0
3 # Usage: objdump -d a.out | awk -f objdump_reformat.awk | ./insn_decoder_test
4 # Reformats the disassembly as follows:
5 # - Removes all lines except the disassembled instructions.
6 # - For instructions that exceed 1 line (7 bytes), crams all the hex bytes
8 # - Remove bad(or prefix only) instructions
14 bad_expr = "(\\(bad\\)|^rex|^.byte|^rep(z|nz)$|^lock$|^es$|^cs$|^ss$|^ds$|^fs$|^gs$|^data(16|32)$|^addr(16|32|64))"
19 /^ *[0-9a-f]+ <[^>]*>:/ {
21 printf("%s%s\n", $2, $1)
25 if (split($0, field, "\t") < 3) {
26 # This is a continuation of the same insn.
27 prev_hex = prev_hex field[2]
29 # Skip bad instructions
30 if (match(prev_mnemonic, bad_expr))
32 # Split fwait from other f* instructions
33 if (match(prev_hex, fwait_expr) && prev_mnemonic != "fwait") {
34 printf "%s\t%s\n", prev_addr, fwait_str
35 sub(fwait_expr, "", prev_hex)
38 printf "%s\t%s\t%s\n", prev_addr, prev_hex, prev_mnemonic
41 prev_mnemonic = field[3]
47 printf "%s\t%s\t%s\n", prev_addr, prev_hex, prev_mnemonic