Im learning asm stuff so in the future i mean the future i can eventually get at the security field to knowing about xploits so i have a amd64 machine but many examples comes in 32bits asm programs so in my ubuntu based machine MINT i have to compile with 32bits option but i was not sure if i can do this so the google-fu save and check that i need to put the option -m32 on gcc so i try it out
$ gcc -m32 -o example example1.c
but i get:
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: ld returned 1 exit status
$
... so google-fu again and find that i have to actually install multilib for gcc so i check out the version of my gcc and use the GUI to manage the packet but actually in the command will be
$ sudo apt-get install gcc-4.6-multilib
after this
$ gcc -m32 -o example example1.c
and then OK
$ objdump -m intel -d example1
80482d8: 53 push %ebx
80482d9: 83 ec 08 sub $0x8,%esp
80482dc: e8 00 00 00 00 call 80482e1 <_init+0x9>
80482e1: 5b pop %ebx
80482e2: 81 c3 13 1d 00 00 add $0x1d13,%ebx
80482e8: 8b 83 fc ff ff ff mov -0x4(%ebx),%eax
80482ee: 85 c0 test %eax,%eax
No comments:
Post a Comment