Thread: runtime function names

  1. #1
    Registered User
    Join Date
    Jun 2008

    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?

  2. #2
    Registered User
    Join Date
    Oct 2001
    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.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    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.
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  2. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  3. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  4. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 08:55 AM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM