My setup consists of the default mingw64 package in arch linux, which I use to output an subsystem 10 application (EFI application). Since the uefi environment does not have the standard libraries, I compile it as freestanding.
At the moment, I'm having a linking error though. For easyness I currently simply allocated a big buffer (well, not too big) on the stack (I know, bad practice). I expected that I could have issues like a stack not being big enough (even though the allocation is still not too big). However, when using a big buffer, I get errors during the linking stage. The generated code by gcc, tries to call a function ___chkstk_ms, which (I think ) tries to check the stack. I'm linking the executable with libgcc, but this has not solved the issue.
The parameters I use to compile:
Code: Select all
x86_64-w64-mingw32-gcc -ffreestanding -Wall -Wextra -std=c11 -O0 -fno-stack-protector -fpic -mno-red-zone -fno-builtin -o src/main.o -c src/main.c
x86_64-w64-mingw32-gcc -nostdlib -Wl,-dll -shared -Wl,--subsystem,10 -pie -e kernel_main -lgcc -o bin/EFI/Boot/bootx64.efi src/main.o
Code: Select all
src/main.o: In function `kernel_main':
/home/rob/Projects/C-C++/RobOS/src/main.c:36: undefined reference to `___chkstk_ms'
collect2: error: ld returned 1 exit status