diff options
author | Richard Braun <rbraun@sceen.net> | 2018-07-30 20:55:20 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2018-07-30 20:55:20 +0200 |
commit | 096f0ea4c29feb19d2747f8b1eda3526952d6b0c (patch) | |
tree | 4bca4ca0e78d36029a020ce01ffb75faea01ad9c | |
parent | 8fb839b9a5fe2b9a0d44e33ab997d8fafdf6e07c (diff) |
tools/gen_symtab.py: put symbol names in the symbol table section
GCC apparently reserves memory for all symbol names in the .rodata section
which meant adding symbol names would reuse those without changing the
size of the .rodata section. That's not the case with Clang.
-rwxr-xr-x | tools/gen_symtab.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tools/gen_symtab.py b/tools/gen_symtab.py index b691da12..7a3dfef2 100755 --- a/tools/gen_symtab.py +++ b/tools/gen_symtab.py @@ -5,7 +5,6 @@ Embedded symbol table generator. import sys -symtab_size = 0 symtab = [] for line in sys.stdin: @@ -16,15 +15,19 @@ for line in sys.stdin: if len(parts) != 3 or parts[2].startswith("__func__."): continue - symtab.append("{ 0x%s, 0x%s, \"%s\" }" % tuple(parts)) - symtab_size += 1 + sym = {'addr': parts[0], 'size': parts[1], 'name': parts[2]} + symtab.append(sym) print("#include <kern/symbol.h>") + +for index, sym in enumerate(symtab): + print("static const char symbol_name_%u[] __symbol_table = \"%s\";" % (index, sym['name'])) + print("const struct symbol symbol_table[] __symbol_table = {") -for elem in symtab: - print(" " + elem + ",",) +for index, sym in enumerate(symtab): + print(" { 0x%s, 0x%s, symbol_name_%u }," % (sym['addr'], sym['size'], index)) print("};") -print("const size_t symbol_table_size = %d;" % symtab_size) +print("const size_t symbol_table_size = %d;" % len(symtab)) print("const struct symbol *symbol_table_ptr = symbol_table;") |