summaryrefslogtreecommitdiffstats
path: root/lld/COFF/Chunks.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* COFF: Fix common symbol alignment.Rui Ueyama2015-06-201-4/+4
| | | | llvm-svn: 240217
* COFF: Support base relocations.Rui Ueyama2015-06-151-1/+39
| | | | | | | | | | | | | | | | | | | PE/COFF executables/DLLs usually contain data which is called base relocations. Base relocations are a list of addresses that need to be fixed by the loader if load-time relocation is needed. Base relocations are in .reloc section. We emit one base relocation entry for each IMAGE_REL_AMD64_ADDR64 relocation. In order to save disk space, base relocations are grouped by page. Each group is called a block. A block starts with a 32-bit page address followed by 16-bit offsets in the page. That is more efficient representation of addresses than just an array of 32-bit addresses. llvm-svn: 239710
* COFF: Add an assertion. NFC.Rui Ueyama2015-06-141-2/+1
| | | | | | | r239458 changed callee side of this function, so Live can never be true when this function is called. llvm-svn: 239705
* COFF: Support Windows resource files.Rui Ueyama2015-06-141-3/+4
| | | | | | | | | | | Resource files are data files containing i18n messages, icon images, etc. MSVC has a tool to convert a resource file to a regular COFF file so that you can just link that file to embed resources to an executable. However, you can directly pass resource files to the linker. If you do that, the linker invokes the tool automatically. This patch implements that feature. llvm-svn: 239704
* COFF: De-virtualize and inline garbage collector functions.Rui Ueyama2015-06-101-17/+16
| | | | | | | | | | | | isRoot, isLive and markLive functions are called very frequently. Previously, they were virtual functions. This patch make them non-virtual. Also this patch checks chunk liveness before calling its mark(). Previously, we did that at beginning of markLive(), so the virtual function would return immediately if it's live. That was inefficient. llvm-svn: 239458
* COFF: Print out log messages to stdout.Rui Ueyama2015-06-081-1/+1
| | | | llvm-svn: 239288
* COFF: Set non-1 alignment to common chunks.Rui Ueyama2015-06-081-0/+7
| | | | | | | | | | | | | I don't know what the right thing to do here, but at least 1 does not seem like a correct value. If we do not align common chunks at all, a small program which calls puts() from global dtors crashes mysteriously in a kernel32's function. I believe the crash was caused by symbols overlapping each other, and my guess is that alignment has something to do with that, but I am not 100% sure. Needs investigating. llvm-svn: 239280
* COFF: Fix typo.Rui Ueyama2015-06-071-1/+1
| | | | | | | This change doesn't change its functionality since the value passed here is converted to uint16_t immediately. llvm-svn: 239271
* COFF: Move Windows-specific code from Chunk.{cpp,h} to DLL.{cpp,h}.Rui Ueyama2015-06-071-107/+0
| | | | llvm-svn: 239239
* Remove redundant `using namespace`.Rui Ueyama2015-06-061-2/+0
| | | | llvm-svn: 239234
* COFF: Move .idata constructor from Writer to Chunk.Rui Ueyama2015-06-061-23/+76
| | | | | | | | Previously, half of the constructor for .idata contents was in Chunks.cpp and the rest was in Writer.cpp. This patch moves the latter to Chunks.cpp. Now IdataContents class manages everything for .idata section. llvm-svn: 239230
* COFF: Merge Chunk::applyRelocations with Chunk::writeTo.Rui Ueyama2015-06-061-13/+10
| | | | | | | | In this design, Chunk is the only thing that knows how to write its contents to output file as well as how to apply relocations there. The writer shouldn't know about the details. llvm-svn: 239216
* COFF: Support import-by-ordinal DLL imports.Rui Ueyama2015-06-011-8/+21
| | | | | | | | | | | | | | | | | 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: Use Chunk instead of its derived classes.Rui Ueyama2015-06-011-1/+1
| | | | | | | | | I'm adding ordinal-only (nameless) imports to the import table. The chunk for that type is going to be different from LookupChunk. Without this change, we cannot add objects of the new type to the vectors. llvm-svn: 238779
* COFF: Fix the import table Hint/Name field.Rui Ueyama2015-06-011-2/+5
| | | | llvm-svn: 238719
* COFF: Define an error category for the linker.Rui Ueyama2015-06-011-1/+0
| | | | | | | | | | | | | 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: Fill imort table HintName field.Rui Ueyama2015-05-291-4/+5
| | | | | | | | | 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
* Fix non-debug build.Rui Ueyama2015-05-281-1/+2
| | | | llvm-svn: 238474
* COFF: Teach Chunk to write to a mmap'ed output file.Rui Ueyama2015-05-281-8/+14
| | | | | | | | | | | | | | Previously Writer directly handles writes to a file. Chunks needed to give Writer a continuous chunk of memory. That was inefficent if you construct data in chunks because it would require two memory copies (one to construct a chunk and the other is to write that to a file). This patch teaches chunk to write directly to a file. From readability point of view, this is also good because you no longer have to call hasData() before calling getData(). llvm-svn: 238464
* COFF: Add a new PE/COFF port.Rui Ueyama2015-05-281-0/+207
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