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?
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.
As mentioned, it can refer to run-time or link-time symbol resolution. However you shouldn't forget compile-time symbol resolution.
This is the rules a language uses to map symbols to "things". Symbols being just about anything that looks like a name (local, members and global variables, functions, methods, types, etc.) and "things" being the compilers understanding of what the name refers to.
The rules for doing this can be fairly simple (for instance, IIRC in C it's little more than an ordered list of places to look) or complex (C++ has all sorts of case with overloading, templates and whatnot). Generally, these rules interact with the semantics of the program and sometimes they can even result in (potentially) ambiguities:
C++:
int First(int i) { return i; }
float First(float f) { return f; }
void Second(int (*fn)(int)) { printf("int"); }
void Second(float (*fn)(float); { printf("float"); }
...
Second(&First); // What will be printed?
I am not sure what context you mean symbol resolution in. But it reminds me of dlopen(3), and dlsym(3) for run-time symbol resolution in shared libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With