Skip to content

Commit 64e1660

Browse files
thejhmasahir0y
authored andcommitted
kallsyms: get rid of code for absolute kallsyms
Commit cf8e865 ("arch: Remove Itanium (IA-64) architecture") removed the last use of the absolute kallsyms. Signed-off-by: Jann Horn <[email protected]> Acked-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ [[email protected]: rebase the code and reword the commit description] Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 7efcb39 commit 64e1660

File tree

7 files changed

+33
-78
lines changed

7 files changed

+33
-78
lines changed

init/Kconfig

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,24 +1789,6 @@ config KALLSYMS_ABSOLUTE_PERCPU
17891789
depends on KALLSYMS
17901790
default X86_64 && SMP
17911791

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-
18101792
# end of the "standard kernel features (expert users)" menu
18111793

18121794
config ARCH_HAS_MEMBARRIER_CALLBACKS

kernel/kallsyms.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ static unsigned int get_symbol_offset(unsigned long pos)
148148

149149
unsigned long kallsyms_sym_address(int idx)
150150
{
151-
if (!IS_ENABLED(CONFIG_KALLSYMS_BASE_RELATIVE))
152-
return kallsyms_addresses[idx];
153-
154151
/* values are unsigned offsets if --absolute-percpu is not in effect */
155152
if (!IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PERCPU))
156153
return kallsyms_relative_base + (u32)kallsyms_offsets[idx];
@@ -325,7 +322,7 @@ static unsigned long get_symbol_pos(unsigned long addr,
325322
unsigned long symbol_start = 0, symbol_end = 0;
326323
unsigned long i, low, high, mid;
327324

328-
/* Do a binary search on the sorted kallsyms_addresses array. */
325+
/* Do a binary search on the sorted kallsyms_offsets array. */
329326
low = 0;
330327
high = kallsyms_num_syms;
331328

kernel/kallsyms_internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <linux/types.h>
66

7-
extern const unsigned long kallsyms_addresses[];
87
extern const int kallsyms_offsets[];
98
extern const u8 kallsyms_names[];
109

kernel/vmcore_info.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,8 @@ static int __init crash_save_vmcoreinfo_init(void)
216216
VMCOREINFO_SYMBOL(kallsyms_num_syms);
217217
VMCOREINFO_SYMBOL(kallsyms_token_table);
218218
VMCOREINFO_SYMBOL(kallsyms_token_index);
219-
#ifdef CONFIG_KALLSYMS_BASE_RELATIVE
220219
VMCOREINFO_SYMBOL(kallsyms_offsets);
221220
VMCOREINFO_SYMBOL(kallsyms_relative_base);
222-
#else
223-
VMCOREINFO_SYMBOL(kallsyms_addresses);
224-
#endif /* CONFIG_KALLSYMS_BASE_RELATIVE */
225221
#endif /* CONFIG_KALLSYMS */
226222

227223
arch_crash_save_vmcoreinfo();

scripts/kallsyms.c

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* of the GNU General Public License, incorporated herein by reference.
77
*
88
* Usage: kallsyms [--all-symbols] [--absolute-percpu]
9-
* [--base-relative] [--lto-clang] in.map > out.S
9+
* [--lto-clang] in.map > out.S
1010
*
1111
* Table compression uses all the unused char codes on the symbols and
1212
* maps these to the most used substrings (tokens). For instance, it might
@@ -63,7 +63,6 @@ static struct sym_entry **table;
6363
static unsigned int table_size, table_cnt;
6464
static int all_symbols;
6565
static int absolute_percpu;
66-
static int base_relative;
6766
static int lto_clang;
6867

6968
static int token_profit[0x10000];
@@ -76,7 +75,7 @@ static unsigned char best_table_len[256];
7675
static void usage(void)
7776
{
7877
fprintf(stderr, "Usage: kallsyms [--all-symbols] [--absolute-percpu] "
79-
"[--base-relative] [--lto-clang] in.map > out.S\n");
78+
"[--lto-clang] in.map > out.S\n");
8079
exit(1);
8180
}
8281

@@ -491,54 +490,43 @@ static void write_src(void)
491490
printf("\t.short\t%d\n", best_idx[i]);
492491
printf("\n");
493492

494-
if (!base_relative)
495-
output_label("kallsyms_addresses");
496-
else
497-
output_label("kallsyms_offsets");
493+
output_label("kallsyms_offsets");
498494

