function Library Management: Ldconfig and/etc/ld.so.conf and LDD

Source: Internet
Author: User

Now know the dynamic and static function library, but also know that most of the current Linux is the function library into a dynamic function library, the following discussion to increase the function library read performance methods. We know that the speed of memory access is several times the hard drive, therefore, if the commonly used dynamic function libraries are loaded into memory (caching, cache), when the software suite is to adopt the Dynamic function library, it does not need to be read out from the hard disk, so it can improve the reading speed of the dynamic function library. This time need ldconfig and /etc/ld.so.conf help.

The process of loading a dynamic function library into the cache (cache) is as follows:

1. First, write down the "directory where you want to read the dynamic function library in the cache" in/etc/ld.so.conf, and note that it is a directory rather than a file.

2. Read the/etc/ld.so.conf data into the cache using the Ldconfig execution file.

3. Record the data in the/etc/ld.so.cache file at the same time.

In fact, Ldconfig can also be used to determine the connection information of a dynamic function library. Quickly use the Fedora Core 4来 test. Suppose you want to add a MySQL function library to the cache:

/* [Root@linux ~]# Ldconfig [F-conf] [-C Cache] [-p] parameter:-F conf:conf refers to a file name, that is, use Conf as the path of the Libarary function library, not/etc /ld.so.conf is the default value-C Cache:cache refers to a file name, that is, using cache as the cache staging function library information instead of/etc/ld.so.cache as the default value-P: Lists all of the currently owned function library data contents (In/ The data in the Etc/ld.so.cache). *//Example://Example one: Suppose the MySQL database function library in/usr/lib/mysql, how to read the cache. [Root@linux ~]# vi/etc/ld.so.conf include Ld.so.conf.d/*.conf/usr/lib/mysql <== this line is new. [Root@linux ~]# Ldconfig # screen will not display any information, normal. [Root@linux ~]# ldconfig-p 928 Libs found in cache '/etc/ld.so.cache ' libz.so.1 (LIBC6) =>/usr/lib/libz.so.1 (LIBC6) =>/usr/lib/libz.so ... The middle omit ...

Through the above actions, we can read the MySQL related function library to him in the cache, which can speed up the efficiency of the function library reading. At some point, you may join some tarball installed dynamic libraries, and you want the associated links of these dynamic libraries to be read into the cache, at which point you can write the directory name of the dynamic function library to the/etc/ld.so.conf, and then execute Ldconfig is fine.

LDD:
Having said so much, how can I tell what Dynamic library is in an executable binary file? Very simple, use LDD can know. For example, I want to know what the dynamic function libraries that/usr/bin/passwd This program contains, and you can do this:
      /* [Root@linux ~]# LDD [-VDR] [filename] parameter:-V: List all content information; d: Re-show the missing link point of the data. -R: Show ELF-related error content. *//Example://Example one: Find out the function library information of/usr/bin/passwd this file [root@linux ~]# ldd/usr/bin/passwd linux-gate.so.1 => (0x00d19000) ... ... libpam_misc.so.0 =>/lib/libpam_misc.so.0 (0x00bd6000)//...... ... In the middle of the omission ... * * The part of our preface is not always to mention passwd has a module used to Pam. How do you know. # Take a look at this file with LDD and see libpam.so. That's the function library Pam provides.//Example Two: Find out about other libraries of functions that/lib/libc.so.6 this function. [Root@linux ~]# ldd/lib/libc.so.6/lib/ld-linux.so.2 (0x00bf1000) linux-gate.so.1 => (0x00632000) [Root@linux ~]#-LDD -v/lib/libc.so.6/lib/ld-linux.so.2 (0x00bf1000) linux-gate.so.1 => (0x00111000) Version information:/lib/ Libc.so.6:ld-linux.so.2 (glibc_2.1) =>/lib/ld-linux.so.2 ld-linux.so.2 (glibc_2.3) =>/lib/ld-linux.so.2 Ld-linux.so.2 (glibc_private) =>/lib/ld-linux.so.2

In the future if you frequently upgrade the installation of RPM packages (described in the next section), you should often find the problem of ' dependent attributes '. That's right. We can first inspect the dependencies between the ' dependent function libraries ' with LDD. To get an understanding first. For example, in the above example, we examined libc.so.6, a library of functions in/lib, and found that he was actually related to ld-linux.so.2. So we need to get to know what the file is, the library of functions. Using the-V argument also lets you know which suite the library comes from. Like the above information, you can get the libc.so.6 can actually support glibc_2.1 and so on version.

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.