What exactly does <puts@plt> mean?

拟墨画扇 提交于 2020-07-17 07:51:14

问题


at the moment i try to get a bit closer to assembler programming and therefore looked at the assembler code of an easy hello world program:

#include <stdio.h>

int main () 
{
    int i;
    for(i=0; i<10; i++)
    {
        printf("Hello, world!\n");
    }
    return 0;
}

Now i try to understand how a fiew simple assembler commands work while going step by step through the assembler code and analyzing what exactly happens:

   0x000000000040052d <+0>: push   rbp
   0x000000000040052e <+1>: mov    rbp,rsp
   0x0000000000400531 <+4>: sub    rsp,0x10
   0x0000000000400535 <+8>: mov    DWORD PTR [rbp-0x4],0x0
   0x000000000040053c <+15>:    jmp    0x40054c <main+31>
   0x000000000040053e <+17>:    mov    edi,0x4005e4
   0x0000000000400543 <+22>:    call   0x400410 <puts@plt>
   0x0000000000400548 <+27>:    add    DWORD PTR [rbp-0x4],0x1
   0x000000000040054c <+31>:    cmp    DWORD PTR [rbp-0x4],0x9
   0x0000000000400550 <+35>:    jle    0x40053e <main+17>
   0x0000000000400552 <+37>:    mov    eax,0x0
   0x0000000000400557 <+42>:    leave  
   0x0000000000400558 <+43>:    ret 

The problem is that i dont really understand this line:

0x0000000000400543 <+22>:   call   0x400410 <puts@plt>

I tried looking at the adress 0x400410 in various ways but i dont really get it what it really does :/ Also i dont know what this exactly means: <puts@plt>

Would be really great if someone could help me to understand this specific line :) Greetings Sleepy


回答1:


PLT means Procedure Linkage Table. It is a special technique used in ELF files to localize fixing up at load time on machines where relative addressing is available.

The function you're calling is located in another module (typically, libc.so.x), therefore the actual address of the function must be provided when the program is loaded for execution.

PLT is essentially an area in your executable file (or .so file) where all outstanding references are collected together. They have the form of the target machine's jump instruction with the actual address remaining unfilled. It is up to loader to fill the addresses. The process is called fixing up.

Because the remaining part of your module makes function calls through the PLT using relative addressing, and the offset to the PLT is known at the time of linking, nothing has to be fixed up there. This means that most of your module may continue to be mapped onto the module file instead of swap file.

It has also to be noted that complementary to the PLT is the GOT, Global Offset Table. While PLT is used for function calls, GOT is used for data.



来源:https://stackoverflow.com/questions/25667205/what-exactly-does-putsplt-mean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!