'Illegal Instruction in Hello World Program

I have an Assembly file called "main.asm" which has the following code:

    section .data
    hello: db "Hello World", 10
    helloLen: equ $-hello
section .text
    global _start
_start:
    mov rax, 1
    mov rdi, 1
    mov rsi, hello
    mov rdx, helloLen
    mov rdx, 14
    syscall
    mov rax, 60
    mov rdi, 0
    syscall

But when I assemble and link it with:

nasm -f elf64 main.asm -o main.o && ld main.o -o main && ./main

It gives me the following output:

enter image description here

This is weird because it worked for several days printing out "Hello World" and now it's this.



Solution 1:[1]

The problem was that my PC changed the Terminal from Kali Linux which I'm using with WSL to "Git Bash", it created a main.o and main file but it couldn't give an output from the file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1