summaryrefslogtreecommitdiffstats
path: root/lld/lib/Driver/WinLinkDriver.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [PECOFF] Emit the delay-import tableRui Ueyama2014-10-091-2/+0
| | | | | | | | | | | This is a partial patch to emit the delay-import table. With this, LLD is now able to emit the table that llvm-readobj can read and dump. The table lacks a few fields, such as the address of HMODULE, the import address table, etc. They'll be added in subsequent patches. llvm-svn: 219384
* [PECOFF] Remember DLL names given with /delayload option.Rui Ueyama2014-10-081-0/+1
| | | | | | This is a step toward full support of /delayload. llvm-svn: 219344
* [PECOFF] Infer machine type from input object fileRui Ueyama2014-10-071-3/+39
| | | | | | | If /machine option is omitted, the linker needs to infer that from input object files. This patch implements that. llvm-svn: 219180
* [PECOFF] Resolve __delayLoadHelper2 if /delayload is givenRui Ueyama2014-10-031-0/+5
| | | | | | | | | | | | | | | | | | DLL delay importing is a feature to load a DLL lazily, instead of at program start-up time. If the feature is turned on with the /delayload flag, the linker resolves the delay-load helper function. All function pointer table entries for the DLL are initially pointing to the helper function. When called, the function loads and resolves the DLL symbols using dlopen-ish Windows system calls and then write the reuslts to the function pointer table. The helper function is in "delayimp.lib". Note that this feature is not completely implemented yet. LLD also needs to emit the table that's consumed by the delay-load helper function. That'll be done in another patch. llvm-svn: 218943
* [PECOFF] Allow /export:<symbol>,PRTVATE.Rui Ueyama2014-09-301-3/+7
| | | | | | PRIVATE option is also an undocumented feature. llvm-svn: 218696
* [PECOFF] Fix /export option.Rui Ueyama2014-09-301-3/+12
| | | | | | | | | | | MSDN doesn't say about /export:foo=bar style option, but it turned out MSVC link.exe actually accepts that. So we need that too. It also means that the export directive in the module definition file and /export command line option are functionally equivalent. llvm-svn: 218695
* [PECOFF] Keep unmangled name in the export table descriptorRui Ueyama2014-09-241-0/+1
| | | | | | | | | | | | | | | | | The export table descriptor is a data structure to keep information about the export table. It contains a symbol name, and the name may or may not be mangled. We need unmangled names for the export table, so we demangle them before writing them to the export table. Obviously this is not a correct round-trip conversion. That could drop a leading underscore from a symbol because that's indistinguishable from a mangled name. What we need to do is to keep unmangled names. This patch does that. llvm-svn: 218345
* [PECOFF] Simplify /machine option handlingRui Ueyama2014-09-241-1/+0
| | | | | | | | /machine:ebc was previously recognized but rejected. Unknown architecture names were handled differently but eventually rejected too. We don't need to distinguish them. llvm-svn: 218344
* Driver: accept /machine:arm for Windows linkerSaleem Abdulrasool2014-09-191-1/+3
| | | | | | | | | Accept /machine:arm as an argument. This is changed to support ARM NT. Although there is no way to differentiate between ARM (Windows CE) and ARM NT (Windows on ARM), since LLVM currently only supports Windows on ARM, simply take /machine:arm to mean Windows on ARM. llvm-svn: 218105
* [PECOFF] Run cvtres.exe with /machine:x64.Rui Ueyama2014-09-051-3/+4
| | | | | | | | If we are creating a PE+ executable, we need to run cvtres with /machine:x64 instead of /machine:x86. Otherwise the resulting executable would be invalid. llvm-svn: 217214
* [PECOFF] Add /HighEntropyVA.Rui Ueyama2014-08-251-0/+1
| | | | | | | This is yet another command line flag to set a bit in DLLCharacteristics. Default on Win64 is "on". llvm-svn: 216414
* Use LLD naming style.Rui Ueyama2014-08-251-8/+8
| | | | llvm-svn: 216402
* Update for LLVM api changeRafael Espindola2014-08-251-9/+8
| | | | llvm-svn: 216395
* [PECOFF] Fix PE+ relocationsRui Ueyama2014-08-221-1/+1
| | | | | | | | | | | | | The implementation of AMD64 relocations was imcomplete and wrong. On AMD64, we of course have to use AMD64 relocations instead of i386 ones. This patch fixes the issue. LLD is now able to link hello64.obj (created from hello64.asm) against user32.lib and kernel32.lib to create a Win64 binary. llvm-svn: 216253
* [PECOFF] Fix /profile option.Rui Ueyama2014-08-111-2/+2
| | | | | | | /profile implies /fixed:no -- so we had to *enable* base relocations rather than disabling it. llvm-svn: 215389
* [PECOFF] Fix /include option in .drectve section.Rui Ueyama2014-08-041-3/+10
| | | | | | | | | | | | | | | | | | | | | | | /INCLUDE arguments passed as command line options are handled in the same way as Unix -u. All option values are converted to an undefined symbol and added to a dummy input file, so that the specified symbols are resolved. One tricky thing on Windows is that the option is also allowed to appear in the object file's directive section. At the time when it's being read, all (regular) command line options have already been processed. We cannot add undefined atoms to the dummy file anymore. Previously, we added such /INCLUDE to a set that has already been processed. As a result the options were ignored. This patch fixes the issue. Now, /INCLUDE symbols in the directive section are handled as real undefined symbol in the COFF file. We create an undefined symbol for each /INCLUDE argument and add it to the file being parsed. llvm-svn: 214824
* [PECOFF] Add /profile command line option.Rui Ueyama2014-07-251-0/+7
| | | | llvm-svn: 213984
* [PECOFF] Add the entry point file at the right place.Rui Ueyama2014-07-231-1/+7
| | | | | | | | | The entry point file needs to be processed after all other object files and before all .lib files. It was processed after .lib files. That caused an issue that the entry point function was not resolved from the standard library files. llvm-svn: 213804
* [PECOFF] Fix entry point functions selectionRui Ueyama2014-07-231-23/+0
| | | | | | | | | | | | | | | | | | | | | On Windows there are four "main" functions -- main, wmain, WinMain, or wWinMain. Their parameter types are diffferent. The standard library provides four different entry functions (i.e. {w,}{WinMain,main}CRTStartup) for them. You need to use the right entry routine for your "main" function. If you give an /entry option, the specified name is used unconditionally. Otherwise, the linker needs to select the right one based on user-supplied entry point function. This can be done after the linker reads all the input files. This patch moves the code to determine the entry point function from the driver to a virtual input file. It also implements the correct logic for the entry point function selection. llvm-svn: 213713
* [PECOFF] Remember /noentry option so that later passes can handle it.Rui Ueyama2014-07-221-1/+5
| | | | | | | | | | This is a part of a larger change to move the entry point processing to a later pass than the driver. On Windows the default entry point function varies depending on user-provided functions. That means the driver is not able to correctly know the entry point function name. Only passes after the core linker can infer it. llvm-svn: 213697
* [PECOFF] s/context/ctx/ for consistency.Rui Ueyama2014-07-101-16/+16
| | | | llvm-svn: 212766
* [PECOFF] Invoke cvtres.exe in the driver.Rui Ueyama2014-07-101-38/+99
| | | | | | | | | | | | | | | | | Previously we invoked cvtres.exe for each compiled Windows resource file. The generated files were then concatenated and embedded to the executable. That was not the correct way to merge compiled Windows resource files. If you just concatenate generated files, only the first file would be recognized and the rest would be ignored as trailing garbage. The right way to merge them is to call cvtres.exe with multiple input files. In this patch we do that in the Windows driver. llvm-svn: 212763
* [all]: Use range-based ArgList adapter instead of filtered_begin/filtered_endTim Northover2014-07-091-11/+6
| | | | | | Some of those loops were pretty monstrous. llvm-svn: 212616
* Update for llvm api change.Rafael Espindola2014-07-061-7/+7
| | | | llvm-svn: 212407
* Revert "temporary commit."Rui Ueyama2014-05-091-16/+0
| | | | | | This reverts accidental commit r208427. llvm-svn: 208433
* temporary commit.Rui Ueyama2014-05-091-0/+16
| | | | llvm-svn: 208427
* [PECOFF] Add a test for lib.exe subcommand.Rui Ueyama2014-05-011-0/+4
| | | | | | | | | | | | Previously the input file for the lib.exe command would be removed as soon as the command exits, so we couldn't write a test to check the file contents are correct. This patch adds /lldmoduledeffile: option to retain a copy of the temporary file at the given file path, so that you can see the file if you want. llvm-svn: 207727
* [PECOFF] Allow multiple directives in one module-definition file.Rui Ueyama2014-04-261-30/+30
| | | | | | | | I'm a bit surprised that I have not implemented this yet. This is definitely needed to handle real-world module definition files. This patch contains a unit test for r207294. llvm-svn: 207297
* [PECOFF] Add /IMPLIB command line option.Rui Ueyama2014-04-251-0/+4
| | | | | | This option is to override the default import file path. llvm-svn: 207175
* [PECOFF] Better handling of /OPT option.Rui Ueyama2014-04-221-7/+16
| | | | | | | | | | | Previously LLD would fail if /OPT:icf, /OPT:lbr or such are specified, because these command line flags would be handled as unknown ones. We rather want LLD to ignore these known but yet-to-be-implemented options for now. Added tests for the driver as well. llvm-svn: 206863
* [PECOFF] Win64 DLL entry function name is _DllMainCRTStartup.Rui Ueyama2014-04-181-4/+7
| | | | | | Unlike Win32/x86, it has no "@12" suffix. llvm-svn: 206648
* [PECOFF] Support LIBRARY directive.Rui Ueyama2014-04-181-0/+5
| | | | | | | LIBRARY directive in a module definition file specifies the output DLL file name. It also takes an optional value for the base address. llvm-svn: 206647
* [PECOFF] Support /manifestuac:NO.Rui Ueyama2014-04-181-20/+26
| | | | | | | If the value for /manifestuac is "NO", LLD will create a manifest XM file but won't emit <trustinfo> element. llvm-svn: 206633
* Add missing includes.Benjamin Kramer2014-04-121-0/+1
| | | | llvm-svn: 206113
* Rename getInputGraph() and getNextFile().Rui Ueyama2014-04-041-3/+3
| | | | | | | | | Seems getSomething() is more common naming scheme than just a noun to get something, so renaming these members. Differential Revision: http://llvm-reviews.chandlerc.com/D3285 llvm-svn: 205589
* Expand 'auto' that's hard for human to deduce its real type.Rui Ueyama2014-04-031-1/+1
| | | | llvm-svn: 205564
* Greatly simplify InputGraph.Rui Ueyama2014-04-011-1/+1
| | | | | | | | | | | | | | | | | | | | | InputGraph has too many knobs and controls that are not being used. This patch is to remove dead code, unused features and a class. There are two things that worth noting, besides simple dead code removal: 1. ControlNode class is removed. We had it as the base class of Group class, but it provides no functionality particularly meaningful. We now have shallower class hierarchy that is easier to understand. 2. InputGraph provides a feature to replace a node with its internal data. It is being used to "expand" some type of node, such as a Linker Script node, with its actual files. We used to have two options when replacing it -- ExpandOnly or ExpandAndReplace. ExpandOnly was to expand it but not remove the node from the tree. There is no use of that option in the code, so it was a dead feature. Differential Revision: http://llvm-reviews.chandlerc.com/D3252 llvm-svn: 205363
* s/dyn_cast/cast/ where return value should never be null.Rui Ueyama2014-04-011-1/+1
| | | | | | | | cast<X> asserts the type is correct and does not return null on failure. So we should use cast<X> rather than dyn_cast<X> at such places where we don't expect type conversion could fail. llvm-svn: 205332
* [PECOFF] Treat .imp as an import library file.Rui Ueyama2014-04-011-1/+1
| | | | | | | | | | | | Some Clang build uses .imp not .lib file extension for an import library file, so we need to treat such file as a library file. Ideally we should not rely on file extensions to detect file type. Instead we should use magic bytes at beginning of a file. The GNU-compatible driver actually does that but it made writing unit tests hard, so I chose an ad-hoc approach for now. llvm-svn: 205283
* [PECOFF] Avoid C-style cast.Rui Ueyama2014-03-261-1/+1
| | | | llvm-svn: 204855
* [PECOFF] Use RAII object for mutex.Rui Ueyama2014-03-261-15/+8
| | | | llvm-svn: 204853
* [PECOFF] Print out command line if we have expanded response files.Rui Ueyama2014-03-251-3/+15
| | | | | | | | | | | If a response file is given via command line, the final command line arguments will not appear in the log because the actual arguments are in the given file. This patch is to show the final command line if /verbose is specified to help users. llvm-svn: 204754
* [PECOFF] Fix possible response file buffer overrun.Rui Ueyama2014-03-211-1/+2
| | | | | | | | Response file is not NUL terminated, so when creating a StringRef for the buffer contents, we need to pass the buffer size as well as the pointer pointing to the buffer. llvm-svn: 204420
* [PECOFF] Fix link order.Rui Ueyama2014-03-141-20/+16
| | | | | | | | | | | | | | | | LLD fails to link symbol "_main" if the symbol is in a library file and the library file is given as a bare argument (i.e. not with /defaultlib option). It's because library files given as bare arguments are processed before other libraries given with /defaultlib, so when Linker finds msvcrtd needs a definition for "_main", the file providing the main function has already been processed and skipped. Linker don't revisit libraries if it's not given with /defaultlib. To fix it this patch change the way of command line handling; files end with ".lib" are treated as if they are given with /defaultlib. I don't believe it's 100% correct behavior but it's better than before. llvm-svn: 203892
* [PECOFF] Fix arguments passed to lib.exe.Rui Ueyama2014-03-141-1/+1
| | | | llvm-svn: 203891
* [PECOFF] Make WinLinkDriver::parse() and allocate*() functions thread-safe.Rui Ueyama2014-03-141-3/+15
| | | | | | Looks like a major cause of instability on Windows is this thread-safety bug. llvm-svn: 203889
* [PECOFF] Implement /lib option.Rui Ueyama2014-03-141-2/+30
| | | | | | This option is not documented and seems weird, but yeah we need it anyway. llvm-svn: 203884
* Use short identifier, s/diagnostics/diag/.Rui Ueyama2014-03-141-67/+62
| | | | llvm-svn: 203876
* [PECOFF] Support response files.Rui Ueyama2014-03-141-4/+66
| | | | | | | | If the driver finds a command line option in the form of "@filename", the option will be replaced with the content of the given file. It's an error if a response file cannot be read. llvm-svn: 203875
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-131-4/+4
| | | | | | | | This results in some simplifications to the code where an OwningPtr had to be used with the previous api and then ownership moved to a unique_ptr for the rest of lld. llvm-svn: 203809
OpenPOWER on IntegriCloud