Geoff Chappell - Software Analyst
This option sets the preferred base address and maximum image size for the executable.
Two distinct syntaxes apply:
For the filename, address and size arguments, characters up to but not including an equals sign are ignored without complaint. The filename syntax is selected if the first argument begins with an @ sign. Otherwise, the address syntax applies.
If a /base option (with at least one argument) is given as a directive in an object file and the base address is regarded as having been set by an earlier instance, then the option is ignored without complaint. Thus, /base is valid as a directive in an object file but cannot override a /base from the command line.
It is a fatal error (LNK1147) if the address argument is not interpretable as a 64-bit number. The same fatal error results if the optional size argument is not a number no greater than 0x80000000. Provision of more than two arguments is a fatal error (LNK1111).
The filename syntax requires two arguments. The filename argument names a text file, here called the base file, that may list choices for what the address syntax would have allowed as the address and size. The key argument selects from the choices.
The filename is interpreted according to the usual rules for default extensions and search paths for input files, but with “.txt” as the default extension. The file counts as an input file for the purpose of test-case reproduction. It is a fatal error (LNK1104) if the file cannot be opened for reading in text mode with write access denied to sharers.
The base file is parsed in lines. For this purpose, a line is as many as 259 characters up to and including a line-feed (or carriage-return and line-feed, allowing for text-mode translation) or the last byte of text, whichever comes first. On any given line, a terminating line-feed is ignored, as are all characters from the first semicolon onwards.
The key argument selects one line. There may be any number of spaces and tabs, including none, before the case-insensitive key, which must in turn run to a space or tab or to the end of the line. Only the first matching line matters.
If no line matches the key, warning LNK4198 occurs. Though the text of this warning reads as if LINK reverts to a default, there are some subtleties. If an earlier /base set a valid address, then the earlier setting persists. Otherwise, LINK treats this /base as having set the address successfully, as if to a value that just happens to be the default. At this stage, the default is 0x00400000 irrespective of any special cases about subsystem or executable type. This is not the same as having given no /base option, but is instead the same as having given /base:0x00400000 explicitly.
The syntax expected of the matching line is:
key address size
There may be any number of spaces and tabs, including none, before the key. There must be at least one space or tab before the address and before the size, which must in turn run to a space or tab or to the end of the line.
The address and size arguments are numbers in decimal or in C-language hexadecimal or octal notation, with a sign prefix allowed, evaluated as unsigned integers truncated to 64 and 32 bits respectively. For each, excess (non-numerical) characters are ignored without complaint. It is a fatal error (LNK1111) not to provide both an address and a size. It is a fatal error (LNK1147) if the size is greater than 0x80000000.