Westrock Westrock - 2 months ago 5x
C Question

Add ASCII comments to a C binary?

I have extrememly small amount of experience with C programming.

The operating system is Linux. When you do

on a program file it shows a bunch of random characters, but it also shows some of the readable ASCII characters in the original C source code.

Is there a way to force comments to show up in the binary, preferably near the beginning of the program file so that someone could get an idea of what this is used for? The formatting of the comments does not have to be pretty, a continuous line of text is fine.


Comments are only present in the source code and will not be present in the binary. In case you find any readable text in the binary, it is because you came across string literals used by the program.

Binaries should only be read by computers and not humans, so it doesn't make any sense to include comments in them anyhow.

If you would for reasons unknown need something like a binary with comments, then generate a disassembly from the C source. It will contain the machine code together with the C code and C code comments.

That being said, you could force the program to link a string to the binary even if that string isn't used by the program, by adding something like:

volatile const char foo [] = "STOP LOOKING AT MY BINARY!";