Page 1 of 1

Creating Flat Binary with Cygwin (NASM + C)

Posted: Sun Nov 25, 2012 10:54 am
by Geometrian
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:

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
It produces:

Code: Select all

Assembler messages:
Fatal error: selected target format 'pe-i386' unknown
and

Code: Select all

C:\dev\Perl\c\bin\ld.exe: unrecognised emulation mode: elf_i386
Supported emulations: i386pep
What are the correct flags for everything?

Thanks,

Re: Creating Flat Binary with Cygwin (NASM + C)

Posted: Sun Nov 25, 2012 11:28 am
by Combuster
Use the proper tools.
GCC Cross-Compiler