Ldd and pvs commands in Linux

Source: Internet
Author: User

The ldd command and the pvs command ldd command in Linux are used to determine the dynamic library contained in an executable binary file.
Parameter description: -- version prints the version number of ldd-v -- verbose prints all information, for example, including the version information of the symbol-d -- data-relocs re-deployment, and report the missing target object (only applicable to the ELF format)-r -- function-relocs re-deploys the target object and function execution, and report the missing target object and function (applicable only to the ELF format) www.2cto.com -- help usage information. If the given library name in the command line contains '/', the libc5 version of this program uses it as the Library name; otherwise, it will search for the library in the standard location. Run a shared library under the current directory with the prefix "./". Error: ldd cannot work on a. out shared library. Ldd cannot work on some very old a. out programs that have been created before the release of ldd compilers. If you use ldd in this type of program, the program will try the running mode of argc = 0, and the result is unpredictable. For example, ldd/bin/bash, but ldd itself is not a program, but only a shell script: $ which ldd/usr/bin/ldd $ file/usr/bin/ldd: the Bourne-Again shell script text executable ldd command is actually implemented by setting some environment variables (that is to say, ldd only sets the value of some environment variables), such as: LD_TRACE_LOADED_OBJECTS
You only need to set its value to a non-null value. $ Export LD_TRACE_LOADED_OBJECTS = 1 $ ls/usrlinux-gate.so.1 => (0xb7fac000) librt. so.1 =>/lib/tls/i686/cmov/librt. so.1 (0xb7f93000) libselinux. so.1 =>/lib/libselinux. so.1 (0xb7f79000) libacl. so.1 =>/lib/libacl. so.1 (0xb7f70000) libc. so.6 =>/lib/tls/i686/cmov/libc. so.6 (0xb7e0d000) libpthread. so.0 =>/lib/tls/i686/cmov/libpthread. so.0 (0xb7df4000)/lib/ld-linux.so.2 (0xb7fad000) www.2cto.com libdl. so.2 =>/Lib/tls/i686/cmov/libdl. so.2 (0xb7df0000) libattr. so.1 =>/lib/libattr. so.1 (0xb7dea000) undo this environment variable, and ls can resume normal use: $ unset LD_TRACE_LOADED_OBJECTS $ ls/usr/bin games include lib lib32 lib64 local sbin share src X11R6 more environment variables: 1. The default environment variables LD_TRACE_LOADED_OBJECTS2, LD_WARN3, LD_BIND_NOW4, LD_LIBRARY_VERSION5, LD_VERBOSE6, and LD_DEBUG ldd are: Environment = 1 and other variables (and values) corresponding to some options, -- data-relocs-> LD_WARN = Yes-r, -- function-relocs-> LD_WARN and LD_BIND_NOW = yes-u, -- unused-> LD_DEBUG = "unused"-v, -- verbose-> LD_VERBOSE = yes www.2cto.com LD_TRACE_LOADED_OBJECTS is the necessary environment variable. Others depend on the actual situation. The essence of the ldd command is to execute:/lib/ld-linux.so. * We can find from the above content (ls/usr):/lib/ld-linux.so.2 (0xb7fad000 ). $ Ls-l/lib/ld-linux.so. * lrwxrwxrwx 1 root 9/lib/ld-linux.so.2-> the ld-2.9.so just compiled file may be:/lib/ld. so. For libc5, It is/lib/ld-linux.so.1, while glibc2 should be/lib/ld-linux.so.2. $/Lib/ld-linux.so.2-list/bin/lslinux-gate.so.1 => (0xb8050000) librt. so.1 =>/lib/tls/i686/cmov/librt. so.1 (0xb8037000) libselinux. so.1 =>/lib/libselinux. so.1 (0xb801d000) libacl. so.1 =>/lib/libacl. so.1 (0xb8014000) libc. so.6 =>/lib/tls/i686/cmov/libc. so.6 (0xb7eb1000) libpthread. so.0 =>/lib/tls/i686/cmov/libpthread. so.0 (0xb7e98000)/lib/ld-linux.so.2 (0xb8051000) libdl. so.2 =>/lib/tls/i686/cmo V/libdl. so.2 (0xb7e94000) libattr. so.1 =>/lib/libattr. so.1 (0xb7e8e000) We can see that the above is equivalent to ldd ls. The shared library files available for ldd are actually files (/etc/ld. so. cache) created by reading the ldconfig command ). The default shared library file search/lib takes precedence over/usr/lib, and only the two directories are available. To add other paths, use the ldconfig command to configure related files.
The general ld-linux.so will search the shared library in the following order: 1, DT_RPATH or DT_RUNPATH Segment 2, environment variable LD_LIBRARY_PATH3,/etc/ld. so. path in the cache file, but if the executable program adds the-z nodeflib option during connection, Skip. 4. The default path is/lib and/usr/lib. If-z nodeflib is added, skip this step. PVSDisplay the internal version information of dynamic objects within an ELF file. commonly these files are dynamic executables and shared objects, and possibly relocatable objects. this version information can be fall into one of the following two categories: www.2cto.com Version definitions described the interface made available by an ELF file. each version definition is associated to a set of global symbols provided by the file. version dependencies describe the binding requirements of dynamic objects on the version definition of any shared object dependencies. when a dynamic object is built with a shared object, the link-editor records information within the dynamic object indicating that the shared object is a dependency. syntaxpvs [-d] [-l] [-n] [-o] [-r] [-s] [-v] [-N name] file-d Print version definition information. -l When used with the-s option, print any symbols that have been forced CED from global to local binding due to versioning. by convention, these symbol entries are located in. symtab section, and fall between the FILE symbol representing the output file, and the FILE symbol representing the first input file used to generate the output file. these incluced symbol entries are assigned the fabricated version definition _ already CED _. noreduced symbols will be printed if the file has been stripped, or if the symbolentry convention cannot be determined. -n Normalize version definition information. by default, all version definitions within the object are displayed. however, version definitions may inherit other version definitions, and under normalization only the head of each inheritance list is displayed. -o Create one-line version definition output. by default, file, version definitions, and any symbol output is indented to define human inspection. this option prefixes each output line with the file and version definition name and may be more useful for analysis with automatic tools. www.2cto.com-r Print version dependency (requirements) information. -s Print the symbols associated with each version definition. any data symbols are accompanied with the size, in bytes, of the data item. -v Verbose output. indicates any weak version definitions, and any version definition inheritance. when used with the-N and-d options, the inheritance of the base version definition is also shown. when used with the-s option, the version symbol definition is also shown. -N name Print only the information for the given version definition name and any of its inherited version definitions (when used with the-d option ), or for the given dependency file name (when used with the-r option ). file The ELF file about which internal version information is displayed. examplespvs/usr/lib/64/libc. so.1 author icybay

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.