summaryrefslogtreecommitdiffstats
path: root/lld/ELF
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] - Print LMA in a -Map file.George Rimar2018-04-051-11/+18
| | | | | | | | | | Currently, LLD prints VA, but not LMA in a map file. It seems can be useful to print both to reveal layout details and patch implements it. Differential revision: https://reviews.llvm.org/D44899 llvm-svn: 329271
* Initialize OffsetMap earlier.Rafael Espindola2018-04-052-16/+12
| | | | | | | Now that getSectionPiece uses OffsetMap, it is advantageous to initialize it earlier. llvm-svn: 329242
* Do not show alignment 0 because that is equivalent to 1.Rui Ueyama2018-04-041-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D44991 llvm-svn: 329233
* Don't ignore addend in getOffset.Rafael Espindola2018-04-041-3/+0
| | | | | | | | We were ignoring the addend if the piece was dead. I don't expect this to make a difference in any real world situations, but it is simpler anyway. llvm-svn: 329219
* [ELF] - X86_64: Use white list for relocations checked by isPicRel.George Rimar2018-04-041-3/+2
| | | | | | | | | | isPicRel is used to check if we want to create the dynamic relocations. Not all of the dynamic relocations we create are passing through this check, but those that are, probably better be whitelisted. Differential revision: https://reviews.llvm.org/D45252 llvm-svn: 329203
* [ELF] - Use early return. NFC.George Rimar2018-04-041-14/+16
| | | | llvm-svn: 329180
* [ELF] - Cleanup. NFCI.George Rimar2018-04-043-7/+11
| | | | | | | | | Rename field, added comments. This is splitted from the D44894. Requested to be committed as independent cleanup. llvm-svn: 329162
* [ELF] - Rename checkSectionOverlap() to checkSections(). NFC.George Rimar2018-04-041-3/+3
| | | | | | Renaming was requested in post commit review for D43820. llvm-svn: 329159
* [ELF] - Revert r329060 "Simplify createFiles. NFCI."George Rimar2018-04-041-7/+14
| | | | | | Was requested during post commit review. llvm-svn: 329155
* Return early. NFC.Rui Ueyama2018-04-031-15/+20
| | | | llvm-svn: 329126
* Merge two `if`s and add a few blank lines. NFC.Rui Ueyama2018-04-031-4/+6
| | | | llvm-svn: 329125
* Inline initOffsetMap.Rafael Espindola2018-04-033-21/+18
| | | | | | | | | | | | | | | In the lld perf builder r328686 had a negative impact in stalled-cycles-frontend. Somehow that stat is not showing on my machine, but the attached patch shows an improvement on cache-misses, which is probably a reasonable proxy. My working theory is that given a large input the pieces vector is out of cache by the time initOffsetMap runs. Both finalizeContents implementation have a convenient location for initializing the OffsetMap, so this seems the best solution. llvm-svn: 329117
* Instead of using std::copy, clear the vector first and add new elements. NFC.Rui Ueyama2018-04-031-10/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D45227 llvm-svn: 329107
* ELF: Use a vector of pairs to sort sections ordered using ↵Peter Collingbourne2018-04-031-10/+14
| | | | | | | | | | --symbol-ordering-file. This improved performance by 0.5-1% linking Chromium for Android. Differential Revision: https://reviews.llvm.org/D45222 llvm-svn: 329106
* Fix buildbots.Rui Ueyama2018-04-031-0/+5
| | | | | | r329092 broke buildbots. llvm-svn: 329103
* Make fetchIfLazy only fetch an object file. NFC.Rui Ueyama2018-04-033-18/+29
| | | | | | | Previously, fetchIfLazy did more than the name says. Now, setting to UsedInRegularObj is moved to another function. llvm-svn: 329092
* [lld] fix data race in ELF/ICF.cppBob Haarman2018-04-031-12/+18
| | | | | | | | | | | | | | | | Summary: r328610 fixed a data race in the COFF linker. This change makes a similar fix to the ELF linker. Reviewers: ruiu, pcc, rnk Reviewed By: ruiu Subscribers: emaste, llvm-commits, arichardson Differential Revision: https://reviews.llvm.org/D45192 llvm-svn: 329088
* [ELF] - Eliminate Lazy class.George Rimar2018-04-036-49/+31
| | | | | | | | | Patch removes Lazy class which is just an excessive layer. Differential revision: https://reviews.llvm.org/D45083 llvm-svn: 329086
* [ELF] - Check that output sections fit in address space.George Rimar2018-04-031-6/+14
| | | | | | | | | | Added checks to test that we do not produce output where VA of sections overruns the address space available. Differential revision: https://reviews.llvm.org/D43820 llvm-svn: 329063
* [ELF] - Fix the comment. NFC.George Rimar2018-04-031-3/+2
| | | | llvm-svn: 329062
* [ELF] - Relax checks for R_386_8/R_386_16 relocations.George Rimar2018-04-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes PR36927. The issue is next. Imagine we have -Ttext 0x7c and code below. .code16 .global _start _start: movb $_start+0x83,%ah So we have R_386_8 relocation and _start at 0x7C. Addend is 0x83 == 131. We will sign extend it to 0xffffffffffffff83. Now, 0xffffffffffffff83 + 0x7c gives us 0xFFFFFFFFFFFFFFFF. Techically 0x83 + 0x7c == 0xFF, we do not exceed 1 byte value, but currently LLD errors out, because we use checkUInt<8>. Let's try to use checkInt<8> now and the following code to see if it can help (no): main.s: .byte foo input.s: .globl foo .hidden foo foo = 0xff Here, foo is 0xFF. And addend is 0x0. Final value is 0x00000000000000FF. Again, it fits one byte well, but with checkInt<8>, we would error out it, so we can't use it. What we want to do is to check that the result fits 1 byte well. Patch changes the check to checkIntUInt to fix the issue. Differential revision: https://reviews.llvm.org/D45051 llvm-svn: 329061
* [ELF] - Simplify createFiles. NFCI.George Rimar2018-04-031-14/+7
| | | | | | | | Groups paired options together. Differential revision: https://reviews.llvm.org/D45090 llvm-svn: 329060
* [ELF] - X86_64: don't allow 8/16 bit dynamic relocations.George Rimar2018-04-031-2/+3
| | | | | | | | | | | Having 8/16 bits dynamic relocations is incorrect. Both gold and bfd (built from latest sources) disallow that too. Differential revision: https://reviews.llvm.org/D45158 llvm-svn: 329059
* [ELF] - Remove dead declaration. NFC.George Rimar2018-04-031-2/+0
| | | | llvm-svn: 329058
* Use OffsetMap in getSectionPiece.Rafael Espindola2018-04-031-5/+17
| | | | | | | | | | OffsetMap maps to a SectionPiece index, but we were not taking advantage of that in getSectionPiece. With this patch both getOffset and getSectionPiece use OffsetMap and the binary search is moved to findSectionPiece. llvm-svn: 329044
* Merge LazyArchive::fetch() and ArchiveFile::getMember(). NFC.Rui Ueyama2018-04-034-36/+23
| | | | | | | | They are to pull out an object file for a symbol, but for a historical reason the code is written in two separate functions. This patch merges them. llvm-svn: 329039
* Inline two trivial functions that are called only once. NFC.Rui Ueyama2018-04-022-9/+4
| | | | llvm-svn: 329034
* Define TrapInst for ppc64.Rafael Espindola2018-04-021-0/+2
| | | | | | | This is nice for testing since it is the first TrapInst whose bytes are not all the same. llvm-svn: 329014
* [PPC64] Minor changes for Plt relocations.Sean Fertile2018-04-021-2/+8
| | | | | | | | | | The Plt relative relocations are R_PPC64_JMP_SLOT in the V2 abi, and we only reserve 2 double words instead of 3 at the start of the array of PLT entries for lazy linking. Differential Revision: https://reviews.llvm.org/D44951 llvm-svn: 329006
* [PPC64] Write plt stubs for ElfV2 abiSean Fertile2018-04-021-14/+31
| | | | | | | | Add the default version of a plt stub for the V2 Elf abi. Differential Revision: https://reviews.llvm.org/D44850 llvm-svn: 329004
* [ELF] Simplify read32. NFCFangrui Song2018-03-301-3/+2
| | | | llvm-svn: 328908
* ELF: Place ordered sections in the middle of the unordered section list on ↵Peter Collingbourne2018-03-301-1/+69
| | | | | | | | | | | | | | | | | | | | | targets with limited-range branches. It generally does not matter much where we place sections ordered by --symbol-ordering-file relative to other sections. But if the ordered sections are hot (which is the case already for some users of --symbol-ordering-file, and is increasingly more likely to be the case once profile-guided section layout lands) and the target has limited-range branches, it is beneficial to place the ordered sections in the middle of the output section in order to decrease the likelihood that a range extension thunk will be required to call a hot function from a cold function or vice versa. That is what this patch does. After D44966 it reduces the size of Chromium for Android's .text section by 60KB. Differential Revision: https://reviews.llvm.org/D44969 llvm-svn: 328905
* Initialize Elf Header to zero to ensure that bytes not assigned any value ↵Rumeet Dhindsa2018-03-301-0/+4
| | | | | | | | later on are initialized properly. Differential Revision: https://reviews.llvm.org/D44986 llvm-svn: 328902
* ELF: Try to create last thunk section at ThunkSectionSpacing bytes before ↵Peter Collingbourne2018-03-301-3/+18
| | | | | | | | | | | | | | | | | | | | | | the end. Now that we have the ability to create short thunks, it is beneficial for thunk sections to be surrounded by ThunkSectionSpacing bytes of code on both sides in order to increase the likelihood that the distance from the thunk to the target will be sufficiently small to allow for the creation of a short thunk. This is currently the case for most thunks that we create, except for the last one, which could, depending on the size of the output section, potentially appear near the end and therefore have a relatively small amount of code after it. This patch moves the last thunk section to ThunkSectionSpacing bytes before the end of the output section, as long as the section is larger than 2*ThunkSectionSpacing bytes. It reduces the size of Chromium for Android's .text section by 32KB. Differential Revision: https://reviews.llvm.org/D44966 llvm-svn: 328889
* Improve error message for an unknown --plugin-opt.Rui Ueyama2018-03-301-6/+16
| | | | | | | | | | | | | | | | Before: $ ld.lld --plugin-opt=-foo ld.lld: --Unknown command line argument '-abc' After: $ ld.lld --plugin-opt=-foo ld.lld: --plugin-opt: ld.lld --Unknown command line argument '-abc' Differential Revision: https://reviews.llvm.org/D45075 llvm-svn: 328880
* Re-implement --just-symbols as a regular object file.Rui Ueyama2018-03-303-51/+38
| | | | | | | | | | | | I tried a few different designs to find a way to implement it without too much hassle and settled down with this. Unlike before, object files given as arguments for --just-symbols are handled as object files, with an exception that their section tables are handled as if they were all null. Differential Revision: https://reviews.llvm.org/D42025 llvm-svn: 328852
* ELF: Add support for short thunks on ARM.Peter Collingbourne2018-03-291-44/+151
| | | | | | | | | | | A short thunk uses a direct branch (b or b.w) instruction, and is used when the target has the same thumbness as the thunk and is within direct branch range (32MB for ARM, 16MB for Thumb-2). Reduces the size of Chromium for Android's .text section by around 160KB. Differential Revision: https://reviews.llvm.org/D44963 llvm-svn: 328846
* Do not use template for check{Int,UInt,IntUInt,Alignment}.Rui Ueyama2018-03-298-78/+82
| | | | | | | | Template is just unnecessary. Differential Revision: https://reviews.llvm.org/D45063 llvm-svn: 328843
* ELF: Allow thunks to change size. NFCI.Peter Collingbourne2018-03-295-56/+84
| | | | | | Differential Revision: https://reviews.llvm.org/D44962 llvm-svn: 328841
* Simplify. NFC.Rui Ueyama2018-03-291-28/+11
| | | | llvm-svn: 328817
* Exit early from a loop. NFC.Rui Ueyama2018-03-291-1/+1
| | | | | | | | This patch fixes an issue introduced in r328810 which made the algorithm to always run the loop O(n^2) times, though we can break early. The output remains the same. llvm-svn: 328811
* Refactor Writer::checkNoOverlappingSections. NFC.Rui Ueyama2018-03-291-47/+48
| | | | | | | This patch rewrites the function to remove lambda callbacks and use of template. The algorithm is the same as before. llvm-svn: 328810
* [ELF] Fix X86 & X86_64 PLT retpoline paddingAndrew Ng2018-03-292-20/+32
| | | | | | | | | | | | | | The PLT retpoline support for X86 and X86_64 did not include the padding when writing the header and entries. This issue was revealed when linker scripts were used, as this disables the built-in behaviour of filling the last page of executable segments with trap instructions. This particular behaviour was hiding the missing padding. Added retpoline tests with linker scripts. Differential Revision: https://reviews.llvm.org/D44682 llvm-svn: 328777
* Rename NonLocal -> Global.Rui Ueyama2018-03-282-12/+12
| | | | | | | | NonLocal is technically more accurate, but we already use the term "Global" to specify the non-local part of the symbol table, and Local <-> Global is easier to digest. llvm-svn: 328740
* Move code so that the code matches with a comment. NFC.Rui Ueyama2018-03-281-5/+9
| | | | llvm-svn: 328739
* Strip @VER suffices from the LTO output.Rafael Espindola2018-03-283-1/+9
| | | | | | | | | | | | | | | This fixes pr36623. The problem is that we have to parse versions out of names before LTO so that LTO can use that information. When we get the LTO produced .o files, we replace the previous symbols with the LTO produced ones, but they still have @ in their names. We could just trim the name directly, but calling parseSymbolVersion to do it is simpler. llvm-svn: 328738
* Unloop a for-loop so that we can comment on each symbol. NFC.Rui Ueyama2018-03-281-4/+6
| | | | llvm-svn: 328736
* Merge nested "if"s. NFC.Rui Ueyama2018-03-281-6/+4
| | | | llvm-svn: 328733
* ELF: Make required Thunk methods pure virtual and remove an unused argument. ↵Peter Collingbourne2018-03-284-33/+33
| | | | | | | | | | | NFC. Also make certain Thunk methods non-const as this will be required for an upcoming change. Differential Revision: https://reviews.llvm.org/D44961 llvm-svn: 328732
* [ELF] - Linkerscript: support MIN and MAX.George Rimar2018-03-281-0/+10
| | | | | | | | | | | | | | Sample for the OVERLAY command from the spec (https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/sections.html) uses MAX command that we do not support currently: . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1)); This patch implements support for MIN and MAX. Differential revision: https://reviews.llvm.org/D44734 llvm-svn: 328696
OpenPOWER on IntegriCloud