Skip to content

Commit 01157dd

Browse files
Brian GerstIngo Molnar
Brian Gerst
authored and
Ingo Molnar
committed
kallsyms: Remove KALLSYMS_ABSOLUTE_PERCPU
x86-64 was the only user. Signed-off-by: Brian Gerst <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Ard Biesheuvel <[email protected]> Cc: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 4b00c11 commit 01157dd

File tree

4 files changed

+14
-79
lines changed

4 files changed

+14
-79
lines changed

init/Kconfig

-5
Original file line numberDiff line numberDiff line change
@@ -1869,11 +1869,6 @@ config KALLSYMS_ALL
18691869

18701870
Say N unless you really need all symbols, or kernel live patching.
18711871

1872-
config KALLSYMS_ABSOLUTE_PERCPU
1873-
bool
1874-
depends on KALLSYMS
1875-
default n
1876-
18771872
# end of the "standard kernel features (expert users)" menu
18781873

18791874
config ARCH_HAS_MEMBARRIER_CALLBACKS

kernel/kallsyms.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,8 @@ static unsigned int get_symbol_offset(unsigned long pos)
148148

149149
unsigned long kallsyms_sym_address(int idx)
150150
{
151-
/* values are unsigned offsets if --absolute-percpu is not in effect */
152-
if (!IS_ENABLED(CONFIG_KALLSYMS_ABSOLUTE_PERCPU))
153-
return kallsyms_relative_base + (u32)kallsyms_offsets[idx];
154-
155-
/* ...otherwise, positive offsets are absolute values */
156-
if (kallsyms_offsets[idx] >= 0)
157-
return kallsyms_offsets[idx];
158-
159-
/* ...and negative offsets are relative to kallsyms_relative_base - 1 */
160-
return kallsyms_relative_base - 1 - kallsyms_offsets[idx];
151+
/* values are unsigned offsets */
152+
return kallsyms_relative_base + (u32)kallsyms_offsets[idx];
161153
}
162154

163155
static unsigned int get_symbol_seq(int index)

scripts/kallsyms.c

+12-60
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* This software may be used and distributed according to the terms
66
* of the GNU General Public License, incorporated herein by reference.
77
*
8-
* Usage: kallsyms [--all-symbols] [--absolute-percpu] in.map > out.S
8+
* Usage: kallsyms [--all-symbols] in.map > out.S
99
*
1010
* Table compression uses all the unused char codes on the symbols and
1111
* maps these to the most used substrings (tokens). For instance, it might
@@ -37,7 +37,6 @@ struct sym_entry {
3737
unsigned long long addr;
3838
unsigned int len;
3939
unsigned int seq;
40-
bool percpu_absolute;
4140
unsigned char sym[];
4241
};
4342

@@ -55,14 +54,9 @@ static struct addr_range text_ranges[] = {
5554
#define text_range_text (&text_ranges[0])
5655
#define text_range_inittext (&text_ranges[1])
5756

58-
static struct addr_range percpu_range = {
59-
"__per_cpu_start", "__per_cpu_end", -1ULL, 0
60-
};
61-
6257
static struct sym_entry **table;
6358
static unsigned int table_size, table_cnt;
6459
static int all_symbols;
65-
static int absolute_percpu;
6660

6761
static int token_profit[0x10000];
6862

@@ -73,7 +67,7 @@ static unsigned char best_table_len[256];
7367

7468
static void usage(void)
7569
{
76-
fprintf(stderr, "Usage: kallsyms [--all-symbols] [--absolute-percpu] in.map > out.S\n");
70+
fprintf(stderr, "Usage: kallsyms [--all-symbols] in.map > out.S\n");
7771
exit(1);
7872
}
7973

@@ -164,7 +158,6 @@ static struct sym_entry *read_symbol(FILE *in, char **buf, size_t *buf_len)
164158
return NULL;
165159

166160
check_symbol_range(name, addr, text_ranges, ARRAY_SIZE(text_ranges));
167-
check_symbol_range(name, addr, &percpu_range, 1);
168161

169162
/* include the type field in the symbol name, so that it gets
170163
* compressed together */
@@ -175,7 +168,6 @@ static struct sym_entry *read_symbol(FILE *in, char **buf, size_t *buf_len)
175168
sym->len = len;
176169
sym->sym[0] = type;
177170
strcpy(sym_name(sym), name);
178-
sym->percpu_absolute = false;
179171

180172
return sym;
181173
}
@@ -319,11 +311,6 @@ static int expand_symbol(const unsigned char *data, int len, char *result)
319311
return total;
320312
}
321313

