Dynamic linker (3) steps and Implementation of Dynamic Links

Source: Internet
Author: User

General steps: dynamic linker auto-uploads (related to. Dynamic segments) Load shared objects (involving global symbol tables, symbol priorities, etc.) for relocation and initialization <? XML: namespace prefix = o ns = "urn: Schemas-Microsoft-com: Office: office"/>

1> gcc-xlinker-rpath./indicates that the linker searches for shared objects in the current path.

 

2> when the shared library is loaded to the address space of the process, all the symbols in the shared library will be incorporated into the global symbol table.

 

3> after the automatic configuration is completed, the dynamic linker can merge the executable files and the symbols of the linker into a symbol table. We can call it a global symbol table.

 

4> global symbol intervention: the global symbol in a shared object is overwritten by the global symbol of the same name in another shared object.

 

5> in Linux, the dynamic linker defines a rule, that is, when a symbol needs to be added to the global symbol table, if the same symbol name already exists, the added symbols are ignored. (Therefore, duplicate symbols should be avoided for shared objects.

 

6> the syntax of the stait func () function is to compile the function into a unit private function and make sure it is not called by other modules. That is, the internal call command of the module can speed up the call without processing. Got. PLT. Does this mean that code is not generated in cross-module mode?

 

7> in Linux, the virtual space loaded to the process is called through the execve () system, and the control is handed over to the dynamic linker. The entry to the static link program is the e_entry address in the ELF file header. For dynamic links, the kernel analyzes the dynamic linker address (in the. interp segment ). Map the dynamic linker to the process address space and give control to the dynamic linker. The actual shared objects and executable files are not distinguished by their own quality. In Windows, rundll32.exe can also be directly used as a. dll file.

 

8> Linux dynamic linker is part of glibc. Its source code is located under the elf directory of glibc source code.

About dynamic linker:

1> the dynamic linker should be a static link, and it does not depend on any shared object.

2> it is not necessarily a pic, but it is a pic. Brings many benefits

 

Shared Library Organization

1> the Linux shared library is named libname. So. x. y. z x. The main version number is Y. The minor version number is Z.

Different major versions are completely incompatible, which changes the excuse. This version adds new interfaces for backward compatibility. The release version number interface remains unchanged, and is only an internal change.

 

2> use so-name as the name to create a soft link: So-name is used for all modules that depend on the shared library. No detailed version number is required, which makes it easy to update.

 

3> when the shared library is upgraded: If the master version is not upgraded, replace the old version with the new version of the shared library and change the so-name soft link to the new version; however, if you upgrade the system with the primary version number, there will be multiple SO-NEME, one old one, which will not affect the operation of the old program

 

4> In short, so-name indicates the interface of a library. If the interface is not backward compatible, so-name changes.

 

5> after the shared library is installed, the ldconfig tool provided in Linux will search for all the shared library directories in/lib/usr/lib, and then update all soft links.


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.