runtime function names
After messing around with the objdump disassembler, I started seeing the names of functions like printf and it made me wonder if the names of functions are actually stored at runtime. I did a test and the function name I made actually showed up in the disassembler. I thought that function names were discarded at complication time just like variable names, but I guess there not huh?
It's compilation time, not complication time.
variable names and function names are kept around for as long as they're needed.
When you make an object file, the static functions could be deduced to a number. When the object files are linked, the ones that are resolved (ie the ones that don't refer to an unlinked library) can be turned into a number. The others that refer to library functions that weren't linked in might be turned into a number or kept as a name, depending on the linking method.
If you compile with debugging symbols in, then they would probably stick around in the program file.
To get the debugging symbols out, use the strip command.
Library functions such as printf always keep their names, because those are used by the loader to dynamically link. (Windows DLLs also support linking by ordinal, but this is discouraged by MS, as it's mostly an artefact of Win16.)
A disassembler can use the executable's import table to deduce the name of called functions. If it can't do that, because the function is not imported, it can look for debug information. If that' missing too, it can still see if the executable itself exports the function and look the name up in the export table. (Note that by default on Linux, all symbols are exported.) Failing all that, it can't recover the real name.