499495
for (i = 0; i < table_cnt; i++) {
500-
if (base_relative) {
501-
/*
502-
* Use the offset relative to the lowest value
503-
* encountered of all relative symbols, and emit
504-
* non-relocatable fixed offsets that will be fixed
505-
* up at runtime.
506-
*/
496+
/*
497+
* Use the offset relative to the lowest value
498+
* encountered of all relative symbols, and emit
499+
* non-relocatable fixed offsets that will be fixed
500+
* up at runtime.
501+
*/
507502

508-
long long offset;
509-
int overflow;
510-
511-
if (!absolute_percpu) {
512-
offset = table[i]->addr - relative_base;
513-
overflow = (offset < 0 || offset > UINT_MAX);
514-
} else if (symbol_absolute(table[i])) {
515-
offset = table[i]->addr;
516-
overflow = (offset < 0 || offset > INT_MAX);
517-
} else {
518-
offset = relative_base - table[i]->addr - 1;
519-
overflow = (offset < INT_MIN || offset >= 0);
520-
}
521-
if (overflow) {
522-
fprintf(stderr, "kallsyms failure: "
523-
"%s symbol value %#llx out of range in relative mode\n",
524-
symbol_absolute(table[i]) ? "absolute" : "relative",
525-
table[i]->addr);
526-
exit(EXIT_FAILURE);
527-
}
528-
printf("\t.long\t%#x /* %s */\n", (int)offset, table[i]->sym);
529-
} else if (!symbol_absolute(table[i])) {
530-
output_address(table[i]->addr);
503+
long long offset;
504+
int overflow;
505+
506+
if (!absolute_percpu) {
507+
offset = table[i]->addr - relative_base;
508+
overflow = (offset < 0 || offset > UINT_MAX);
509+
} else if (symbol_absolute(table[i])) {
510+
offset = table[i]->addr;
511+
overflow = (offset < 0 || offset > INT_MAX);
531512
} else {
532-
printf("\tPTR\t%#llx\n", table[i]->addr);
513+
offset = relative_base - table[i]->addr - 1;
514+
overflow = (offset < INT_MIN || offset >= 0);
515+
}
516+
if (overflow) {
517+
fprintf(stderr, "kallsyms failure: "
518+
"%s symbol value %#llx out of range in relative mode\n",
519+
symbol_absolute(table[i]) ? "absolute" : "relative",
520+
table[i]->addr);
521+
exit(EXIT_FAILURE);
533522
}
523+
printf("\t.long\t%#x /* %s */\n", (int)offset, table[i]->sym);
534524
}
535525
printf("\n");
536526

537-
if (base_relative) {
538-
output_label("kallsyms_relative_base");
539-
output_address(relative_base);
540-
printf("\n");
541-
}
527+
output_label("kallsyms_relative_base");
528+
output_address(relative_base);
529+
printf("\n");
542530

543531
if (lto_clang)
544532
for (i = 0; i < table_cnt; i++)
@@ -820,7 +808,6 @@ int main(int argc, char **argv)
820808
static const struct option long_options[] = {
821809
{"all-symbols", no_argument, &all_symbols, 1},
822810
{"absolute-percpu", no_argument, &absolute_percpu, 1},
823-
{"base-relative", no_argument, &base_relative, 1},
824811
{"lto-clang", no_argument, &lto_clang, 1},
825812
{},
826813
};
@@ -841,8 +828,7 @@ int main(int argc, char **argv)
841828
if (absolute_percpu)
842829
make_percpus_absolute();
843830
sort_symbols();
844-
if (base_relative)
845-
record_relative_base();
831+
record_relative_base();
846832
optimize_token_table();
847833
write_src();
848834

scripts/link-vmlinux.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ kallsyms()
156156
kallsymopt="${kallsymopt} --absolute-percpu"
157157
fi
158158

159-
if is_enabled CONFIG_KALLSYMS_BASE_RELATIVE; then
160-
kallsymopt="${kallsymopt} --base-relative"
161-
fi
162-
163159
if is_enabled CONFIG_LTO_CLANG; then
164160
kallsymopt="${kallsymopt} --lto-clang"
165161
fi

tools/perf/tests/vmlinux-kallsyms.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ static bool is_ignored_symbol(const char *name, char type)
2626
* when --all-symbols is specified so exclude them to get a
2727
* stable symbol list.
2828
*/
29-
"kallsyms_addresses",
3029
"kallsyms_offsets",
3130
"kallsyms_relative_base",
3231
"kallsyms_num_syms",

0 commit comments

Comments
 (0)