aboutsummaryrefslogtreecommitdiff
path: root/core/utils.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-11-18 19:33:51 +1100
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-11-18 19:33:51 +1100
commitc38c2e8d08e03e905b72334747a9f8795f3526c2 (patch)
tree94a7e5ec6124998eee1d1a27577370b03304c4e6 /core/utils.c
parent94796c825b0708c8c86e7135d60c435fc3fd00a5 (diff)
downloadskiboot-c38c2e8d08e03e905b72334747a9f8795f3526c2.zip
skiboot-c38c2e8d08e03e905b72334747a9f8795f3526c2.tar.gz
skiboot-c38c2e8d08e03e905b72334747a9f8795f3526c2.tar.bz2
Add symbolic backtraces and expose skiboot map to Linux
We use a double link technique, doing a first pass with a .o containing a dummy symbol map, then re-linking with a new .o Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'core/utils.c')
-rw-r--r--core/utils.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/core/utils.c b/core/utils.c
index 63046fc..1a81ae2 100644
--- a/core/utils.c
+++ b/core/utils.c
@@ -68,3 +68,30 @@ char __attrconst tohex(uint8_t nibble)
return __tohex[nibble];
}
+unsigned long get_symbol(unsigned long addr, char **sym, char **sym_end)
+{
+ unsigned long prev = 0, next;
+ char *psym = NULL, *p = __sym_map_start;
+
+ *sym = *sym_end = NULL;
+ while(p < __sym_map_end) {
+ next = strtoul(p, &p, 16) | SKIBOOT_BASE;
+ if (next > addr && prev <= addr) {
+ p = psym + 3;;
+ if (p >= __sym_map_end)
+ return 0;
+ *sym = p;
+ while(p < __sym_map_end && *p != 10)
+ p++;
+ *sym_end = p;
+ return prev;
+ }
+ prev = next;
+ psym = p;
+ while(p < __sym_map_end && *p != 10)
+ p++;
+ p++;
+ }
+ return 0;
+}
+