| ||
Descriptions of the command-line options of the MASM linker (LINK.EXE) are provided in Table 5.3.
Parameter | Description |
---|---|
/ALIGN: number | Define the section alignment for the flat memory model. The default value is 4096. |
/BASE : {address @filename, key} | Define the base address (loading address). For an EXE file, the default value is 0x400000; for a DLL file, it is 0x10000000. |
/COMMENT: [] COMMENT [] | Define the comment placed into headers of EXE and DLL files. |
/DEBUG | Create debug information for EXE and DLL files. The debug information is placed into a PDB file. |
/DEBUGTYPE: {CV COFF BOTH] | CV indicates the debug information in the Microsoft format, COFF indicates the debug information in COFF. BOTH means that both types of debug information are created. |
/DEF: filename | Define the DEF file. |
/DEFAULTLIB: library | Add one library to the list of used libraries. |
/DLL | Create a DLL file. |
/DRIVER [: {UPONLYWDM}] | Used for building an NT driver (kernel mode driver). |
/ENTRY: symbol | Define the starting address for EXE and DLL files. |
/EXETYPE : DYNAMIC | This option is used when creating VXD drivers. |
/EXPORT: ENTRYNAME [=INTERNALNAME] [,@ORDINAL [, NONAME]][, DATA] | This option allows you to export a function from your program, making it available to other programs. In this case, an import library will be created. |
/FIXED [: NO] | Fix the base address specified in the /BASE option. |
/FORCE [: {MULTIPLE UNRESOLVED}] | This option allows you to create an executable file even if the external name is not found or several definitions are available. |
/GPSIZE: number | Define the size of general variables for MIPS and Alpha platforms. |
/HEAP: reserve [, commit] | Define the heap ( HEAP ) size in bytes. The default value is 1 MB. |
/IMPLIB: filename | Define the name of the import library. It is necessary to create one. |
/INCLUDE: symbol | Add a name to the name table. |
/INCREMENTAL: {YES NO} | If the /INCREMENTAL:YES option is set, then additional information will be added to the EXE file, allowing you to quickly recompile that file. By default, this information will not be added into the file. |
/LARGEADDRESSAWARE[:NO] | Specify that the application operates with addresses larger than 2 GB. |
/LIBPATH:dir | Define the library that will be sought first by the compiler. |
/MACHINE: {ALPHA ARM IX86MIPS MIPS16MIPSR41XXPPCSH3SH4} | Define the target platform. In most cases, there is no need to do so. |
/MAP [: filename] | Instruct the linker to create a MAP file. |
/MAPINFO : { EXPORTS FIXUPSLINES} | Instruct the linker to include appropriate information in the MAP file. |
/MERGE: from=to | Instruct the linker to merge the from section to the to section and assign it the name to . |
/NODEFAULTLIB[:library] | Ignore all libraries or a specific library. |
/NONENTRY | This is required to create a DLL file. |
/NOLOGO | Do not display the linker's logo message. |
/OPT : {ICF[, iterations] NOICF NOREFNOWIN98REFWIN98} | Define the linker's optimization method. |
/ORDER:@filename | Optimize the program by inserting specific initialized data (COMDAT). |
/OUT: filename | Define the output file. |
/PDB: {filename NONE} | Define the name of the file containing debug information. |
/PDBTYPE:{CON [SOLI DATE] SEPT [YPE S]} | Define the type of the PDB file. |
/PROFILE | This is used for working with the profiler. |
/RELEASE | Place the checksum into the output file. |
/SECTION:name, [E] [R] [w] [s] [D] [K] [L] [P] [X] | This option allows you to change the section attribute. |
/STACK: reserve [, commit] | Define the size of the allocated stack. Commit defines the memory size interpreted by the operating system. |
/STUB: filename | Define the STUB file that starts under MS-DOS. |
/SUBSYSTEM:{NATIVE WINDOWS CONSOLE WINDOWSCEPOSIX}[,#[.##]] | Set the method of starting the resulting EXE file: CONSOLE starts using console application, WINDOWS uses the normal Windows application, NATIVE uses Windows NT applications, and POSIX uses the application for the Windows NT POSIX subsystem. |
/SWAPRUN:{CDNET} | Instruct the operating system to copy the output file into the swap file (Windows NT). |
/VERBOSE[:LIB] | This indicates the verbose mode of the linking process. |
/VERSION :#[.#] | Place version information into the EXE header. |
/VXD | Create a VXD driver. |
/WARN[:warninglevel] | Specify the number of possible linker warnings. |
/WS: AGGRESSIVE | Decrease the execution speed of the target application (Windows NT). The operating systern removes this application from the memory when it runs idle. |
In Borland C software products, starting from 1997, there were two programs for linking object files: TLINK32.EXE (Table 5.4) and ILINK32.EXE. Command-line options of these programs were practically the same. ILINK32.EXE is an incremental linker. It saves information about the preceding linking operations, which allows you to considerably speed up the entire process of repeated compiling operations. Recently, the TLINK32.EXE program was removed from the distribution set. Later in this book, I won't note the difference between these two programs. Options marked with the plus sign (+) have appeared in the newer versions of ILINK32.EXE, and options marked by the minus sign ( ˆ ) have been removed. In newer versions, the slash (/) is used instead of the dash (-) to separate an option.
Parameter | Description |
---|---|
-m | Create a MAP file with information about the segments and two listings with PUBLIC names (in alphabetic and sequential order). |
-s | Include detailed information about the segments in the MAP file. |
-M | Include abbreviated identifier names in the MAP file. |
-c | Distinguish uppercase and lowercase letters in PUBLIC and EXTERNAL names. |
-Enn | Specify the maximum number of errors. If this number is exceeded, the linking process stops. |
-P- | Do not pack segments. This makes sense for 16-bit applications only ( -P = allow). |
-B: xxxx | Specify the base address. The default value is 400000H (+). |
-B: xxxx | This is similar to the -b option but doesn't create a tuning table. Using the -b and -B keys may somewhat improve program performance. |
-wxxx | This indicates possible warnings. For example, -w-stk warns you to ignore the lack of stack segment. |
-Txx | Type of the output file may be as follows : |
-Tpx PE image (x: e=EXE, d=DLL) |
|
-ax |
|
-r | Instruct the compiler to display information about the linking progress. |
-Vd. d | Place the expected Windows version into the EXE header. |
-ud. d | Place the program version into the EXE file header (+). |
-o | Import by function number (-). |
-Ao: nnnn | Define the alignment value (multiple of 2 and minimum value of 16). |
-Af: nnnn | This is the alignment file. |
-Sc:xxxx | Define the stack size. |
-s: xxxx | Define the reserve stack size. The minimum value is 4 KB. |
-Hc: xxxx | Define the special heap size. |
-H : xxxx | Define the reserve heap size. |
-n | This means that there is no default library (-). |
-v | Include full debug information in the executable file. For the selective inclusion of debug information in individual files, use -v+ and -v- . |
-j | Define the search path for OBJ files. |
-L | Define the path to the LIB library. |
-x | Do not create a MAP file. |
-Rr | This allows you to replace or delete resources (+). |
-d | Set the DLL loading delay. It will be loaded only when the main procedure is called (+). |
-Dxxxx | Place a special descriptor into the PE header. |
-GC | Place a string or strings into the PE headerfor example, -GC Hello! (+). |
-GD | Generate a Delphi-compatible resource file (+). |
-GF | Set one of the following flags for the loadable module:
|
-Gk | In case of error, this instructs the linker to leave the files that otherwise would be deleted (+). |
-Gl | Generate a LIB file (+). |
-Gpr | Create a run-time package (+). |
-Gpd | Create a compile-time package (+). |
-Gn | Disable incremental compiling (+). |
-GS: string | -GS:string = [ECIRWSDKP] . This adds flags to the existing section flags (+). |
-Gz | Place the executable module checksum into the PE header. |
Similar to assemblers, UNK.EXE and TLINK32.EXE can work with batch files. For example, assume that your command line appears as follows:
link /windows:console mt.obj
Instead of this command line, you can create a text file named MTL.CMD containing the following:
/subsystem:console Mt.obj
Having completed this, issue the following command:
link @mtl.cmd
TLINK32.EXE works in a similar way.
At first glance, it is difficult to detect any differences that would make you prefer MASM32 or TASM32. However, consider the following:
MASM32 has slightly more reach capabilities. In this case, I mean command-line options.
TASM32 is no longer supported as a standalone product. Because of this, MASM has beaten its competitor in the number of examples, the extent of its libraries, the amount of documentation, etc.
TASM32 carries out a more complicated algorithm for calling API functions, which makes the executable modules built using TASM32 larger than those built using MASM32.
To conclude this chapter, I'd like to provide some easy examples.
| ||