summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* [LLD][ELF] - A follow up for r350819 ("Support MSP430") : add a test case ↵George Rimar2019-01-101-0/+40
| | | | | | | | missing. It got lost for some reason. llvm-svn: 350833
* Modify InputSectionBase::getLocation to add section and offset to every loc.Sean Fertile2019-01-104-7/+10
| | | | | | | | | | | | | | The section and offset can be very helpful in diagnosing certian errors. For example on a relocation overflow or misalignment diagnostic: test.c:(function foo): relocation R_PPC64_ADDR16_DS out of range: ... The function foo can have many R_PPC64_ADDR16_DS relocations. Adding the offset and section will identify exactly which relocation is causing the failure. Differential Revision: https://reviews.llvm.org/D56453 llvm-svn: 350828
* [PPC64] Fix RelType in checkInt and checkAlignment diagnsotics.Sean Fertile2019-01-103-10/+12
| | | | | | | | | | | | In the PPC64 target we map toc-relative relocations, dynamic thread pointer relative relocations, and got relocations into a corresponding ADDR16 relocation type for handling in relocateOne. This patch saves the orignal RelType before mapping to an ADDR16 relocation so that any diagnostic messages will not mistakenly use the mapped type. Differential Revision: https://reviews.llvm.org/D56448 llvm-svn: 350827
* [LLD][ELF] - Fix the test cases after r350823.George Rimar2019-01-103-35/+5
| | | | | | r350823 changed the output of the llvm-objdump. llvm-svn: 350824
* [LLD][ELF] - Support MSP430.George Rimar2019-01-107-0/+105
| | | | | | | | | | | Patch by Michael Skvortsov! This change adds a basic support for linking static MSP430 ELF code. Implemented relocation types are intended to correspond to the BFD. Differential revision: https://reviews.llvm.org/D56535 llvm-svn: 350819
* Fix formatting. NFC.Rui Ueyama2019-01-091-2/+3
| | | | llvm-svn: 350767
* lld-link: Add help strings for /manifest, /nodefaultlib, /noentry; tweak ↵Nico Weber2019-01-091-9/+17
| | | | | | | | | | | manifest help strings My main motivation is that I can never remember /nodefaultlib and `lld-link /? | grep no` didn't display it due to it not having a help string. Differential Revision: https://reviews.llvm.org/D56502 llvm-svn: 350750
* [LLD][ELF] - Fix BB after r350726.George Rimar2019-01-091-1/+1
| | | | | | | D56123 changed the llvm-objdump output format. Now we print the symbol address when dumping. llvm-svn: 350728
* [ARM][AArch64] Increase TLS alignment to reserve space for Android's TCBRyan Prichard2019-01-099-50/+66
| | | | | | | | | | | | | | | | | | | | | | | | ARM and AArch64 use TLS variant 1, where the first two words after the thread pointer are reserved for the TCB, followed by the executable's TLS segment. Both the thread pointer and the TLS segment are aligned to at least the TLS segment's alignment. Android/Bionic historically has not supported ELF TLS, and it has allocated memory after the thread pointer for several Bionic TLS slots (currently 9 but soon only 8). At least one of these allocations (TLS_SLOT_STACK_GUARD == 5) is widespread throughout Android/AArch64 binaries and can't be changed. To reconcile this disagreement about TLS memory layout, set the minimum alignment for executable TLS segments to 8 words on ARM/AArch64, which reserves at least 8 words of memory after the TP (2 for the ABI-specified TCB and 6 for alignment padding). For simplicity, and because lld doesn't know when it's targeting Android, increase the alignment regardless of operating system. Differential Revision: https://reviews.llvm.org/D53906 llvm-svn: 350681
* [ELF] Remove checking for spurious '@' at the end of dynamic sym namesJames Henderson2019-01-0854-145/+145
| | | | | | | | | | | | llvm-readobj currently has a bug (see PR40097) where it prints '@' at the end of unversioned dynamic symbols. This bug will be fixed in a separate later commit, but these tests need fixing first. Reviewed by: ruiu, Higuoxing Differential Revision: https://reviews.llvm.org/D56388 llvm-svn: 350614
* [WebAssembly] Instruction renamingThomas Lively2019-01-0817-24/+24
| | | | | | | | | | | | Summary: Associated with D56338. Reviewers: aheejin, aardappel Subscribers: dschuff, sbc100, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D56339 llvm-svn: 350610
* [CodeView] More appropriate name and type for a Microsoft precompiled ↵Alexandre Ganea2019-01-072-6/+6
| | | | | | headers parameter. NFC llvm-svn: 350520
* [docs] Add a known limitation to the comment about lld supporting GCC/MinGW ↵Martin Storsjo2019-01-051-1/+4
| | | | | | | | object files. NFC. Differential Revision: https://reviews.llvm.org/D56335 llvm-svn: 350465
* [MinGW] Expand comment for MinGW driver. NFC.Martin Storsjo2019-01-051-3/+21
| | | | | | | | Originally authored by Rui Ueyama. Differential Revision: https://reviews.llvm.org/D53031 llvm-svn: 350464
* [LLD][COFF] PDB: Parallel sort publicsAlexandre Ganea2019-01-051-4/+5
| | | | | | | | | | | | | | | | Saves up to 1.3 sec on large PDBs. Figures below are for the "Globals Stream Layout" pass: Before This patch Large EXE (PDB is ~2 GB) 3330 ms 2022 ms Large EXE (PDB is ~2 GB) 2680 ms 1608 ms Large DLL (PDB is ~1 GB) 1455 ms 938 ms Large DLL (PDB is ~800 MB) 1215 ms 800 ms Small DLL (PDB is ~200 MB) 224 ms 146 ms Differential Revision: https://reviews.llvm.org/D56334 llvm-svn: 350452
* [LLD][COFF] Fix namespace compilation issue with a upcoming patch. NFCAlexandre Ganea2019-01-051-4/+4
| | | | llvm-svn: 350450
* [LLD][COFF] Fix file/line retrieval when a undefined symbol is to be printedAlexandre Ganea2019-01-042-7/+173
| | | | | | Differential Revision: https://reviews.llvm.org/D55951 llvm-svn: 350438
* [test] Enable system-linker-elf feature on NetBSD [NFC]Michal Gorny2019-01-021-1/+1
| | | | | | | Since NetBSD uses ELF linker, enable the relevant feature. It's not currently used for anything, though. llvm-svn: 350253
* Fix linker-defined symbols possibly not being defined when -wrap is usedThomas Anderson2019-01-023-3/+21
| | | | | | | | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=40134 addWrappedSymbols() must be called before addReservedSymbols() because the latter only defines reserved symbols when they are undefined in the symbol table. If addWrappedSymbols() is called after, then addUndefined() is called which may lazily pull in more object files that could reference reserved symbols. Differential Revision: https://reviews.llvm.org/D56110 llvm-svn: 350251
* [ELF] A shared object is needed if any of its occurrences is neededFangrui Song2018-12-273-2/+20
| | | | | | | | | | | | | | | | | | | | | | | Summary: If a DSO appears more than once with and without --as-needed, ld.bfd and gold consider --no-as-needed to takes precedence over --as-needed. lld didn't and this patch makes it do so. This makes it a bit away from the position-dependent behavior (how different occurrences of the same DSO interact) and protects us from some mysterious runtime errors: if some interceptor libraries add their own --no-as-needed dependencies (e.g. librt.so), and the user application specifies -Wl,--as-needed -lrt , the absence of the DT_NEEDED entry would make dlsym(RTLD_NEXT, "clock_gettime") return NULL and would break at runtime. Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D56089 llvm-svn: 350105
* Use error() instead of fatal() to report an invalid address range.Rui Ueyama2018-12-262-17/+9
| | | | | | In this patch we also use toString() to stringize a section. llvm-svn: 350070
* [LLD][ELF] - Cleanup gdb-index-dwarf5-low-high.s. NFC.George Rimar2018-12-241-36/+35
| | | | | | Remove tabs and .debug_macinfo sections. llvm-svn: 350051
* Tolerate flaky LLD tests on NetBSDKamil Rytarowski2018-12-231-0/+5
| | | | | | | | | | | | | | | | | | | | | Summary: For unknown reasons LLD tests are flaky on the NetBSD buildbot, but not on local machines of developers. Unless the linker will be fully functional on this target, allow to pass flaky tests with optional retry. Reviewers: joerg, mgorny, ruiu Reviewed By: mgorny Subscribers: lebedev.ri, MaskRay, llvm-commits, #lld Tags: #lld Differential Revision: https://reviews.llvm.org/D56053 llvm-svn: 350036
* Test DWARFv5 with gdb-index and low_pc/high_pc on the CU (rather than ranges)David Blaikie2018-12-221-0/+50
| | | | | | | | There was a bug in LLVM's libDebugInfo where it did not porpagate the section index through the range query built from low_pc/high_pc. Hard to test in LLVM, so I'm adding a test here. llvm-svn: 350011
* gdb-index: Handle errors when parsing rangesDavid Blaikie2018-12-223-6/+62
| | | | | | | | | | When parsing CU ranges for gdb-index, handle the error (now propagated up though the API lld is calling here - previously the error was printed within the libDebugInfo API, not allowing lld to format or handle the message at all) - including information about the object and archive name, as well as failing the link. llvm-svn: 349979
* keymethod -> keyfunctionFangrui Song2018-12-213-3/+3
| | | | | | Pointed out by ruiu in rLLD349969 llvm-svn: 349974
* key method -> key functionFangrui Song2018-12-212-11/+11
| | | | | | | | The latter is what is actually called in the ABI http://itanium-cxx-abi.github.io/cxx-abi/abi.html#vague-vtable Pointed out by rsmith llvm-svn: 349969
* [ELF] .gnu.hash bloom filter: use Shift2 = 26 instead of 6Fangrui Song2018-12-214-10/+13
| | | | | | | | | | | | | | | | | | | | | Summary: For the 2-bit bloom filter, we currently pick the bits Hash%64 and Hash>>6%64 (Shift2=6), but bits [6:...] are also used to select a word, causing a loss of precision. In this patch, we choose Shift2=26, with is suggested by Ambrose Feinstein. Note, Shift2 is computed as maskbitslog2 in bfd/elflink.c and gold/dynobj.cc It is varying with the number of dynamic symbols but we don't necessarily copy its rule. Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D55971 llvm-svn: 349966
* Add a doc for missing key function and an error message referencing the doc.Rui Ueyama2018-12-213-0/+92
| | | | | | | | | | | | | | | | Summary: This is a common error, and because many people don't know what the key function is, it is sometimes very confusing. The doc was originally written by Brooks Moses and slightly edited by me. Reviewers: MaskRay, espindola Subscribers: emaste, llvm-commits, arichardson Differential Revision: https://reviews.llvm.org/D55968 llvm-svn: 349941
* Remove dead code.Rui Ueyama2018-12-201-4/+0
| | | | | | | | This code is no-op because of r349849. Differential Revision: https://reviews.llvm.org/D55962 llvm-svn: 349859
* Simplify. NFC.Rui Ueyama2018-12-201-12/+7
| | | | llvm-svn: 349850
* [ELF] Move IsNeeded logic from SymbolTable::addShared to MarkLive, and check ↵Fangrui Song2018-12-204-4/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IsUsedInRegularObj Summary: In glibc, libc.so is a linker script with an as-needed dependency on ld-linux-x86-64.so.2 GROUP ( /lib/x86_64-linux-gnu/libc.so.6 /usr/lib/x86_64-linux-gnu/libc_nonshared.a AS_NEEDED ( /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ) ) ld-linux-x86-64.so.2 (as-needed) defines some symbols which resolve undefined references in libc.so.6, it will therefore be added as a DT_NEEDED entry, which isn't necessary. The test case as-needed-not-in-regular.s emulates the libc.so scenario, where ld.bfd and gold don't add DT_NEEDED for a.so The relevant code in gold/resolve.cc: // If we have a non-WEAK reference from a regular object to a // dynamic object, mark the dynamic object as needed. if (to->is_from_dynobj() && to->in_reg() && !to->is_undef_binding_weak()) to->object()->set_is_needed(); in_reg() appears to do something similar to IsUsedInRegularObj. This patch makes lld do the similar thing, but moves the check from addShared to a later stage MarkLive where all symbols are scanned. Reviewers: ruiu, pcc, espindola Reviewed By: ruiu Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D55902 llvm-svn: 349849
* [PPC64] Add toc-optimizations for got based relocations.Sean Fertile2018-12-202-7/+32
| | | | | | Differential Revision: https://reviews.llvm.org/D54907 llvm-svn: 349772
* Simplify. NFC.Rui Ueyama2018-12-191-7/+12
| | | | | | Differential Revision: https://reviews.llvm.org/D55903 llvm-svn: 349697
* [LLD][ELF] - Report a location for symbols from the linker script when ↵George Rimar2018-12-192-2/+30
| | | | | | | | | | | | | | | | | | | reporting an error. When we report an error for symbols defined in the linker script, we do not report the location properly. For example: ld.lld: error: relocation R_AARCH64_CALL26 cannot refer to absolute symbol: aliasto__text >>> defined in <internal> >>> referenced by rtoabs.o:(.text+0x4) This patch fixes that. Differential revision: https://reviews.llvm.org/D55360 llvm-svn: 349612
* Use unique_ptr to manage a TarWriter instance. NFC.Rui Ueyama2018-12-183-4/+3
| | | | llvm-svn: 349581
* Fix error message.Rui Ueyama2018-12-181-2/+1
| | | | | | | | | | Previously, this code printed out an error message like this ld.lld: error: --reproduce: failed to open /foo: cannot open /foo Apparently "failed to open /foo:" part is redundant. llvm-svn: 349571
* Reject .so files if -static is given.Rui Ueyama2018-12-183-2/+14
| | | | | | | | | | Previously, if you pass -static to lld, lld searches for only foo.a and skips foo.so for -lfoo option. However, it didn't reject .so files if you directly pass their pathnames via the command line, which is a bug. Differential Revision: https://reviews.llvm.org/D55845 llvm-svn: 349557
* [ELF] Place .note in the first page to ensure they are available in core filesFangrui Song2018-12-182-21/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Other large sections (e.g. .rela.dyn .dynstr) may push .note.* off the first page. They won't be available in core files if RLIMIT_CORE is limited. This patch gives priority to alloctable SHT_NOTE sections so that they are assuredly in the first page and will be available in core files. They are small and contain important information (e.g. .note.gnu.build-id identifies the origin of the core, .note.tag stores NT_FREEBSD_ABI_TAG). Note: gold Output_section_order has a similar rule: // Loadable read-only note sections come next so that the PT_NOTE // segment is on the first page of the executable. ORDER_RO_NOTE, Reviewers: ruiu, pcc, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D55800 llvm-svn: 349524
* [PPC64] Support got-based relocations.Sean Fertile2018-12-182-2/+67
| | | | | | Differential Revison: https://reviews.llvm.org/D54859 llvm-svn: 349511
* [COFF] Set the CPU string for LTO like ELF doesReid Kleckner2018-12-182-0/+22
| | | | | | Fixes PR40043 llvm-svn: 349436
* [codeview] Align symbol records to save 441MB during linking clang.pdbReid Kleckner2018-12-181-4/+6
| | | | | | | | | | | | | | | | | | | | In PDBs, symbol records must be aligned to four bytes. However, in the object file, symbol records may not be aligned. MSVC does not pad out symbol records to make sure they are aligned. That means the linker has to do extra work to insert the padding. Currently, LLD calculates the required space with alignment, and copies each record one at a time while padding them out to the correct size. It has a fast path that avoids this copy when the records are already aligned. This change fixes a bug in that codepath so that the copy is actually saved, and tweaks LLVM's symbol record emission to align symbol records. Here's how things compare when doing a plain clang Release+PDB build: - objs are 0.65% bigger (negligible) - link is 3.3% faster (negligible) - saves allocating 441MB - new LLD high water mark is ~1.05GB llvm-svn: 349431
* ELF: AArch64: Fix errata patch address calculation.Peter Collingbourne2018-12-172-1/+21
| | | | | | | | | | | The code here wants the output section offset of the instruction requiring the errata patch, not the virtual address. Without this change we can end up placing a patch out of range if the virtual address of the code section is large enough. Differential Revision: https://reviews.llvm.org/D55732 llvm-svn: 349386
* [ELF][ARM] Add support for architecture v6m thunksPeter Smith2018-12-173-44/+153
| | | | | | | | | | | | | | | | | | | | | | ARM Architecture v6m is used by the smallest microcontrollers such as the cortex-m0. It is Thumb only (no Thumb 2) which prevents it from using the existing Thumb 2 range extension thunks as these use the Thumb 2 movt/movw instructions. Range extension thunks are not usually needed for microcontrollers due to the small amount of flash and ram on the device, however if code is copied from flash into ram then a range extension thunk is required to call that code. This change adds support for v6m range extension thunks. The procedure call standard APCS permits a thunk to corrupt the intra-procedural scratch register r12 (referred to as ip in the APCS). Most Thumb instructions do not permit access to high registers (r8 - r15) so the thunks must spill some low registers (r0 - r7) to perform the control transfer. Fixes pr39922 Differential Revision: https://reviews.llvm.org/D55555 llvm-svn: 349337
* ELF: Handle R_ARM_V4BX correctly in PIC output files.Peter Collingbourne2018-12-152-6/+8
| | | | | | | | | | | | | | | Previously we considered R_ARM_V4BX to be an absolute relocation, which meant that we rejected it in read-only sections in PIC output files. Instead, treat it as a hint relocation so that relocation processing ignores it entirely. Also fix a problem with the test case where it was never being run because it has a .yaml extension and we don't run tests with that extension. Differential Revision: https://reviews.llvm.org/D55728 llvm-svn: 349216
* [test] Capture stderr from 'tar --version' call as wellMichal Gorny2018-12-141-3/+6
| | | | | | | | | | | Capture the stderr from 'tar --version' call as otherwise error messages spill onto user's terminal unnecessarily (e.g. on NetBSD where tar does not support long options). While at it, refactor the code to use communicate() instead of reinventing the wheel. Differential Revision: https://reviews.llvm.org/D55443 llvm-svn: 349204
* Add --plugin-opt=emit-llvm option.Rui Ueyama2018-12-145-0/+31
| | | | | | | | | | | | | | `--plugin-opt=emit-llvm` is an option for LTO. It makes the linker to combine all bitcode files and write the result to an output file without doing codegen. Gold LTO plugin has this option. This option is being used for some post-link code analysis tools that have to see a whole program but don't need to see them in the native machine code. Differential Revision: https://reviews.llvm.org/D55717 llvm-svn: 349198
* Correctly handle skewed streams in drop_front() method.Zachary Turner2018-12-131-1/+4
| | | | | | | | | | | | When calling BinaryStreamArray::drop_front(), if the stream is skewed it means we must never drop the first bytes of the stream since offsets which occur in records assume the existence of those bytes. So if we want to skip the first record in a stream, then what we really want to do is just set the begin pointer to the next record. But we shouldn't actually remove those bytes from the underlying view of the data. llvm-svn: 349066
* [ELF][AArch64] Fix adrp to undefined weak reference.Peter Smith2018-12-132-3/+3
| | | | | | | | | | | | | | | | | | In the ABI for the 64-bit Arm architecture the section on weak references states: During linking, the symbol value of an undefined weak reference is: - Zero if the relocation type is absolute - The address of the place if the relocation type is pc-relative. The relocations associated with an ADRP are relative so we should resolve the undefined weak reference to the place instead of 0. This matches GNU ld.bfd behaviour. fixes pr34928 Differential Revision: https://reviews.llvm.org/D55599 llvm-svn: 349024
* [WebAssembly] Add "needed" list to dylink sectionSam Clegg2018-12-121-0/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D55613 llvm-svn: 348990
OpenPOWER on IntegriCloud