aboutsummaryrefslogtreecommitdiff
path: root/flashstub/dump-to-array.sh
diff options
context:
space:
mode:
Diffstat (limited to 'flashstub/dump-to-array.sh')
-rwxr-xr-xflashstub/dump-to-array.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/flashstub/dump-to-array.sh b/flashstub/dump-to-array.sh
new file mode 100755
index 0000000..78584d0
--- /dev/null
+++ b/flashstub/dump-to-array.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+#
+# Convert the output of objdump to an array of half-words that can be
+# included into C code to represent the stub.
+#
+# Invoke with something like this:
+#
+# objdump -z -d FILE.o | dump-to-array.sh > FILE.stub
+#
+
+sed -E "/^[ ][ ]*[0-9a-fA-F]+:/!d; s/([0-9a-fA-F]+):[ \t]+([0-9a-fA-F]+).*/[0x\1\/2] = 0x\2,/ ; s/0x(....)(....),/0x\2, 0x\1,/"