Index: kernel/generic/src/debug/symtab.c
===================================================================
--- kernel/generic/src/debug/symtab.c	(revision da139823a6e0523217c1ab89cf8936eb8fd62ea2)
+++ kernel/generic/src/debug/symtab.c	(revision dc5c303e2b29ccbf0ee833267061709da23d9de6)
@@ -36,36 +36,33 @@
  */
 
+#include <abi/elf.h>
+#include <byteorder.h>
+#include <console/prompt.h>
+#include <debug/sections.h>
+#include <errno.h>
+#include <proc/task.h>
+#include <stdio.h>
+#include <str.h>
 #include <symtab.h>
-#include <byteorder.h>
-#include <str.h>
-#include <stdio.h>
 #include <typedefs.h>
-#include <errno.h>
-#include <console/prompt.h>
-
-#include <abi/elf.h>
-#include <debug/sections.h>
-
-static inline size_t symtab_len()
-{
-	return symtab_size / sizeof(elf_symbol_t);
-}
-
-static inline const char *symtab_entry_name(int entry)
-{
-	size_t index = symtab[entry].st_name;
-
-	if (index >= strtab_size)
-		return NULL;
-
-	return strtab + index;
-}
-
-static inline size_t symtab_next(size_t i)
-{
-	for (; i < symtab_len(); i++) {
-		const char *name = symtab_entry_name(i);
-		int st_bind = elf_st_bind(symtab[i].st_info);
-		int st_type = elf_st_type(symtab[i].st_info);
+
+static inline const char *symtab_entry_name(debug_sections_t *scs, int entry)
+{
+	size_t index = scs->symtab[entry].st_name;
+
+	if (index >= scs->strtab_size)
+		return NULL;
+
+	return scs->strtab + index;
+}
+
+static inline size_t symtab_next(debug_sections_t *scs, size_t i)
+{
+	size_t symtab_len = scs->symtab_size / sizeof(elf_symbol_t);
+
+	for (; i < symtab_len; i++) {
+		const char *name = symtab_entry_name(scs, i);
+		int st_bind = elf_st_bind(scs->symtab[i].st_info);
+		int st_type = elf_st_type(scs->symtab[i].st_info);
 
 		if (st_bind == STB_LOCAL)
@@ -82,6 +79,11 @@
 }
 
-const char *symtab_name_lookup(uintptr_t addr, uintptr_t *symbol_addr)
-{
+const char *symtab_name_lookup(uintptr_t addr, uintptr_t *symbol_addr, debug_sections_t *scs)
+{
+	const elf_symbol_t *symtab = scs->symtab;
+	size_t symtab_len = scs->symtab_size / sizeof(elf_symbol_t);
+	const char *strtab = scs->strtab;
+	size_t strtab_size = scs->strtab_size;
+
 	if (symtab == NULL || strtab == NULL)
 		return NULL;
@@ -90,5 +92,5 @@
 	uintptr_t closest_symbol_name = 0;
 
-	for (size_t i = symtab_next(0); i < symtab_len(); i = symtab_next(i + 1)) {
+	for (size_t i = symtab_next(scs, 0); i < symtab_len; i = symtab_next(scs, i + 1)) {
 		if (symtab[i].st_value > addr)
 			continue;
@@ -132,5 +134,5 @@
 const char *symtab_fmt_name_lookup(uintptr_t addr)
 {
-	const char *name = symtab_name_lookup(addr, NULL);
+	const char *name = symtab_name_lookup(addr, NULL, &kernel_sections);
 	if (name == NULL)
 		name = "<unknown>";
@@ -150,7 +152,10 @@
 errno_t symtab_addr_lookup(const char *name, uintptr_t *addr)
 {
-	for (size_t i = symtab_next(0); i < symtab_len(); i = symtab_next(i + 1)) {
-		if (str_cmp(name, symtab_entry_name(i)) == 0) {
-			*addr = symtab[i].st_value;
+	debug_sections_t *scs = &kernel_sections;
+	size_t symtab_len = scs->symtab_size / sizeof(elf_symbol_t);
+
+	for (size_t i = symtab_next(scs, 0); i < symtab_len; i = symtab_next(scs, i + 1)) {
+		if (str_cmp(name, symtab_entry_name(scs, i)) == 0) {
+			*addr = scs->symtab[i].st_value;
 			return EOK;
 		}
@@ -163,5 +168,8 @@
 void symtab_print_search(const char *name)
 {
-	if (symtab == NULL || strtab == NULL) {
+	debug_sections_t *scs = &kernel_sections;
+	size_t symtab_len = scs->symtab_size / sizeof(elf_symbol_t);
+
+	if (scs->symtab == NULL || scs->strtab == NULL) {
 		printf("No symbol information available.\n");
 		return;
@@ -170,9 +178,9 @@
 	size_t namelen = str_length(name);
 
-	for (size_t i = symtab_next(0); i < symtab_len(); i = symtab_next(i + 1)) {
-		const char *n = symtab_entry_name(i);
+	for (size_t i = symtab_next(scs, 0); i < symtab_len; i = symtab_next(scs, i + 1)) {
+		const char *n = symtab_entry_name(scs, i);
 
 		if (str_lcmp(name, n, namelen) == 0) {
-			printf("%p: %s\n", (void *) symtab[i].st_value, n);
+			printf("%p: %s\n", (void *) scs->symtab[i].st_value, n);
 		}
 	}
@@ -182,5 +190,8 @@
 const char *symtab_hints_enum(const char *input, const char **help, void **ctx)
 {
-	if (symtab == NULL || strtab == NULL)
+	debug_sections_t *scs = &kernel_sections;
+	size_t symtab_len = scs->symtab_size / sizeof(elf_symbol_t);
+
+	if (scs->symtab == NULL || scs->strtab == NULL)
 		return NULL;
 
@@ -189,6 +200,6 @@
 
 	size_t len = str_length(input);
-	for (size_t i = symtab_next((size_t) *ctx); i < symtab_len(); i = symtab_next(i + 1)) {
-		const char *curname = symtab_entry_name(i);
+	for (size_t i = symtab_next(scs, (size_t) *ctx); i < symtab_len; i = symtab_next(scs, i + 1)) {
+		const char *curname = symtab_entry_name(scs, i);
 
 		if (str_lcmp(input, curname, len) == 0) {
