205-backtrace_module_info.patch 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. From: Felix Fietkau <[email protected]>
  2. Subject: kernel: when KALLSYMS is disabled, print module address + size for matching backtrace entries
  3. [[email protected]: felix will add this to his upstream queue]
  4. [email protected]: fixed FTB when CONFIG_MODULES=n
  5. lede-commit 53827cdc824556cda910b23ce5030c363b8f1461
  6. Signed-off-by: Felix Fietkau <[email protected]>
  7. Signed-off-by: Maksim Dmitrichenko <[email protected]>
  8. ---
  9. lib/vsprintf.c | 15 +++++++++++----
  10. 1 file changed, 11 insertions(+), 4 deletions(-)
  11. --- a/lib/vsprintf.c
  12. +++ b/lib/vsprintf.c
  13. @@ -990,8 +990,12 @@ char *symbol_string(char *buf, char *end
  14. struct printf_spec spec, const char *fmt)
  15. {
  16. unsigned long value;
  17. -#ifdef CONFIG_KALLSYMS
  18. char sym[KSYM_SYMBOL_LEN];
  19. +#ifndef CONFIG_KALLSYMS
  20. +#ifdef CONFIG_MODULES
  21. + struct module *mod;
  22. +#endif
  23. + int len;
  24. #endif
  25. if (fmt[1] == 'R')
  26. @@ -1012,8 +1016,16 @@ char *symbol_string(char *buf, char *end
  27. return string_nocheck(buf, end, sym, spec);
  28. #else
  29. - return special_hex_number(buf, end, value, sizeof(void *));
  30. + len = snprintf(sym, sizeof(sym), "0x%lx", value);
  31. +#ifdef CONFIG_MODULES
  32. + mod = __module_address(value);
  33. + if (mod)
  34. + snprintf(sym + len, sizeof(sym) - len, " [%s@%p+0x%x]",
  35. + mod->name, mod->mem[MOD_TEXT].base,
  36. + mod->mem[MOD_TEXT].size);
  37. +#endif
  38. #endif
  39. + return string(buf, end, sym, spec);
  40. }
  41. static const struct printf_spec default_str_spec = {