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
While PLT is used for function calls, GOT is used for data. GOT also holds the actual pointers to external code used by the PLT stubs (though sometimes they're grouped in a separate .plt.got section).
Just need clarification of one line of code in a 'hello world' program in x86 assembly 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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With