"? You just need to clarify one line of code in the "hello world" program in x86 assembly " call 0x80482f0 < puts...">

Msgstr "call 0x80482f0 <puts @plt>"? You just need to clarify one line of code in the "hello world" program in x86 assembly

" call 0x80482f0 < puts@plt > "? I just need help with a single line of code in the hello world program in x86 assembly.

NOTE. I run ubuntu linux during programming / debugging, using gcc as a compiler and gdb for debugging.

I read Hacking: The Art of Exploitation V2 and I compiled this program in C:

 1 #include <stdio.h> 2 3 int main() 4 { 5 int i; 6 for(i=0; i<10; i++) 7 { 8 printf("Hello, world\n"); 9 } 10 return 0; 

into this program in the assembly:

  0x080483b4 <+0>: push ebp 0x080483b5 <+1>: mov ebp,esp 0x080483b7 <+3>: and esp,0xfffffff0 0x080483ba <+6>: sub esp,0x20 0x080483bd <+9>: mov DWORD PTR [esp+0x1c],0x0 0x080483c5 <+17>: jmp 0x80483d8 <main+36> 0x080483c7 <+19>: mov DWORD PTR [esp],0x80484b0 0x080483ce <+26>: call 0x80482f0 < puts@plt > => 0x080483d3 <+31>: add DWORD PTR [esp+0x1c],0x1 0x080483d8 <+36>: cmp DWORD PTR [esp+0x1c],0x9 0x080483dd <+41>: jle 0x80483c7 <main+19> 0x080483df <+43>: mov eax,0x0 0x080483e4 <+48>: leave 0x080483e5 <+49>: ret 

now .. I understand every part of this program until it reaches:

  0x080483ce <+26>: call 0x80482f0 < puts@plt > 

what I don't understand is .. if "Hello, world \ n" is stored in 0x80484b0, and this address is then stored in the address in ESP, why:

 0x080483ce <+26>: call 0x80482f0 < puts@plt > 

refer to 0x80482f0 instead of [esp] or just "0x80484b0" to print "Hello, world \ n" on the screen? I used gdb and I can't figure out what exactly refers to 0x80482f0 .. any help would be great

thanks (and remember I'm just starting with this stuff, so im no no)

In addition, I copy and paste the disassembled main function from gdb for convenience, if you need more information, just ask. and if you want to explain that one command is for me, that would be great, because I used only "int 80h" to print the material on the screen before

+3
assembly debugging x86 linux
source share
1 answer

0x80482f0 is the address of the puts function. More precisely, it points to an entry for puts() in the program linker (PLT) table - basically just a bunch of JMP <some routine in a so-library> (this is a little more complicated than that, but it is not important for this discussion). The puts function looks for its argument on the stack, i.e. In [esp] .

You may be wondering where this puts() call came from - the compiler here was smart enough to make sure you didn't actually use any format string parameters in your call to printf() and replaced that call with a call to (somewhat faster) puts() . If you look carefully, you will see that it also deleted a new line from your line, because puts() adds a new line after printing the line that it sets.

+14
source share

All Articles