summaryrefslogtreecommitdiff
path: root/tools/gen_symtab.py
blob: b691da12ad018538a00d4fec7428f582e7bbac3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
'''
Embedded symbol table generator.
'''

import sys

symtab_size = 0
symtab = []

for line in sys.stdin:
    line = line.strip()
    parts = line.split(' ')
    del parts[2]

    if len(parts) != 3 or parts[2].startswith("__func__."):
        continue

    symtab.append("{ 0x%s, 0x%s, \"%s\" }" % tuple(parts))
    symtab_size += 1

print("#include <kern/symbol.h>")
print("const struct symbol symbol_table[] __symbol_table = {")

for elem in symtab:
    print("    " + elem + ",",)

print("};")
print("const size_t symbol_table_size = %d;" % symtab_size)
print("const struct symbol *symbol_table_ptr = symbol_table;")