sunxi-tools/thunks/objdump_to_h.awk
Bernhard Nortmann 55253760e5 thunks: Adjust build system for ARM thunk .h
"make headers" (which in turn invokes "make -C thunks/" should now
build the include files via awk, avoiding the need for ruby.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2017-01-27 23:03:18 +01: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
}