203-kallsyms_uncompressed.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. --- a/scripts/kallsyms.c
  2. +++ b/scripts/kallsyms.c
  3. @@ -54,6 +54,7 @@ static struct text_range text_ranges[] =
  4. static struct sym_entry *table;
  5. static unsigned int table_size, table_cnt;
  6. static int all_symbols = 0;
  7. +static int uncompressed = 0;
  8. static char symbol_prefix_char = '\0';
  9. int token_profit[0x10000];
  10. @@ -360,6 +361,9 @@ static void write_src(void)
  11. free(markers);
  12. + if (uncompressed)
  13. + return;
  14. +
  15. output_label("kallsyms_token_table");
  16. off = 0;
  17. for (i = 0; i < 256; i++) {
  18. @@ -418,6 +422,9 @@ static void *find_token(unsigned char *s
  19. {
  20. int i;
  21. + if (uncompressed)
  22. + return NULL;
  23. +
  24. for (i = 0; i < len - 1; i++) {
  25. if (str[i] == token[0] && str[i+1] == token[1])
  26. return &str[i];
  27. @@ -490,6 +497,9 @@ static void optimize_result(void)
  28. {
  29. int i, best;
  30. + if (uncompressed)
  31. + return;
  32. +
  33. /* using the '\0' symbol last allows compress_symbols to use standard
  34. * fast string functions */
  35. for (i = 255; i >= 0; i--) {
  36. @@ -646,7 +656,9 @@ int main(int argc, char **argv)
  37. if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\''))
  38. p++;
  39. symbol_prefix_char = *p;
  40. - } else
  41. + } else if (strcmp(argv[i], "--uncompressed") == 0)
  42. + uncompressed = 1;
  43. + else
  44. usage();
  45. }
  46. } else if (argc != 1)
  47. --- a/init/Kconfig
  48. +++ b/init/Kconfig
  49. @@ -1257,6 +1257,17 @@ config KALLSYMS_ALL
  50. Say N unless you really need all symbols.
  51. +config KALLSYMS_UNCOMPRESSED
  52. + bool "Keep kallsyms uncompressed"
  53. + depends on KALLSYMS
  54. + help
  55. + Normally kallsyms contains compressed symbols (using a token table),
  56. + reducing the uncompressed kernel image size. Keeping the symbol table
  57. + uncompressed significantly improves the size of this part in compressed
  58. + kernel images.
  59. +
  60. + Say N unless you need compressed kernel images to be small.
  61. +
  62. config HOTPLUG
  63. def_bool y
  64. --- a/scripts/link-vmlinux.sh
  65. +++ b/scripts/link-vmlinux.sh
  66. @@ -83,6 +83,10 @@ kallsyms()
  67. kallsymopt="${kallsymopt} --all-symbols"
  68. fi
  69. + if [ -n "${CONFIG_KALLSYMS_UNCOMPRESSED}" ]; then
  70. + kallsymopt="${kallsymopt} --uncompressed"
  71. + fi
  72. +
  73. local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
  74. ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
  75. --- a/kernel/kallsyms.c
  76. +++ b/kernel/kallsyms.c
  77. @@ -106,6 +106,11 @@ static unsigned int kallsyms_expand_symb
  78. * For every byte on the compressed symbol data, copy the table
  79. * entry for that byte.
  80. */
  81. +#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
  82. + memcpy(result, data + 1, len - 1);
  83. + result += len - 1;
  84. + len = 0;
  85. +#endif
  86. while (len) {
  87. tptr = &kallsyms_token_table[kallsyms_token_index[*data]];
  88. data++;
  89. @@ -133,6 +138,9 @@ static unsigned int kallsyms_expand_symb
  90. */
  91. static char kallsyms_get_symbol_type(unsigned int off)
  92. {
  93. +#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
  94. + return kallsyms_names[off + 1];
  95. +#endif
  96. /*
  97. * Get just the first code, look it up in the token table,
  98. * and return the first char from this token.