summaryrefslogtreecommitdiffstats
path: root/common/kallsyms.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-05-20 04:35:14 -0400
committerWolfgang Denk <wd@denx.de>2009-06-12 20:45:48 +0200
commitecb1dc892297d5d99876907328fed732feefeab2 (patch)
tree60f14fd9310612bb4ee23d819d9f8fad859beda7 /common/kallsyms.c
parent36c9169aa6f79ddf604a3bca64e145654f94888b (diff)
downloadblackbird-obmc-uboot-ecb1dc892297d5d99876907328fed732feefeab2.tar.gz
blackbird-obmc-uboot-ecb1dc892297d5d99876907328fed732feefeab2.zip
Add support for Linux-like kallsysms
The kernel stores address<->symbol names in it so things can be decoded at runtime. Do it in U-Boot, and we get nice symbol decoding when crashing. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'common/kallsyms.c')
-rw-r--r--common/kallsyms.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/common/kallsyms.c b/common/kallsyms.c
new file mode 100644
index 0000000000..ce42a932bb
--- /dev/null
+++ b/common/kallsyms.c
@@ -0,0 +1,44 @@
+/*
+ * Helper functions for working with the builtin symbol table
+ *
+ * Copyright (c) 2008-2009 Analog Devices Inc.
+ * Licensed under the GPL-2 or later.
+ */
+
+#include <common.h>
+
+/* We need the weak marking as this symbol is provided specially */
+extern const char system_map[] __attribute__((weak));
+
+/* Given an address, return a pointer to the symbol name and store
+ * the base address in caddr. So if the symbol map had an entry:
+ * 03fb9b7c_spi_cs_deactivate
+ * Then the following call:
+ * unsigned long base;
+ * const char *sym = symbol_lookup(0x03fb9b80, &base);
+ * Would end up setting the variables like so:
+ * base = 0x03fb9b7c;
+ * sym = "_spi_cs_deactivate";
+ */
+const char *symbol_lookup(unsigned long addr, unsigned long *caddr)
+{
+ const char *sym, *csym;
+ char *esym;
+ unsigned long sym_addr;
+
+ sym = system_map;
+ csym = NULL;
+ *caddr = 0;
+
+ while (*sym) {
+ sym_addr = simple_strtoul(sym, &esym, 16);
+ sym = esym;
+ if (sym_addr > addr)
+ break;
+ *caddr = sym_addr;
+ csym = sym;
+ sym += strlen(sym) + 1;
+ }
+
+ return csym;
+}
OpenPOWER on IntegriCloud