S
S
sos1mple2020-03-23 19:05:34
GCC
sos1mple, 2020-03-23 19:05:34

Why is the object(Nasm) file not going to the executable?

There is a code written in NASM:

global start

    section .data
message: db "Hello, World", 10

    section .text
start:
    mov rax, 0x20000004
    mov rdi, 1
    mov rsi, message
    mov rdx, 13
    syscall
    mov rax, 0x20000001
    xor rdi, rdi
    syscall


I assemble it with the command
nasm -f macho64 file.asm
. I try to turn the resulting file file.o into an executable file with the help of
gcc file.o
which an error is generated:
Undefined symbols for architecture x86_64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64


Thanks in advance for your reply!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-03-23
@sos1mple

Hold on, but start learning asembler on a poppy, it's kind of cool
; /usr/local/bin/nasm -f macho64 64.asm && ld -macosx_version_min 10.7.0 -lSystem -o 64 64.o && ./64
https://gist.github.com/FiloSottile/7125822
I don't know. Write a makefile, I have everything assembled
5f9e1ee5df.jpg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question