Some kbuild fixes
These are some generic Kbuild fixes from the LTO tree. These are not really LTO specific and can be applied indepdently.
-Andi
PATCH 1/3 kbuild: Increase kallsyms max symbol length
From: Joe Mario <[email protected]>
[AK: This seems like a ticking time bomb even without LTO, so should be merged now. It causes very weird problems. Thanks to Joe for tracking them down.]
With the added postfixes that LTO adds for local
symbols, the longest name in the kernel overflows
the namebuf[KSYM_NAME_LEN] array by two bytes. That name is:
__pci_fixup_resumePCI_VENDOR_ID_SERVERWORKSPCI_DEVICE_ID_SERVERWORKS_HT1000SBquirk_disable_broadcom_boot_interrupt.1488004.672802
Double the max symbol name length.
--- include/linux/kallsyms.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/kallsyms.h +1 -1
@@ -9,7 +9,7 @@#include <linux/kernel.h> #include <linux/stddef.h> -#define KSYM_NAME_LEN 128 +#define KSYM_NAME_LEN 256#define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1)
Signature · 1 line
1.8.3.1
Re: [PATCH 1/3] kbuild: Increase kallsyms max symbol length
Quoted 6 lines · Andi Kleen
From: Joe Mario <[email protected]>
[AK: This seems like a ticking time bomb even without LTO, so should be merged now. It causes very weird problems. Thanks to Joe for tracking them down.]
Quoted 6 lines
With the added postfixes that LTO adds for local
symbols, the longest name in the kernel overflows
the namebuf[KSYM_NAME_LEN] array by two bytes. That name is:
__pci_fixup_resumePCI_VENDOR_ID_SERVERWORKSPCI_DEVICE_ID_SERVERWORKS_HT1000SBquirk_disable_broadcom_boot_interrupt.1488004.672802Double the max symbol name length.
[]
include/linux/kallsyms.h line 12
Quoted 10 lines
include/linux/kallsyms.h +1
-1@@ -9,7 +9,7 @@#include <linux/kernel.h> #include <linux/stddef.h> -#define KSYM_NAME_LEN 128 +#define KSYM_NAME_LEN 256
Doesn't doubling seems a tad excessive given the
silly length of that symbol above?
Re: [PATCH 1/3] kbuild: Increase kallsyms max symbol length
Quoted 2 lines
Doesn't doubling seems a tad excessive given the
silly length of that symbol above?
No, it doesn't.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Re: [PATCH 1/3] kbuild: Increase kallsyms max symbol length
Quoted 4 lines · Andi Kleen
Quoted 2 lines
Doesn't doubling seems a tad excessive given the
silly length of that symbol above?No, it doesn't.
Does it work?
Doesn't kallsyms:get_symbol_offset restrict the maximum possible length to 255?
PATCH 1/3 kbuild: Increase kallsyms max symbol length v2
In reply to Joe PerchesFrom: Joe Mario <[email protected]>
[AK: This seems like a ticking time bomb even without LTO, so should be merged now. It causes very weird problems. Thanks to Joe for tracking them down.]
With the added postfixes that LTO adds for local
symbols, the longest name in the kernel overflows
the namebuf[KSYM_NAME_LEN] array by two bytes. That name is:
__pci_fixup_resumePCI_VENDOR_ID_SERVERWORKSPCI_DEVICE_ID_SERVERWORKS_HT1000SBquirk_disable_broadcom_boot_interrupt.1488004.672802
Double the max symbol name length.
v2: Use 255 (Joe Perches)
--- include/linux/kallsyms.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/kallsyms.h +1 -1
@@ -9,7 +9,7 @@#include <linux/kernel.h> #include <linux/stddef.h> -#define KSYM_NAME_LEN 128 +#define KSYM_NAME_LEN 255#define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ 2*(BITS_PER_LONG*3/10) + (MODULE_NAME_LEN - 1) + 1)
Signature · 4 lines
1.8.4 -- [email protected] -- Speaking for myself only.
Re: [PATCH 1/3] kbuild: Increase kallsyms max symbol length v2
Quoted 11 lines · Andi Kleen
From: Joe Mario <[email protected]>
[AK: This seems like a ticking time bomb even without LTO, so should be merged now. It causes very weird problems. Thanks to Joe for tracking them down.]
With the added postfixes that LTO adds for local
symbols, the longest name in the kernel overflows
the namebuf[KSYM_NAME_LEN] array by two bytes. That name is:
__pci_fixup_resumePCI_VENDOR_ID_SERVERWORKSPCI_DEVICE_ID_SERVERWORKS_HT1000SBquirk_disable_broadcom_boot_interrupt.1488004.672802
Quoted 4 lines
Double the max symbol name length.
v2: Use 255 (Joe Perches)
Signed-off-by Andi Kleen <[email protected]>
Applied to kbuild.git#kbuild.
Michal
PATCH 2/3 Kbuild: Handle longer symbols in kallsyms.c
In reply to Andi KleenFrom: Andi Kleen <[email protected]>
Also warn for too long symbols
--- scripts/kallsyms.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
scripts/kallsyms.c +7 -1
@@ -27,7 +27,7 @@#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof(arr[0]))#endif -#define KSYM_NAME_LEN 128 +#define KSYM_NAME_LEN 256struct sym_entry {unsigned long long addr;
@@ -118,6 +118,12 @@ static int read_symbol(FILE *in, struct sym_entry *s)fprintf (stderr,"Read error or end of file.\n" );return -1 ; } +if (strlen (str) >KSYM_NAME_LEN ) { +fprintf (stderr,"Symbol %s too long for kallsyms.\n" +"Please increase KSYM_NAME_LEN both in kernel and kallsyms.c" , + str); +return -1 ; + } sym = str;/* skip prefix char */
Signature · 1 line
1.8.3.1
Re: [PATCH 2/3] Kbuild: Handle longer symbols in kallsyms.c
Quoted 3 lines · Andi Kleen
From: Andi Kleen <[email protected]>
Also warn for too long symbols
[]
scripts/kallsyms.c
Quoted 1 line
scripts/kallsyms.c +0
-0
[]
scripts/kallsyms.c line 30
Quoted 6 lines
scripts/kallsyms.c +1
-1@@ -27,7 +27,7 @@#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof(arr[0]))#endif -#define KSYM_NAME_LEN 128 +#define KSYM_NAME_LEN 256
Maybe nicer to get these #defines via #include <>
to avoid getting out of sync.
scripts/kallsyms.c static int read_symbol(FILE *in, struct sym_entry *s) · line 124
Quoted 10 lines
scripts/kallsyms.c +4
-0struct sym_entry {unsigned long long addr;@@ -118,6 +118,12 @@ static int read_symbol(FILE *in, struct sym_entry *s)fprintf (stderr,"Read error or end of file.\n" );return -1 ; } +if (strlen (str) >KSYM_NAME_LEN ) { +fprintf (stderr,"Symbol %s too long for kallsyms.\n" +"Please increase KSYM_NAME_LEN both in kernel and kallsyms.c" , + str);
Missing newline?
Also maybe nicer to show symbol length and KSYM_NAME_LEN values.
PATCH 2/3 Kbuild: Handle longer symbols in kallsyms.c v2
Also warn for too long symbols
v2: Add missing newline. Use 255 max (Joe Perches)
--- scripts/kallsyms.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
scripts/kallsyms.c +7 -1
@@ -27,7 +27,7 @@#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof(arr[0]))#endif -#define KSYM_NAME_LEN 128 +#define KSYM_NAME_LEN 255struct sym_entry {unsigned long long addr;
@@ -118,6 +118,12 @@ static int read_symbol(FILE *in, struct sym_entry *s)fprintf (stderr,"Read error or end of file.\n" );return -1 ; } +if (strlen (str) >KSYM_NAME_LEN ) { +fprintf (stderr,"Symbol %s too long for kallsyms (%lu vs %d).\n" +"Please increase KSYM_NAME_LEN both in kernel and kallsyms.c\n" , + str,strlen (str),KSYM_NAME_LEN ); +return -1 ; + } sym = str;/* skip prefix char */
Signature · 4 lines
1.8.4 -- [email protected] -- Speaking for myself only.
Re: [PATCH 2/3] Kbuild: Handle longer symbols in kallsyms.c v2
Quoted 5 lines · Andi Kleen
Also warn for too long symbols
v2: Add missing newline. Use 255 max (Joe Perches)
Signed-off-by Andi Kleen <[email protected]>
Applied to kbuild.git#kbuild.
Michal
PATCH 3/3 kbuild, bloat-o-meter: fix static detection
In reply to Andi KleenFrom: Andi Kleen <[email protected]>
Disable static detection: the static currently drops a lot of useful information including clones generated by gcc. Drop this. The statics will appear now without static. prefix.
But remove the LTO .NUMBER postfixes that look ugly
--- scripts/bloat-o-meter | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/bloat-o-meter +2 -2
@@ -20,8 +20,8 @@ def getsizes(file): if type in "tTdDbBrR": # strip generated symbols if name[:6] == "__mod_": continue - # function names begin with '.' on 64-bit powerpc - if "." in name[1:]: name = "static." + name.split(".")[0] + # statics and some other optimizations adds random .NUMBER + name = re.sub(r'\.[0-9]+', '', name) sym[name] = sym.get(name, 0) + int(size, 16) return sym
Signature · 1 line
1.8.3.1
Re: [PATCH 3/3] kbuild, bloat-o-meter: fix static detection
Quoted 9 lines · Andi Kleen
From: Andi Kleen <[email protected]>
Disable static detection: the static currently drops a lot of useful information including clones generated by gcc. Drop this. The statics will appear now without static. prefix.
But remove the LTO .NUMBER postfixes that look ugly
Signed-off-by Andi Kleen <[email protected]>
Applied to kbuild.git#kbuild.
Michal