/BASE (Base Address)
| Overview | How Do I | Linker Options
The Base Address (/BASE:{address | @filename,key}) option sets a base address for the program, overriding the default location for an .EXE 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.
To find this option in the development environment, click Settings on the Project menu. Then click the Link tab, and click General in the Output box.
Type the preferred base address in the Base Address text box (or in the address argument on the command line). The linker rounds the specified number up to the nearest multiple of 64K.
On the command line, another way to specify the base address is by using the 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 the DLLs your program will use. The linker looks for filename in either the specified path or, if no path is specified, in directories specified in the LIB environment variable. Each line in filename represents one DLL and has the following syntax:
keyaddresssize ;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-language, hexadecimal, or decimal notation 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. A comment is specified by a semicolon (;) and can be on the same or a separate line. The linker ignores all text from the semicolon to the end of the line. This 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.
Another way to set the base address is with the BASE argument in a NAME or LIBRARY statement. The /BASE and /DLL options together are equivalent to the LIBRARY statement.