sunxi-tools/thunks/objdump_to_h.awk
2023-10-20 19:54:56 +08:00

34 lines
698 B
Awk

# labels
/[[:xdigit:]]+ <\w+>:/ {
# (Note: using $0 instead of $2 would also include the address)
if (style=="old")
printf "\t/* %s */\n", $2
else
printf "\t\t/* %s */\n", $2
}
# disassembly lines
/[[:xdigit:]]+:/ {
if (style=="old")
printf "\t0x%s, /* %9s %-10s", $2, $1, $3
else
printf "\t\thtole32(0x%s), /* %5s %-5s", $2, $1, $3
for (i = 4; i <= NF; i++)
if ($i == ";") {
# strip comment (anything after and including ';')
NF = i - 1
break
}
# clear $1 to $3, which re-calculates $0 (= remainder of line)
$3 = ""
$2 = ""
$1 = ""
gsub("^\\s+", "") # strip leading whitespace
if (style=="old")
printf " %-28s */\n", $0
else
printf " %-23s */\n", $0
}