203-kallsyms_uncompressed.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. --- a/scripts/kallsyms.c
  2. +++ b/scripts/kallsyms.c
  3. @@ -58,6 +58,7 @@ static struct addr_range percpu_range =
  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 int absolute_percpu = 0;
  9. static char symbol_prefix_char = '\0';
  10. static unsigned long long kernel_start_addr = 0;
  11. @@ -406,6 +407,9 @@ static void write_src(void)
  12. free(markers);
  13. + if (uncompressed)
  14. + return;
  15. +
  16. output_label("kallsyms_token_table");
  17. off = 0;
  18. for (i = 0; i < 256; i++) {
  19. @@ -464,6 +468,9 @@ static void *find_token(unsigned char *s
  20. {
  21. int i;
  22. + if (uncompressed)
  23. + return NULL;
  24. +
  25. for (i = 0; i < len - 1; i++) {
  26. if (str[i] == token[0] && str[i+1] == token[1])
  27. return &str[i];
  28. @@ -536,6 +543,9 @@ static void optimize_result(void)
  29. {
  30. int i, best;
  31. + if (uncompressed)
  32. + return;
  33. +
  34. /* using the '\0' symbol last allows compress_symbols to use standard
  35. * fast string functions */
  36. for (i = 255; i >= 0; i--) {
  37. @@ -706,7 +716,9 @@ int main(int argc, char **argv)
  38. } else if (strncmp(argv[i], "--page-offset=", 14) == 0) {
  39. const char *p = &argv[i][14];
  40. kernel_start_addr = strtoull(p, NULL, 16);
  41. - } else
  42. + } else if (strcmp(argv[i], "--uncompressed") == 0)
  43. + uncompressed = 1;
  44. + else
  45. usage();
  46. }
  47. } else if (argc != 1)
  48. --- a/init/Kconfig
  49. +++ b/init/Kconfig
  50. @@ -1358,6 +1358,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW
  51. the unaligned access emulation.
  52. see arch/parisc/kernel/unaligned.c for reference
  53. +config KALLSYMS_UNCOMPRESSED
  54. + bool "Keep kallsyms uncompressed"
  55. + depends on KALLSYMS
  56. + help
  57. + Normally kallsyms contains compressed symbols (using a token table),
  58. + reducing the uncompressed kernel image size. Keeping the symbol table
  59. + uncompressed significantly improves the size of this part in compressed
  60. + kernel images.
  61. +
  62. + Say N unless you need compressed kernel images to be small.
  63. +
  64. config HAVE_PCSPKR_PLATFORM
  65. bool
  66. --- a/scripts/link-vmlinux.sh
  67. +++ b/scripts/link-vmlinux.sh
  68. @@ -90,6 +90,10 @@ kallsyms()
  69. kallsymopt="${kallsymopt} --absolute-percpu"
  70. fi
  71. + if [ -n "${CONFIG_KALLSYMS_UNCOMPRESSED}" ]; then
  72. + kallsymopt="${kallsymopt} --uncompressed"
  73. + fi
  74. +
  75. local aflags="${KBUILD_AFLAGS} ${KBUILD_AFLAGS_KERNEL} \
  76. ${NOSTDINC_FLAGS} ${LINUXINCLUDE} ${KBUILD_CPPFLAGS}"
  77. --- a/kernel/kallsyms.c
  78. +++ b/kernel/kallsyms.c
  79. @@ -109,6 +109,11 @@ static unsigned int kallsyms_expand_symb
  80. * For every byte on the compressed symbol data, copy the table
  81. * entry for that byte.
  82. */
  83. +#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
  84. + memcpy(result, data + 1, len - 1);
  85. + result += len - 1;
  86. + len = 0;
  87. +#endif
  88. while (len) {
  89. tptr = &kallsyms_token_table[kallsyms_token_index[*data]];
  90. data++;
  91. @@ -141,6 +146,9 @@ tail:
  92. */
  93. static char kallsyms_get_symbol_type(unsigned int off)
  94. {
  95. +#ifdef CONFIG_KALLSYMS_UNCOMPRESSED
  96. + return kallsyms_names[off + 1];
  97. +#endif
  98. /*
  99. * Get just the first code, look it up in the token table,
  100. * and return the first char from this token.