summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* Inline a trivial function. NFC.Rui Ueyama2019-03-285-12/+10
| | | | | | | I found that hiding this particular actual expression doesn't help readers understand the code. So I remove and inline that function. llvm-svn: 357140
* [ELF] Dump symbols ordered by profiled guided section layout to file.Rui Ueyama2019-03-276-0/+106
| | | | | | | | | | | | | | | | Patch by Tiancong Wang. In D36351, Call-Chain Clustering (C3) heuristic is implemented with option --call-graph-ordering-file <file>. This patch adds a flag --print-symbol-order=<file> to LLD, and when specified, it prints out the symbols ordered by the heuristics to the file. The symbols printout is helpful to those who want to understand the heuristics and want to reproduce the ordering with --symbol-ordering-file in later pass. Differential Revision: https://reviews.llvm.org/D59311 llvm-svn: 357133
* [LLD] Restore tests that use "-" as outputAndrew Ng2019-03-275-38/+19
| | | | | | | | | | No longer require workarounds for output to "-" (stdout) for Windows. These workarounds were just hiding the actual problem which has been fixed in r357058. Differential Revision: https://reviews.llvm.org/D59824 llvm-svn: 357072
* Revert "[lld] Reapply "Prevent duplicate files in debug line header in dwarf ↵Ali Tamur2019-03-262-7/+9
| | | | | | | | | | | 5."" This reverts commit rL357020 Reason: rL357018, which this commit depend on breaks the test: llvm/test/tools/llvm-objdump/embedded-source.test on some architectures. llvm-svn: 357025
* [WebAssembly] Initial implementation of PIC code generationSam Clegg2019-03-267-43/+83
| | | | | | | | | | | | | | | | | | | | | | | | This change implements lowering of references global symbols in PIC mode. This change implements lowering of global references in PIC mode using a new @GOT reference type. @GOT references can be used with function or data symbol names combined with the get_global instruction. In this case the linker will insert the wasm global that stores the address of the symbol (either in memory for data symbols or in the wasm table for function symbols). For now I'm continuing to use the R_WASM_GLOBAL_INDEX_LEB relocation type for this type of reference which means that this relocation type can refer to either a global or a function or data symbol. We could choose to introduce specific relocation types for GOT entries in the future. See the current dynamic linking proposal: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md Differential Revision: https://reviews.llvm.org/D54647 llvm-svn: 357022
* [lld] Reapply "Prevent duplicate files in debug line header in dwarf 5."Ali Tamur2019-03-262-9/+7
| | | | | | | | | | | | | | | Reapply rL356943; the previous attempt was reverted because the patch rL356941 that this depended on had broken a test. Original commit message: [lld] Prevent duplicate files in debug line header in dwarf 5. Tags: #llvm Differential Revision: https://reviews.llvm.org/D59671 llvm-svn: 357020
* Reland "[WebAssembly] Add linker options to control feature checking"Thomas Lively2019-03-268-19/+224
| | | | | | | | | Do not pipe binary data between processes in lit tests this time, since it turns out that can break on Windows. This reverts commit 84c8652fc3085155d0f9c355455e5a797c6d9db6. llvm-svn: 356975
* [ELF] Change GOT*_FROM_END (relative to end(.got)) to GOTPLT* (start(.got.plt))Fangrui Song2019-03-2524-176/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This should address remaining issues discussed in PR36555. Currently R_GOT*_FROM_END are exclusively used by x86 and x86_64 to express relocations types relative to the GOT base. We have _GLOBAL_OFFSET_TABLE_ (GOT base) = start(.got.plt) but end(.got) != start(.got.plt) This can have problems when _GLOBAL_OFFSET_TABLE_ is used as a symbol, e.g. glibc dl_machine_dynamic assumes _GLOBAL_OFFSET_TABLE_ is start(.got.plt), which is not true. extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden; return _GLOBAL_OFFSET_TABLE_[0]; // R_X86_64_GOTPC32 In this patch, we * Change all GOT*_FROM_END to GOTPLT* to fix the problem. * Add HasGotPltOffRel to denote whether .got.plt should be kept even if the section is empty. * Simplify GotSection::empty and GotPltSection::empty by setting HasGotOffRel and HasGotPltOffRel according to GlobalOffsetTable early. The change of R_386_GOTPC makes X86::writePltHeader simpler as we don't have to compute the offset start(.got.plt) - Ebx (it is constant 0). We still diverge from ld.bfd (at least in most cases) and gold in that .got.plt and .got are not adjacent, but the advantage doing that is unclear. Reviewers: ruiu, sivachandra, espindola Subscribers: emaste, mehdi_amini, arichardson, dexonsmith, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59594 llvm-svn: 356968
* Use a class instead of lambda-based callbacks to organize garbage collector.Rui Ueyama2019-03-251-117/+120
| | | | | | | | | | | | | | | | | | | | | | lld's mark-sweep garbage collector was written in the visitor pattern. There are functions that traverses a given graph, and the functions calls callback functions to dispatch according to node type. The code was originaly pretty simple, and lambdas worked pretty well. However, as we add more features to the garbage collector, that became more like a callback hell. We now have a callback function that wraps another callback function, for example. It is not easy to follow the flow of the control. This patch rewrites it as a regular class. What was once a lambda is now a regular class member function. I think this change fixes the readability issue. No functionality change intended. Differential Revision: https://reviews.llvm.org/D59800 llvm-svn: 356966
* Revert "[lld] Prevent duplicate files in debug line header in dwarf 5."Ali Tamur2019-03-252-7/+9
| | | | | | | | This reverts commit 5aa7478a55fa86dae45913b82bd05ed32d9c0973. Some things are broken; I will fix and try to commit again. llvm-svn: 356949
* [lld] Prevent duplicate files in debug line header in dwarf 5.Ali Tamur2019-03-252-9/+7
| | | | | | | | | | | | | | | | | Summary: Changes to a couple of tests that will start failing after https://reviews.llvm.org/D59515 is submitted. Reviewers: echristo, ruiu, espindola Reviewed By: echristo, ruiu Subscribers: emaste, arichardson, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59671 llvm-svn: 356943
* Revert "[WebAssembly] Add linker options to control feature checking"Thomas Lively2019-03-258-200/+7
| | | | | | This reverts commit 5991328c96b6146999cfa74ede42901f8c01f2fa. llvm-svn: 356932
* [LLD][COFF] Separate module descriptors creation from type/symbol mergingAlexandre Ganea2019-03-223-31/+44
| | | | | | | | | | Take module DBI creation out of PDBLinker::addObjFile() into its own function. This is groundwork towards parallelizable type merging, as proposed in D59226. Differential Revision: https://reviews.llvm.org/D59261 llvm-svn: 356815
* Simplify PltSection.Rui Ueyama2019-03-222-22/+11
| | | | | | | | | Previously, `Entries` contains pairs of symbols and their indices. The indices are always 0, x, 2x, 3x, ..., where x is the size of relocation entry. We didn't have to store that values because we can compute them when we consume them. llvm-svn: 356812
* [WebAssembly] Add linker options to control feature checkingThomas Lively2019-03-228-7/+200
| | | | | | | | | | | | | | | | | | | | | Summary: Adds --check-features and --no-check-features. The default for now is to enable the checking, but this might change in the future. Also adds --features=foo,bar for precisely controlling the features used in the output binary. Depends on D59173. Reviewers: sbc100, aheejin Subscribers: dschuff, jgravelle-google, sunfish, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59274 llvm-svn: 356805
* [DWARF] Refactor RelocVisitor and fix computation of SHT_RELA-typed ↵Fangrui Song2019-03-221-2/+24
| | | | | | | | | | | | | | | | | | relocation entries Summary: This is the lld-side change of D57939 Reviewers: echristo, dblaikie, ruiu, espindola Reviewed By: echristo, ruiu Subscribers: jdoerfert, emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57940 llvm-svn: 356730
* Fix lld wasm tests after r356610Reid Kleckner2019-03-213-9/+15
| | | | | | | Apparently stdout is not opened in binary mode, so the executable gets corrupted when piping to obj2yaml. llvm-svn: 356694
* [ELF][ARM] Revert Redesign of .ARM.exidx handling to use a SyntheticSectionPeter Smith2019-03-2111-391/+175
| | | | | | | | | There is a reproducible buildbot failure (segfault) on the 2 stage clang-cmake-armv8-lld bot. Reverting while I investigate. Differential Revision: https://reviews.llvm.org/D59216 llvm-svn: 356684
* [ELF][ARM] Redesign of .ARM.exidx handling to use a SyntheticSectionPeter Smith2019-03-2111-175/+391
| | | | | | | | | | | | | | | | | Instead of creating extra Synthetic .ARM.exidx sections to account for gaps in the table, create a single .ARM.exidx SyntheticSection that can derive the contents of the gaps from a sorted list of the executable InputSections. This has the benefit of moving the ARM specific code for SyntheticSections in SHF_LINK_ORDER processing and the table merging code into the ARM specific SyntheticSection. This also makes it easier to create EXIDX_CANTUNWIND table entries for executable InputSections that don't have an associated .ARM.exidx section. Fixes pr40277 Differential Revision: https://reviews.llvm.org/D59216 llvm-svn: 356666
* [WebAssembly] Target features sectionThomas Lively2019-03-2010-5/+263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Implements a new target features section in assembly and object files that records what features are used, required, and disallowed in WebAssembly objects. The linker uses this information to ensure that all objects participating in a link are feature-compatible and records the set of used features in the output binary for use by optimizers and other tools later in the toolchain. The "atomics" feature is always required or disallowed to prevent linking code with stripped atomics into multithreaded binaries. Other features are marked used if they are enabled globally or on any function in a module. Future CLs will add linker flags for ignoring feature compatibility checks and for specifying the set of allowed features, implement using the presence of the "atomics" feature to control the type of memory and segments in the linked binary, and add front-end flags for relaxing the linkage policy for atomics. Reviewers: aheejin, sbc100, dschuff Subscribers: jgravelle-google, hiraditya, sunfish, mgrang, jfb, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59173 llvm-svn: 356610
* [TailCallElim] Update tests for LTO pipeline changeRobert Lougher2019-03-203-19/+8
| | | | | | | | | D58391 changed the LTO pipelines to add the tailcall elimination pass. This caused three LLD tests to fail. Differential Revision: https://reviews.llvm.org/D59604 llvm-svn: 356593
* Python 2/3 compatibilitySerge Guelton2019-03-201-4/+9
| | | | | | | | This should be the only change required to have lld's python code base compatible with both Python 2 and Python 3 Differential Revision: https://reviews.llvm.org/D59538 llvm-svn: 356538
* [ELF] Allow sh_entsize to be unrelated to sh_addralign and not a power of 2Fangrui Song2019-03-186-12/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This implements Rui Ueyama's idea in PR39044. I've checked that ld.bfd and gold do not have the power-of-2 requirement and do not require sh_entsize to be a multiple of sh_align. Now on the updated test merge-entsize.s, all the 3 linkers happily create .rodata that is not 3-byte aligned. This has a use case in Linux arch/x86/crypto/sha512-avx2-asm.S It uses sh_entsize of 640, which is not a power of 2. See https://github.com/ClangBuiltLinux/linux/issues/417 Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: nickdesaulniers, E5ten, emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59478 llvm-svn: 356428
* [DebugInfo][PDB] Don't write empty debug streamsAlexandre Ganea2019-03-184-10/+18
| | | | | | | | | | | Before, empty debug streams were written as 8 bytes (4 bytes signature + 4 bytes for the GlobalRefs count). With this patch, unused empty streams aren't emitted anymore. Modules now encode 65535 as an 'unused stream' value, by convention. Also fix the * Linker * contrib section which wasn't correctly emitted previously. Differential Revision: https://reviews.llvm.org/D59502 llvm-svn: 356395
* lld-link: Run conflict-mangled.test on all systemsNico Weber2019-03-181-1/+0
| | | | | | | | | | | | | It seems to pass fine on my Mac, and it running it only on Windows made me miss it in r355959 and required r355959. When the test was added in r288992 we still used Win-only UnDecorateSymbolName() for demangling. Now we use LLVM's microsoftDemangle() which is cross-platform. Differential Revision: https://reviews.llvm.org/D59497 llvm-svn: 356380
* [ELF] Emit weak-undef symbols in .dynsym of a PIE binary only if linked ↵Siva Chandra2019-03-186-4/+44
| | | | | | | | | | | | | | against shared libs. Reviewers: espindola Subscribers: emaste, arichardson, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59275 llvm-svn: 356374
* [LLD][ELF] - Replace one of the tests with a YAML version.George Rimar2019-03-173-4/+17
| | | | | | | | This removes one more binary from the inputs. Differential revision: https://reviews.llvm.org/D59085 llvm-svn: 356334
* [ELF] De-virtualize findOrphanPos, excludeLibs and handleARMTlsRelocationFangrui Song2019-03-173-6/+3
| | | | llvm-svn: 356331
* [WebAssembly] Error on R_WASM_MEMORY_ADDR relocations against undefined data ↵Sam Clegg2019-03-163-36/+70
| | | | | | | | | | | | | | symbols. For these types of relocations an absolute memory address is required which is not possible for undefined data symbols. For symbols that can be undefined at link time (i.e. external data symbols in shared libraries) a different type of relocation (i.e. via a GOT) will be needed. Differential Revision: https://reviews.llvm.org/D59337 llvm-svn: 356310
* [COFF] Delete unused declarations and add a missing forward declaration. NFCFangrui Song2019-03-154-3/+2
| | | | llvm-svn: 356241
* [ELF] Delete unused forward declarations and unused ↵Fangrui Song2019-03-154-20/+0
| | | | | | DynamicReloc::getInputSec(). NFC llvm-svn: 356239
* [ELF] De-template wrapSymbols, isReserved and addGotEntry. NFCFangrui Song2019-03-153-7/+7
| | | | llvm-svn: 356237
* [ELF] Add a test for large .bss.rel.roFangrui Song2019-03-151-0/+44
| | | | | | | | | | | | | | Reviewers: ruiu, pcc, espindola Reviewed By: pcc Subscribers: emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59404 llvm-svn: 356230
* [ELF] Fix 3 tests after D56828Fangrui Song2019-03-153-21/+21
| | | | | | | | | | | | | | | | | arm-plt-reloc.s arm-thumb-plt-reloc.s: update offset calculations pack-dyn-relocs-loop.s: this test is very sensitive to exact section offsets and sizes. If we comment out the following two lines in SyntheticSections.cpp, we should reproduce `ld.lld: error: thunk creation not converged` caused by oscillation of the section size. if (RelocData.size() < OldSize) RelocData.append(OldSize - RelocData.size(), 0); Use -z norelro to counteract the layout change (to be more specific, we have to place .dynamic below .foo so that offset(foo) remains 0x10004) llvm-svn: 356229
* [ELF] Split RW PT_LOAD on the PT_GNU_RELRO boundaryFangrui Song2019-03-1521-105/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Based on Peter Collingbourne's suggestion in D56828. Before D56828: PT_LOAD(.data PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) .bss) Old: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) .data .bss) New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro)) PT_LOAD(.data. .bss) The new layout reflects the runtime memory mappings. By having two PT_LOAD segments, we can utilize the NOBITS part of the first PT_LOAD and save bytes for .bss.rel.ro. .bss.rel.ro is currently small and only used by copy relocations of symbols in read-only segments, but it can be used for other purposes in the future, e.g. if a relro section's statically relocated data is all zeros, we can move it to .bss.rel.ro. Reviewers: espindola, ruiu, pcc Reviewed By: ruiu Subscribers: nemanjai, jvesely, nhaehnle, javed.absar, kbarton, emaste, arichardson, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58892 llvm-svn: 356226
* [LLD][COFF] Add /summary to print statisticsAlexandre Ganea2019-03-146-3/+73
| | | | | | | | /summary prints information about the data (OBJ/LIB/PDB) processed by LLD. The goal is have an estimate about the inputs and outputs, to better understand where the timings go. Differential Revision: https://reviews.llvm.org/D58599 llvm-svn: 356188
* Make a hack for LTO work only when you are actually doing LTO.Rui Ueyama2019-03-143-6/+23
| | | | | | | | | | | | We allow an archive file without symbol table as a linker input as a workaround for a very common error in LTO build. But that logic worked even for an archive file containing non-bitcode files, which is not expected. This patch limits that workaround to one that contains only bitcode files. Differential Revision: https://reviews.llvm.org/D59373 llvm-svn: 356186
* [ELF] Simplify RelRo, TLS, NOBITS section ranks and make RW PT_LOAD start ↵Fangrui Song2019-03-14117-893/+882
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with RelRo Old: PT_LOAD(.data | PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .bss) New: PT_LOAD(PT_GNU_RELRO(.data.rel.ro .bss.rel.ro) | .data .bss) The placement of | indicates page alignment caused by PT_GNU_RELRO. The new layout has simpler rules and saves space for many cases. Old size: roundup(.data) + roundup(.data.rel.ro) New size: roundup(.data.rel.ro + .bss.rel.ro) + .data Other advantages: * At runtime the 3 memory mappings decrease to 2. * start(PT_TLS) = start(PT_GNU_RELRO) = start(RW PT_LOAD). This simplifies binary manipulation tools. GNU strip before 2.31 discards PT_GNU_RELRO if its address is not equal to the start of its associated PT_LOAD. This has been fixed by https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f2731e0c374e5323ce4cdae2bcc7b7fe22da1a6f But with this change, we will be compatible with GNU strip before 2.31 * Before, .got.plt (non-relro by default) was placed before .got (relro by default), which made it impossible to have _GLOBAL_OFFSET_TABLE_ (start of .got.plt on x86-64) equal to the end of .got (R_GOT*_FROM_END) (https://bugs.llvm.org/show_bug.cgi?id=36555). With the new ordering, we can improve on this regard if we'd like to. Reviewers: ruiu, espindola, pcc Subscribers: emaste, arichardson, llvm-commits, joerg, jdoerfert Differential Revision: https://reviews.llvm.org/D56828 llvm-svn: 356117
* [WebAssembly] Improve support for "needed" list in dylink sectionSam Clegg2019-03-137-2/+64
| | | | | | | | | | | This change adds basic support for shared library dependencies via the dylink section. See https://github.com/WebAssembly/tool-conventions/pull/77 Differential Revision: https://reviews.llvm.org/D59237 llvm-svn: 356102
* [mips] Remove redundant setup of less-significant bit. NFCSimon Atanasyan2019-03-131-2/+2
| | | | | | | The less-significant bit for microMIPS symbols configured in the `getSymVA` function. Do not need to setup it once again. llvm-svn: 356058
* [WebAssembly] Handle undefined data symbols in shared librariesSam Clegg2019-03-124-7/+39
| | | | | | | | | | | | When linking shared libraries, we import a mutable wasm global to represent the address of each undefined data symbol. This is a step towards supporting dynamic linking and shared libraries. Differential Revision: https://reviews.llvm.org/D59270 llvm-svn: 355988
* Reland "[Remarks] Add -foptimization-record-passes to filter remark emission"Francis Visoiu Mistrih2019-03-126-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently we have -Rpass for filtering the remarks that are displayed as diagnostics, but when using -fsave-optimization-record, there is no way to filter the remarks while generating them. This adds support for filtering remarks by passes using a regex. Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline` will only emit the remarks coming from the pass `inline`. This adds: * `-fsave-optimization-record` to the driver * `-opt-record-passes` to cc1 * `-lto-pass-remarks-filter` to the LTOCodeGenerator * `--opt-remarks-passes` to lld * `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2 * `-opt-remarks-passes` to gold-plugin Differential Revision: https://reviews.llvm.org/D59268 Original llvm-svn: 355964 llvm-svn: 355984
* ELF: Don't add .dynamic strings to .dynstr early.Peter Collingbourne2019-03-123-23/+20
| | | | | | | | | | This does not appear to be necessary because StringTableSection does not need to be finalized, which also means that we can remove the call to finalizeSynthetic on .dynstr. Differential Revision: https://reviews.llvm.org/D59240 llvm-svn: 355977
* Revert "[Remarks] Add -foptimization-record-passes to filter remark emission"Francis Visoiu Mistrih2019-03-126-13/+0
| | | | | | This reverts commit 20fff32b7d1f1a1bd417b22aa9f26ededd97a3e5. llvm-svn: 355976
* ELF: Use bump pointer allocator for uncompressed section buffers. NFCI.Peter Collingbourne2019-03-122-10/+16
| | | | | | | | | | | | | | This shaves another word off SectionBase and makes it possible to clone a section using the implicit copy constructor. This basically reverts r311056, which removed the mutex in order to make the code easier to understand. On balance I think it's probably more straightforward to have a mutex here than to have an unusual copy constructor in SectionBase. Differential Revision: https://reviews.llvm.org/D59269 llvm-svn: 355966
* [Remarks] Add -foptimization-record-passes to filter remark emissionFrancis Visoiu Mistrih2019-03-126-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | Currently we have -Rpass for filtering the remarks that are displayed as diagnostics, but when using -fsave-optimization-record, there is no way to filter the remarks while generating them. This adds support for filtering remarks by passes using a regex. Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline` will only emit the remarks coming from the pass `inline`. This adds: * `-fsave-optimization-record` to the driver * `-opt-record-passes` to cc1 * `-lto-pass-remarks-filter` to the LTOCodeGenerator * `--opt-remarks-passes` to lld * `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2 * `-opt-remarks-passes` to gold-plugin Differential Revision: https://reviews.llvm.org/D59268 llvm-svn: 355964
* Fixup test to work after changes in r355878.Douglas Yung2019-03-121-1/+5
| | | | | | This should fix the PS4 Windows build bot. llvm-svn: 355959
* ELF: Simplify. NFCI.Peter Collingbourne2019-03-121-3/+1
| | | | | | | | | We don't need to take a slice of SectionCommands in addOrphanSections() because it is not modified until the end of the function. Differential Revision: https://reviews.llvm.org/D59239 llvm-svn: 355954
* fix break tests after rL355922. NFCIXing GUO2019-03-121-3/+3
| | | | llvm-svn: 355925
* [LLD][ELF] - Show symbols visibility in "undefined symbol..." error messages.George Rimar2019-03-127-11/+17
| | | | | | | | | This teaches LLD to report visibility when showing undefined symbol errors and fixes https://bugs.llvm.org/show_bug.cgi?id=40770. Differential revision: https://reviews.llvm.org/D58577 llvm-svn: 355909
OpenPOWER on IntegriCloud