summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* [LLD][ELF] - Add a test for "unbalanced --push-state/--pop-state" error.George Rimar2018-11-261-0/+3
| | | | | | We had no such test. llvm-svn: 347552
* [LLD][ELF] - Add a check for --split-stack-adjust-size error message. NFCI.George Rimar2018-11-261-0/+2
| | | | | | | "--split-stack-adjust-size: size must be >= 0" message was never tested. llvm-svn: 347550
* [LLD][ELF] - Do not crash when parsing the -defsym option from a error state.George Rimar2018-11-262-0/+8
| | | | | | | | | | | | | | When we are in a error state, script parser will not parse the -defsym expression and hence will not tokenize it. Then ScriptLexer::Pos will be 0 and LLD will assert and crash here: MemoryBufferRef ScriptLexer::getCurrentMB() { assert(!MBs.empty() && Pos > 0); // Bang ! Solution - stop parsing the defsym in a error state. That is consistent with the regular case (when we parse the linker script). llvm-svn: 347549
* [LLD][ELF] - Remove the excessive safety return. NFC.George Rimar2018-11-261-3/+0
| | | | | | | | | | | | We explicitly call finalizeContents() only once for DynamicSection. The code testing we do not do it twice is just excessive. It could be an assert, but we don't do that for other sections, so does not seem we should do it here too. llvm-svn: 347543
* [LLD][ELF] - Add llvm_unreachable. NFC.George Rimar2018-11-261-1/+3
| | | | | | We never should call writeTo() for BSS section. llvm-svn: 347540
* [ELF] - Added test case for invalid relocation target errors. NFCI.George Rimar2018-11-262-0/+50
| | | | | | We had a proper error reporting, but no test cases. llvm-svn: 347536
* [LLD][ELF] - Add a test for non-null terminated mergeable strings section. NFCI.George Rimar2018-11-261-0/+8
| | | | | | LLD reports an error in this case, but we had no test. llvm-svn: 347535
* [LLD][ELF] - Simplify. NFCI.George Rimar2018-11-232-7/+5
| | | | | | | This makes getRISCVPCRelHi20 to be static local helper, and rotates the 'if' condition. llvm-svn: 347497
* [LLD][ELF] - Fix mistype. NFC.George Rimar2018-11-231-1/+1
| | | | llvm-svn: 347485
* [ELF] - Make SymbolTable::addDefined return Defined.George Rimar2018-11-223-13/+12
| | | | | | | | | Now it returns Symbol. This should be NFC that avoids doing cast at the caller's sides. Differential revision: https://reviews.llvm.org/D54627 llvm-svn: 347455
* COFF: ICF: Include contents of referenced sections in initial partitioning ↵Peter Collingbourne2018-11-211-1/+11
| | | | | | | | | | | | | | | | | | | | | | hash. NFCI. Previously we were taking over 13 minutes to link Firefox's xul.dll on ARM64; this reduces link time to around 18s on my machine. The root cause of the problem was that all of the input .pdata sections had the same unrelocated section data and therefore the same hash, which made segregation quadratic in the number of .pdata sections. The reason why we weren't observing this on other architectures was that ARM has a different .pdata format. On non-ARM the format is (start address, end address, .xdata), which caused the size of the function to appear in the unrelocated section data where the end address field is. However, the ARM format omits the end address field. Fixes PR39667. Differential Revision: https://reviews.llvm.org/D54809 llvm-svn: 347429
* [ELF] Write IPLT header in -static -z retpolineplt modeFangrui Song2018-11-213-4/+34
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This fixes PR39711: -static -z retpolineplt does not produce retpoline PLT header. -z now is not relevant. Statically linked executable does not have PLT, but may have IPLT with no header. When -z retpolineplt is specified, however, the repoline PLT header should still be emitted. I've checked that this fixes the FreeBSD reproduce in PR39711 and a Linux program statically linked against glibc. The programm print "Hi" rather than SIGILL/SIGSEGV. getPltEntryOffset may look dirty after this patch, but it can be cleaned up later. Another possible improvement is that when there are non-preemptible IFUNC symbols (rare case, e.g. -Bsymbolic), both In.Plt and In.Iplt can be non-empty and we'll emit the retpoline PLT header twice. Reviewers: espindola, emaste, chandlerc, ruiu Reviewed By: emaste Subscribers: emaste, arichardson, krytarowski, llvm-commits Differential Revision: https://reviews.llvm.org/D54782 llvm-svn: 347404
* [ARM] Change REQUIRES: ARM to Requires: armPeter Smith2018-11-212-4/+3
| | | | | | | | | | When REQUIRES: ARM is used the test is skipped as ARM is not recognized. Change to REQUIRES: arm so that it is run. This required updating one of the tests due to changes in expected output. Differential Revision: https://reviews.llvm.org/D54786 llvm-svn: 347388
* [WebAssembly] Delete unused using statements (NFC)Heejin Ahn2018-11-216-11/+0
| | | | | | | | | | Reviewers: sbc100, dschuff Subscribers: mehdi_amini, jgravelle-google, sunfish, steven_wu, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D54683 llvm-svn: 347370
* [CodeView] RelocPtr points to little endian data.Zachary Turner2018-11-201-1/+1
| | | | | | | | | | Don't use a uint32_t*, use a ulittle32_t* to make this correct on big endian systems. Patch by James Clarke Differential Revision: https://reviews.llvm.org/D54421 llvm-svn: 347349
* [ELF] Allow --noinhibit-exec to produce corrupted executable with relocation ↵Fangrui Song2018-11-202-3/+5
| | | | | | | | | | | | | | | | | | | overflow Summary: When --noinhibit-exec is used, ld.bfd/gold emit errors but allow to produce corrupted executable, which is handy for debugging purpose. lld's --noinhibit-exec has a different meaning and changes some errors to warnings. This patch replaces "error" with "errorOrWarn" to exploit that property. We may revisit this: if we should keep them as errors (as ld.bfd/gold do) but allow to produce a (corrupted) executable. Reviewers: ruiu, grimar, espindola Reviewed By: grimar Subscribers: Timmmm, jhenderson, emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D54651 llvm-svn: 347327
* [WebAssembly] Fix inaccurate comments / assertion messagesHeejin Ahn2018-11-193-6/+4
| | | | | | | | | | Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54688 llvm-svn: 347273
* [WebAssembly] Make starting indices calcaulation simpler (NFC)Heejin Ahn2018-11-191-2/+4
| | | | | | | | | | | | | | | | | Summary: At the beginning of `assignIndexes() function, when `FunctionIndex` and `GlobalIndex` variables are created, `InputFunctions` and `InputGlobals` vectors are guaranteed to be empty, because those vectors are only populated in `assignIndexes()` function. Current code looks like they are nonempty, so this patch deletes them for better readability. Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54687 llvm-svn: 347272
* Support ARM_V4BX relocationFangrui Song2018-11-162-0/+44
| | | | | | | | | | | | | | | | Summary: This patch implementation the handler for ARM_V4BX. This relocation is used by GNU runtime files and other armv4 applications. Patch by Yin Ma Reviewers: espindola, MaskRay, ruiu, peter.smith, pcc Reviewed By: ruiu Subscribers: yinma, pcc, peter.smith, MaskRay, rovka, efriedma, emaste, javed.absar, arichardson, kristof.beyls, chrib, llvm-commits Differential Revision: https://reviews.llvm.org/D53444 llvm-svn: 347077
* [ELF][MIPS] Use MIPS R6 `sigrie` as a trap instructionSimon Atanasyan2018-11-166-125/+83
| | | | | | | | | | | | | | | Current value using as a trap instruction (0xefefefef) is not a good choice for MIPS because it's a valid MIPS instruction `swc3 $15,-4113(ra)`. This patch replaces 0xefefefef by 0x04170001. For all MIPS ISA revisions before R6, this value is just invalid instruction. Starting from MIPS R6 it's a valid instruction `sigrie 1` which signals a Reserved Instruction exception. mips-traps.s test case is added to test trap encoding. Other test cases are modified to remove redundant checking. Differential revision: https://reviews.llvm.org/D54154 llvm-svn: 347029
* [WebAssembly] Import the stack pointer when building shared librariesSam Clegg2018-11-156-66/+92
| | | | | | Differential Revision: https://reviews.llvm.org/D54558 llvm-svn: 346974
* [WebAssembly] Refactor config setting and checking. NFC.Sam Clegg2018-11-152-53/+66
| | | | | | | | This matches the way the ELF backend does it. Differential Revision: https://reviews.llvm.org/D54559 llvm-svn: 346972
* [ELF] - Renamed few more AArch64 specific relocation expressions. NFC.George Rimar2018-11-154-17/+18
| | | | | | They are AArch64 only, so have to have AARCH64_* prefix. llvm-svn: 346963
* [ELF] Fix compilation with GCC 5Martin Storsjo2018-11-151-1/+1
| | | | | | | | | | | | | | | | | | Remove the default initializer for TrapInstr; all subclasses overwrite the defaults in their constructors anyway. This fixes compilation errors like these, with GCC 5.4 on Ubuntu 16.04, present since SVN r346893: In file included from ../tools/lld/ELF/Arch/AArch64.cpp:12:0: ../tools/lld/ELF/Target.h:125:49: error: array must be initialized with a brace-enclosed initializer std::array<uint8_t, 4> TrapInstr = {0, 0, 0, 0}; ^ ../tools/lld/ELF/Target.h:125:49: error: too many initializers for ‘std::array<unsigned char, 4ul>’ Differential Revision: https://reviews.llvm.org/D54569 llvm-svn: 346934
* [WebAssembly] Initial support for shared objects (-shared)Sam Clegg2018-11-1511-17/+212
| | | | | | | | | | | | Based on the initial spec proposal: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md The llvm/codegen side of this is still missing but I believe this change is still worth landing as an incremental step Differential Revision: https://reviews.llvm.org/D54249 llvm-svn: 346918
* [ELF] Make TrapInstr and Filler byte arrays. NFC.Simon Atanasyan2018-11-149-29/+33
| | | | | | | | | | | | The uint32_t type does not clearly convey that these fields are interpreted in the target endianness. Converting them to byte arrays should make this more obvious and less error-prone. Patch by James Clarke Differential Revision: http://reviews.llvm.org/D54207 llvm-svn: 346893
* [PPC64] Long branch thunks.Sean Fertile2018-11-1413-62/+532
| | | | | | | | | | | | | | | | | | On PowerPC64, when a function call offset is too large to encode in a call instruction the address is stored in a table in the data segment. A thunk is used to load the branch target address from the table relative to the TOC-pointer and indirectly branch to the callee. When linking position-dependent code the addresses are stored directly in the table, for position-independent code the table is allocated and filled in at load time by the dynamic linker. For position-independent code the branch targets could have gone in the .got.plt but using the .branch_lt section for both position dependent and position independent binaries keeps it consitent and helps keep this PPC64 specific logic seperated from the target-independent code handling the .got.plt. Differential Revision: https://reviews.llvm.org/D53408 llvm-svn: 346877
* [NFC] Change address __tls_getaddr is defined at so it does not need a thunk.Sean Fertile2018-11-141-2/+2
| | | | | | | Minor update to a ppc64 tls test so that it won't need to use a thunk once the range-extending thunk patch is landed. llvm-svn: 346876
* [AArch64] Fix resolution of R_PLT_PAGE RelExprPeter Smith2018-11-142-7/+55
| | | | | | | | | | | | | The R_AARCH64_ADR_PREL_PG_HI21 relocation type is given the R_PAGE_PC RelExpr. This can be transformed to R_PLT_PAGE_PC via toPlt(). Unfortunately the resolution is identical to R_PAGE_PC so instead of getting the address of the PLT entry we get the address of the symbol which may not be correct in the case of static ifuncs. The fix is to handle the cases separately and use getPltVA() + A with R_PLT_PAGE_PC. Differential Revision: https://reviews.llvm.org/D54474 llvm-svn: 346863
* [COFF] Fix a longstanding typo in a variable name. NFC.Martin Storsjo2018-11-141-5/+5
| | | | llvm-svn: 346846
* Fix r346747 and r346796Diana Picus2018-11-142-0/+2
| | | | | | | Require x86 for the tests in order to fix non-x86 bots. This seems to be the case for all other tests in that directory. llvm-svn: 346842
* [PDB] Simplify symbol handling code, NFCReid Kleckner2018-11-131-25/+22
| | | | | | | | | | | | | | | | | - Make mergeSymbolRecords a method of PDBLinker to reduce the number of parameters it needs. - Remove a stale FIXME comment about error handling. We already drop unknown symbol records, log them, and continue. - Update a comment about why we're copying the symbol record. We do it to realign the record. We can already mutate the symbol record memory, it's memory allocated by relocateDebugChunk. - Avoid the extra `CVSymbol NewSym` variable. We can mutate Sym in place, which is best, since we're mutating the underlying record anyway. llvm-svn: 346817
* [ELF] Add a better test for the multi-CU .gdb_index bug that D54361 fixedFangrui Song2018-11-133-2/+82
| | | | | | | | gdb-index-multiple-cu-2.s puts the symbol in question to another object file %t1.o, so that its CuIndex is affected by the number of CUs in %t.o Also change `Kind:` in a comment to `Attributes:` as a follow-up of D54480 and D54481 llvm-svn: 346796
* [ELF] Rename NameTypeEntry to NameAttrEntry and its field "Type" to ↵Fangrui Song2018-11-132-12/+12
| | | | | | | | | | | | | | | | | | | CuIndexAndAttrs Summary: NameTypeEntry::Type is a bit-packed value of CU index+attributes (https://sourceware.org/gdb//onlinedocs/gdb/Index-Section-Format.html), which is named cu_index_and_attrs in a local variable in gdb/dwarf2read.c:dw2_symtab_iter_next The new name CuIndexAndAttrs is more meaningful. Reviewers: ruiu, dblaikie, espindola Reviewed By: dblaikie Subscribers: emaste, aprantl, arichardson, JDevlieghere, arphaman, llvm-commits Differential Revision: https://reviews.llvm.org/D54481 llvm-svn: 346794
* [COFF] Simplify relocation to discarded section diagnostic code, NFCReid Kleckner2018-11-131-29/+36
| | | | | | Move it out of the loop that applies relocations for readability. llvm-svn: 346777
* [ELF] - Renamed AArch64 specific relocations expressions. NFC.George Rimar2018-11-134-17/+18
| | | | | | They did not have AArch64 prefix. Now they do. llvm-svn: 346749
* [ELF] .gdb_index: fix CuOff when a .debug_info section contains more than 1 ↵Fangrui Song2018-11-132-9/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | DW_TAG_compile_unit Summary: Idx passed to readPubNamesAndTypes was an index into Chunks, not an index into the CU list. This would be incorrect if some .debug_info section contained more than 1 DW_TAG_compile_unit. In real world, glibc Scrt1.o is a partial link of start.os abi-note.o init.o and contains 2 CUs in debug builds. Without this patch, any application linking such Scrt1.o would have invalid .gdb_index The issue could be demonstrated by: (gdb) py print(gdb.lookup_global_symbol('main')) None Reviewers: espindola, ruiu Reviewed By: ruiu Subscribers: Higuoxing, grimar, dblaikie, emaste, aprantl, arichardson, JDevlieghere, arphaman, llvm-commits Differential Revision: https://reviews.llvm.org/D54361 llvm-svn: 346747
* [ELF] Change GnuPub{Names,Types}Section from StringRef to LLDDWARFSectionFangrui Song2018-11-113-23/+24
| | | | | | | | | | | | | | | Summary: The debug_info_offset value may be relocated. This is lld side change of D54375. Reviewers: ruiu, dblaikie, grimar, espindola Subscribers: emaste, arichardson, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D54376 llvm-svn: 346616
* [ELF] Fix relocation-common.s after rL346610Fangrui Song2018-11-111-6/+6
| | | | llvm-svn: 346614
* [ELF] Fix objdump tests after rL346610Fangrui Song2018-11-1110-27/+27
| | | | llvm-svn: 346613
* [lld][test] Update tests using objdumpKristina Brooks2018-11-111-1/+1
| | | | | | Followup fix for LLD test for new format in rL346610. llvm-svn: 346612
* [PDB] Simplify some ghash code, NFCReid Kleckner2018-11-101-17/+21
| | | | | | | Instead of calling the same function twice with different parameters, make the parameters depend on the condition. llvm-svn: 346578
* [WebAssembly] Respect `--no-mangle` in more locationsSam Clegg2018-11-095-14/+17
| | | | | | | | | | | | | `--no-demangle` now also applies to the name section. This change was motivated by the rust team that have a slightly different name mangling scheme to the standard C++ itanium one and prefer to do their de-mangling as a post-link setp. Patch by Alex Crichton! Differential Revision: https://reviews.llvm.org/D54279 llvm-svn: 346516
* Fix -Wextra-qualification warningReid Kleckner2018-11-081-1/+1
| | | | llvm-svn: 346431
* [COFF] Improve relocation against discarded section errorReid Kleckner2018-11-084-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Reuse the "referenced by" note diagnostic code that we already use for undefined symbols. In my case, it turned this: lld-link: error: relocation against symbol in discarded section: .text lld-link: error: relocation against symbol in discarded section: .text ... Into this: lld-link: error: relocation against symbol in discarded section: .text >>> referenced by libANGLE.lib(CompilerGL.obj):(.SCOVP$M) >>> referenced by libANGLE.lib(CompilerGL.obj):(.SCOVP$M) ... lld-link: error: relocation against symbol in discarded section: .text >>> referenced by obj/third_party/angle/libGLESv2/entry_points_egl_ext.obj:(.SCOVP$M) >>> referenced by obj/third_party/angle/libGLESv2/entry_points_egl_ext.obj:(.SCOVP$M) ... I think the new output is more useful. Reviewers: ruiu, pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54240 llvm-svn: 346427
* [LLD] Fix Microsoft precompiled headers cross-compile on LinuxAlexandre Ganea2018-11-083-33/+31
| | | | | | Differential revision: https://reviews.llvm.org/D54122 llvm-svn: 346403
* [DWARFv5] Read and dump multiple .debug_info sections.Paul Robinson2018-11-071-2/+4
| | | | | | | | Type units go in .debug_info comdats, not .debug_types, in v5. Differential Revision: https://reviews.llvm.org/D53907 llvm-svn: 346360
* [PPC64] Use INT32_MIN instead of std::numeric_limits<int32_t>::min()Fangrui Song2018-11-071-2/+1
| | | | | | | | | | | | | | | | | | | | Summary: D53821 fixed the bogus MSVC (at least 2017) C4146 warning (unary minus applied on unsigned type) by using std::numeric_limits<int32_t>::min(). The warning was because -2147483648 is incorrectly treated as unsigned long instead of long long) Let's use INT32_MIN which is arguably more readable. Note, on GCC or clang, -0x80000000 works fine (ILP64: long, LP64: long long). Reviewers: ruiu, jhenderson, sfertile, espindola Reviewed By: sfertile Subscribers: emaste, nemanjai, arichardson, kbarton, jsji, llvm-commits Differential Revision: https://reviews.llvm.org/D54200 llvm-svn: 346356
* [lld][NFC] Use explicit --symbols instead of -t in tests using llvm-readelf.Jordan Rupprecht2018-11-064-5/+5
| | | | llvm-svn: 346260
* [WebAssembly] Address review comments from r346248 [NFC]Derek Schuff2018-11-061-3/+4
| | | | llvm-svn: 346249
OpenPOWER on IntegriCloud