summaryrefslogtreecommitdiffstats
path: root/lld/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* [PECOFF] Writer: Refactor the chunk class hierarchy.Rui Ueyama2013-12-111-99/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch, we had the following class hierarchy. Chunk -> AtomChunk -> SectionChunk -> GenericSectionChunk -> BaseRelocChunk -> HeaderChunk Chunk represented the generic concept of contiguous range in an output file. AtomChunk represented a chunk consists of atoms. That class hierarchy had many issues: 1) BaseRelocChunk does not really consist of atoms, so inheriting from AtomChunk was plainly wrong, and 2) the hierarchy is unecessarily too deep. This patch correct them. The new hierachy is shown below. Chunk -> SectionChunk -> AtomChunk -> BaseRelocChunk -> HeaderChunk In the new hierarchy, AtomChunk represents a chunk consists of atoms. Other types of sections (currently only BaseRelocChunk) should inherit directly from SectionChunk. llvm-svn: 197038
* [PECOFF] Add "const" qualifiers to BaseRelocChunk methods.Rui Ueyama2013-12-111-7/+7
| | | | | | Also removed unused field. llvm-svn: 197027
* [PECOFF] Writer: Remove BaseRelocAtom.Rui Ueyama2013-12-111-32/+27
| | | | | | No functionality change. llvm-svn: 197025
* [PECOFF] Writer: Remove rawSize().Rui Ueyama2013-12-111-6/+4
| | | | | | | Because sections no longer have trailing NULL bytes, size() and rawSize() now return the same value. llvm-svn: 197020
* [PECOFF] Remove enum for Data Directory atom which no longer exist.Rui Ueyama2013-12-111-4/+2
| | | | llvm-svn: 197019
* [PECOFF] Remove code which is no longer needed because of r197016.Rui Ueyama2013-12-112-60/+6
| | | | llvm-svn: 197018
* [PECOFF] Refactor IdataPass.Rui Ueyama2013-12-116-114/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is to basically move the functionality to construct Data Directory from IdataPass to WriterPECOFF. Data Directory is a part of the PE/COFF header and contains the addresses of the import tables. We used to represent the link from Data Directory to the import tables as relocation references. The idea behind it is that, because relocation references are processed by the Writer, we wouldn't have to do anything special to fill the addresses of the import tables. I thought that the addresses would be set "automatically". But it turned out that that design made the pass and the writer rather complicated. In order to make relocation references between Data Directory to the import tables, these data structures needed to be represented as Atom. However, because Data Directory is not a section content but a part of the PE/COFF header, it did not fit well as an Atom. So we ended up having complicated code both in IdataPass and the writer. This patch simplifies it. One side effect of this patch is that we now have ".idata.a", ".idata.d" and "idata.t" sections for the import address table, the import directory table, and the import lookup table. The writer looks for the sections by name to find the start addresses of the sections. We probably should have a better way to find a specific atom from the core linking result, but currently using the section name seems to be the easiest way to do that. The Windows loader do not care about the import table's section layout. llvm-svn: 197016
* Simplify code a bit. No functionality change.Rui Ueyama2013-12-111-5/+2
| | | | llvm-svn: 197009
* [PECOFF] Writer: Move SectionChunk's ctor inline.Rui Ueyama2013-12-111-5/+3
| | | | llvm-svn: 197008
* Use "static" instead of anonymous namespace.Rui Ueyama2013-12-111-5/+5
| | | | llvm-svn: 197007
* [PECOFF] Make a member functions non-virtual.Rui Ueyama2013-12-111-1/+1
| | | | llvm-svn: 197006
* [PECOFF] Writer: Remove NULL padding at the end of each section.Rui Ueyama2013-12-111-13/+4
| | | | | | | | If section size is not multiple of 512, the writer added NULL bytes at the end of it to make it so. That is not required by the PE/COFF spec, and the MSVC's linker does not do that too. So we don't need to do that, too. llvm-svn: 197002
* s/NULL/nullptr/Rui Ueyama2013-12-111-1/+1
| | | | llvm-svn: 196994
* [PECOFF] WriterPECOFF: Rename getCharacteristics -> computeCharacteristics.Rui Ueyama2013-12-111-7/+6
| | | | | | | The base class has a member function with the same name. We should avoid it being shadowed. llvm-svn: 196992
* [PECOFF] WriterPECOFF::ExecutableWriter: Small cleanup.Rui Ueyama2013-12-111-3/+4
| | | | llvm-svn: 196991
* Add explicit keyword.Rui Ueyama2013-12-101-4/+5
| | | | llvm-svn: 196898
* [PECOFF] Make more member functions non-virtual.Rui Ueyama2013-12-101-4/+4
| | | | llvm-svn: 196897
* [PECOFF] Optimize the writer a bit by removing a loop.Rui Ueyama2013-12-101-45/+33
| | | | llvm-svn: 196896
* [PECOFF] Refactor COFF section header creation.Rui Ueyama2013-12-101-75/+46
| | | | | | | Code to create COFF section header was scattered across many member functions of SectionChunk. Consolidate it to a member function of SectionHeaderTableChunk. llvm-svn: 196895
* Add more const qualifiers.Rui Ueyama2013-12-101-4/+5
| | | | llvm-svn: 196891
* Remove data members used for relocationsRui Ueyama2013-12-101-11/+17
| | | | | | ... because they are used only in the function for relocations. llvm-svn: 196890
* Skip the body of a loop as early as possible.Rui Ueyama2013-12-101-4/+4
| | | | llvm-svn: 196884
* Style fixes. No functionality change.Rui Ueyama2013-12-103-24/+16
| | | | llvm-svn: 196883
* Make anonymous namespace as small as possible.Rui Ueyama2013-12-107-56/+46
| | | | | | Use of static is recommended by the style guide. llvm-svn: 196877
* Add const qualifiers.Rui Ueyama2013-12-101-29/+31
| | | | llvm-svn: 196867
* [PECOFF] Make some member functions non-virtual.Rui Ueyama2013-12-101-18/+13
| | | | | | | These member functions are not overriden and not intended to be, so adding virtual does not make sense. llvm-svn: 196866
* Revert "Remove makeArrayRef() calls."Rui Ueyama2013-12-104-22/+32
| | | | | | | This reverts commit r196475 because it made the build to fail with GCC 4.7/4.8/4.9. Reported by Mikael Lyngvig. llvm-svn: 196853
* [PECOFF] Simplify PE/COFF header writer.Rui Ueyama2013-12-091-18/+12
| | | | llvm-svn: 196767
* [PECOFF] Simplify WriterPECOFF.Rui Ueyama2013-12-091-5/+1
| | | | llvm-svn: 196762
* [PECOFF] Implement /alternatename weak symbols.Rui Ueyama2013-12-091-4/+16
| | | | llvm-svn: 196754
* [PECOFF] Add /alternatename option parser.Rui Ueyama2013-12-093-0/+32
| | | | | | | | | | | | | | /ALTERNATENAME is a rarely-used, undocumented command line option that is needed to link LLD for release build. It seems that the option is for defining an weak alias; /alternatename:foo=bar defines weak symbol "foo" for "bar". If "foo" is defined in an input file, it'll be linked normally and the command line option will have no effect. If it's not defined, "foo" will be handled as an alias for "bar". This patch implements the parser for the option. The actual weak alias handling will be implemented in a separate patch. llvm-svn: 196743
* Move scattered debug functions into one #ifndef-guarded place.Rui Ueyama2013-12-091-110/+106
| | | | llvm-svn: 196741
* Fix -Wunused-function to unbreak buildbot.Rui Ueyama2013-12-081-0/+2
| | | | llvm-svn: 196716
* Move static member functions out of a class.Rui Ueyama2013-12-081-10/+10
| | | | | | | Because compare() and its heper functions no longer have to be members of LayoutPass class, we can remove it from the class. No functionality change. llvm-svn: 196715
* Optimize the layout pass.Rui Ueyama2013-12-081-30/+45
| | | | | | | | | | | | | | | | The comparator used in the layout pass has many calls of map::find(). Because std::sort runs the comparator N*log2(N) times, the maps are looked up with the same key again and again. The map lookup is not a very fast operation. It made the pass slow. This patch eliminates the duplicate map lookups using decorate-sort-undecorate idiom. The pass used to take 1.1 seconds when linking LLD with LLD on Windows, but it now takes only 0.3 seconds. Overall performance gain in that case is from 6.1 seconds to 5.2 seconds. Differential Revision: http://llvm-reviews.chandlerc.com/D2358 llvm-svn: 196714
* Re-submit r195852 with GroupedSectionsPass change.Rui Ueyama2013-12-073-107/+23
| | | | | | | | | | | | | | | | GroupedSectionsPass was a complicated pass. That pass's job was to reorder atoms by section name, so that the atoms with the same section prefix will be emitted consecutively to the executable. The pass added layout edges to atoms, and let the layout pass to actually reorder them. This patch simplifies the design by making GroupedSectionPass to directly reorder atoms, rather than adding layout edges. This resembles ELF's ArrayOrderPass. This patch improves the performance of LLD; it used to take 7.1 seconds to link LLD with LLD on my Macbook Pro, but it now takes 6.1 seconds. llvm-svn: 196628
* Make error code variables to have narrower scope.Rui Ueyama2013-12-061-6/+5
| | | | llvm-svn: 196564
* Move definitions to cpp file. No functionality change.Rui Ueyama2013-12-062-0/+157
| | | | llvm-svn: 196563
* [PECOFF] Handle .lib files as if they are grouped by --{start,end}-group.Rui Ueyama2013-12-051-19/+45
| | | | | | | | | | | | | | Currently we do not de-duplicate library files specified by /defaultlib option. As a result, the same files are added multiple times to the input graph. In particular, some popular files, such as kernel32.lib or oldnames.lib, are added more than 10 times during linking of LLD. That makes the linker slower, as it needs to parse the same file again and again. This patch solves the issue by de-duplicating. The same file will be added only once to the input graph. This patch improved the LLD linking time from 10.5 seconds to 7.7 seconds on my 4-core Core i7 Macbook Pro. llvm-svn: 196504
* Remove makeArrayRef() calls.Rui Ueyama2013-12-054-32/+22
| | | | | | | Because ArrayRef has implicit conversion from C arrays, we don't need makeArrayRef. llvm-svn: 196475
* Use makeArrayRef to construct ArrayRefs from C arrays.Rui Ueyama2013-12-052-8/+11
| | | | llvm-svn: 196465
* [PECOFF] Emit the import table to .idata section.Rui Ueyama2013-12-051-0/+2
| | | | | | | | Emitting idata atoms to their own section would make debugging easier. The Windows loader do not really care about whether the DLL import table is in .rdata or its own .idata section, so there is no change in functionality. llvm-svn: 196458
* Delete dead code.Rui Ueyama2013-12-041-19/+0
| | | | llvm-svn: 196366
* [PECOFF] Ignore /functionpadmin option.Rui Ueyama2013-12-041-0/+1
| | | | | | | | | If /functionpadmin is specified, the linker is supposed to make room at the beginning of each function, so that self-modifying program would easily hotpatch existing functions. Since I'm not sure if this feature is really used, I'll make LLD to ignore the option for now. llvm-svn: 196363
* [PECOFF] Do not strip .debug section.Rui Ueyama2013-12-031-7/+0
| | | | llvm-svn: 196332
* [PECOFF] Implement IMAGE_REL_I386_{SECTION,SECREL} relocations.Rui Ueyama2013-12-032-6/+44
| | | | | | These relocations are used in .debug section. llvm-svn: 196262
* Simplify a switch statement.Rui Ueyama2013-12-031-13/+7
| | | | llvm-svn: 196200
* [PECOFF] Print input file names if /verbose is specified.Rui Ueyama2013-12-032-2/+5
| | | | llvm-svn: 196196
* [PECOFF] Print reason if file parsing failed.Rui Ueyama2013-12-032-3/+8
| | | | llvm-svn: 196185
* [PECOFF] Make /subsystem option parser a separate function.Rui Ueyama2013-12-021-18/+29
| | | | llvm-svn: 196092
OpenPOWER on IntegriCloud