blob: fe18d90505c58165b959d22e081641fe327c0f31 [file] [log] [blame]
#!/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 <>
# 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
for c in sym:
if c not in string.letters + string.digits + '_':
syms.append((sym, addr))
print """
#ifndef __OFFSET16_AUTO_H
#define __OFFSET16_AUTO_H
// Auto generated file - please see
// 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__':