I've been toying around with x86 64 bit assembly on linux recently and after compiling a seemingly simple program I am left scratching my head :P
Although I compile and link it throws no errors and produces a linux ELF When i try to run it I get:
.:[ h4unt3r@sp3ctr4l-h0st asm ]:.
#(0)> ./hello
bash: ./hello: No such file or directory
I assume its producing an invalid ELF file which is why it reports hello is not there even though it IS. Not sure why-- I'll probably keep playing around with it, just curious if this can be solved the easy way ^_^
Here is my compile / link command line:
nasm -f elf64 hello.s -g
ld -o hello hello.o -lc
Here is the code:
section .data
msg: db "Hello, world!",0xa,0
section .text
extern printf
global main
main:
push rbp
mov rbp, rsp
mov rdi, msg
xor rax, rax
call printf
xor rax, rax
pop rbp
ret
Edit -- I do not want to use gcc :)