Skip to content

Commit ff5cd9a

Browse files
alexkapshukgregkh
authored andcommitted
ver_linux: Query ld cache for versions of libc/libcpp run-time
Query ld cache for versions of both libc and libcpp run-time, instead of querying /proc/self/maps for libc run-time, and ld cache for libcpp run-time, thus reducing code size and complexity. Signed-off-by: Alexander Kapshuk <alexander.kapshuk@gmail.com> Link: https://lore.kernel.org/r/20200209140057.20181-1-alexander.kapshuk@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bb6d3fb commit ff5cd9a

1 file changed

Lines changed: 7 additions & 17 deletions

File tree

‎scripts/ver_linux‎

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ BEGIN {
1414
printf("\n")
1515

1616
vernum = "[0-9]+([.]?[0-9]+)+"
17+
libc = "libc[.]so[.][0-9]+$"
18+
libcpp = "(libg|stdc)[+]+[.]so[.][0-9]+$"
1719

1820
printversion("GNU C", version("gcc -dumpversion"))
1921
printversion("GNU Make", version("make --version"))
@@ -35,26 +37,14 @@ BEGIN {
3537
printversion("Bison", version("bison --version"))
3638
printversion("Flex", version("flex --version"))
3739

38-
while (getline <"/proc/self/maps" > 0) {
39-
if (/libc.*\.so$/) {
40-
n = split($0, procmaps, "/")
41-
if (match(procmaps[n], vernum)) {
42-
ver = substr(procmaps[n], RSTART, RLENGTH)
43-
printversion("Linux C Library", ver)
44-
break
45-
}
46-
}
40+
while ("ldconfig -p 2>/dev/null" | getline > 0) {
41+
if ($NF ~ libc && !seen[ver = version("readlink " $NF)]++)
42+
printversion("Linux C Library", ver)
43+
else if ($NF ~ libcpp && !seen[ver = version("readlink " $NF)]++)
44+
printversion("Linux C++ Library", ver)
4745
}
4846

4947
printversion("Dynamic linker (ldd)", version("ldd --version"))
50-
51-
while ("ldconfig -p 2>/dev/null" | getline > 0) {
52-
if (/(libg|stdc)[+]+\.so/) {
53-
libcpp = $NF
54-
break
55-
}
56-
}
57-
printversion("Linux C++ Library", version("readlink " libcpp))
5848
printversion("Procps", version("ps --version"))
5949
printversion("Net-tools", version("ifconfig --version"))
6050
printversion("Kbd", version("loadkeys -V"))

0 commit comments

Comments
 (0)