2017-01-08 13:38:48 +03:00
|
|
|
#!/usr/bin/env python3
|
2014-03-10 06:36:28 +04:00
|
|
|
"""
|
2017-01-08 13:38:48 +03:00
|
|
|
Generate a symbol table from nm output.
|
2014-03-10 06:36:28 +04:00
|
|
|
"""
|
|
|
|
|
2015-05-20 10:12:20 +03:00
|
|
|
import sys
|
|
|
|
|
|
|
|
# Write extern + type
|
|
|
|
def extern(name):
|
2017-01-08 13:38:48 +03:00
|
|
|
print(".extern %s" % (name))
|
|
|
|
print(".type %s, @function" % (name))
|
|
|
|
print("")
|
2015-05-20 10:12:20 +03:00
|
|
|
|
|
|
|
# Write an entry
|
|
|
|
def entry(name):
|
2017-01-08 13:38:48 +03:00
|
|
|
print(".long %s" % (name))
|
|
|
|
print(".asciz \"%s\"" % (name))
|
|
|
|
print("")
|
2015-05-20 10:12:20 +03:00
|
|
|
|
|
|
|
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
|
2017-01-08 13:38:48 +03:00
|
|
|
print(".section .symbols")
|
|
|
|
print("")
|
2015-05-20 10:12:20 +03:00
|
|
|
for name in lines:
|
|
|
|
extern(name)
|
|
|
|
|
2017-01-08 13:38:48 +03:00
|
|
|
print(".global kernel_symbols_start")
|
|
|
|
print("kernel_symbols_start:")
|
|
|
|
print("")
|
2015-05-20 10:12:20 +03:00
|
|
|
for name in lines:
|
|
|
|
entry(name)
|
2014-03-10 06:36:28 +04:00
|
|
|
|
2017-01-08 13:38:48 +03:00
|
|
|
print(".global kernel_symbols_end")
|
|
|
|
print("kernel_symbols_end:")
|
2014-03-10 06:36:28 +04:00
|
|
|
|
|
|
|
|
|
|
|
|