flat binary

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
engine252

flat binary

Post by engine252 »

i use the djgpp compiler just a while but how can i make
the compiler compile to a flat binary file? ???
PlayOS

Re:flat binary

Post by PlayOS »

Just compile your file, then use objcopy to strip the header(s).

Like this:

gcc -c file.c -o file.o
objcopy -O binary file.o file.bin

That -O is O for October not Zero.

You must also make sure that you file does not rely on any external variables or functions, or otherwise the flat binary file will not work.

Hope this helps.
Tim

Re:flat binary

Post by Tim »

You must also make sure that you file does not rely on any external variables or functions, or otherwise the flat binary file will not work.
That's because you forgot to link it.

gcc -c file1.c -o file1.o
gcc -c file2.c -o file2.o
ld -o file.out file1.o file2.o
objcopy -O binary file.out file.bin
PlayOS

Re:flat binary

Post by PlayOS »

:o ::)
engine252

Re:flat binary

Post by engine252 »

isn't there a good ide out there that take care of all that linking and stuff???
Tim

Re:flat binary

Post by Tim »

Sure, plenty. Visual Studio is my favourite.
Tom

Re:flat binary

Post by Tom »

I will be making a IDE...and someone else here will....I think it is "M@rtin12345"
engine252

Re:flat binary

Post by engine252 »

can visual studio outpu binary files and is it possibel to create a OS system dispite the fact you may only create windows software with it.
Tom

Re:flat binary

Post by Tom »

Nope....only win32 bins...but the ide can make the files you type up.
engine252

Re:flat binary

Post by engine252 »

if somebody made a good ide for djgpp please let me know if you make the ide please make sure there is good support for outputting binary files ;D
Tom

Re:flat binary

Post by Tom »

I'm working on it now...but first...I need to download DGJPP
whyme_t

Re:flat binary

Post by whyme_t »

Textpad is a good win32 ide ;) You can add programs to run as commands with keyboard shortcuts. So ctrl+1 could run nasm, ctrl+2 could run gcc, ctrl+3 could run ld. etc. Add you can use $File and $FileDir as parameters to the programs.

You can also view hex files, dos, ansi, unix, etc, etc.

www.textpad.com
Schol-R-LEA

Re:flat binary

Post by Schol-R-LEA »

engine252 wrote: isn't there a good ide out there that take care of all that linking and stuff???
The Emacs C and C++ modes have a preset compile command that runs "make -k" by default. You'd still have to write a Makefile, but given the kinds of things that can be done automatically by [tt]make[/tt](1), this is a Good Thing. You can go far beyond just compiling with a single step that way.
Tim

Re:flat binary

Post by Tim »

Tom wrote:Nope....only win32 bins...but the ide can make the files you type up.
No, the linker emits Portable Executable files, which Windows happens to use, as do ReactOS, Mobius, and various loaders. My point is: VC++ isn't tied to Windows.
Post Reply