< puts @ plt>到底是什么?意思是? [英] What exactly does <puts@plt> mean?

查看:295
本文介绍了< puts @ plt>到底是什么?意思是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此刻,我尝试更接近汇编程序编程,因此着眼于一个简单的hello world程序的汇编程序代码:

#include <stdio.h>

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

现在,我逐步逐步了解汇编代码并分析实际发生​​的情况,然后尝试了解几个简单的汇编命令的工作原理:

   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 

问题是我不太了解这一行:

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

我尝试以各种方式查看地址0x400410,但我没有真正了解它的真正作用:/另外,我也不知道这到底是什么意思:<puts@plt>

如果有人可以帮助我理解这一特定行,那将真的很棒:) 昏昏欲睡的问候

解决方案

PLT表示过程链接表.这是一种特殊的技术,用于ELF文件中,可以在加载有可用相对寻址的计算机上本地化修复问题.

您正在调用的函数位于另一个模块(通常为libc.so. x )中,因此,在加载要执行的程序时必须提供该函数的实际地址./p>

PLT本质上是可执行文件(或.so文件)中的所有未完成引用都收集到的区域.它们具有目标计算机的跳转指令的形式,而实际地址仍未填充.由加载程序填充地址.该过程称为修复.

由于模块的其余部分使用相对寻址通过PLT进行函数调用,并且在链接时知道PLT的偏移量,因此无需在此进行任何固定.这意味着您的大多数模块可能会继续映射到模块文件而不是交换文件上.

还必须注意,与PLT互补的是GOT(全局偏移表). PLT用于函数调用,而GOT用于数据.

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

解决方案

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.

这篇关于&lt; puts @ plt&gt;到底是什么?意思是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