diff options
author | Ian Moffett <ian@osmora.org> | 2024-06-04 13:41:11 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-06-04 13:45:31 -0400 |
commit | 98ccb3a2d41015b42d46d8b382decc755a003c3f (patch) | |
tree | 4e514830880a4deabebb60c38055792695314ae6 /tools/ksyms |
project: Initial commit
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'tools/ksyms')
-rwxr-xr-x | tools/ksyms | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/ksyms b/tools/ksyms new file mode 100755 index 0000000..643c3e1 --- /dev/null +++ b/tools/ksyms @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +rm -f $1 +printf "#ifndef _KSYMS_H_\n" > $1 +printf "#define _KSYMS_H_\n\n" >> $1 +printf "#include <sys/types.h>\n\nstruct kernel_symbol" >> $1 +printf " {\n\tuint64_t addr;\n\tchar* name;\n};\n\n" >> $1 +printf "const struct kernel_symbol g_ksym_table[] = {\n" >> $1 +nm $2 | grep " [tT] " | awk '{ print " { .addr = 0x"$1", .name = \""$3"\" }," }' | sort >> $1 +printf " { .addr = (size_t)-1, .name = \"\" }\n};\n\n" >> $1 +printf "const int ksym_elem_count = sizeof(g_ksym_table) / sizeof(*g_ksym_table);\n" >> $1 +printf "\n#endif /* !_KSYMS_H_ */\n" >> $1 |