##### SOURCE CODE ########### root@mksecurity:~# cat arm.c #include <stdio.h> void foo(const char *s) { printf("%s", s); } int main(void) { foo("Hello World"); return 0; } #### READELF INFORMATION ####### root@mksecurity:~# arm-linux-gnueabihf-readelf -h arm.bin ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: DYN (Shared object file) Machine: ARM Version: 0x1 Entry point address: 0x495 Start of program headers: 52 (bytes into file) Start of section headers: 9556 (bytes into file) Flags: 0x5000400, Version5 EABI, hard-float ABI Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 9 Size of section headers: 40 (bytes) Number of section headers: 36 Section header string table index: 35 ###### DEBUGGING ######### gdb-peda$ r Starting program: /root/arm.bin warning: Selected architecture arm is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description /build/gdb-A87voC/gdb-7.12/gdb/i387-tdep.c:919: internal-error: void i387_supply_xsave(regcache*, int, const void*): Assertion `tdep->st0_regnum >= I386_ST0_REGNUM' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. This is a bug, please report it. For instructions, see: <http://www.gnu.org/software/gdb/bugs/>. Aborted (core dumped)
Confirmed. gdb shouldn't crash here.
This seems to have been fixed in gdb 13. While 12 crashes for me, with 13 I get: (gdb) r Starting program: /home/tromey/gdb/PRs/pr-21170-wrong-arch/simple_main /bin/bash: line 1: /home/tromey/gdb/PRs/pr-21170-wrong-arch/simple_main: cannot execute binary file: Exec format error /bin/bash: line 1: /home/tromey/gdb/PRs/pr-21170-wrong-arch/simple_main: Success During startup program exited with code 126.