2014-03-10 06:36:28 +04:00
|
|
|
#!/usr/bin/env python2
|
|
|
|
# coding: utf-8
|
|
|
|
"""
|
|
|
|
Generate a symbol table from nm output.
|
|
|
|
"""
|
|
|
|
|
2015-05-20 10:12:20 +03:00
|
|
|
import sys
|
|
|
|
|
|
|
|
# Write extern + type
|
|
|
|
def extern(name):
|
|
|
|
print ".extern %s" % (name)
|
|
|
|
print ".type %s, @function" % (name)
|
|
|
|
print ""
|
|
|
|
|
|
|
|
# Write an entry
|
|
|
|
def entry(name):
|
|
|
|
print ".long %s" % (name)
|
|
|
|
print ".asciz \"%s\"" % (name)
|
|
|
|
print ""
|
|
|
|
|
|
|
|
ignore = [ "abs", "kernel_symbols_start", "kernel_symbols_end" ]
|
|
|
|
lines = [ x.strip().split(" ")[2] for x in sys.stdin.readlines() if x not in ignore ]
|
|
|
|
|
|
|
|
# Generate the assembly
|
|
|
|
print ".section .symbols"
|
|
|
|
print ""
|
|
|
|
for name in lines:
|
|
|
|
extern(name)
|
|
|
|
|
|
|
|
print ".global kernel_symbols_start"
|
2014-03-10 06:36:28 +04:00
|
|
|
print "kernel_symbols_start:"
|
2015-05-20 10:12:20 +03:00
|
|
|
print ""
|
|
|
|
for name in lines:
|
|
|
|
entry(name)
|
2014-03-10 06:36:28 +04:00
|
|
|
|
2015-05-20 10:12:20 +03:00
|
|
|
print ".global kernel_symbols_end"
|
|
|
|
print "kernel_symbols_end:"
|
2014-03-10 06:36:28 +04:00
|
|
|
|
|
|
|
|
|
|
|
|