How to extract and compare the libc versions at runtime with the following restrictions?
- stable solution (commands output parsing is discarded as this may vary)
- should not rely on executing external tools like ldd, gcc or others
- must work on a statically linked binary (AppRun)
- will be implemented in C
Context:
In the AppImage project have been working on a feature to allow creating backward compatible bundles. To achieve this we created a program named AppRun. Things program compares the system glibc version with the one shipped in the bundle and configures the bundle to use the newer at runtime. This program is statically linked and should not depend on external tools.
Right now we scan the libc.so
file for occurrences of GLIBC_X.XX
and store the greater. But this is no longer working in the latest binary include in Ubuntu 20.04. The binary is 2.31 but there are no GLIBC_2.31
strings in the file therefore the method fails.
Related issues: