The Microsoft Linker
One of the items on my new team's plate is the linker so I'm getting to know this tool. In the past I haven't really thought much about the linker. When I'm writing code I usually don't have to worry too much about the linker beyond the occasional LNK2001 (unresolved external) error message when I forget to add a library that's needed to the linker switches. I guess I'm a pretty pedestrian developer...
Now that I'm digging into it, though, it's clear that the linker is a very important tool. Its main function is to gather all the individual intermediate files that contain bits that need to be combined into an executable file and build the executable file (quite a job, as it turns out...). But, as I'm finding about, it does a more:
- It assembles the debug information for the generated executable if requested.
- It invokes the C++ compiler back end to generate code when you use whole program optimization.
- It Inovkes the MIDL compiler for attributed code that uses MIDL attributes.
- It's the back end for a number of other tools (dumpbin, editbin, lib).
- It Implements the delay loading mechanism (the ability to have your executable not load implicitly linked DLLs until code in the DLL is called at runtime).
- It can create a map file that shows the offsets in the executable module where the code and data that make up the module are located.
- It can calculate a checksum when requested and embeds it into the executable image (usually only for device drivers).
- It allows the setting of various attributes on the executable module (version numbers, heap sizes, stack size, etc.).
- Probably some other stuff I don't know about yet.
When you think about it, the linker is really the glue between a lot of disparate things (compilers, the operating system, debuggers) and is really the one tool that has a complete view of all the pieces that come together to make executable files build and run. Pretty important.
But, when I look on Amazon, I only find one book on linkers. I guess there's a couple of reasons for that:
- Most people only care about the linker when it fails.
- It's pretty specific to the OS's and compilers that it works with.
Be that as it may, I'll be delving into the MS Linker on this page in future posts. For those of you who don't care about esoteric aspects of this tool, you have been warned... 8^)
12:51:52 PM
|
|