compiler-constructionsymbols

What is Symbol Resolution?


This seems to be one of those things that every talks about but no one defines...I can't seem to find any information on this topic. What is symbol resolution? This is the best thing I've found: http://docs.oracle.com/cd/E23824_01/html/819-0690/chapter2-90421.html#chapter2-93321

Does it have something to do with how your program is compiled?


Solution

  • Well, now that you mention Unix's nm, I can pinpoint the symbol resolution.

    Executable files can make reference to entities which are not defined inside themselves. For instance, variables or procedures on shared libraries. Those entities are identified by external symbols. The executable might as well have internal symbols that can be referenced by external files -- as is the case, of course of libraries.

    Symbol resolution, in this context, is, once a program has been loaded into memory, assigning proper addresses to all external entities it refers to. This means changing every position in the loaded program where a reference to an external symbol was made.

    These addresses will depend on where, in the memory, the code with the external symbols has been loaded.

    In Unix, the default compilation mode for programs is to use the systems shared library, instead of pre-linking everything necessary in the executable. When compiling a program with gcc, for instance, you pass the -static flag if you wish it to be statically compiled, instead of having unresolved symbolic references.

    Look up "shared libraries" for further information.