summaryrefslogtreecommitdiff
path: root/common/kallsyms.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2009-06-14 22:05:42 +0200
committerWolfgang Denk <wd@denx.de>2009-06-14 22:05:42 +0200
commit92afd368bba7d98b2b7bfb51082c3639bb2119b3 (patch)
tree74ffc8a3f4980f7c6bad6bf80bb41d3974eff685 /common/kallsyms.c
parent6b1f78ae6ad037382ad430b07064105c88f7ac02 (diff)
parent388517e4b745b00256c2fa201ce7bccb67b4f245 (diff)
downloadu-boot-imx-92afd368bba7d98b2b7bfb51082c3639bb2119b3.zip
u-boot-imx-92afd368bba7d98b2b7bfb51082c3639bb2119b3.tar.gz
u-boot-imx-92afd368bba7d98b2b7bfb51082c3639bb2119b3.tar.bz2
Merge branch 'next' of ../master
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 0000000..ce42a93
--- /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;
+}