perche se faccio un programma ad esempio :
codice:
int main(){
printf ("%s","Ciauuu - Benvenuto in GalatolOS !\n");
printf ("%s","Come Ti Chiami : ");
char nome[500];
scanf("%s",nome);
printf ("%s","Ciao ",nome);
}
e poi prendo il codice assembly con GDB
codice:
federico@crash-overflow:~/GalatolOS$ gdb main
GNU gdb 6.6-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
(gdb) disass main
Dump of assembler code for function main:
0x08048208 <main+0>: lea 0x4(%esp),%ecx
0x0804820c <main+4>: and $0xfffffff0,%esp
0x0804820f <main+7>: pushl 0xfffffffc(%ecx)
0x08048212 <main+10>: push %ebp
0x08048213 <main+11>: mov %esp,%ebp
0x08048215 <main+13>: push %ecx
0x08048216 <main+14>: sub $0x214,%esp
0x0804821c <main+20>: mov %gs:0x14,%eax
0x08048222 <main+26>: mov %eax,0xfffffff8(%ebp)
0x08048225 <main+29>: xor %eax,%eax
0x08048227 <main+31>: movl $0x809e4e8,(%esp)
0x0804822e <main+38>: call 0x8048cf0 <puts>
0x08048233 <main+43>: movl $0x809e50a,0x4(%esp)
0x0804823b <main+51>: movl $0x809e51c,(%esp)
0x08048242 <main+58>: call 0x8048c90 <printf>
0x08048247 <main+63>: lea 0xfffffe04(%ebp),%eax
0x0804824d <main+69>: mov %eax,0x4(%esp)
0x08048251 <main+73>: movl $0x809e51c,(%esp)
0x08048258 <main+80>: call 0x8048cc0 <scanf>
0x0804825d <main+85>: lea 0xfffffe04(%ebp),%eax
0x08048263 <main+91>: mov %eax,0x8(%esp)
0x08048267 <main+95>: movl $0x809e51f,0x4(%esp)
---Type <return> to continue, or q <return> to quit---
0x0804826f <main+103>: movl $0x809e51c,(%esp)
0x08048276 <main+110>: call 0x8048c90 <printf>
0x0804827b <main+115>: mov 0xfffffff8(%ebp),%edx
0x0804827e <main+118>: xor %gs:0x14,%edx
0x08048285 <main+125>: je 0x804828c <main+132>
0x08048287 <main+127>: call 0x8050d70 <__stack_chk_fail>
0x0804828c <main+132>: add $0x214,%esp
0x08048292 <main+138>: pop %ecx
0x08048293 <main+139>: pop %ebp
0x08048294 <main+140>: lea 0xfffffffc(%ecx),%esp
0x08048297 <main+143>: ret
End of assembler dump.
(gdb)
lo metto in un file (boot.asm) non va?
boot.asm:
codice:
lea 0x4(%esp),%ecx
and $0xfffffff0,%esp
pushl 0xfffffffc(%ecx)
push %ebp
mov %esp,%ebp
push %ecx
sub $0x214,%esp
mov %gs:0x14,%eax
mov %eax,0xfffffff8(%ebp)
xor %eax,%eax
movl $0x809e4e8,(%esp)
call 0x8048cf0 <puts>
movl $0x809e50a,0x4(%esp)
movl $0x809e51c,(%esp)
call 0x8048c90 <printf>
lea 0xfffffe04(%ebp),%eax
mov %eax,0x4(%esp)
movl $0x809e51c,(%esp)
call 0x8048cc0 <scanf>
lea 0xfffffe04(%ebp),%eax
mov %eax,0x8(%esp)
movl $0x809e51f,0x4(%esp)
movl $0x809e51c,(%esp)
call 0x8048c90 <printf>
mov 0xfffffff8(%ebp),%edx
xor %gs:0x14,%edx
je 0x804828c <main+132>
call 0x8050d70 <__stack_chk_fail>
add $0x214,%esp
pop %ecx
pop %ebp
lea 0xfffffffc(%ecx),%esp
ret
PS. esiste un altro programma per prendere il codice assembly???
GRAZIEEEE