Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kallsyms: get rid of code for absolute kallsyms

Commit cf8e8658100d ("arch: Remove Itanium (IA-64) architecture")
removed the last use of the absolute kallsyms.

Signed-off-by: Jann Horn <jannh@google.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/all/20240221202655.2423854-1-jannh@google.com/
[masahiroy@kernel.org: rebase the code and reword the commit description]
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Jann Horn and committed by
Masahiro Yamada
64e16609 7efcb39e

+32 -77
-18
init/Kconfig
··· 1789 1789 depends on KALLSYMS 1790 1790 default X86_64 && SMP 1791 1791 1792 - config KALLSYMS_BASE_RELATIVE 1793 - bool 1794 - depends on KALLSYMS 1795 - default y 1796 - help 1797 - Instead of emitting them as absolute values in the native word size, 1798 - emit the symbol references in the kallsyms table as 32-bit entries, 1799 - each containing a relative value in the range [base, base + U32_MAX] 1800 - or, when KALLSYMS_ABSOLUTE_PERCPU is in effect, each containing either 1801 - an absolute value in the range [0, S32_MAX] or a relative value in the 1802 - range [base, base + S32_MAX], where base is the lowest relative symbol 1803 - address encountered in the image. 1804 - 1805 - On 64-bit builds, this reduces the size of the address table by 50%, 1806 - but more importantly, it results in entries whose values are build 1807 - time constants, and no relocation pass is required at runtime to fix 1808 - up the entries based on the runtime load address of the kernel. 1809 - 1810 1792 # end of the "standard kernel features (expert users)" menu 1811 1793 1812 1794 config ARCH_HAS_MEMBARRIER_CALLBACKS
+1 -4
kernel/kallsyms.c
··· 148 148 149 149 unsigned long kallsyms_sym_address(int idx) 150 150 { 151 - if (!IS_ENABLED(CONFIG_KALLSYMS_BASE_RELATIVE)) 152 - return kallsyms_addresses[idx]; 153 - 154 151 /* values are unsigned offsets if --absolute-percpu is not in effect */ 155 152 if (!IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PERCPU)) 156 153 return kallsyms_relative_base + (u32)kallsyms_offsets[idx]; ··· 322 325 unsigned long symbol_start = 0, symbol_end = 0; 323 326 unsigned long i, low, high, mid; 324 327 325 - /* Do a binary search on the sorted kallsyms_addresses array. */ 328 + /* Do a binary search on the sorted kallsyms_offsets array. */ 326 329 low = 0; 327 330 high = kallsyms_num_syms; 328 331
-1
kernel/kallsyms_internal.h
··· 4 4 5 5 #include <linux/types.h> 6 6 7 - extern const unsigned long kallsyms_addresses[]; 8 7 extern const int kallsyms_offsets[]; 9 8 extern const u8 kallsyms_names[]; 10 9
-4
kernel/vmcore_info.c
··· 216 216 VMCOREINFO_SYMBOL(kallsyms_num_syms); 217 217 VMCOREINFO_SYMBOL(kallsyms_token_table); 218 218 VMCOREINFO_SYMBOL(kallsyms_token_index); 219 - #ifdef CONFIG_KALLSYMS_BASE_RELATIVE 220 219 VMCOREINFO_SYMBOL(kallsyms_offsets); 221 220 VMCOREINFO_SYMBOL(kallsyms_relative_base); 222 - #else 223 - VMCOREINFO_SYMBOL(kallsyms_addresses); 224 - #endif /* CONFIG_KALLSYMS_BASE_RELATIVE */ 225 221 #endif /* CONFIG_KALLSYMS */ 226 222 227 223 arch_crash_save_vmcoreinfo();
+31 -45
scripts/kallsyms.c
··· 6 6 * of the GNU General Public License, incorporated herein by reference. 7 7 * 8 8 * Usage: kallsyms [--all-symbols] [--absolute-percpu] 9 - * [--base-relative] [--lto-clang] in.map > out.S 9 + * [--lto-clang] in.map > out.S 10 10 * 11 11 * Table compression uses all the unused char codes on the symbols and 12 12 * maps these to the most used substrings (tokens). For instance, it might ··· 63 63 static unsigned int table_size, table_cnt; 64 64 static int all_symbols; 65 65 static int absolute_percpu; 66 - static int base_relative; 67 66 static int lto_clang; 68 67 69 68 static int token_profit[0x10000]; ··· 75 76 static void usage(void) 76 77 { 77 78 fprintf(stderr, "Usage: kallsyms [--all-symbols] [--absolute-percpu] " 78 - "[--base-relative] [--lto-clang] in.map > out.S\n"); 79 + "[--lto-clang] in.map > out.S\n"); 79 80 exit(1); 80 81 } 81 82 ··· 490 491 printf("\t.short\t%d\n", best_idx[i]); 491 492 printf("\n"); 492 493 493 - if (!base_relative) 494 - output_label("kallsyms_addresses"); 495 - else 496 - output_label("kallsyms_offsets"); 494 + output_label("kallsyms_offsets"); 497 495 498 496 for (i = 0; i < table_cnt; i++) { 499 - if (base_relative) { 500 - /* 501 - * Use the offset relative to the lowest value 502 - * encountered of all relative symbols, and emit 503 - * non-relocatable fixed offsets that will be fixed 504 - * up at runtime. 505 - */ 497 + /* 498 + * Use the offset relative to the lowest value 499 + * encountered of all relative symbols, and emit 500 + * non-relocatable fixed offsets that will be fixed 501 + * up at runtime. 502 + */ 506 503 507 - long long offset; 508 - int overflow; 504 + long long offset; 505 + int overflow; 509 506 510 - if (!absolute_percpu) { 511 - offset = table[i]->addr - relative_base; 512 - overflow = (offset < 0 || offset > UINT_MAX); 513 - } else if (symbol_absolute(table[i])) { 514 - offset = table[i]->addr; 515 - overflow = (offset < 0 || offset > INT_MAX); 516 - } else { 517 - offset = relative_base - table[i]->addr - 1; 518 - overflow = (offset < INT_MIN || offset >= 0); 519 - } 520 - if (overflow) { 521 - fprintf(stderr, "kallsyms failure: " 522 - "%s symbol value %#llx out of range in relative mode\n", 523 - symbol_absolute(table[i]) ? "absolute" : "relative", 524 - table[i]->addr); 525 - exit(EXIT_FAILURE); 526 - } 527 - printf("\t.long\t%#x /* %s */\n", (int)offset, table[i]->sym); 528 - } else if (!symbol_absolute(table[i])) { 529 - output_address(table[i]->addr); 507 + if (!absolute_percpu) { 508 + offset = table[i]->addr - relative_base; 509 + overflow = (offset < 0 || offset > UINT_MAX); 510 + } else if (symbol_absolute(table[i])) { 511 + offset = table[i]->addr; 512 + overflow = (offset < 0 || offset > INT_MAX); 530 513 } else { 531 - printf("\tPTR\t%#llx\n", table[i]->addr); 514 + offset = relative_base - table[i]->addr - 1; 515 + overflow = (offset < INT_MIN || offset >= 0); 532 516 } 517 + if (overflow) { 518 + fprintf(stderr, "kallsyms failure: " 519 + "%s symbol value %#llx out of range in relative mode\n", 520 + symbol_absolute(table[i]) ? "absolute" : "relative", 521 + table[i]->addr); 522 + exit(EXIT_FAILURE); 523 + } 524 + printf("\t.long\t%#x /* %s */\n", (int)offset, table[i]->sym); 533 525 } 534 526 printf("\n"); 535 527 536 - if (base_relative) { 537 - output_label("kallsyms_relative_base"); 538 - output_address(relative_base); 539 - printf("\n"); 540 - } 528 + output_label("kallsyms_relative_base"); 529 + output_address(relative_base); 530 + printf("\n"); 541 531 542 532 if (lto_clang) 543 533 for (i = 0; i < table_cnt; i++) ··· 808 820 static const struct option long_options[] = { 809 821 {"all-symbols", no_argument, &all_symbols, 1}, 810 822 {"absolute-percpu", no_argument, &absolute_percpu, 1}, 811 - {"base-relative", no_argument, &base_relative, 1}, 812 823 {"lto-clang", no_argument, &lto_clang, 1}, 813 824 {}, 814 825 }; ··· 828 841 if (absolute_percpu) 829 842 make_percpus_absolute(); 830 843 sort_symbols(); 831 - if (base_relative) 832 - record_relative_base(); 844 + record_relative_base(); 833 845 optimize_token_table(); 834 846 write_src(); 835 847
-1
tools/perf/tests/vmlinux-kallsyms.c
··· 26 26 * when --all-symbols is specified so exclude them to get a 27 27 * stable symbol list. 28 28 */ 29 - "kallsyms_addresses", 30 29 "kallsyms_offsets", 31 30 "kallsyms_relative_base", 32 31 "kallsyms_num_syms",