The difference between printf @plt and puts @plt

I learn assembly language by parsing some C codes. When I parse this basic C code with GDB:

#include <stdio.h>
void main(void) {
    printf("Hello World\n");
}

Among the assembly code, it gives the following line:

0x08048424 <+25>:   call   0x80482e0 <puts@plt>

However, when I parse the code below that has an integer in the printf function:

#include <stdio.h>
void main(void) {
    int a = 1;
    printf("Hello Word %d\n", a);
}

It gives the following line:

0x0804842e <+35>:   call   0x80482e0 <printf@plt>

What is the difference between printf @plt and puts @plt?

Why doesn't the disassembler recognize the printf function without an integer parameter?

+4
source share
3 answers

GCC printf puts . , . , , ( / ) .

puts , , , .

, . printf - printf - . , printf, : . , printf puts.

, printf printf, .. printf - .

( 2005 : http://www.ciselant.de/projects/gcc_printf/gcc_printf.html)

+9

@plt, printf puts - . printf , , . puts , . C

man 3 printf
man 3 puts

Unix- man-. (man printf 3 printf, printf.)

printf("Hello, world\n");

:

puts("Hello, world");

, , , .

printf("Hello Word %d\n", a);

a , . ( , , a ).

, .

(, void main(void) , int main(void).)

+4

puts printf , , . ( @plt), .

, printf puts:

08048370 <printf@plt>:
 8048370:       ff 25 04 a0 04 08       jmp    *0x804a004
 8048376:       68 08 00 00 00          push   $0x8
 804837b:       e9 d0 ff ff ff          jmp    8048350 <_init+0x3c>

08048380 <puts@plt>:
 8048380:       ff 25 08 a0 04 08       jmp    *0x804a008
 8048386:       68 10 00 00 00          push   $0x10
 804838b:       e9 c0 ff ff ff          jmp    8048350 <_init+0x3c>

, - , , . , , printf puts, , . , , printf, puts, , , , .

+1

Source: https://habr.com/ru/post/1651611/


All Articles