aboutsummaryrefslogtreecommitdiff
path: root/tools/defsyms.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/defsyms.py')
-rwxr-xr-xtools/defsyms.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/defsyms.py b/tools/defsyms.py
new file mode 100755
index 0000000..fe18d90
--- /dev/null
+++ b/tools/defsyms.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# Simple script to convert the output from 'nm' to a C style header
+# file with defined offsets.
+#
+# Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
+#
+# This file may be distributed under the terms of the GNU GPLv3 license.
+
+import sys
+import string
+
+def main():
+ syms = []
+ lines = sys.stdin.readlines()
+ for line in lines:
+ addr, type, sym = line.split()
+ if type not in 'TA':
+ # Only interested in global symbols in text segment
+ continue
+ for c in sym:
+ if c not in string.letters + string.digits + '_':
+ break
+ else:
+ syms.append((sym, addr))
+ print """
+#ifndef __OFFSET16_AUTO_H
+#define __OFFSET16_AUTO_H
+// Auto generated file - please see defsyms.py.
+// This file contains symbol offsets of a compiled binary.
+"""
+ for sym, addr in syms:
+ print "#define OFFSET_%s 0x%s" % (sym, addr)
+ print """
+#endif // __OFFSET16_AUTO_H
+"""
+
+if __name__ == '__main__':
+ main()