<Connector and loader> - Overview connector and loader

0. relates term

  (1) address binding

    Abstract symbols more abstract symbol binding, such as binding sqrt symbolic address 0x0020010.

  (2) symbol resolution

    Program interaction by symbols, such as the main program calls a library function sqrt, to resolve the connector by the symbol indicates that the address assigned to sqrt and modify the code so that the command can call the call address.

  (3) Program Load

    Refers to the data copied from disk into memory, often also comprising allocated storage space, a protection bit virtual memory addresses to map virtual memory pages on disk.

 

1. Connector

  (1) is mainly responsible for work

    Database queries, relocation, connection

  (2) Relocation

    Relocation is to rewrite the bind address.

    [1] relocation of development

      Appear before the operating system, an exclusive program memory, the address operation can be determined before the operation, when the connection determining relocation.

      After the operating system appears, the program shared memory address determined run operation, the relocation is determined at the time of loading. Then cover the technology appeared.

      After the emergence of virtual memory, program memory exclusively, determine the address of the connection. Covering technology obsolescence.

    [2] library with relocation  

      Static library

        Complete a static library binding when generating the address, the introduction of the program is called when the connection routine, and reposition.

      Dynamic library

        Is not bound address before the program runs.

  (3) connected to both sides

    Information (1) input connector

      + + Object file libraries connector == ... == "object files

      specific:

      All object files and library files contain two pieces of information: a variety of segments, the symbol table.

      [1] Program segment

        Thanks to the operating system, multiple processes may run a program at the same time, in order to save space, the program is divided into portions will change and will not change, so that the same general process will not change the program period, the connection must be of the same section combine together.

      [Table 2] Symbol

        Import symbol table contains the symbol, the symbol export, import symbols: undefined file, single cited. Export Symbol: File definition, be referenced by other files.

    (2) first scan

      Scan all incoming segment information, symbol table, and obtain the entire memory segment size distribution.

    (3) the second scan

      First scan using the actual connection process control information, reads relocatable object code, a digital address is replaced symbolic references, and adjust the data memory address codes to reflect the segment address relocation and relocatable code written to the output Target file.

      While also output file header information, relocation and symbol table information segment.

      If you call a dynamic library, but also contains the information needed to connect to parse a dynamic symbol of runtime.

      The connector also generates a small amount of code and data, such as program start points of each pointer array initialization routine needs to be called.   

Guess you like

Origin www.cnblogs.com/yangxinrui/p/10991188.html