Am 25.04.21 um 07:50 schrieb Youling Tang:
When using the "help -k" command in the 5.12 kernel, it was
found that the
gcc_version character string was displayed as 0.0.0.
Check the value of the proc_version string to know,
crash> help -k
...
proc_version: Linux version 5.12.0-rc2kexec+ (root@bogon) (gcc (GCC) 7.3.1
20180303 (Red Hat 7.3.1-6), GNU ld version 2.28-13.fc21.loongson.6) #30
SMP PREEMPT Thu Apr 22 09:04:57 HKT 2021
...
Therefore, the "gcc (GCC)" character should be searched to obtain the correct
character string "gcc_version" value.
I don't think that's sufficient to catch current kernels.
Here's another data point from a Debian system:
$ cat /proc/version
Linux version 5.9.0-0.bpo.5-amd64 (debian-kernel(a)lists.debian.org)
(gcc-8 (Debian 8.3.0-6) 8.3.0, GNU ld (GNU Binutils for Debian) 2.31.1)
#1 SMP Debian 5.9.15-1~bpo10+1 (2020-12-31)
So the below pattern won't match this one either.
Maybe we should give up on extracting the version and simply use the
full string for diagnostical messages? Like extracting everything from
"gcc" till the next ","?
Thanks,
Mathias
Signed-off-by: Youling Tang <tangyouling(a)loongson.cn>
---
kernel.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/kernel.c b/kernel.c
index 528f6ee..a1872c2 100644
--- a/kernel.c
+++ b/kernel.c
@@ -1103,9 +1103,13 @@ verify_version(void)
/*
* Keeping the gcc version with #define's is getting out of hand.
*/
- if ((p1 = strstr(kt->proc_version, "gcc version "))) {
+ if ((p1 = strstr(kt->proc_version, "gcc version ")) ||
+ (p1 = strstr(kt->proc_version, "gcc (GCC) "))) {
BZERO(buf, BUFSIZE);
- p1 += strlen("gcc version ");
+ if (strstr(kt->proc_version, "gcc version "))
+ p1 += strlen("gcc version ");
+ else
+ p1 += strlen("gcc (GCC) ");
p2 = buf;
while (((*p1 >= '0') && (*p1 <= '9')) || (*p1 ==
'.')) {
if (*p1 == '.')
@@ -3661,7 +3665,7 @@ module_init(void)
modules_found = TRUE;
break;
}
- }
+ }
if (!modules_found) {
error(WARNING,