Compiling and static linking

Source: Internet
Author: User

    1. Once each source code is compiled independently, it needs to be "assembled", which is the link. The main task of the link is to handle each of the modules in the same place, so that each module can be properly connected. The procedures for

    2. Links mainly include address and space allocation, address binding, and relocation operations. The most basic link procedure for

    3. is as follows, with the source code file (. c), (. O), for each module;

      650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/57/1C/wKiom1SRTgqCyerBAAFMXEAi_4o022.jpg "title=" 02. PNG "width=" height= "479" border= "0" hspace= "0" vspace= "0" style= "WIDTH:350PX;HEIGHT:479PX;" alt= " Wkiom1srtgqcyerbaafmxeai_4o022.jpg "/>

    4. If the function foo () in FUNC.C is called in the program module MAIN.C, so when Foo () is called in Main.c each time, You have to know the address of the function, but since each module compiles independently at compile time, and does not know the exact address of the Foo () function, what should I do? The compiler will first put these calls to Foo () to the target address of the command to wait for the link when the linker to modify its target address, if there is no connector, then we need to manually call Foo to modify the instructions, If the FUN.C module is recompiled, then the address of Foo can change, then need to re-adjust the other module calls the Foo command address, this will be the programmer's nightmare, so the work is done to the connector to do, because the linker in the link will be based on the symbol Foo you reference, automatically to the FUNC.C module Find the address of Foo and then re-modify the instruction of the other module reference Foo to the address of the real Foo function.

    5. At compile time, referring to functions or global variables in other modules, the target address of the response instruction of this module defaults to 0, set aside regardless, wait for the connection when the connector will modify it, the process is not called relocation.

Compile and static linking

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.