Skip to content

Latest commit

 

History

History
340 lines (325 loc) · 26.3 KB

LINK.exe.md

File metadata and controls

340 lines (325 loc) · 26.3 KB

The linker: link.exe

Command Line Switches for link.exe

NB: the following list has not yet been checked and mostly contains findings from looking at link.exe in raw form. Some of the arguments to individual command line switches certainly require more research and confirmation.

Also note: not all findings will apply to older or newer versions of the toolchain.

The undocumented or barely mentioned switches are in bold, the documented ones are not.

Command line switch Purpose
/align Specifies the alignment of each section.
/allowbadrvaforfirstsection
/allowbind Specifies that a DLL can't be bound.
/allowimagesizeover2gb
/allowisolation Specifies behavior for manifest lookup.
/allpdata
/alternatename By specifying /alternatename:X=Y you can tell the linker to use Y when searching for symbol Y
/appcontainer Specifies whether the app must run within an appcontainer process environment.
/arm64hazardexist
/arm64hazardfree
/arm64xaggressiverwdatafold
/arm64xcrossresolve
/arm64xemulatorbuild
/arm64xfastforward
/arm64xfoldrwdata
/arm64xhack
/arm64xnewchameleonlibfmt
/arm64xnomergeimports
/arm64xnoreorderobjs
/arm64xsameaddress
/arm64xuselegacyffs
/armhazardexist
/armhazardfree
/assemblydebug Adds the System.Diagnostics.DebuggableAttribute to a managed image.
/assemblylinkresource Creates a link to a managed resource.
/assemblymodule Specifies that a Microsoft intermediate language (MSIL) module should be imported into the assembly.
/assemblymodulemap
/assemblyresource Embeds a managed resource file in an assembly.
/b2
/base Sets a base address for the program.
/baserelocclustering
/brepro
/cetcompat Marks the binary as CET Shadow Stack compatible.
/cetcompatstrict
/cetdynamicapisinproc
/cetipvalidationrelaxed
/cgthreads Sets number of cl.exe threads to use for optimization and code generation when link-time code generation is specified.
/clrimagetype Sets the type (IJW, pure, or safe) of a CLR image.
/clrloaderoptimization
/clrnetcore
/clrrvaentry
/clrsignhash
/clrsupportlasterror Preserves the last error code of functions that are called through the P/Invoke mechanism.
/clrsupportlasterrordll
/clrthreadattribute Specifies the threading attribute to apply to the entry point of your CLR program.
/clrunmanagedcodecheck Specifies whether the linker will apply the SuppressUnmanagedCodeSecurity attribute to linker-generated P/Invoke stubs that call from managed code into native DLLs.
/coffsecttopdbstrm
/crashondiag
/cvtres
/cxxmodulestrongownership
/d2
/db
/debug Creates debugging information.
/debugtype Specifies which data to include in debugging information.
/def Passes a module-definition (.def) file to the linker.
/defarm64native
/defaultlib Searches the specified library when external references are resolved.
/delay Controls the delayed loading of DLLs.
/delayload Causes the delayed loading of the specified DLL.
/delaysign Partially signs an assembly.
/dependentloadflag Sets default flags on dependent DLL loads.
/didatownsection
/disallowlib
/discardtrack
/dll Builds a DLL.
/dllrename
/driver Creates a kernel mode driver.
/dynamicbase Specifies whether to generate an executable image that's rebased at load time by using the address space layout randomization (ASLR) feature.
/dynamicvalue
/editandcontinue
/emitasx64image
/emitasx64imagewithaa64
/emitpogophaseinfo
/emittoolversioninfo
/emitvolatilemetadata
/enclave
/encpadsize
/entry Sets the starting address.
/errorreport Deprecated. Error reporting is controlled by Windows Error Reporting (WER) settings.
/etm
/expectedoutputsize
/experimental
/export Exports a function.
/exportarm64native
/exportpadmin
/fastfail
/fastgenprofile Both of these options specify generation of a .pgd file by the linker to support profile-guided optimization (PGO). /GENPROFILE and /FASTGENPROFILE use different default parameters.
/fe
/filealign Aligns sections within the output file on multiples of a specified value.
/fixed Creates a program that can be loaded only at its preferred base address.
/force Forces a link to complete even with unresolved symbols or symbols defined more than once.
/forcewinmdversion12
/fullbuild
/funcoverride
/funcoverridedisablefunc
/funcoverrideemitcand
/funcoverrideoncallsites
/functionpadmin Creates an image that can be hot patched.
/genpdbfromscratch
/genprofile Both of these options specify generation of a .pgd file by the linker to support profile-guided optimization (PGO). /GENPROFILE and /FASTGENPROFILE use different default parameters.
/guard Enables Control Flow Guard protection.
/guardsym
/heap Sets the size of the heap, in bytes.
/highentropyva Specifies support for high-entropy 64-bit address space layout randomization (ASLR).
/hotpatchcompatible
/hybriddefupgrade
/hybridexportthunks
/hybriduseguestmachine
/icfsection
/idlout Specifies the name of the .idl file and other MIDL output files.
/ignore Suppresses output of specified linker warnings.
/ignoreidl Prevents the processing of attribute information into an .idl file.
/ilk Overrides the default incremental database file name.
/iltcgwarningoff
/implib Overrides the default import library name.
/impthunkalign
/include Forces symbol references.
/includecoffsection
/incremental Controls incremental linking.
/inferasanlibs Uses inferred sanitizer libraries.
/integritycheck Specifies that the module requires a signature check at load time.
/kernel
/keycontainer Specifies a key container to sign an assembly.
/keyfile Specifies a key or key pair to sign an assembly.
/largeaddressaware Tells the compiler that the application supports addresses larger than 2 gigabytes
/last
/layoutpagesize
/libpath Specifies a path to search before the environmental library path.
/linkrepro Specifies a path to generate link repro artifacts in.
/linkreprotarget Generates a link repro only when producing the specified target.16.1
/logo
/ltcg Specifies link-time code generation.
/ltcgasmlist
/ltcgout
/machine Specifies the target platform.
/manifest Creates a side-by-side manifest file and optionally embeds it in the binary.
/manifestdependency Specifies a <dependentAssembly> section in the manifest file.
/manifestfile Changes the default name of the manifest file.
/manifestinput Specifies a manifest input file for the linker to process and embed in the binary. You can use this option multiple times to specify more than one manifest input file.
/manifestuac Specifies whether User Account Control (UAC) information is embedded in the program manifest.
/map Creates a mapfile.
/mapinfo Includes the specified information in the mapfile.
/maxilksize
/merge Combines sections.
/midl Specifies MIDL command-line options.
/midlexe
/minpdbpathlen
/mt
/natvis Adds debugger visualizers from a Natvis file to the program database (PDB).
/noassembly Suppresses the creation of a .NET Framework assembly.
/nocoffgrpinfo
/nocomentry
/nod
/nodbgdirmerge
/nodefaultlib Ignores all (or the specified) default libraries when external references are resolved.
/noentry Creates a resource-only DLL.
/noexp
/nofunctionpadsection
/noilinkcoffgrppad
/noimplib
/nolinkrepro
/nologo Suppresses the startup banner.
/noltcgoptref
/nomap
/noonfailrepro
/nooptcfg
/nooptdidat
/nooptgids
/nooptidata
/nooptrefbeforeltcg
/noopttls
/novcfeature
/noxdatamerge
/nxcompat Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature.
/objmap
/odr
/odrignore
/odrignoresamesize
/onfailrepro
/opt Controls LINK optimizations.
/opticfbytecomp
/order Places COMDATs into the image in a predetermined order.
/osversion
/out Specifies the output file name.
/pagesize
/pathmap
/pchmap
/pdb Creates a PDB file.
/pdbaltpath Uses an alternate location to save a PDB file.
/pdbcompress
/pdbdbgqsize
/pdbdbgst
/pdbdll
/pdbmap
/pdbmodclosethreads
/pdbpagesize
/pdbpath
/pdbrpc
/pdbstripped Creates a PDB file that has no private symbols.
/pdbthreads
/pdbtmcache
/pgd Specifies a .pgd file for profile-guided optimizations.
/pogonoshare
/pogosafemode Obsolete Creates a thread-safe PGO instrumented build.
/prefetch
/profile Produces an output file that can be used with the Performance Tools profiler.
/rc
/re
/release Sets the Checksum in the .exe header.
/reportnoncomdatguardfunc
/retryonfileopenfailure
/runbelow4gb
/safeseh Specifies that the image will contain a table of safe exception handlers.
/savebaserelocations
/section Overrides the attributes of a section.
/sectionlayout
/simarm
/simarm64
/skipincrementalchecks
/sourcelink Specifies a SourceLink file to add to the PDB.
/sourcemap
/spdembed
/spdidstr
/spdin
/spdindex
/spgo
/stack Sets the size of the stack in bytes.
/stricticfthunkalign
/striprtti
/stub Attaches an MS-DOS stub program to a Win32 program.
/subsystem Tells the operating system how to run the .exe file.
/subsystemversion
/swaprun Tells the operating system to copy the linker output to a swap file before it's run.
/test
/throwingnew
/time Output linker pass timing information.
/time+
/tlbid Specifies the resource ID of the linker-generated type library.
/tlbout Specifies the name of the .tlb file and other MIDL output files.
/trimfile
/tsaware Creates an application that is designed specifically to run under Terminal Server.
/useprofile Uses profile-guided optimization training data to create an optimized image.
/verbose Prints linker progress messages.
/version Assigns a version number.
/vulcannotrecognizenewdelaythunk
/warnduplicatesections
/wbrdcfg
/wbrddll
/wbrdlog
/wbrdreporterrors
/wbrdschema
/wbrdsummary
/wbrdtestencrypt
/weakorder
/wholearchive Includes every object file from specified static libraries.
/win32version
/winmd Enables generation of a Windows Runtime Metadata file.
/winmddelaysign Partially signs a Windows Runtime Metadata (.winmd) file by placing the public key in the winmd file.
/winmdfile Specifies the file name for the Windows Runtime Metadata (winmd) output file that's generated by the /winmd linker option.
/winmdkeycontainer Specifies a key container to sign a Windows Metadata file.
/winmdkeyfile Specifies a key or key pair to sign a Windows Runtime Metadata file.
/winmdmap
/winmdsignhash
/winmdversion
/wowa64
/wowa64lib
/wx Treats linker warnings as errors.
/x86pdata
/xoff
@ Specify a command (or response) file with one command line option per line

