Post

Replies

Boosts

Views

Activity

nasm - Undefined symbols for architecture x86_64:
I am running Catalina - 10.15.6. & all the needed development tools including Xcode. I am getting this error with a simple Mac assembly 'hello world' program hello.asm I will appreciate any help $ nasm -fmacho64 hello.asm && ld hello.o && ./a.out Undefined symbols for architecture x8664:   "main", referenced from:      implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 ; ; Writes "Hello, World" to the console using only system calls. Runs on 64-bit macOS only. ; To assemble and run: ; ; nasm -fmacho64 hello.asm && ld hello.o && ./a.out ; ----------------------------------------------------------------------------------------			global		start section .text start: mov rax, 0x02000004 ; system call for write mov rdi, 1 ; file handle 1 is stdout mov rsi, message ; address of string to output mov rdx, 13 ; number of bytes syscall ; invoke operating system to do the write mov rax, 0x02000001 ; system call for exit xor rdi, rdi ; exit code 0 syscall ; invoke operating system to exit section .data message: db "Hello, World", 10 ; note the newline at the end
2
0
2.2k
Sep ’20