Bonjour,
J'ai un petit pb de comprehension, j'ai un programme qui deborde au
bout 44 octet à cause d'un depassement d ela taille du tableau.
Mais ce que je comprend pas c'ets que ton le oce en assembleur il
reserve 56 octet (Ox38) dans la pile au lieu de 0x20.
Peux on m'expliquer ou dans la partie asm je peux voir la reel taille du tableau ?
Merci d'avance de vos réponses,
code en C :
void return_input (void){
char array[30];
gets (array);
printf("%s\n", array);
}
main() {
return_input();
return 0;
}
code en asm :
Dump of assembler code for function main:
0x080483ea <main+0>: push %ebp
0x080483eb <main+1>: mov %esp,%ebp
0x080483ed <main+3>: sub $0x8,%esp
0x080483f0 <main+6>: and $0xfffffff0,%esp
0x080483f3 <main+9>: mov $0x0,%eax
0x080483f8 <main+14>: sub %eax,%esp
0x080483fa <main+16>: call 0x80483c4 <return_input>
0x080483ff <main+21>: mov $0x0,%eax
0x08048404 <main+26>: leave
0x08048405 <main+27>: ret
End of assembler dump.
(gdb) disas return_input
Dump of assembler code for function return_input:
0x080483c4 <return_input+0>: push %ebp
0x080483c5 <return_input+1>: mov %esp,%ebp
0x080483c7 <return_input+3>: sub $0x38,%esp <--- Reservation de 0x38 octet
0x080483ca <return_input+6>: lea 0xffffffd8(%ebp),%eax
0x080483cd <return_input+9>: mov %eax,(%esp)
0x080483d0 <return_input+12>: call 0x80482c4 <_init+40>
0x080483d5 <return_input+17>: lea 0xffffffd8(%ebp),%eax
0x080483d8 <return_input+20>: mov %eax,0x4(%esp)
0x080483dc <return_input+24>: movl $0x8048524,(%esp)
0x080483e3 <return_input+31>: call 0x80482e4 <_init+72>
0x080483e8 <return_input+36>: leave
0x080483e9 <return_input+37>: ret