summaryrefslogtreecommitdiff
path: root/tools/ksyms
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-06-24 23:00:41 -0400
committerIan Moffett <ian@osmora.org>2024-06-24 23:00:41 -0400
commit963478ff0ad358fc3a44ff5dba0c64ddc889f296 (patch)
treea14c3ea6feb7d1b783364737fcefabce249473ff /tools/ksyms
parent236963e7563be3e3f8220dac7bb4af446928e194 (diff)
parent6f6a36d1e8b3dd50cb4d394fa1de4888663b4ea5 (diff)
Import hyra expt
Diffstat (limited to 'tools/ksyms')
-rwxr-xr-xtools/ksyms12
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