A string command
The string command is mainly used to view the ASCII string in a non-text file. Of course, you can also view the corresponding string of a text file. The command is used as follows:
[22: 41huangyk @ leetcode] $> strings-a numDistinct | grep lib
/Lib64/ld-linux-x86-64.so.2
Libstdc ++. so.6
Libm. so.6
Libgcc_s.so.1
Libc. so.6
_ Libc_start_main
/Usr/local/gcc4.8.3/lib/gcc/x86_64-unknown-linux-gnu/4.8.3/include
Libio. h
Cstdlib
Stdlib. h
_ Libc_csu_fini
_ Libc_start_main @ GLIBC_2.2.5
_ Libc_csu_init
NumDistinct is an executable file. By default, the initialization section and the loadable bytes are printed. After the-a parameter is added, all segments are printed.
Ii. Loading ELF files and links
In some cases, there may be multiple ELF file versions compiled by GCC on our system at the same time. In this case, if you run the program, it is easy to see the problem "/usr/lib64/libstdc ++. so.6: version 'glibcxx _ 3.4.14 'not found solution ". For more information, see the corresponding blog. Here we will discuss a question:
In an ELF file format, How do I know which connector is needed and which version of glibc is used?
Answer: The ELF file contains a lot of information, including the connector and glibc version required to execute this file. You can use the string command to view details. The result is as follows:
[22: 52huangyk @ leetcode] $> strings numDistinct | grep GLIB
GLIBC_2.2.5
GLIBCXX_3.4.5
GLIBCXX_3.4.14
GLIBCXX_3.4