Environment variables for link.exe

Environment variable Description
_CVTCIL_
_LIB_
_LINK_ used after the command line (and LINK)
_PRELIB_
_PUSHTHUNKOBJ_
EnterpriseWDK
LOG_BUILD_COMMANDLINES file name to log command lines into
LINK used before command line
LINK_DB .ilk file name?
LINK_REPRO directory for link repro? can be used instead of /linkrepro
LINK_REPRO_NAME
SPGO_SPD_IDSTR
MSVCETW_PARENT_CONTEXT_THREAD_ID
PRINT_HRESULT_ON_FAIL 1 (or even non-empty?)
VSLANG the LANGID (e.g. 1033/0x409 for US-English)
VS_UNICODE_OUTPUT file number (integer, such as for stdout, stderr), used by Visual Studio IDE, used to detect running in the IDE
VSTEL_SolutionSessionID some GUID; adhoc generated?
VSTEL_CurrentSolutionBuildID an (unsigned?) integer (PID/TID?)
VSTEL_ProjectID a GUID; does it correspond to project GUID?

Used (and populated) internally for /pdbaltpath:

  • _EXT
  • _PDB

Glossary (guessed)

Subjects of the study

These are subject to change, eventually.

  • link.exe (14.34.31933)
    • SHA256: 38f375b084e796c6be3ae724641136897770fbc4858e578724f7956c41c48fce
    • Host/Target: x86-64 / x86-64
    • Version:
      • File: 14.34.31937.0
      • Product: 14.34.31937.0
  • link.exe (14.36.32532)
    • SHA256: 3b0e8472ab78036f3cdaf67b392aee631228ce1dc6131e486d0041f6191c6a9e
    • Host/Target: x86-64 / x86-64
    • Version:
      • File: 14.36.32534.0
      • Product: 14.36.32534.0