203-kallsyms_uncompressed.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. --- a/scripts/kallsyms.c
  2. +++ b/scripts/kallsyms.c
  3. @@ -61,6 +61,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 int base_relative = 0;
  11. @@ -446,6 +447,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. @@ -504,6 +508,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. @@ -576,6 +583,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. @@ -764,6 +774,8 @@ int main(int argc, char **argv)
  38. symbol_prefix_char = *p;
  39. } else if (strcmp(argv[i], "--base-relative") == 0)
  40. base_relative = 1;
  41. + else if (strcmp(argv[i], "--uncompressed") == 0)
  42. + uncompressed = 1;
  43. else
  44. usage();
  45. }
  46. --- a/init/Kconfig
  47. +++ b/init/Kconfig
  48. @@ -1370,6 +1370,17 @@ config SYSCTL_ARCH_UNALIGN_ALLOW
  49. the unaligned access emulation.
  50. see arch/parisc/kernel/unaligned.c for reference
  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 HAVE_PCSPKR_PLATFORM
  63. bool
  64. --- a/scripts/link-vmlinux.sh
  65. +++ b/scripts/link-vmlinux.sh
  66. @@ -136,6 +136,10 @@ kallsyms()
  67. kallsymopt="${kallsymopt} --base-relative"
  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. @@ -113,6 +113,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. @@ -145,6 +150,9 @@ tail:
  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.