user1454902
user1454902

Reputation: 738

C compiler for windows that compiles raw binaries?

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?

Upvotes: -1

Views: 877

Answers (2)

nneonneo
nneonneo

Reputation: 179372

Binary Ninja (https://binary.ninja/, paid tool) ships with a pretty great shellcode-focused C compiler called scc, which compiles a dialect of C into "raw" machine code. The dialect it compiles has extra shellcode-specific features, and it ships with a fantastically tiny-but-functional standard library so you can do e.g. printf from a bit of shellcode without actually linking to libc.

For a free option, ragg2 will compile either regular C or a C-like shellcoding language into raw machine code.

Upvotes: 0

Some programmer dude
Some programmer dude

Reputation: 409136

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.

Upvotes: 1

Related Questions