summaryrefslogtreecommitdiffstats
path: root/lld/COFF/SymbolTable.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Code cleanup in preparation for adding LTO for wasm. NFC.Sam Clegg2018-05-221-1/+2
| | | | | | | | | | | | | | - Move some common code into Common/rrorHandler.cpp and Common/Strings.h. - Don't use `fatal` when incompatible bitcode files are encountered. - Rename NameRef variable to just Name See D47162 Differential Revision: https://reviews.llvm.org/D47206 llvm-svn: 333021
* COFF: Friendlier undefined symbol errors.Peter Collingbourne2018-04-171-1/+65
| | | | | | | | | | | | | | | Summary: This change does three things: - Try to find the file and line number of an undefined symbol reference by reading codeview debug info. - Try to find the name of the function or global variable with the undefined symbol reference by searching the object file's symbol table. - Prints the information in the same style as the ELF linker. Differential Revision: https://reviews.llvm.org/D45467 llvm-svn: 330235
* [lld-link] For suppressible warnings, print the warning number.Nico Weber2018-03-121-2/+2
| | | | | | | The warning can be suppressed by passing the number to /ignore:. https://reviews.llvm.org/D44297 llvm-svn: 327257
* Use DenseMap::lookup() instead of find() and a hand-written null check.Rui Ueyama2018-02-281-4/+1
| | | | llvm-svn: 326382
* Use reinterpret_cast<> instead of C-style cast. NFC.Rui Ueyama2018-02-131-1/+1
| | | | | | | | It is currently interpreted as reinterpret_cast<>. Make it explicit. Differential Revision: https://reviews.llvm.org/D43247 llvm-svn: 325033
* [coff] Print detailed timing information with /TIME.Zachary Turner2018-01-171-0/+5
| | | | | | | | | 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] support /ignore:4217Bob Haarman2017-12-281-6/+9
| | | | | | | | | | | | | | | | | | | | | | | 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] Warn for locally imported symbolsShoaib Meenai2017-12-151-5/+18
| | | | | | | | | Locally imported symbols are a very surprising linker feature. link.exe warns for them, and we should warn too. Differential Revision: https://reviews.llvm.org/D41269 llvm-svn: 320792
* Prefer `ArrayRef` over `const std::vector&`Sam Clegg2017-12-081-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D40993 llvm-svn: 320125
* Move Memory.{h,cpp} to Common.Rui Ueyama2017-11-281-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D40571 llvm-svn: 319221
* Reland r319090, "COFF: Do not create SectionChunks for discarded comdat ↵Peter Collingbourne2017-11-281-43/+23
| | | | | | | | | | | | | | sections." with a fix for debug sections. If /debug was not specified, readSection will return a null pointer for debug sections. If the debug section is associative with another section, we need to make sure that the section returned from readSection is not a null pointer before adding it as an associative section. Differential Revision: https://reviews.llvm.org/D40533 llvm-svn: 319133
* Rename `Symtab` private memory to avoid confusion with global `Symtab`Sam Clegg2017-11-271-5/+5
| | | | | | | | | | | This is also consistent with SymVector that exists in COFF port and soon to be added to the wasm port. Split off as part of https://reviews.llvm.org/D40371 Differential Revision: https://reviews.llvm.org/D40525 llvm-svn: 319113
* Consistent use of <internal> when displaying internal symbol namesSam Clegg2017-11-271-2/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D40510 llvm-svn: 319108
* Revert r319090, "COFF: Do not create SectionChunks for discarded comdat ↵Peter Collingbourne2017-11-271-23/+43
| | | | | | | | | sections." Caused test failures in check-cfi on Windows. http://lab.llvm.org:8011/builders/sanitizer-windows/builds/20284 llvm-svn: 319100
* COFF: Do not create SectionChunks for discarded comdat sections.Peter Collingbourne2017-11-271-43/+23
| | | | | | | | | | | | | | | | | | | | With this change, instead of creating a SectionChunk for each section in the object file, we only create them when we encounter a prevailing comdat section. Also change how symbol resolution occurs between comdat symbols. Now only the comdat leader participates in comdat resolution, and not any other external associated symbols. This is more in line with how COFF semantics are defined, and should allow for a more straightforward implementation of non-ANY comdat types. On my machine, this change reduces our runtime linking a release build of chrome_child.dll with /nopdb from 5.65s to 4.54s (median of 50 runs). Differential Revision: https://reviews.llvm.org/D40238 llvm-svn: 319090
* COFF: Remove the SymbolBodies vector, and rename SparseSymbolBodies to Symbols.Peter Collingbourne2017-11-201-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D40237 llvm-svn: 318683
* Rename replaceBody -> replaceSymbol.Rui Ueyama2017-11-031-12/+13
| | | | llvm-svn: 317383
* Rename SymbolBody -> SymbolRui Ueyama2017-11-031-35/+34
| | | | | | | | | | | | | 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
* Do not access beyond the end of local symbols.Rui Ueyama2017-10-311-1/+11
| | | | | | | | | This patch resurrects code that was removed in r317007 to not access beyond allocated memory for a symbol. Differential Revision: https://reviews.llvm.org/D39458 llvm-svn: 317039
* [COFF] Merge Symbol and SymbolBody.Rui Ueyama2017-10-311-70/+57
| | | | llvm-svn: 317007
* [lld] unified COFF and ELF error handling on new Common/ErrorHandlerBob Haarman2017-10-251-1/+1
| | | | | | | | | | | | | | | | | | | 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] Fix exporting of functions starting with underscores, etcMartin Storsjo2017-10-231-2/+12
| | | | | | | | | | | | | | | | | | | | 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
* Use error() instead of warn() to report undefined symbols.Rui Ueyama2017-10-061-4/+17
| | | | | | | | | | | | | | 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
* COFF: simplify thunk handling (NFC)Saleem Abdulrasool2017-09-011-5/+6
| | | | | | | | | Apply the simplification suggestions that Peter Collingbourne made during the review at D37368. The returned thunk is cast to the appropriate type in the SymbolTable, and the constant symbol's body is not needed directly, so avoid the assignment. NFC llvm-svn: 312391
* COFF: handle multiply defined symbols with different storageSaleem Abdulrasool2017-09-011-8/+12
| | | | | | | | | | | | | | If a symbol is locally defined and is DLL imported in another translation unit, and the object with the locally defined version is loaded prior to the imported version, then the linker will fail to resolve the definition of the thunk and return the locally defined symbol. This will then be attempted to be cast to an import thunk, which will clearly fail. Only return the thunk if the symbol is inserted or a thunk is created. Otherwise, report a duplication error. llvm-svn: 312386
* Add {Obj,Import,Bitcode}File::Instances to COFF input files.Rui Ueyama2017-07-271-8/+8
| | | | | | | 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
* [COFF] Improve synthetic symbol handlingReid Kleckner2017-06-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [COFF] Drop unused comdat sections when GC is turned offReid Kleckner2017-06-161-0/+6
| | | | | | | | | | | | | | | | | Summary: Adds a "Discarded" bool to SectionChunk to indicate if the section was discarded by COMDAT deduplication. The Writer still just checks `isLive()`. Fixes PR33446 Reviewers: ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34288 llvm-svn: 305582
* [COFF] support /ERRORLIMIT optionBob Haarman2017-04-051-1/+1
| | | | | | | | | | | | | | | | | 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
* Do not use errs() or outs() directly. Instead use message(), log() or error()Rui Ueyama2017-02-211-7/+4
| | | | | | | | | LLD is a multi-threaded program. errs() or outs() are not guaranteed to be thread-safe (they are actually not). LLD's message(), log() or error() are thread-safe. We should use them. llvm-svn: 295787
* Revert "[COFF] support /ERRORLIMIT option"David Blaikie2017-02-191-1/+1
| | | | | | | | | | | | | Behavior races on ErrorCount. If the enqueued paths are evaluated eagerly (in enqueuePath) then the behavior is as the test expects. But they may not be evaluated until the future is waited on, in run() - which is after the early return/exit on ErrorCount. (this causes the test to fail (because in the "/ERRORCOUNT:XYZ" test, no other errors are printed), at least for me, on linux) This reverts commit r295507. llvm-svn: 295590
* [COFF] support /ERRORLIMIT optionBob Haarman2017-02-171-1/+1
| | | | | | | | | | | | 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. Reviewers: pcc, ruiu Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D29691 llvm-svn: 295507
* Add an option to use the MSVC linker to link LTO-generated object files.Rui Ueyama2017-02-061-7/+10
| | | | | | | | | | | This patch defines a new command line option, /MSVCLTO, to LLD. If that option is given, LLD invokes link.exe to link LTO-generated object files. This is hacky but useful because link.exe can create PDB files. Differential Revision: https://reviews.llvm.org/D29526 llvm-svn: 294234
* refactor COFF linker to use new LTO APIBob Haarman2017-02-021-95/+55
| | | | | | | | | | | | | | Summary: The COFF linker previously implemented link-time optimization using an API which has now been marked as legacy. This change refactors the COFF linker to use the new LTO API, which is also used by the ELF linker. Reviewers: pcc, ruiu Reviewed By: pcc Subscribers: mgorny, mehdi_amini Differential Revision: https://reviews.llvm.org/D29059 llvm-svn: 293967
* COFF: Change the /lldmap output format to be more like the ELF linker.Peter Collingbourne2017-01-141-11/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D28717 llvm-svn: 291990
* Remove lld/Support/Memory.h.Rui Ueyama2016-12-181-1/+1
| | | | | | | | | | | | I thought for a while about how to remove it, but it looks like we can just copy the file for now. Of course I'm not happy about that, but it's just less than 50 lines of code, and we already have duplicate code in Error.h and some other places. I want to solve them all at once later. Differential Revision: https://reviews.llvm.org/D27819 llvm-svn: 290062
* COFF: Open and map input files asynchronously on Windows.Peter Collingbourne2016-12-151-23/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Profiling revealed that the majority of lld's execution time on Windows was spent opening and mapping input files. We can reduce this cost significantly by performing these operations asynchronously. This change introduces a queue for all operations on input file data. When we discover that we need to load a file (for example, when we find a lazy archive for an undefined symbol, or when we read a linker directive to load a file from disk), the file operation is launched using a future and the symbol resolution operation is enqueued. This implies another change to symbol resolution semantics, but it seems to be harmless ("ninja All" in Chromium still succeeds). To measure the perf impact of this change I linked Chromium's chrome_child.dll with both thin and fat archives. Thin archives: Before (median of 5 runs): 19.50s After: 10.93s Fat archives: Before: 12.00s After: 9.90s On Linux I found that doing this asynchronously had a negative effect on performance, probably because the cost of mapping a file is small enough that it becomes outweighed by the cost of managing the futures. So on non-Windows platforms I use the deferred execution strategy. Differential Revision: https://reviews.llvm.org/D27768 llvm-svn: 289760
* COFF: Fix memory leaks reported by lsan.Peter Collingbourne2016-12-121-1/+1
| | | | llvm-svn: 289451
* COFF: Use CachedHashStringRef in the symbol table.Peter Collingbourne2016-12-111-3/+3
| | | | | | | | This resulted in about a 1% perf improvement linking chrome_child.dll. Differential Revision: https://reviews.llvm.org/D27666 llvm-svn: 289410
* COFF: Load inputs immediately instead of adding them to a queue.Peter Collingbourne2016-12-111-62/+17
| | | | | | | | | | | | This patch replaces the symbol table's object and archive queues, as well as the convergent loop in the linker driver, with a design more similar to the ELF linker where symbol resolution directly causes input files to be added to the link, including input files arising from linker directives. Effectively this removes the last vestiges of the old parallel input file loader. Differential Revision: https://reviews.llvm.org/D27660 llvm-svn: 289409
* COFF: New symbol table design.Peter Collingbourne2016-12-091-192/+220
| | | | | | | | | This ports the ELF linker's symbol table design, introduced in r268178, to the COFF linker. Differential Revision: http://reviews.llvm.org/D21166 llvm-svn: 289280
* COFF: Use make() in SymbolTable and Writer.Rui Ueyama2016-12-091-6/+6
| | | | llvm-svn: 289170
* Remove unnecessary `llvm::`.Rui Ueyama2016-12-081-9/+8
| | | | llvm-svn: 289102
* COFF: Use make() to create a new file object in createFile.Rui Ueyama2016-12-081-11/+11
| | | | llvm-svn: 289097
* Revert r289084: Start using make() in COFF.Rui Ueyama2016-12-081-9/+10
| | | | | | This reverts commit r289084 to appease buildbots. llvm-svn: 289086
* Start using make() in COFF.Rui Ueyama2016-12-081-10/+9
| | | | | | We don't want ELF and COFF to diverge too much. llvm-svn: 289085
* COFF: Define overloaded toString functions.Rui Ueyama2016-12-071-10/+10
| | | | | | | | | | | | | Previously, we had different way to stringize SymbolBody and InputFile to construct error messages. This patch defines overloaded function toString() so that we don't need to memorize all these different function names. With that change, it is now easy to include demangled names in error messages. Now, if there is a symbol name conflict, we'll print out both mangled and demangled names. llvm-svn: 288992
* LTO: Don't follow lazy references when seeing new definitions in the ↵Hans Wennborg2016-10-121-5/+7
| | | | | | | | | | | combined LTO object Following the lazy reference might bring in an object file that depends on bitcode files that weren't part of the LTO step. Differential Revision: https://reviews.llvm.org/D25461 llvm-svn: 283989
* COFF: Update error messages so that they start with lowercase letters.Rui Ueyama2016-07-151-1/+1
| | | | llvm-svn: 275513
OpenPOWER on IntegriCloud