2021-04-28 00:41:55 +03:00
|
|
|
#!/usr/bin/env kuroko
|
|
|
|
'''
|
|
|
|
@brief Generate symbol table.
|
|
|
|
'''
|
|
|
|
import fileio
|
|
|
|
|
2021-05-31 04:47:02 +03:00
|
|
|
let size = 'quad'
|
2021-04-28 00:41:55 +03:00
|
|
|
|
|
|
|
def extern(sym):
|
|
|
|
print(f'.extern {sym}')
|
|
|
|
print(f'.type {sym}, @function')
|
|
|
|
|
|
|
|
def entry(sym):
|
|
|
|
print(f'.{size} {sym}')
|
|
|
|
print(f'.asciz "{sym}"')
|
|
|
|
|
2023-11-10 09:40:41 +03:00
|
|
|
let ignore = ['abs','kernel_symbols_start','kernel_symbols_end','_GLOBAL_OFFSET_TABLE_']
|
2023-05-11 09:23:30 +03:00
|
|
|
let source = (x.strip() for x in fileio.stdin.readlines())
|
|
|
|
let symbols = set(x.split()[0] for x in source if not x.endswith(':'))
|
|
|
|
let lines = sorted(x for x in symbols if x not in ignore)
|
|
|
|
|
2021-04-28 00:41:55 +03:00
|
|
|
|
|
|
|
print('.section .symbols')
|
|
|
|
print()
|
|
|
|
for name in lines:
|
|
|
|
extern(name)
|
|
|
|
|
|
|
|
print('.global kernel_symbols_start')
|
|
|
|
print('kernel_symbols_start:')
|
|
|
|
print()
|
|
|
|
for name in lines:
|
|
|
|
entry(name)
|
|
|
|
|
|
|
|
print('.global kernel_symbols_end')
|
|
|
|
print('kernel_symbols_end:')
|