summaryrefslogtreecommitdiffstats
path: root/lld/COFF/InputFiles.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* COFF: Implement DLL symbol exports for bitcode files.Peter Collingbourne2015-06-181-0/+8
| | | | | | Differential Revision: http://reviews.llvm.org/D10530 llvm-svn: 239994
* COFF: Symbol resolution for common and comdat symbols defined in bitcode.Peter Collingbourne2015-06-111-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | In the case where either a bitcode file and a regular file or two bitcode files export a common or comdat symbol with the same name, the linker needs to pick one of them following COFF semantics. This patch implements a design for resolving such symbols that pushes most of the work onto either LLD's regular mechanism for resolving common or comdat symbols or the IR linker's mechanism for doing the same. We modify SymbolBody::compare to always prefer non-bitcode symbols, so that during the initial phase of symbol resolution, the symbol table always contains a regular symbol in any case where we need to choose between a regular and a bitcode symbol. In SymbolTable::addCombinedLTOObject, we force export any bitcode symbols that were initially pre-empted by a regular symbol, and later use SymbolBody::compare to choose between the regular symbol in the symbol table and the regular symbol from the combined LTO object file. This design seems to be sound, so long as the resolution mechanism is defined to be commutative and associative modulo arbitrary choices between symbols (which seems to be the case for COFF). Differential Revision: http://reviews.llvm.org/D10329 llvm-svn: 239563
* COFF: Skip internal symbols in bitcode files.Peter Collingbourne2015-06-081-2/+6
| | | | | | Differential Revision: http://reviews.llvm.org/D10319 llvm-svn: 239338
* COFF: Read symbol names lazily.Rui Ueyama2015-06-081-18/+16
| | | | | | | | | This change seems to make the linker about 10% faster. Reading symbol name is not very cheap because it needs strlen() on the string table. We were wasting time on reading non-external symbol names that would never be used by the linker. llvm-svn: 239332
* COFF: Check for auxiliary symbol's type.Rui Ueyama2015-06-081-3/+7
| | | | | | | | | | | | | | | | We forgot to check for auxiliary symbol's type. So we sometimes read garbage as associative section definitions. Associative sections are considered as not live themselves by the garbage collector because they are live only when associaited sections are live. By reading more data (or garbage) as associative section definitions, we treated more sections as non-GC-roots, that caused the linker to discard too many sections by mistake. That caused another mysterious bug (such as some global constructors don't run at all for some reason.) llvm-svn: 239287
* COFF: Fix memory leak.Rui Ueyama2015-06-081-1/+1
| | | | llvm-svn: 239272
* COFF: Read linker directives from bitcode files.Peter Collingbourne2015-06-061-0/+17
| | | | | | Differential Revision: http://reviews.llvm.org/D10285 llvm-svn: 239212
* Use reinterpret_cast instead of const_cast and C-style cast.Rui Ueyama2015-06-011-1/+1
| | | | llvm-svn: 238786
* COFF: Remove BitcodeFile::BitcodeFile(StringRef Filename).Rui Ueyama2015-06-011-9/+4
| | | | | | | | In r238690, I made all files have only MemoryBufferRefs. This change is to do the same thing for the bitcode file reader. Also updated a few variable names to match with other code. llvm-svn: 238782
* COFF: Support import-by-ordinal DLL imports.Rui Ueyama2015-06-011-1/+5
| | | | | | | | | | | | | | | | | Symbols exported by DLLs can be imported not by name but by small number or ordinal. Usually, symbols have both ordinals and names, and in that case ordinals are called "hints" and used by the loader as hints. However, symbols can have only ordinals. They are called import-by-ordinal symbols. You need to manage ordinals by hand so that they will never change if you choose to use the feature. But it's supposed to make dynamic linking faster because it needs no string comparison. Not sure if that claim still stands in year 2015, though. Anyways, the feature exists, and this patch implements that. llvm-svn: 238780
* COFF: Initial implementation of link-time optimization.Peter Collingbourne2015-06-011-0/+28
| | | | | | | | This implementation is known to work in very simple cases (see new test case). Differential Revision: http://reviews.llvm.org/D10115 llvm-svn: 238777
* COFF: Fix warnings found by gccDenis Protivensky2015-06-011-3/+3
| | | | llvm-svn: 238734
* COFF: Define an error category for the linker.Rui Ueyama2015-06-011-16/+27
| | | | | | | | | | | | | Instead of returning non-categorized errors, return categorized errors. All uses of make_dynamic_error_code are removed. Because we don't have error reporting mechanism, I just chose to print out error messages to stderr, and then return an error object. Not sure if that's the right thing to do, but at least it seems practical. http://reviews.llvm.org/D10129 llvm-svn: 238714
* COFF: Make the Driver own all MemoryBuffers. NFC.Rui Ueyama2015-05-311-23/+8
| | | | | | | | | | | Previously, a MemoryBuffer of a file was owned by each InputFile object. This patch makes the Driver own all of them. InputFiles now have only MemoryBufferRefs. This change simplifies ownership managment (particularly for ObjectFile -- the object owned a MemoryBuffer only when it's not created from an archive file, because in that case a parent archive file owned the entire buffer. Now it owns nothing unconditionally.) llvm-svn: 238690
* COFF: Fill imort table HintName field.Rui Ueyama2015-05-291-1/+1
| | | | | | | | | Currently we set the field to zero, but as per the spec, we should set numbers we read from import library files. The loader uses the values as starting offsets for binary search when looking up imported symbols from DLL. llvm-svn: 238562
* Rename InputFile::Name -> InputFile::Filename.Rui Ueyama2015-05-281-5/+5
| | | | | | | Other local variables shadowed the member variable. Rename to make that a bit longer. llvm-svn: 238478
* COFF: Add a new PE/COFF port.Rui Ueyama2015-05-281-0/+247
This is an initial patch for a section-based COFF linker. The patch has 2300 lines of code including comments and blank lines. Before diving into details, you want to start from reading README because it should give you an overview of the design. All important things are written in the README file, so I write summary here. - The linker is already able to self-link on Windows. - It's significantly faster than the existing implementation. The existing one takes 5 seconds to link LLD on my machine, while the new one only takes 1.2 seconds, even though the new one is not multi-threaded yet. (And a proof-of-concept multi- threaded version was able to link it in 0.5 seconds.) - It uses much less memory (250MB vs. 2GB virtual memory space to self-host). - IMHO the new code is much simpler and easier to read than the existing PE/COFF port. http://reviews.llvm.org/D10036 llvm-svn: 238458
OpenPOWER on IntegriCloud