Creating Flat Binary with Cygwin (NASM + C)
Posted: Sun Nov 25, 2012 10:54 am
I'm trying to write a very basic kernel. I have a .asm file that jumps to a function in a .c file. I'm trying to compile these into a flat binary (.bin) under Cygwin.
I've run into so many errors and tried so many different things, it's not even funny.
The most reasonable thing I've tried:It produces:and
What are the correct flags for everything?
Thanks,
I've run into so many errors and tried so many different things, it's not even funny.
The most reasonable thing I've tried:
Code: Select all
nasm.exe jump.asm -f elf32 -o jump.o
gcc.exe -c -m32 -Wall -Wextra -Werror -nostdlib -fno-builtin -nostartfiles -nodefaultlibs kernel.c -o kernel.o
ld.exe -m elf_i386 -s -r --oformat binary --entry jump jump.o kernel.o -o kernel.bin
Code: Select all
Assembler messages:
Fatal error: selected target format 'pe-i386' unknown
Code: Select all
C:\dev\Perl\c\bin\ld.exe: unrecognised emulation mode: elf_i386
Supported emulations: i386pep
Thanks,