Recently I started developing for UEFI. So far, everything has been going great. The setup of the development environment is a bit weird and it was hard to find a right one, but once you have it running, it works fine (Except for debugging, which is still shitty since you have to tell gdb each time where the code is executed...).
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:
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
The exact error that I get:
Code:
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
I figured that it may be because I'm not using a self built crosscompiler. I tried to compile gcc for the x86_64-w64-mingw32 target but this kept failing with errors about not having a valid /lib/cpp environment when compiling libgcc. I may be able to work around all the errors here, but I thought to first ask here if it actually is a problem with the environment, or whether I simply forget to link a certain library or something.