summaryrefslogtreecommitdiffstats
path: root/lld/COFF/Driver.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Ignore /natvis option for now.Rui Ueyama2017-09-111-0/+1
| | | | | | | | | | /natvis is a new command line option introduced by MSVC 2017. We eventually have to support it, but for now, let's ignore it so that we can at least link stuff instead of printing out an error. Patch by Michael Rickert. llvm-svn: 312966
* COFF: Implement ThinLTO cache and cache pruning support.Peter Collingbourne2017-09-081-0/+10
| | | | | | Differential Revision: https://reviews.llvm.org/D37607 llvm-svn: 312770
* COFF: Remove unnecessary casts. NFCI.Peter Collingbourne2017-09-071-7/+7
| | | | llvm-svn: 312762
* lld-link: Add --rsp-quoting= flag.Nico Weber2017-09-051-0/+1
| | | | | | | | | | This ports https://reviews.llvm.org/D19425 from clang / https://reviews.llvm.org/D22015 from the ELF port to COFF lld. This can be useful when linking COFF files on a posix host. https://reviews.llvm.org/D37452 llvm-svn: 312594
* Simplify writeArchive return type.Rui Ueyama2017-08-301-3/+3
| | | | | | | | | | writeArchive returned a pair, but the first element of the pair is always its first argument on failure, so it doesn't make sense to return it from the function. This patch change the return type so that it does't return it. Differential Revision: https://reviews.llvm.org/D37313 llvm-svn: 312177
* Move a function from Driver.cpp to InputFile.cpp.Rui Ueyama2017-08-301-19/+0
| | | | | | | This patch doesn't improve code per se, but it should make the following patch's diff easier to read. llvm-svn: 312170
* Remove Symtab aliases.Rui Ueyama2017-08-281-32/+36
| | | | | | | | | Various classes have `Symtab` member variables even though we have lld::coff::Symtab variable because previous attempts to make COFF lld's internal structure resemble to ELF's was incomplete. This patch finishes that job by removing member variables. llvm-svn: 311938
* Keep an instance of COFFOptTable alive as long as InputArgList is alive.Rui Ueyama2017-08-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: ArgParser created an instance of COFFOptTable on stack to use it to parser command line arguments. Parsed arguments were then returned from the function as InputArgList. This was safe because InputArgList referred only statically-allocated InfoTable. That is not a safe assumption after https://reviews.llvm.org/D36782, which changes the type of its internal table from ArrayRef to std::vector. To make lld work with that patch, we need to keep an instance of COFFOptTable at least as long as an InputArgList is alive. This patch does that. Reviewers: yamaguchi Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37217 llvm-svn: 311930
* Simplify. NFC.Rui Ueyama2017-08-241-2/+1
| | | | llvm-svn: 311700
* Minor refactoring. NFC.Rui Ueyama2017-08-241-4/+4
| | | | llvm-svn: 311696
* [COFF] Don't produce weak aliases in import librariesMartin Storsjo2017-08-161-1/+1
| | | | | | | | | | | | | | When creating an import library from lld, the cases with Name != ExtName shouldn't end up as a weak alias, but as a real export of the new name, which is what actually is exported from the DLL. This restores the behaviour of renamed exports to what it was in 4.0. Differential Revision: https://reviews.llvm.org/D36634 llvm-svn: 310992
* [COFF] Fix the name type for stdcall functions in import librariesMartin Storsjo2017-08-161-2/+2
| | | | | | | | | | | | | | | | | | | | | Since SVN r303491 and r304573, LLD used the COFFImportLibrary functions from LLVM. These only had two names, Name and ExtName, which wasn't enough to convey all the details of stdcall functions. Stdcall functions got the wrong symbol name in the import library itself in r303491, which is why it was reverted in r304561. When re-landed and fixed in r304573 (after adding a test in r304572), the symbol name itself in the import library ended up right, but the name type of the import library entry was wrong. This had the effect that linking to the import library succeeded (contrary to in r303491, where linking to such an import library failed), but at runtime, the symbol wouldn't be found in the DLL (since the caller linked to the stdcall decorated name). Differential Revision: https://reviews.llvm.org/D36545 llvm-svn: 310989
* [COFF] Add support for aligncomm directivesMartin Storsjo2017-08-141-0/+24
| | | | | | | | | | | | | | These are emitted for comm symbols in object files, when targeting a GNU environment. Alternatively, just ignore them since we already align CommonChunk to the natural size of the content (up to 32 bytes). That would only trade away the possibility to overalign small symbols, which doesn't sound like something that might not need to be handled? Differential Revision: https://reviews.llvm.org/D36304 llvm-svn: 310871
* Add {Obj,Import,Bitcode}File::Instances to COFF input files.Rui Ueyama2017-07-271-5/+5
| | | | | | | We did the same thing for ELF in r309152, and I want to maintain COFF and ELF as close as possible. llvm-svn: 309239
* Rename ObjectFile ObjFile for COFF as well.Rui Ueyama2017-07-261-6/+6
| | | | llvm-svn: 309228
* lld: only write .manifest files if /manifest is passed, PR33925Nico Weber2017-07-251-7/+19
| | | | | | | | | Also emit an error if /manifestinput: is used without /manifest:embed. Increases compatibility with link.exe https://reviews.llvm.org/D35842 llvm-svn: 308998
* Use StringRef::contains().Rui Ueyama2017-07-191-2/+2
| | | | llvm-svn: 308526
* Handle option aliases in a better way.Rui Ueyama2017-07-191-1/+1
| | | | | | In this way, we don't need to know which options have aliases. llvm-svn: 308519
* COFF: improve link conformance for import namesSaleem Abdulrasool2017-07-191-6/+31
| | | | | | | | | | | | | | | | Improve the link conformance for the import name embedded into the import library. This requires the associated change to the LLVM portion for the DEF file parser. The import file generation embeds a different name based on whether the driver is invoked as "link" or "lib". Furthermore, the LIBRARY keyword in the DEF file influences the import name. The behaviour can be summarised according to the following table: | LIBRARY w/ ext | LIBRARY w/o ext | no LIBRARY -----+----------------+---------------------+------------------ LINK | {value} | {value}.{.dll/.exe} | {output name} LIB | {value} | {value}.dll | {output name}.dll llvm-svn: 308407
* [lld/pdb] Add some basic linker module symbols.Zachary Turner2017-07-101-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D35152 llvm-svn: 307590
* [COFF] Improve synthetic symbol handlingReid Kleckner2017-06-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The main change is that we can have SECREL and SECTION relocations against ___safe_se_handler_table, which is important for handling the debug info in the MSVCRT. Previously we were using DefinedRelative for __safe_se_handler_table and __ImageBase, and after we implement CFGuard, we plan to extend it to handle __guard_fids_table, __guard_longjmp_table, and more. However, DefinedRelative is really only suitable for implementing __ImageBase, because it lacks a Chunk, which you need in order to figure out the output section index and output section offset when resolving SECREl and SECTION relocations. This change renames DefinedRelative to DefinedSynthetic and gives it a Chunk. One wart is that __ImageBase doesn't have a chunk. It points to the PE header, effectively. We could split DefinedRelative and DefinedSynthetic if we think that's cleaner and creates fewer special cases. I also added safeseh.s, which checks that we don't emit a safe seh table entries pointing to garbage collected handlers and that we don't emit a table at all when there are no handlers. Reviewers: ruiu Reviewed By: ruiu Subscribers: inglorion, pcc, llvm-commits, aprantl Differential Revision: https://reviews.llvm.org/D34577 llvm-svn: 306293
* Define __guard_{iat,longjmp}_{count,table} symbols.Rui Ueyama2017-06-211-1/+5
| | | | | | | | | | | VC2017 contains these new symbols as undefined symobls. They are used for /guard:cf. Since we do not support the control flow guard, but we want to at least ignore these symbols so that we can link against VS2017 libraries. Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=727193. llvm-svn: 305876
* Update documentation to reflection disuse of external cvtres.Eric Beckmann2017-06-171-3/+3
| | | | | | | | Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34316 llvm-svn: 305631
* Remove /dumppdb option from LLD.Zachary Turner2017-06-161-1/+0
| | | | | | | | This option is no longer needed. Differential Revision: https://reviews.llvm.org/D34302 llvm-svn: 305610
* COFF: add support for lib mode usageSaleem Abdulrasool2017-06-151-2/+13
| | | | | | | | | | When link is invoked with `/def:` and no input files, it behaves as if `lib.exe` was invoked. Emulate this behaviour, generating the import library from the def file that was passed. Because there is no input to actually generate the dll, we simply process the def file early and exit once we have created the import library. llvm-svn: 305502
* Inline a small function. NFC.Rui Ueyama2017-06-141-5/+1
| | | | llvm-svn: 305428
* Use check() to report an error.Rui Ueyama2017-06-081-8/+2
| | | | llvm-svn: 305033
* Move Object format code to lib/BinaryFormat.Zachary Turner2017-06-071-2/+1
| | | | | | | | | | | | This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 llvm-svn: 304864
* Re-land "COFF: migrate def parser from LLD to LLVM"Reid Kleckner2017-06-021-4/+84
| | | | | | | | | | | | | | | | | | | | | | This reverts commit r304561 and re-lands r303490 & co. The fix was to use "SymbolName" when translating LLD's internal export list to lib/Object's short export struct. The SymbolName reflects the actual symbol name, which may include fastcall and stdcall mangling bits not included in the /EXPORT or .def file EXPORTS name: @@ -434,8 +434,7 @@ std::vector<COFFShortExport> createCOFFShortExportFromConfig() { std::vector<COFFShortExport> Exports; for (Export &E1 : Config->Exports) { COFFShortExport E2; - E2.Name = E1.Name; + // Use SymbolName, which will have any stdcall or fastcall qualifiers. + E2.Name = E1.SymbolName; E2.ExtName = E1.ExtName; E2.Ordinal = E1.Ordinal; E2.Noname = E1.Noname; llvm-svn: 304573
* Revert "COFF: migrate def parser from LLD to LLVM"Reid Kleckner2017-06-021-83/+4
| | | | | | | | | | This reverts commits r303490, r303491, r303493, and r303494. This caused http://crbug.com/728726. Essentially, exporting stdcall functions doesn't appear to work after this change. Reduced test case soon. llvm-svn: 304561
* COFF: migrate def parser from LLD to LLVM [2/2]Martell Malone2017-05-201-4/+83
| | | | | | | | | | | | This is split up into two commits. This commit removes the DEF parser from LLD See the previous commit for the creation in LLVM. Reviewers: ruiu Differential Revision: https://reviews.llvm.org/D32689 llvm-svn: 303491
* Set IMAGE_DLL_CHARACTERISTICS_NO_BIND.Rui Ueyama2017-05-181-2/+0
| | | | | | | | | Our output is not compatible with the Binding feature, so make it explicit that. Differential Revision: https://reviews.llvm.org/D33336 llvm-svn: 303378
* Use make<> everywhere in COFF to make it consistent with ELF.Rui Ueyama2017-05-181-2/+1
| | | | | | | | | We've been using make<> to allocate new objects in ELF. We have the same function in COFF, but we didn't use it widely due to negligence. This patch uses the function in COFF to close the gap between ELF and COFF. llvm-svn: 303357
* [COFF] Fix interaction between /DEBUG and /PDBZachary Turner2017-05-181-1/+0
| | | | | | | | | | | | | | | When /DEBUG is not specified, /PDB should be ignored. When /DEBUG is specified, a PDB should be output regardless of whether or not /PDB is specified. /PDB just overrides the default name. This patch implements this behavior, and adds some tests, while also removing a dead option /DEBUGPDB which was unused in any code. Differential Revision: https://reviews.llvm.org/D33302 llvm-svn: 303352
* Move lib/LibDriver -> lib/ToolDrivers/llvm-lib. NFCI.Peter Collingbourne2017-05-131-1/+1
| | | | | | | This reorganisation prevents us from cluttering up the top-level lib directory with more driver libraries such as llvm-dlltool (see D29892). llvm-svn: 302995
* [coff] for /msvclto, pass archive members with prevailing symbols firstBob Haarman2017-04-211-0/+17
| | | | | | | | | | | | | | Summary: When using /msvclto, lld and MSVC's linker both do their own symbol resolution. This can cause them to select different archive members, which can result in undefined references. This change avoids that situation by extracting archive members that are selected by lld and passing those to link.exe before any archives, so that MSVC's uses those objects for symbol resolution instead of different archive members. Reviewers: pcc, rnk, ruiu Reviewed By: pcc Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D32317 llvm-svn: 301045
* [coff] use newlines instead of spaces as separators in msvclto response fileBob Haarman2017-04-181-4/+4
| | | | | | | | | | | | | | Summary: Fixes PR32689: /msvclto creates response files with lines that are too long for msvc's linker (LNK1170). Reviewers: hans, rnk, ruiu Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D32185 llvm-svn: 300612
* Update to match LLVM r300135.Richard Smith2017-04-121-2/+2
| | | | llvm-svn: 300141
* COFF: support the /appcontainer flagSaleem Abdulrasool2017-04-061-0/+3
| | | | | | | | | The /appcontainer flag indicates that the module may only be used inside an application container (for isolation). This has been supported by link.exe since Windows 8.0. It sets an additional bit in the PE DLL Characteristics flag to indicate the behavioural change. llvm-svn: 299728
* [COFF] support /ERRORLIMIT optionBob Haarman2017-04-051-23/+49
| | | | | | | | | | | | | | | | | Summary: This adds support for reporting multiple errors in a single invocation of lld-link. The limit defaults to 20 and can be changed with the /ERRORLIMIT command line parameter, or set to unlimited by passing a value of 0. This is a new attempt after r295507, which was reverted because opening files raced with exiting early, causing the test to be flaky. This version avoids the race by exiting before calling enqueuePath. Reviewers: pcc, ruiu Reviewed By: ruiu Subscribers: llvm-commits, dblaikie Differential Revision: https://reviews.llvm.org/D31688 llvm-svn: 299496
* Add parsing of mllvm command line options.Rui Ueyama2017-03-301-0/+7
| | | | | | | | | Patch by Alberto Magni Original patch by Kyungwoo Lee <kyulee@microsoft.com> Differential Revision: https://reviews.llvm.org/D31388 llvm-svn: 299106
* Add a /nopdb flag to disable PDB generationReid Kleckner2017-03-221-0/+4
| | | | | | | | | | This will be used in the sanitizer test suite, which wants to use DWARF line tables. At some point we should reconsider how LLD handles the long section names required by DWARF debug sections. llvm-svn: 298544
* [COFF] Put the PDB next to the image if the user doesn't pass /PDB:Reid Kleckner2017-03-221-0/+6
| | | | | | | | | | | | Summary: This is compatible with MSVC link.exe. Reviewers: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31224 llvm-svn: 298467
* [COFF] Don't let /def override /out filenameReid Kleckner2017-03-211-3/+6
| | | | | | | | | | | | | | | | Summary: This also delays setting the output filename based on the first input argument until after processing /def. Fixes PR32354 Reviewers: ruiu, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31152 llvm-svn: 298327
* COFF: Strip /lldsavetemps from MSVC command line during /msvclto.Peter Collingbourne2017-03-171-0/+1
| | | | llvm-svn: 298035
* COFF: Do not create empty temporary archives for /msvclto.Peter Collingbourne2017-03-171-3/+5
| | | | | | | | The MSVC linker doesn't support them. Differential Revision: https://reviews.llvm.org/D31067 llvm-svn: 298034
* COFF: Fix use-after-free in /msvclto implementation.Peter Collingbourne2017-03-171-13/+11
| | | | | | | | | The Archive object owns the memory buffers of any thin archive members, so we need to make sure the object is still in scope when we access archive members. Differential Revision: https://reviews.llvm.org/D31066 llvm-svn: 298033
* Do not pass archive files containing non-native object files.Rui Ueyama2017-03-161-33/+92
| | | | | | | | | | | | | | | | | | | | | | The MSVC linker doesn't like archive files containing non-native object files. When we are doing an LTO build, we may create archive files containing both LLVM bitcode files and native object files. For example, if a project contains assembly files and C++ files, we create native object files for the assembly files and LLVM bitcode files for the C++ files. With the /msvclto option, LLD passes archive files to the MSVC linker. Previously, we didn't pass archive files if they contain at least one bitcode files. That wasn't correct because the native object files that weren't passed to the MSVC linker may be needed to complete linking. In this patch, we create new temporary archive files to strip bitcode files. Differential Revision: https://reviews.llvm.org/D31053 llvm-svn: 297997
* Pass archive files to link.exe if they contain at least one native object file.Rui Ueyama2017-03-071-4/+8
| | | | | | | | | | | | Some archive files created during chromium build contains both BC and native files. If that's the case, we want to pass the archive file to link.exe. Otherwise, the MSVC linker would complain that there's an unresolved symbol in a given set of files. I cannot explain why link.exe doesn't complain about the presence of bitcode files in this case, but it seems link.exe doesn't touch BC. llvm-svn: 297229
* Do not pass archive files containing bitcode files to the MSVC Linker.Rui Ueyama2017-03-071-2/+25
| | | | | | | | | | | | | | | | If /msvclto is specified, we compile bitcode files and pass it to the MSVC linker, stripping all bitcode files. We haven't stripped archive files, because I was thinking that the MSVC linker wouldn't touch files in archive files. When we pass an object file to link.exe, all symbols have been resolved already, so link.exe shoulnd't need any of the files in archives. It turns out that even though link.exe doesn't need to do that, it seems to try to read each file in all archives. And if there's a non- COFF file in an archive, it exists with an error message. So we need to remove archives from the command line too. llvm-svn: 297191
OpenPOWER on IntegriCloud