Skip to content

Commit aed7c22

Browse files
liu-song-6gregkh
authored andcommitted
kallsyms: Do not cleanup .llvm.<hash> suffix before sorting symbols
[ Upstream commit 020925c ] Cleaning up the symbols causes various issues afterwards. Let's sort the list based on original name. Signed-off-by: Song Liu <[email protected]> Fixes: 8cc32a9 ("kallsyms: strip LTO-only suffixes from promoted global functions") Reviewed-by: Masami Hiramatsu (Google) <[email protected]> Tested-by: Masami Hiramatsu (Google) <[email protected]> Acked-by: Petr Mladek <[email protected]> Reviewed-by: Sami Tolvanen <[email protected]> Reviewed-by: Luis Chamberlain <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 7e3a7d5 commit aed7c22

File tree

2 files changed

+2
-33
lines changed

2 files changed

+2
-33
lines changed

scripts/kallsyms.c

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +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]
9-
* [--lto-clang] in.map > out.S
8+
* Usage: kallsyms [--all-symbols] [--absolute-percpu] in.map > out.S
109
*
1110
* Table compression uses all the unused char codes on the symbols and
1211
* maps these to the most used substrings (tokens). For instance, it might
@@ -63,7 +62,6 @@ static struct sym_entry **table;
6362
static unsigned int table_size, table_cnt;
6463
static int all_symbols;
6564
static int absolute_percpu;
66-
static int lto_clang;
6765

6866
static int token_profit[0x10000];
6967

@@ -74,8 +72,7 @@ static unsigned char best_table_len[256];
7472

7573
static void usage(void)
7674
{
77-
fprintf(stderr, "Usage: kallsyms [--all-symbols] [--absolute-percpu] "
78-
"[--lto-clang] in.map > out.S\n");
75+
fprintf(stderr, "Usage: kallsyms [--all-symbols] [--absolute-percpu] in.map > out.S\n");
7976
exit(1);
8077
}
8178

@@ -345,25 +342,6 @@ static int symbol_absolute(const struct sym_entry *s)
345342
return s->percpu_absolute;
346343
}
347344

348-
static void cleanup_symbol_name(char *s)
349-
{
350-
char *p;
351-
352-
/*
353-
* ASCII[.] = 2e
354-
* ASCII[0-9] = 30,39
355-
* ASCII[A-Z] = 41,5a
356-
* ASCII[_] = 5f
357-
* ASCII[a-z] = 61,7a
358-
*
359-
* As above, replacing the first '.' in ".llvm." with '\0' does not
360-
* affect the main sorting, but it helps us with subsorting.
361-
*/
362-
p = strstr(s, ".llvm.");
363-
if (p)
364-
*p = '\0';
365-
}
366-
367345
static int compare_names(const void *a, const void *b)
368346
{
369347
int ret;
@@ -528,10 +506,6 @@ static void write_src(void)
528506
output_address(relative_base);
529507
printf("\n");
530508

531-
if (lto_clang)
532-
for (i = 0; i < table_cnt; i++)
533-
cleanup_symbol_name((char *)table[i]->sym);
534-
535509
sort_symbols_by_name();
536510
output_label("kallsyms_seqs_of_names");
537511
for (i = 0; i < table_cnt; i++)
@@ -808,7 +782,6 @@ int main(int argc, char **argv)
808782
static const struct option long_options[] = {
809783
{"all-symbols", no_argument, &all_symbols, 1},
810784
{"absolute-percpu", no_argument, &absolute_percpu, 1},
811-
{"lto-clang", no_argument, &lto_clang, 1},
812785
{},
813786
};
814787

scripts/link-vmlinux.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,6 @@ kallsyms()
159159
kallsymopt="${kallsymopt} --absolute-percpu"
160160
fi
161161

162-
if is_enabled CONFIG_LTO_CLANG; then
163-
kallsymopt="${kallsymopt} --lto-clang"
164-
fi
165-
166162
info KSYMS "${2}.S"
167163
scripts/kallsyms ${kallsymopt} "${1}" > "${2}.S"
168164

0 commit comments

Comments
 (0)