1 #!/bin/awk -f 2 # SPDX-License-Identifier: GPL-2.0 3 # Usage: objdump -d a.out | awk -f objdump_ref 4 # Reformats the disassembly as follows: 5 # - Removes all lines except the disassembled 6 # - For instructions that exceed 1 line (7 byt 7 # into a single line. 8 # - Remove bad(or prefix only) instructions 9 10 BEGIN { 11 prev_addr = "" 12 prev_hex = "" 13 prev_mnemonic = "" 14 bad_expr = "(\\(bad\\)|<unknown>|^rex| 15 fwait_expr = "^9b[ \t]*fwait" 16 fwait_str="9b\tfwait" 17 } 18 19 /^ *[0-9a-f]+ <[^>]*>:/ { 20 # Symbol entry 21 printf("%s%s\n", $2, $1) 22 } 23 24 /^ *[0-9a-f]+:/ { 25 if (split($0, field, /: |\t/) < 3) { 26 # This is a continuation of th 27 prev_hex = prev_hex field[2] 28 } else { 29 # Skip bad instructions 30 if (match(prev_mnemonic, bad_e 31 prev_addr = "" 32 # Split fwait from other f* in 33 if (match(prev_hex, fwait_expr 34 printf "%s\t%s\n", pre 35 sub(fwait_expr, "", pr 36 } 37 if (prev_addr != "") 38 printf "%s\t%s\t%s\n", 39 prev_addr = field[1] 40 prev_hex = field[2] 41 prev_mnemonic = field[3] 42 } 43 } 44 45 END { 46 if (prev_addr != "") 47 printf "%s\t%s\t%s\n", prev_ad 48 }
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.