chiark / gitweb /
bin/datasyms: New utility to print the writable-data symbols in object files.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 4 Sep 2019 18:10:52 +0000 (19:10 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 4 Sep 2019 18:12:10 +0000 (19:12 +0100)
It turns out that I have a habit of forgetting to declare constant
tables as being `const'.  This tool is one of the few ways to notice
that I've done this.

Makefile
bin/datasyms [new file with mode: 0755]

index 98998242415e57ebed71c8e2d8fdf8bbbbed48ac..85978ddb6140c2d65a90e882fd99d7af392e8e02 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -222,6 +222,7 @@ SCRIPTLINKS         += mdw-conf
 SCRIPTLINKS            += svnwrap
 SCRIPTLINKS            += guest-console
 SCRIPTLINKS            += hyperspec
+SCRIPTLINKS            += datasyms
 
 ## Random odds and ends.
 DOTLINKS               += .infokey .sqliterc
diff --git a/bin/datasyms b/bin/datasyms
new file mode 100755 (executable)
index 0000000..d54ede6
--- /dev/null
@@ -0,0 +1,7 @@
+#! /bin/sh -e
+objdump -t "$@" | sed -En '
+       /^(.*\.o:) .*$/ { s//\1/; h; }
+       /(\.data|\.bss|\*COM\*)[[:space:]]+[0-9]+ [^.]/ {
+               x; /./ p; s/.*//; x
+               s/^/    /; p
+       }'