322-
static bool symbol_absolute(const struct sym_entry *s)
323-
{
324-
return s->percpu_absolute;
325-
}
326-
327314
static int compare_names(const void *a, const void *b)
328315
{
329316
int ret;
@@ -455,22 +442,11 @@ static void write_src(void)
455442
*/
456443

457444
long long offset;
458-
bool overflow;
459-
460-
if (!absolute_percpu) {
461-
offset = table[i]->addr - relative_base;
462-
overflow = offset < 0 || offset > UINT_MAX;
463-
} else if (symbol_absolute(table[i])) {
464-
offset = table[i]->addr;
465-
overflow = offset < 0 || offset > INT_MAX;
466-
} else {
467-
offset = relative_base - table[i]->addr - 1;
468-
overflow = offset < INT_MIN || offset >= 0;
469-
}
470-
if (overflow) {
445+
446+
offset = table[i]->addr - relative_base;
447+
if (offset < 0 || offset > UINT_MAX) {
471448
fprintf(stderr, "kallsyms failure: "
472-
"%s symbol value %#llx out of range in relative mode\n",
473-
symbol_absolute(table[i]) ? "absolute" : "relative",
449+
"relative symbol value %#llx out of range\n",
474450
table[i]->addr);
475451
exit(EXIT_FAILURE);
476452
}
@@ -725,44 +701,22 @@ static void sort_symbols(void)
725701
qsort(table, table_cnt, sizeof(table[0]), compare_symbols);
726702
}
727703

728-
static void make_percpus_absolute(void)
729-
{
730-
unsigned int i;
731-
732-
for (i = 0; i < table_cnt; i++)
733-
if (symbol_in_range(table[i], &percpu_range, 1)) {
734-
/*
735-
* Keep the 'A' override for percpu symbols to
736-
* ensure consistent behavior compared to older
737-
* versions of this tool.
738-
*/
739-
table[i]->sym[0] = 'A';
740-
table[i]->percpu_absolute = true;
741-
}
742-
}
743-
744704
/* find the minimum non-absolute symbol address */
745705
static void record_relative_base(void)
746706
{
747-
unsigned int i;
748-
749-
for (i = 0; i < table_cnt; i++)
750-
if (!symbol_absolute(table[i])) {
751-
/*
752-
* The table is sorted by address.
753-
* Take the first non-absolute symbol value.
754-
*/
755-
relative_base = table[i]->addr;
756-
return;
757-
}
707+
/*
708+
* The table is sorted by address.
709+
* Take the first symbol value.
710+
*/
711+
if (table_cnt)
712+
relative_base = table[0]->addr;
758713
}
759714

760715
int main(int argc, char **argv)
761716
{
762717
while (1) {
763718
static const struct option long_options[] = {
764719
{"all-symbols", no_argument, &all_symbols, 1},
765-
{"absolute-percpu", no_argument, &absolute_percpu, 1},
766720
{},
767721
};
768722

@@ -779,8 +733,6 @@ int main(int argc, char **argv)
779733

780734
read_map(argv[optind]);
781735
shrink_table();
782-
if (absolute_percpu)
783-
make_percpus_absolute();
784736
sort_symbols();
785737
record_relative_base();
786738
optimize_token_table();

scripts/link-vmlinux.sh

-4
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ kallsyms()
144144
kallsymopt="${kallsymopt} --all-symbols"
145145
fi
146146

147-
if is_enabled CONFIG_KALLSYMS_ABSOLUTE_PERCPU; then
148-
kallsymopt="${kallsymopt} --absolute-percpu"
149-
fi
150-
151147
info KSYMS "${2}.S"
152148
scripts/kallsyms ${kallsymopt} "${1}" > "${2}.S"
153149

0 commit comments

Comments
 (0)