summaryrefslogtreecommitdiffstats
path: root/lld/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* [Mips] Factor out the code that extracts a relocation 'tag' intoSimon Atanasyan2015-03-251-2/+6
| | | | | | | | | the separate function That keeps "extracting" logic into the single place and removes a VC++ compilation warning. llvm-svn: 233186
* PECOFF: Reduce import table size.Rui Ueyama2015-03-241-6/+19
| | | | | | | | | | | | | Import Lookup Table in Import Directory Table has the same contents as Hint/Name Table. Symbol names imported from DLLs are pointed by both Import Directory Table and Hint/Name Table. We had duplicate strings there. This patch eliminates that duplication to make the table smaller. This should reduce binary size by the sum of lengths of imported symbols. llvm-svn: 233128
* [Mips] Suppress "right shift by too large amount" warningSimon Atanasyan2015-03-241-2/+2
| | | | | | | | | | | | | Visual C++ shows the "right shift by too large amount" warning if `MipsELFReference` is instantiated for 32-bit target and `Elf_Rel_Impl::getType` method has `unsigned char` return type. We can freely suppress the warning in that case because MIPS 32-bit ABI does not pack multiple relocation types into the single field `r_type` and the `MipsELFReference::_tag` should be always zero in that case. No functional changes. llvm-svn: 233088
* [Mips] Do not use inheriting constructor due build problem on WindowsSimon Atanasyan2015-03-241-1/+3
| | | | | | No functional changes. llvm-svn: 233058
* [Mips] Support MIPS N64 relocation record formatSimon Atanasyan2015-03-2411-62/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | N64 ABI relocation record r_info field in fact consists of five subfields: * r_sym - symbol index * r_ssym - special symbol * r_type3 - third relocation type * r_type2 - second relocation type * r_type - first relocation type Up to three these relocations applied one by one. The first relocation uses an addendum from the relocation record. Each subsequent relocation takes as its addend the result of the previous operation. Only the final operation actually modifies the location relocated. The first relocation uses as a reference symbol specified by the `r_sym` field. The third relocation assumes NULL symbol. The patch represents these data using LLD model and takes in account additional relocation types during a relocation calculation. Additional relocations do not introduce any new relations between two atoms and just specify operations need to be done during a relocation calculation. The first relocation type (`r_type`) stored in the `Reference::_kindValue`. The rest of relocations and `r_ssym` value are stored in the new `Reference::_tag` field "as-is". I decided to do not "decode" these data on the core LLD level to prevent pollution of the core LLD model by very target specific data. Also I have to override writing of relocation records in the `RelocationTable` class to convert MIPS N64 ABI relocation information from the `Reference` class back to the ELF relocation record. http://reviews.llvm.org/D8533 llvm-svn: 233057
* [Mips] Fix typo in the error messageSimon Atanasyan2015-03-241-1/+1
| | | | llvm-svn: 233054
* [ELF/X86_64] Fix handling of R_X86_64_GOTTPOFF relocation.Davide Italiano2015-03-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | The aforementioned relocation generate a GOT entry with a R_X86_64_TPOFF64. The new relocation is processed at startup time by the loader. lld didn't generate the outstanding relocation, now it does. This bug was found while trying to link ls(1) on FreeBSD. Simplified repro: #include <stdio.h> #include <wchar.h> #include <wctype.h> int main(void) { wchar_t wc = 98; if (!iswprint(wc)) printf("blah\n"); else printf("foo\n"); return (0); } which incorrectly outputs "blah" when linked with lld before this patch. llvm-svn: 233051
* [ELF] Remove extraneous semicolon in DefaultLayoutRafael Auler2015-03-231-1/+1
| | | | llvm-svn: 232985
* Fix the CMake shared build.Benjamin Kramer2015-03-238-6/+18
| | | | | | | The ELF backends now depend on lld::script::Sema, which is in libReaderWriter. Link it explicitly. llvm-svn: 232953
* [ARM] Fix entry point for Thumb codeDenis Protivensky2015-03-231-0/+20
| | | | | | | Test cases for both entry functions in ARM and Thumb code are added. llvm-svn: 232942
* [ELF] Add missing override keywordSimon Atanasyan2015-03-231-16/+16
| | | | | | No functional changes. llvm-svn: 232938
* [Mips] Pass type of relocation and addendum to the `calculateRelocation`Simon Atanasyan2015-03-221-34/+40
| | | | | | | | | | | separately This change reduce difference between the trunk and upcoming patch and simplify the future code review. No functional changes. llvm-svn: 232919
* [Mips] Rename template argument ELFType => ELFTSimon Atanasyan2015-03-221-21/+17
| | | | | | No functional changes. llvm-svn: 232915
* [Mips] Use allocator from the base classSimon Atanasyan2015-03-221-3/+2
| | | | | | No functional changes. llvm-svn: 232914
* [ELF] GLOBAL_OFFSET_TABLE is a hidden symbolShankar Easwaran2015-03-202-2/+2
| | | | llvm-svn: 232868
* [ELF] Dont add local symbols for dynamic lookup.Shankar Easwaran2015-03-201-0/+5
| | | | | | | Unable to add a unit test for this, as there is only one local undefined symbol in regular shared libraries without a name. llvm-svn: 232867
* [ELF] OrderPass : Order atoms only by ordinals.Shankar Easwaran2015-03-203-38/+62
| | | | | | | | | | | | | | | | | | | | | | Move the init array/fini array sorting to the Output ELF writer. AFAIK, this is only needed by the X86_64/ARM ABI. This shaves time taken to self host lld by 0.2 seconds. Before patch ---------------- 4791.062059 task-clock # 1.634 CPUs utilized ( +- 0.28% ) 61,107 context-switches # 0.013 M/sec ( +- 0.56% ) 2.932902671 seconds time elapsed ( +- 0.84% ) After patch ------------- 4608.417248 task-clock # 1.669 CPUs utilized ( +- 0.30% ) 61,616 context-switches # 0.013 M/sec ( +- 0.63% ) 2.761012703 seconds time elapsed ( +- 0.63% ) llvm-svn: 232866
* [ELF][X86_64] Use anonymous namespace only for class declarationsShankar Easwaran2015-03-201-10/+10
| | | | llvm-svn: 232865
* [ELF] Use unordered_map for AdditionalSegmentsShankar Easwaran2015-03-201-3/+4
| | | | | | Fix a leftover class during implementation. llvm-svn: 232864
* [ELF] Use MapVector.Shankar Easwaran2015-03-201-1/+2
| | | | | | Order is still deterministic and we dont need a sorted order. llvm-svn: 232863
* [ELF][X86_64] Remove relative references to include filesShankar Easwaran2015-03-205-4/+8
| | | | llvm-svn: 232862
* [ELF][X86_64] Sort includesShankar Easwaran2015-03-204-5/+3
| | | | llvm-svn: 232861
* [Mips] Create special PLT entry in case of MIPS R6 ABISimon Atanasyan2015-03-201-1/+32
| | | | llvm-svn: 232806
* [Mips] Add comments to the relocation calculation functionsSimon Atanasyan2015-03-191-1/+6
| | | | | | No functional changes. llvm-svn: 232761
* [Mips] Implement R_MIPS_PCHI16 / R_MIPS_PCLO16 relocations handlingSimon Atanasyan2015-03-193-0/+24
| | | | llvm-svn: 232757
* [Mips] Implement R_MIPS_PC18_S3 relocation handlingSimon Atanasyan2015-03-191-0/+12
| | | | llvm-svn: 232756
* [Mips] Implement R_MIPS_PC19_S2 / R_MIPS_PC26_S2 relocations handlingSimon Atanasyan2015-03-191-0/+24
| | | | llvm-svn: 232755
* [ARM] Implement static (initial exec) TLS modelDenis Protivensky2015-03-195-5/+128
| | | | | | | | This includes handling of R_ARM_TLS_IE32 and R_ARM_TLS_LE32 relocs. Differential Revision: http://reviews.llvm.org/D8353 llvm-svn: 232708
* [Mips] Implement R_MIPS_PC21_S2 relocation handlingSimon Atanasyan2015-03-191-0/+12
| | | | llvm-svn: 232707
* [Mips] Recognize and check compatibility MIPS32R6 / MIPS64R6 ISA'sSimon Atanasyan2015-03-191-0/+4
| | | | llvm-svn: 232706
* [Mips] Replace "hand-made" function by the `llvm::SignExtend32()` routineSimon Atanasyan2015-03-191-12/+7
| | | | | | No functional changes. llvm-svn: 232705
* PECOFF: Do not copy all undefined symbols to a set. NFC.Rui Ueyama2015-03-181-12/+8
| | | | llvm-svn: 232646
* Remove unused parameter.Rui Ueyama2015-03-181-7/+3
| | | | llvm-svn: 232639
* [ELF][ARM] Place gotSymbol in an anonymous namespaceShankar Easwaran2015-03-171-5/+8
| | | | | | Address comments from Espindola. llvm-svn: 232497
* [ARM] Read initial addend for REL32 and PREL31 relocsDenis Protivensky2015-03-171-0/+3
| | | | llvm-svn: 232474
* [ARM] Implement relocations: R_ARM_REL32, R_ARM_THM_JUMP11, R_ARM_PREL31Denis Protivensky2015-03-171-1/+81
| | | | | | | | Test case for every relocation is added. Differential Revision: http://reviews.llvm.org/D7565 llvm-svn: 232464
* [ELF] Use parallel_for_each for writing.Shankar Easwaran2015-03-172-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This changes improves performance of lld, when self-hosting lld, when compared with the bfd linker. BFD linker on average takes 8 seconds in elapsed time. lld takes 3 seconds elapased time average. Without this change, lld takes ~5 seconds average. The runtime comparisons were done on a release build and measured by running linking thrice. lld self-host without the change ---------------------------------- real 0m3.196s user 0m4.580s sys 0m0.832s lld self-host with lld ----------------------- user 0m3.024s user 0m3.252s sys 0m0.796s time taken to build lld with bfd -------------------------------- real 0m8.419s user 0m7.748s sys 0m0.632s llvm-svn: 232460
* Make it compile with MSVC 2013.Rui Ueyama2015-03-171-5/+6
| | | | | | | MSVC 2013 cannot compile this code because of C1001 "internal error". Stop using initializer list without type name. llvm-svn: 232448
* PECOFF: Make FileCOFF:findAtomAt from O(n) to O(1).Rui Ueyama2015-03-161-19/+18
| | | | | | | | I knew I cut corners when I wrote this. Turned out that it is actually slow when a file being read has many symbols. This patch is to stop doing linear search and instead do map lookup. llvm-svn: 232436
* [ELF] Use pcrel format for eh_frame_ptr field encodingSimon Atanasyan2015-03-161-8/+12
| | | | | | | | | | | | | The `eh_frame_ptr` field in the `.eh_frame_hdr` section contains an address of the `.eh_frame` section. Using an absolute 32-bit format for encoding of this field does not work for 64-bit targets. It is better to use a relative format because it covers both 32-bit and 64-bit cases. Sure this work if a distance between `.eh_frame_hdr` and `.eh_frame` sections is less than 4 Gb but it is a rather correct assumption. http://reviews.llvm.org/D8352 llvm-svn: 232414
* [LinkerScript] Handle symbols defined in linker scriptsRafael Auler2015-03-168-27/+74
| | | | | | | | | | Puts symbols defined in linker script expressions in a runtime file that is added as input to the resolver, making the input object files see symbols defined in linker scripts. http://reviews.llvm.org/D8263 llvm-svn: 232409
* [LinkerScript] Implement semantics for simple sections mappingsRafael Auler2015-03-1610-36/+610
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit implements the behaviour of the SECTIONS linker script directive, used to not only define a custom mapping between input and output sections, but also order input sections in the output file. To do this, we modify DefaultLayout with hooks at important places that allow us to re-order input sections according to a custom order. We also add a hook in SegmentChunk to allow us to calculate linker script expressions while assigning virtual addresses to the input sections that live in a segment. Not all SECTIONS constructs are currently supported, but only the ones that do not use special sort orders. It adds two LIT test as practical examples of which sections directives are currently supported. In terms of high-level changes, it creates a new class "script::Sema" that owns all linker script ASTs and the logic for linker script semantics as well. ELFLinkingContext owns a single copy of Sema, which will be used throughout the object file writing process (to layout sections as proposed by the linker script). Other high-level change is that the writer no longer uses a "const" copy of the linking context. This happens because linker script expressions must be calculated *while* calculating final virtual addresses, which is a very late step in object file writing. While calculating these expressions, we need to update the linker script symbol table (inside the semantics object), and, thus, we are "modifying our context" as we prepare to write the file. http://reviews.llvm.org/D8157 llvm-svn: 232402
* [Mips] clang-format the codeSimon Atanasyan2015-03-161-3/+2
| | | | | | No functional changes. llvm-svn: 232364
* [Mips] Do not check the relocation type twiceSimon Atanasyan2015-03-161-10/+6
| | | | | | No functional changes. llvm-svn: 232363
* [Mips] Add `const` qualifier to some member functionsSimon Atanasyan2015-03-161-23/+23
| | | | | | No functional changes. llvm-svn: 232362
* [Mips] Implement R_MIPS_TLS_xxx relocation handling in case of N64 ABISimon Atanasyan2015-03-165-13/+48
| | | | llvm-svn: 232361
* [Mips] Implement R_MIPS_GOT_DISP/PAGE/OFST relocations handlingSimon Atanasyan2015-03-164-27/+99
| | | | llvm-svn: 232360
* [Mips] Group some cases in the switch statementSimon Atanasyan2015-03-161-9/+6
| | | | | | No functional changes. llvm-svn: 232359
* [ELF][ARM] Make gotSymbol a member.Shankar Easwaran2015-03-161-9/+5
| | | | | | | | | | | The gotSymbol need not be a global static variable. Apart from this reason, This variable was creating an issue with self hosting lld, as there seems to be an issue running global initializers, when initializing the guard for this static variable. Program received signal SIGTRAP, Trace/breakpoint trap. llvm-svn: 232341
* Use setVisibility() rather than assigning the value directly.Davide Italiano2015-03-142-4/+5
| | | | | | | We don't want to risk to override wrong st_other bits, and when we need to zero, we can do that explictly. llvm-svn: 232282
OpenPOWER on IntegriCloud