Partager via


/BASE (Base Address)

/BASE:{address[,size] | @filename,key}

The /BASE 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.

The linker issues an error if address is not a multiple of 64K. You can optionally specify the size of the program, so the linker will warn if the program can not fit in the size you specified.

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:

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-language, hexadecimal, or decimal notation and an optional 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

Remarks

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.

To set this linker option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.

  2. Click the Linker folder.

  3. Click the Advanced property page.

  4. Modify the Base Address property.

To set this linker option programmatically

See Also

Reference

Setting Linker Options

Linker Options