Skip to content

Commit 7d02b49

Browse files
Andi KleenH. Peter Anvin
authored andcommitted
Kbuild, lto: Drop .number postfixes in modpost
LTO turns all global symbols effectively into statics. This has the side effect that they all have a .NUMBER postfix to make them unique. In modpost drop this postfix because it confuses it. Signed-off-by: Andi Kleen <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: H. Peter Anvin <[email protected]>
1 parent 77ab21a commit 7d02b49

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

scripts/mod/modpost.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1684,6 +1684,19 @@ static void check_sec_ref(struct module *mod, const char *modname,
16841684
}
16851685
}
16861686

1687+
static char *remove_dot(char *s)
1688+
{
1689+
char *end;
1690+
int n = strcspn(s, ".");
1691+
1692+
if (n > 0 && s[n] != 0) {
1693+
strtoul(s + n + 1, &end, 10);
1694+
if (end > s + n + 1 && (*end == '.' || *end == 0))
1695+
s[n] = 0;
1696+
}
1697+
return s;
1698+
}
1699+
16871700
static void read_symbols(char *modname)
16881701
{
16891702
const char *symname;
@@ -1722,7 +1735,7 @@ static void read_symbols(char *modname)
17221735
}
17231736

17241737
for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
1725-
symname = info.strtab + sym->st_name;
1738+
symname = remove_dot(info.strtab + sym->st_name);
17261739

17271740
handle_modversions(mod, &info, sym, symname);
17281741
handle_moddevtable(mod, &info, sym, symname);

scripts/mod/modpost.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ struct elf_info {
127127
Elf_Section export_gpl_sec;
128128
Elf_Section export_unused_gpl_sec;
129129
Elf_Section export_gpl_future_sec;
130-
const char *strtab;
130+
char *strtab;
131131
char *modinfo;
132132
unsigned int modinfo_len;
133133

0 commit comments

Comments
 (0)