Geoff Chappell - Software Analyst
The Microsoft Visual C++ suite includes a LINK.EXE program that works primarily with object files as input, to produce an executable as output, but also is capable of much other work concerning these and related files. The different kinds of work are separated by having LINK.EXE act as several programs in one.
The selection of what is effectively a program within the program depends on the first command-line argument:
First Argument | Sub-Program |
---|---|
/dump | Dumper |
/edit | Editor |
/help | Helper |
/lib | Library Manager |
/link | Linker |
These selection switches are case-insensitive and may begin with either the forward slash or the hyphen. The default, if the first argument is not one of these switches (including because the command line has no arguments), is to select the Linker. Note that the command line in question truly is the command line. LINK.EXE may later take options from elsewhere, notably from environment variables or from files, and thereafter treat these as if they had been given on the command line. However, none of that applies to these few switches.
There is an exception to the requirement that these switches be first on the command line. The very first thing that LINK.EXE does with its command line is look for arguments that are exactly -db (in lower case and with the hyphen specifically) or which begin as -db followed immediately by at least a digit. Only the last occurrence of such an argument has any meaning (not that this meaning is yet pursued in this study), but all occurrences are removed from further consideration of the command line as if they had never been on it. Checking for a selection switch as the first argument is then, strictly speaking, the second thing that LINK.EXE does with its command line. If found, the selection switch also is removed from further consideration of the command line.
The selection switches are rarely used in practice. Indeed, the Helper must be run very rarely indeed, else someone at Microsoft surely would have noticed (and, less surely, would have corrected) that the simple command link /help causes an Internal error during SetupPhase. The others are typically run through one or another of the DUMPBIN.EXE, EDITBIN.EXE or LIB.EXE front-end programs, which each just execute LINK.EXE with the corresponding switch inserted into the command line:
Front-End Command | LINK.EXE Command |
---|---|
dumpbin [arguments] | link -dump [arguments] |
editbin [arguments] | link -edit [arguments] |
lib [arguments] | link -lib [arguments] |
The general practice throughout this documentation, is to refer to LINK.EXE as the linker (with a lower-case initial). To run LINK (with no extension) means specifically to execute LINK.EXE as the Linker (with an upper-case initial). Execution of LINK.EXE to run as the Dumper, Editor or Library Manager is instead referred to as running the corresponding front-end program, DUMPBIN, EDITBIN or LIB.
The LINK.EXE version studied for these notes is 7.00.9466. Information about implementation details and (especially, one might hope) coding errors may be highly specific to that version. References to Microsoft’s documentation assume a roughly contemporaneous edition (January 2004) of the MSDN Library on CD. No plans exist to track future versions, of either the software or the documentation. The teams of programmers at Microsoft can write this stuff much faster than I can study it—and they also have the advantage of earning at least wage while they put their time into it.