* [PATCH] ver_linux: Query ld cache for versions of libc/libcpp run-time
@ 2020-02-09 14:00 Alexander Kapshuk
0 siblings, 0 replies; only message in thread
From: Alexander Kapshuk @ 2020-02-09 14:00 UTC (permalink / raw)
To: linux-kernel; +Cc: gregkh, masahiroy, alexander.kapshuk
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>
---
scripts/ver_linux | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/scripts/ver_linux b/scripts/ver_linux
index 85005d6b7f10..0968a3070eff 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -14,6 +14,8 @@ BEGIN {
printf("\n")
vernum = "[0-9]+([.]?[0-9]+)+"
+ libc = "libc[.]so[.][0-9]+$"
+ libcpp = "(libg|stdc)[+]+[.]so[.][0-9]+$"
printversion("GNU C", version("gcc -dumpversion"))
printversion("GNU Make", version("make --version"))
@@ -35,26 +37,14 @@ BEGIN {
printversion("Bison", version("bison --version"))
printversion("Flex", version("flex --version"))
- while (getline <"/proc/self/maps" > 0) {
- if (/libc.*\.so$/) {
- n = split($0, procmaps, "/")
- if (match(procmaps[n], vernum)) {
- ver = substr(procmaps[n], RSTART, RLENGTH)
- printversion("Linux C Library", ver)
- break
- }
- }
+ while ("ldconfig -p 2>/dev/null" | getline > 0) {
+ if ($NF ~ libc && !seen[ver = version("readlink " $NF)]++)
+ printversion("Linux C Library", ver)
+ else if ($NF ~ libcpp && !seen[ver = version("readlink " $NF)]++)
+ printversion("Linux C++ Library", ver)
}
printversion("Dynamic linker (ldd)", version("ldd --version"))
-
- while ("ldconfig -p 2>/dev/null" | getline > 0) {
- if (/(libg|stdc)[+]+\.so/) {
- libcpp = $NF
- break
- }
- }
- printversion("Linux C++ Library", version("readlink " libcpp))
printversion("Procps", version("ps --version"))
printversion("Net-tools", version("ifconfig --version"))
printversion("Kbd", version("loadkeys -V"))
--
2.25.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-02-09 14:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-09 14:00 [PATCH] ver_linux: Query ld cache for versions of libc/libcpp run-time Alexander Kapshuk
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.