When trying to debug (after compiling and linking) assembly 86-64x program called hello_world, I got a gdb error "not in executable format: file format not recognized".
ubuntu@ubuntu:~$ gdb hello_world
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
"/home/ubuntu/hello_world": not in executable format: File format not recognized
I use Ubuntu 64x OS and gdb 8.1.0 64x.
I have looked for other answers, but couldn't understand what to do or the solution was for mac OS.
When running
`ubuntu@ubuntu:~$ file hello_world
I got
hello_world: ASCII text
After looking this answer I understood that gdb doesn't know what to do with this file, but I didn't figure out how to change the file's format.
My hello_world program:
global _start
section .text
_start:
mov rax,1
mov rdi,1
mov rsi,message
mov rdx,13
syscall
mov rax,60
xor rdi,rdi
syscall
section .data
message: db "Hello, World",10
I have compiled and linked using the next commands:
ubuntu@ubuntu:~$ nasm -felf64 hello_world
ubuntu@ubuntu:~$ ld hello_world.o