Should made main symbol global, so that linker could find it in object file when linking. Corrected code.
When doing task, tried to call simple C function from the assembly(YASM assembler):
Wrote C function:
str_t_c db "Wow", 0
global main ; That is the solution - let linker find global symbol
mov rbp, rsp
lea rdi, [str_to_c]
yasm -f elf64 -m amd64 -g dwarf2 main.asm
gcc -o main_c.o -c main_c.c
gcc -o main main_c.o main.o
In function _start:
(.text+0x20): undefined reference to main
You need to make the
main label global first, since otherwise, the object file will not contain the symbol and the linker won't recognize it.