as i'm new about cross-debugging and cross-compilation i need some help because i feel so confused. I have a MIPS elf file, [myelf][1] .You can see bellow the output of file myelf
:
myelf: ELF 32-bit LSB executable, MIPS, MIPS-I version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, BuildID[sha1]=0xc89c3571514c7ec1afc74a189a9c2d24e276ec4c, with unknown capability 0xf41 = 0x756e6700, with unknown capability 0x70100 = 0x1040000 stripped
I just want to run and debug the program. So i don't need a cross compiler right ? As i don't have MIPS hardware (i have an INTEL microprocessor), i need an emulator. I've chosen to use QEMU. According to this site, i downloaded the following kernel image and initrds:
debian_squeeze_mips_standard.qcow2
vmlinux-2.6.32-5-4kc-malta
Then i've run the specified command for a 32 bit (because the elf informations) MIPS system.
qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta -hda debian_squeeze_mips_standard.qcow2 -append "root=/dev/sda1 console=tty0"
So far, i have the emulator running in one shell and the command uname -a gives me:
Linux debian-mips 2.6.32-5-4kc-malta #1 Tue Sep 24 00:02:22 UTC 2013 mips GNU/Linux
There are only the very basics commands/tools on the emulator. I've read that gdb can debug on a remote target (here the MIPS-emulator) from an host machine which is my x86_64. And to be honest i have no idea about what i should do now. I first tried to install gdb itself on the the qemu emulator.When i run gdb my elf i can see that gdb was automatically configured as mips-linux-gnu.
root@debian-mips:~# gdb myelf
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "mips-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /root/myelf...(no debugging symbols found)...done.
The info files gives me the right informations (i disassembled the elf with IDA so i can confirm).
(gdb) info files
Symbols from "/root/myelf".
Local exec file:
`/root/myelf', file type elf32-tradlittlemips.
Entry point: 0x400670
0x00400154 - 0x00400161 is .interp
0x00400164 - 0x00400184 is .note.ABI-tag
0x00400184 - 0x0040019c is .reginfo
0x0040019c - 0x004001c0 is .note.gnu.build-id
0x004001c0 - 0x00400298 is .dynamic
0x00400298 - 0x0040033c is .hash
0x0040033c - 0x0040049c is .dynsym
0x0040049c - 0x0040057b is .dynstr
0x0040057c - 0x004005a8 is .gnu.version
0x004005a8 - 0x004005d8 is .gnu.version_r
0x004005d8 - 0x00400668 is .init
0x00400670 - 0x00400b00 is .text
0x00400b00 - 0x00400ba0 is .MIPS.stubs
0x00400ba0 - 0x00400bec is .fini
0x00400bec - 0x00400c2c is .rodata
0x00400c2c - 0x00400c30 is .eh_frame
0x00410c30 - 0x00410c3c is .ctors
0x00410c3c - 0x00410c44 is .dtors
0x00410c44 - 0x00410c48 is .jcr
0x00410c50 - 0x00410e00 is .data
0x00410e00 - 0x00410e04 is .rld_map
0x00410e10 - 0x00410e6c is .got
0x00410e6c - 0x00410e70 is .sdata
0x00410e70 - 0x00410e80 is .bss
But when i want to run the program nothing is happening:
(gdb) r
Starting program: /root/myelf
I waited about 10 mins and nothing happened. (Normally the program should print a string "Usage : ./myelf password" as i didn't give any arguments). Then i tried with gdbserver on the emulator and a gdb configured for a mipsel processor on the host machine but it didn't work..
I may do something wrong or stupid because i'm quite confused. If anybody can tell me what's wrong in my process or if someone tried to run myelf file, I would know how he did in order to be able to run any program on different machine.
Thank you, have a good day!