I need a C compiler that can compile raw binaries (No structure or headers). I tried using GCC and I could not do it. Anyone have any suggestions?
Asked
Active
Viewed 787 times
0
-
4What do you mean by "I could not do it" ? – Lee Taylor Sep 09 '12 at 23:49
-
Do you mean you want to take the contents of a file and build them into an object module that contains a data section which contains the file contents? So the object module could be compiled with other object modules into an executable program, and the program would have the data from the file as part of its image? – Eric Postpischil Sep 09 '12 at 23:51
-
Outside of .COM files, there are no "raw binaries" that run under windows. You've got to get back into some 16bit, DOS based software to find a C-compiler that will do that. – Jeremy J Starcher Sep 09 '12 at 23:55
-
I am developing an OS. I ment there was no option in GCC to do that. – user1454902 Sep 09 '12 at 23:56
-
2The way you do it with GCC is produce an object file and then use `objcopy` to create a flat binary: http://stackoverflow.com/q/3615392/163956 – Greg Inozemtsev Sep 10 '12 at 00:18
-
3Please update your question to clarify what you mean by "compiles raw binaries". You seem to be saying that the *input* to the compiler should be "raw binaries" rather than C source. I presume that's not what you meant. – Keith Thompson Sep 10 '12 at 02:42
-
From the question I don't know what it's talking about. What is the expected input & output? – Mine Sep 10 '12 at 07:42
1 Answers
1
If you are making your own operating system, you should really look at some of the existing tutorial on the Internet. They show how to create "raw binaries". See e.g. the OSDev wiki. For example the bare bones tutorial.
But to answer your question: You can use something like objcopy
as suggested in a comment, but the recommended way is to make your own custom linker script.

Some programmer dude
- 400,186
- 35
- 402
- 621