summaryrefslogtreecommitdiffstats
path: root/lld/COFF/Driver.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [COFF] Keep the underscore on exported decorated stdcall functions in MSVC modeMartin Storsjo2018-01-201-1/+1
| | | | | | | | This fixes PR35733. Differential Revision: https://reviews.llvm.org/D41632 llvm-svn: 323036
* [coff] Print detailed timing information with /TIME.Zachary Turner2018-01-171-1/+15
| | | | | | | | | The classes used to print and update time information are in common, so other linkers could use this as well if desired. Differential Revision: https://reviews.llvm.org/D41915 llvm-svn: 322736
* [COFF] Process /EXPORT option in fastpathRui Ueyama2018-01-091-20/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by Takuto Ikuta. This patch reduces lld link time of chromium's blink_core.dll in component build. Total size of input argument in .directives become nearly 300MB in the build and almost all its content are /EXPORT. To reduce time of parsing too many /EXPORT option in the build, I introduce fastpath for /EXPORT in ArgParser::parseDirectives. On my desktop machine, 4 times stats of the link time are like below. Improved around 20%. This patch TotalSeconds : 8.6217627 TotalSeconds : 8.5402175 TotalSeconds : 8.6855853 TotalSeconds : 8.3624441 Ave : 8.5525024 master TotalSeconds : 10.9975031 TotalSeconds : 11.3409428 TotalSeconds : 10.6332897 TotalSeconds : 10.7650687 Ave : 10.934201075 llvm-svn: 322117
* [COFF] Delete CanExitEarlyShoaib Meenai2018-01-081-1/+0
| | | | | | | | | It was being set but never used, and its value is only ever needed locally in lld::coff::link. Differential Revision: https://reviews.llvm.org/D41814 llvm-svn: 322026
* [COFF] Initalize ErrorHandler with CanExitEarly valueShoaib Meenai2018-01-081-0/+1
| | | | | | | | | | | | | Previously, the COFF driver would call exit(1) from the ErrorHandler in the case of a link error, even if CanExitEarly=false was specified. Now it initializes the ErrorHandler in the same way that the ELF driver does. Patch by Andrew Kelley. Differential Revision: https://reviews.llvm.org/D41803 llvm-svn: 321983
* Do not parse the same /export string more than once.Rui Ueyama2017-12-281-0/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D41607 llvm-svn: 321513
* [COFF] support /ignore:4217Bob Haarman2017-12-281-0/+7
| | | | | | | | | | | | | | | | | | | | | | | Summary: lld-link accepts link.exe's /ignore option, but used to ignore it. This can lead to semantic differences when warnings are treated as fatal errors. One such case is when we resolve an __imp_ symbol to a local definition. We emit a warning in that case, which /wx turns into a fatal. This change makes lld-link accept /ignore:4217 to suppress that warning, so that code that links with link.exe /wx /ignore:4217 links with lld-link, too. Fixes PR35762. Reviewers: rnk, ruiu Reviewed By: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41606 llvm-svn: 321512
* [COFF] Do not parse args twice if no rsp files existsRui Ueyama2017-12-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by Takuto Ikuta. This patch reduces link time of chromium's blink_core.dll in component build. Total size of input argument in .directives become nearly 300MB in the build and no rsp file is used. Speedup link by skipping duplicate parsing. On my desktop machine, 4 times stats are like below. Improved around 15%. This patch TotalSeconds : 18.408538 TotalSeconds : 17.2996744 TotalSeconds : 17.1053862 TotalSeconds : 17.809777 avg: 17.6558439 master TotalSeconds : 20.9290504 TotalSeconds : 19.9158213 TotalSeconds : 21.0643515 TotalSeconds : 20.8775831 avg: 20.696701575 Differential Revision: https://reviews.llvm.org/D41581 llvm-svn: 321470
* [COFF] Clean up debug option handlingShoaib Meenai2017-12-161-7/+5
| | | | | | | | | | | | | | | /debug and /debug:dwarf are orthogonal. An object file can contain both CodeView and DWARF debug info, so the combination of /debug:dwarf and /debug should generate both DWARF and a PDB, rather than /debug:dwarf always suppressing PDB creation. /nopdb is now redundant and can be removed. /debug /nopdb was previously used to support DWARF, but specifying /debug:dwarf is entirely equivalent to that combination now. Differential Revision: https://reviews.llvm.org/D41310 llvm-svn: 320896
* [COFF] Update an outdated comment. NFCShoaib Meenai2017-12-151-1/+1
| | | | | | | This comment dates from when LLD didn't produce actual PDBs, and is very outdated now. llvm-svn: 320894
* [COFF] Simplify hasArgs calls. NFCShoaib Meenai2017-12-151-4/+3
| | | | | | | We can just pass multiple options to hasArgs (which will check for any of those options being present) instead of calling it multiple times. llvm-svn: 320892
* [COFF] Teach LLD to use the COFF .debug$H section.Zachary Turner2017-12-141-1/+3
| | | | | | | | | | | | This adds the /DEBUG:GHASH option to LLD which will look for the existence of .debug$H sections in linker inputs and use them to accelerate type merging. The clang-cl side has already been added, so this completes the work necessary to begin experimenting with this feature. Differential Revision: https://reviews.llvm.org/D40980 llvm-svn: 320719
* [COFF] Disallow -dynamicbase:no for arm and arm64Martin Storsjo2017-12-121-0/+5
| | | | | | | | This matches what MSVC link.exe does. Differential Revision: https://reviews.llvm.org/D41051 llvm-svn: 320517
* [COFF] Don't error out on undefined references to __enclave_configMartin Storsjo2017-12-121-0/+2
| | | | | | | | This is required for linking the CRT from MSVC 2017 15.5. Differential Revision: https://reviews.llvm.org/D41089 llvm-svn: 320462
* Do not read the same .lib file more than once.Rui Ueyama2017-12-111-0/+2
| | | | | | | | | | | | | | | In the following command line, lld-link foo/bar.lib /defaultlib:bar.lib "/defaultlib:bar.lib" should be a nop even if a file with the same name exists in other library search path. Fixes https://bugs.llvm.org/show_bug.cgi?id=35476 Differential Revision: https://reviews.llvm.org/D41094 llvm-svn: 320434
* Always evaluate the second argument for CHECK() lazily.Rui Ueyama2017-12-061-9/+9
| | | | | | | | | This patch is to rename check CHECK and make it a C macro, so that we can evaluate the second argument lazily. Differential Revision: https://reviews.llvm.org/D40915 llvm-svn: 319974
* toString function take a const refs where possibleSam Clegg2017-12-051-3/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D40824 llvm-svn: 319787
* Revert "Merge .xdata into .rdata by default"Reid Kleckner2017-12-011-4/+0
| | | | | | | This reverts commit r318699, it is breaking 32-bit SEH handlers in Chromium. llvm-svn: 319508
* [LLD] [COFF] Support ENTRY and SUBSYSTEM in .drectve sectionsRui Ueyama2017-11-291-12/+21
| | | | | | | | | | | | | Adds support for "/ENTRY" and "/SUBSYSTEM" linker options in .drectve sections. Some Mozilla binaries were using these directives and MSVC link.exe appears to allow them. No attempt is made to reconcile these with the options on the command line. Patch by David Major! Differential Revision: https://reviews.llvm.org/D39972 llvm-svn: 319356
* Move Memory.{h,cpp} to Common.Rui Ueyama2017-11-281-5/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D40571 llvm-svn: 319221
* COFF: Emit a COFF symbol table if /debug:dwarf is specified.Peter Collingbourne2017-11-211-0/+1
| | | | | | | | | This effectively reverts r318548 and r318635 while keeping the functionality behind the flag and preserving the bug fix from r318548. Differential Revision: https://reviews.llvm.org/D40264 llvm-svn: 318721
* Merge .xdata into .rdata by defaultReid Kleckner2017-11-201-0/+4
| | | | | | | | | | | | Summary: MSVC does this. The user can override it with their own /merge: flag. Reviewers: ruiu, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D40197 llvm-svn: 318699
* COFF: Stop emitting a non-standard COFF symbol table into PEs.Peter Collingbourne2017-11-171-2/+0
| | | | | | | | | | | | Now that our support for PDB emission is reasonably good, there is no longer a need to emit a COFF symbol table. Also fix a bug where we would fail to emit a string table for long section names if /debug was not specified. Differential Revision: https://reviews.llvm.org/D40189 llvm-svn: 318548
* Remove a std::map and std::set that show up in LLD profilesReid Kleckner2017-11-131-1/+4
| | | | | | | | | | | | | | | | | | For GC roots, add a bit to SymbolBody to ensure that we don't add the same root twice, and switch to a vector. In addition to being faster, this may also fix some latent non-determinism. We iterate the GCRoot list later and it the order should be deterministic. For fixupExports, we can just use DenseMap. This is a simple string uniquing task, and we don't iterate the map. Reviewers: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39609 llvm-svn: 318072
* Disable GC and ICF when /debug is presentReid Kleckner2017-11-131-24/+25
| | | | | | | | | | | | | | | | | | | | | ICF and GC impair debugging, so MSVC disables these optimizations when /debug is passed. They are still on by default when no PDB is produced. This change also makes /opt:ref enable ICF, which is consistent with MSVC: https://msdn.microsoft.com/en-us/library/bxwfs976.aspx We should consider making /opt:icf fold readonly data in the near future. LLD used to do this, but we disabled it because it breaks too many programs. MSVC only does this if the user explicitly passes /opt:icf. Reviewers: ruiu, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D39885 llvm-svn: 318071
* [MinGW] Output debug info by default, unless the -s parameter is passedMartin Storsjo2017-11-031-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D39541 llvm-svn: 317376
* Rename SymbolBody -> SymbolRui Ueyama2017-11-031-5/+5
| | | | | | | | | | | | | Now that we have only SymbolBody as the symbol class. So, "SymbolBody" is a bit strange name now. This is a mechanical change generated by perl -i -pe s/SymbolBody/Symbol/g $(git grep -l SymbolBody lld/ELF lld/COFF) nd clang-format-diff. Differential Revision: https://reviews.llvm.org/D39459 llvm-svn: 317370
* [COFF] Autoexport symbols as data if they don't point to an executable sectionMartin Storsjo2017-11-031-0/+3
| | | | | | | | This was already taken care of for the output def file. Differential Revision: https://reviews.llvm.org/D39573 llvm-svn: 317367
* [COFF] Merge Symbol and SymbolBody.Rui Ueyama2017-10-311-7/+7
| | | | llvm-svn: 317007
* [lld] unified COFF and ELF error handling on new Common/ErrorHandlerBob Haarman2017-10-251-16/+19
| | | | | | | | | | | | | | | | | | | Summary: The COFF linker and the ELF linker have long had similar but separate Error.h and Error.cpp files to implement error handling. This change introduces new error handling code in Common/ErrorHandler.h, changes the COFF and ELF linkers to use it, and removes the old, separate implementations. Reviewers: ruiu Reviewed By: ruiu Subscribers: smeenai, jyknight, emaste, sdardis, nemanjai, nhaehnle, mgorny, javed.absar, kbarton, fedor.sergeev, llvm-commits Differential Revision: https://reviews.llvm.org/D39259 llvm-svn: 316624
* COFF: Don't add /manifest* flags to the response file.Peter Collingbourne2017-10-251-0/+6
| | | | | | | | | | | | If /manifest:embed is enabled we're already creating a resource file out of these flags and adding it to the linkrepro, and it doesn't seem worth being able to repro side-by-side manifests. Includes a test that covers this commit as well as r315948. Differential Revision: https://reviews.llvm.org/D38975 llvm-svn: 316547
* [COFF] Clean up boolean flag handlingShoaib Meenai2017-10-241-20/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | LLD's handling of boolean flags is suboptimal: * All boolean flags have a corresponding `:no` flag to turn the flag off, and the linker should scan for both the non-suffixed and suffixed flags (and the last one should win), but right now it only scans for either the suffixed or non-suffixed flag (depending on the default flag value). * The `B` multiclass only allows specifying help text for the suffixed (`:no`) flag, but for some flags (e.g. `/appcontainer`) the help text should be associated with the non-suffixed flag instead. Extend the `B` multiclass to have help text for both non-suffixed and suffixed flag variants, and alter the existing help text accordingly in some cases. Scan for both the non-suffixed and suffixed variants in the driver and set config values accordingly. This should mostly have no behavior change, apart from the added help text and the modified argument scanning. Some flags are handled slightly differently now, however; for example, LLD would previously always treat 64-bit images as large address aware, whereas `/largeaddressaware:no` is now respected for 64-bit images (which is also how link.exe behaves). Differential Revision: https://reviews.llvm.org/D39216 llvm-svn: 316501
* lld::COFF: better behavior when using as a libraryRui Ueyama2017-10-231-9/+10
| | | | | | | | | | | | | | | Previously, the COFF driver would call exit(0) when called as a library. Now it takes `ExitEarly` option, and if it is false, it doesn't exit. So it is now more library-friendly. Furthermore, link() calls freeArena() before returning, to clean up resources. Based on an Andrew Kelley's patch. Differential Revision: https://reviews.llvm.org/D39202 llvm-svn: 316370
* Add the --version option.Rui Ueyama2017-10-231-0/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D38972 llvm-svn: 316329
* [COFF] Fix exporting of functions starting with underscores, etcMartin Storsjo2017-10-231-3/+4
| | | | | | | | | | | | | | | | | | | | This fixes exporting functions in the following cases: - functions starting with an underscore in def files - functions starting with an underscore, via dllexport attributes, for mingw - fastcall and vectorcall functions when declared undecorated in def files - vectorcall functions when declared decorated in def files - stdcall functions when declared decorated in def files for mingw This still exports the stdcall functions with the wrong name in the normal msvc/link.exe mode, if declared with decoration in the def file though (this is not a regression though). Exporting functions via def files including decoration is not something I believe is routinely done though, but is tested to try to match link.exe's behaviour as far as easily possible. Differential Revision: https://reviews.llvm.org/D39170 llvm-svn: 316317
* [COFF] Move MinGW specific functions/classes to a separate file. NFC.Martin Storsjo2017-10-191-107/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D39067 llvm-svn: 316178
* [COFF] Exclude certain static libraries and object files when exporting all ↵Martin Storsjo2017-10-191-39/+87
| | | | | | | | | | symbols This more or less matches what GNU ld does. Differential Revision: https://reviews.llvm.org/D38937 llvm-svn: 316148
* COFF: Add resource files to linkrepro instead of the cvtres object file.Peter Collingbourne2017-10-161-14/+15
| | | | | | | | | Now that we have our own implementation of cvtres, we can add resource files directly to the linkrepro. Differential Revision: https://reviews.llvm.org/D38974 llvm-svn: 315954
* [COFF] Fix indentation. NFC.Martin Storsjo2017-10-151-1/+1
| | | | llvm-svn: 315879
* [COFF] Fix the description of the data type in a comment. NFC.Martin Storsjo2017-10-151-1/+1
| | | | | | | This was missed when changing data types back and forth during review. llvm-svn: 315878
* [COFF] Add support for automatically exporting all symbolsMartin Storsjo2017-10-121-0/+80
| | | | | | | | | | | | | | | | | | | | | | | | | GNU ld automatically exports all symbols if no symbols have been chosen to export via either def files or dllexport attributes. The same behaviour can also be enabled via the GNU ld option --export-all-symbols, in case some symbols are marked for export via a def file or dllexport attribute. The list of excluded symbols is from GNU ld, minus the cygwin specific symbols. Also add support for outputting the actual list of exported symbols in a def file, as in the GNU ld option --output-def. These options in GNU ld are documented in https://sourceware.org/binutils/docs/ld/WIN32.html. This currently exports all symbols from object files pulled in from libmingw32 and libmingwex and other static libraries that are linked in. Differential Revision: https://reviews.llvm.org/D38760 llvm-svn: 315562
* Use error() instead of warn() to report undefined symbols.Rui Ueyama2017-10-061-0/+2
| | | | | | | | | | | | | | I believe the reason why we used warn() instead of error() to report undefined symbols is because the older implementation of error() exitted immediately. Here, we want to find as many undefined symbols as we can, so I chose to use warn() instead of error(). Now error() does not exit immediately, so it doesn't make sense to keep them as warnings. Differential Revision: https://reviews.llvm.org/D38652 llvm-svn: 315131
* Move new lld's code to Common subdirectory.Rui Ueyama2017-10-021-1/+1
| | | | | | | | | | New lld's files are spread under lib subdirectory, and it isn't easy to find which files are actually maintained. This patch moves maintained files to Common subdirectory. Differential Revision: https://reviews.llvm.org/D37645 llvm-svn: 314719
* Update for llvm change.Rafael Espindola2017-09-211-5/+8
| | | | llvm-svn: 313938
* [COFF] Check for sections larger than 4 GiBShoaib Meenai2017-09-191-0/+3
| | | | | | | | | | Sections are limited to 4 GiB. Error out early if a section exceeds this size, rather than overflowing the section size and getting confusing assertion failures/segfaults later. Differential Revision: https://reviews.llvm.org/D38005 llvm-svn: 313699
* Revert r303378: Set IMAGE_DLL_CHARACTERISTICS_NO_BIND.Rui Ueyama2017-09-151-0/+2
| | | | | | | | | | r303378 was submitted because r303374 (Merge IAT and ILT) made lld's output incompatible with the Binding feature. Now that r303374 was reverted, we do not need to keep this change. Pointed out by pcc. llvm-svn: 313414
* Remove {get,set}Align accessor functions and use Alignment member variable ↵Rui Ueyama2017-09-131-2/+6
| | | | | | instead. llvm-svn: 313204
* Do not use hasArgNoClaim().Rui Ueyama2017-09-131-3/+3
| | | | | | | | | Arg instances can be claimed. After claimed, its `isClaimed` function returns true. We do not use that notion in lld, so using NoClaim versions of functions is just confusing. This patch is to just use hasArg instead of hasArgNoClaim. llvm-svn: 313187
* [MinGW] Support dllexport on i386Martin Storsjo2017-09-131-0/+10
| | | | | | | | | | | | In MinGW configurations (GCC, or clang with a *-windows-gnu target), the -export directives in the object file contains the undecorated symbol name, while it is decorated in MSVC configurations. (On the command line, link.exe takes an undecorated symbol name for the -export argument though.) Differential Revision: https://reviews.llvm.org/D37772 llvm-svn: 313174
* [COFF] Add support for the -wholearchive optionMartin Storsjo2017-09-131-14/+39
| | | | | | | | This fixes PR31824. Differential Revision: https://reviews.llvm.org/D37709 llvm-svn: 313123
OpenPOWER on IntegriCloud