The role of the PLT is a springboard that preserves the offset of a symbol in the relocation table (used to find a symbol for the first time) and the corresponding address of the corresponding. Got.plt.
. Rel.dyn saved the start address of the. Got segment, not proven
. Rel.plt saved information for the relocation table
. Got is said to be the offset of each symbol that holds the elf file itself, i.e., do not dynamically link, does not prove
. GOT.PLT saved the relocation address.
For example, printf is a relocatable symbol, which is the process when the symbol needs to be connected:
The main function is one address in the call. PLT segment, The first sentence here is to switch to the address of the saved printf in the. GOT.PLT, if it is the first time, then the saved address is. In the next sentence of the PLT, the next sentence is to press the offset of the relocation table in the. REL.PLT, and then the LD program will add this offset based on the information in the relocation table Find this address and save it to the address pointed to by the relocation table, which is actually an address of the. GOT.PLT segment.
The second call can be taken directly to the address saved in the. got.plt.
In short, this design makes people feel very complete, have the connection, 6666666
The relationship of the. Plt. Rel.dyn. Rel.plt. Got. Got.plt in the elf file