"In-depth understanding of computer Systems" chapter seventh reading notes

Source: Internet
Author: User

I. Links Overview 1. Links
    1. Definition: A link is the process of collecting various kinds of data and code into a single file (this file can be copied to the memory and executed)
    2. Occasion:
      • Compile time: The source code is translated into machine code
      • Load: Program loaded into memory by loader and executed
      • Run-time
    3. Role:
      • Makes it possible to split a compilation (breaking large applications into several small modules)
2. Foreshadowing-compile driver and target file, symbol table

The compilation driver invokes the language preprocessor, compiler, assembler, and connector on behalf of the user

    1. The preprocessor translates. c files into ASCII intermediate files. I;
    2. The compiler translates. I files into an ASCII assembly language file. S;
    3. The assembler translates. s files into relocatable target files. O;
    4. The linker program combines the. o file with some necessary files to create an executable target file;
    5. The loader copies the executable code and data to the memory and then transfers control to the program header

There are three forms of the target file:

    1. To relocate a target file
    2. Executable Target file
    3. Share destination file
3. Static link

The two main tasks of a linker

    1. Symbolic parsing: Associate each symbol reference with exactly one symbol definition
    2. Reposition: The linker links each symbol definition to a memory location.
4. Symbol parsing
    1. For those local symbols that are defined in the same module as the reference, the compiler allows only one definition for each local symbol in each module
    2. For the resolution of global symbols
      • When the compiler encounters a symbol that is not defined in the current module, it assumes that the symbol is defined in a module, generates a linker symbol table entry, and then gives it to the linker to process
      • If the referenced symbol is not found in any of the linker's modules, it outputs an error message and then terminates
      • For global symbols with multiple definitions:
        • The function and the initialized global variable are strongly signed, and the uninitialized global variable is a weak symbol
        • Rules:
          1. Multiple strong symbols are not allowed
          2. If you have a strong symbol and multiple weak symbols, select the strong symbol
          3. If you have more than one weak symbol, choose one from either
5. Reposition

Relocation consists of two steps

    1. Reposition section and Symbol definitions: the linker merges all sections of the same type into a new aggregation section of the same type
    2. The symbol reference in the relocate section: the linker modifies the reference to each symbol in the Code section and data section so that they point to the correct runtime address

Relocation Entries:

Whenever the assembler encounters a target reference to the final location, it generates a relocation entry that tells the linker how to modify the reference when it merges the target file into an executable file.

6. Connecting to a static library
    1. Overview: The compilation system provides a mechanism to package all relevant target modules into a single file, called a static library, which can be used as a linker input
    2. Advantages:
      • The associated function can be compiled into a separate target module and then encapsulated into a separate static library file
      • The linker copies only the target modules referenced by the referenced program, which reduces the size of the executable file in disk and memory
7. Loading the executable file
    1. The loader copies the code and data from the disk to the storage in the executable target file, and then runs the program by jumping to the first instruction of the program
    2. A runtime memory image is added to each UNIX program

"In-depth understanding of computer Systems" chapter seventh reading notes

Related Article

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.