I have this assembmly code
main.asm
[bits 32]
global _start
extern foo_main
section .mbHeader
align 0x4
MODULEALIGN equ 1<<0
MEMINFO equ 1<<1
FLAGS equ MODULEALIGN | MEMINFO
MAGIC equ 0x1BADB002
CHECKSUM equ -(MAGIC + FLAGS)
MultiBootHeader:
dd MAGIC
dd FLAGS
dd CHECKSUM
_start:
push ebx
call foo_main
foo.cpp
void foo_main()
{
// stuff
}
Makefile
foo_source_files := $(shell find . -name *.cpp)
foo_object_files := $(patsubst %.cpp, build/%.o, $(foo_source_files))
asm_source_files := $(shell find . -name *.asm)
asm_object_files := $(patsubst ./%.asm, build/%.o, $(asm_source_files))
$(foo_object_files): ./build/%.o : ./%.cpp
mkdir -p $(dir $@) && \
g++ -m32 -c $(foo_source_files) -o $@ -ffreestanding -O2 -Wall -Wextra
$(asm_object_files): ./build/boot/%.o : ./boot/%.asm
mkdir -p $(dir $@) && \
nasm -f elf $(asm_source_files) -o $@
.PHONY: build
build: $(foo_object_files) $(asm_object_files)
mkdir -p ./dist && \
ld -m elf_i386 -T ./targets/linker.ld $(kernel_object_files) $(asm_object_files) -o MyOS.bin -nostdlib
.PHONY: clear
clear:
rm -rf ./build/*
But when I run "make build" I get this error
ld: build/boot.o: in function `_start':
./boot/main.asm:(.mbHeader+0xe): undefined reference to `foo_main'
make: *** [Makefile:19: build] Error 1
So how would I make it able to call the assembly function from the main.asm file with call foo_main
without getting this error