/BASE

Syntax:

/BASE:{address | @filename,key}

This option sets a base address for the program, overriding the default location for an executable file (at 0x400000) or a DLL (at 0x10000000). The operating system first attempts to load a program at its specified or default base address. If sufficient space is not available there, the system relocates the program. To prevent relocation, use the /FIXED option.

Specify the preferred base address in the text box (or in the address argument on the command line). The linker rounds the specified number up to the nearest multiple of 64K.

Another way to specify the base address is by using a filename, preceded by an at sign (@), and a key into the file. The filename is a text file that contains the locations and sizes of all DLLs your program uses. The linker looks for filename in either the specified path or, if no path is specified, in directories named in the LIB environment variable. Each line in filename represents one DLL and has the following syntax:

key address size ;comment

The key is a string of alphanumeric characters and is not case sensitive. It is usually the name of a DLL but it need not be. The key is followed by a base address in C-notation hexadecimal or decimal and a maximum size. All three arguments are separated by spaces or tabs. The linker issues a warning if the specified size is less than the virtual address space required by the program. Indicate a comment by a semicolon (;). Comments can be on the same or a separate line. The linker ignores all text from the semicolon to the end of the line. The following example shows part of such a file:

  main   0x00010000   0x08000000   ; for PROJECT.EXE
  one    0x28000000   0x00100000   ; for DLLONE.DLL
  two    0x28100000   0x00300000   ; for DLLTWO.DLL

If the file that contains these lines is called DLLS.TXT, the following example command applies this information.

  link dlltwo.obj  /dll  /base:dlls.txt,two

You can reduce paging and improve performance of your program by assigning base addresses so that DLLs do not overlap in the address space.

An alternate way to set the base address is with the BASE argument in a NAME or LIBRARY module-definition statement. The /BASE and /DLL options together are equivalent to the LIBRARY statement. For information on module-definition statements, see Module-Definition Files.