summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* [WebAssembly] Wrap definitions in namespace lld { namespace wasm {. NFCFangrui Song2019-10-1011-158/+187
| | | | | | | | | | Similar to D68323, but for wasm. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D68759 llvm-svn: 374279
* [lld][WebAssembly] Refactor markLive.cpp. NFCSam Clegg2019-10-101-30/+61
| | | | | | | | | This pattern matches the ELF implementation add if also useful as part of a planned change where running `mark` more than once is needed. Differential Revision: https://reviews.llvm.org/D68749 llvm-svn: 374275
* dummy comment typo fix commit to cycle the botsNico Weber2019-10-105-9/+8
| | | | llvm-svn: 374270
* Unify the two CRC implementationsHans Wennborg2019-10-091-4/+2
| | | | | | | | | | | | | | | | | | | | | David added the JamCRC implementation in r246590. More recently, Eugene added a CRC-32 implementation in r357901, which falls back to zlib's crc32 function if present. These checksums are essentially the same, so having multiple implementations seems unnecessary. This replaces the CRC-32 implementation with the simpler one from JamCRC, and implements the JamCRC interface in terms of CRC-32 since this means it can use zlib's implementation when available, saving a few bytes and potentially making it faster. JamCRC took an ArrayRef<char> argument, and CRC-32 took a StringRef. This patch changes it to ArrayRef<uint8_t> which I think is the best choice, and simplifies a few of the callers nicely. Differential revision: https://reviews.llvm.org/D68570 llvm-svn: 374148
* Use lld-link instead of llvm-dlltool to create an implibRui Ueyama2019-10-091-1/+1
| | | | | | Suggested by Martin Storsjö. llvm-svn: 374142
* [lld] Don't create hints-section if Hint/Name Table is emptyRui Ueyama2019-10-093-1/+23
| | | | | | | | | | | Fixes assert in addLinkerModuleCoffGroup() when using by-ordinal imports only. Patch by Stefan Schmidt. Differential revision: https://reviews.llvm.org/D68352 llvm-svn: 374140
* [lld][Hexagon] Support PLT relocation R_HEX_B15_PCREL_X/R_HEX_B9_PCREL_XSid Manning2019-10-083-25/+157
| | | | | | | | These are sometimes generated by tail call optimizations. Differential Revision: https://reviews.llvm.org/D66542 llvm-svn: 374052
* Use /dev/null for tests that we do not need outputsRui Ueyama2019-10-081-8/+8
| | | | llvm-svn: 374023
* Report error if -export-dynamic is used with -rRui Ueyama2019-10-083-6/+6
| | | | | | | | | | | | | The combination of the two flags doesn't make sense. And other linkers seem to just ignore --export-dynamic if --relocatable is given, but we probably should report it as an error to let users know that is an invalid combination. Fixes https://bugs.llvm.org/show_bug.cgi?id=43552 Differential Revision: https://reviews.llvm.org/D68441 llvm-svn: 374022
* [ELF][MIPS] De-template writeValue. NFCFangrui Song2019-10-071-23/+20
| | | | | | Depends on D68561. llvm-svn: 373886
* [ELF] Wrap things in `namespace lld { namespace elf {`, NFCFangrui Song2019-10-0737-341/+439
| | | | | | | | | | | This makes it clear `ELF/**/*.cpp` files define things in the `lld::elf` namespace and simplifies `elf::foo` to `foo`. Reviewed By: atanasyan, grimar, ruiu Differential Revision: https://reviews.llvm.org/D68323 llvm-svn: 373885
* [ELF][MIPS] Use lld::elf::{read,write}* instead of ↵Fangrui Song2019-10-071-70/+68
| | | | | | | | | | | | | | llvm::support::endian::{read,write}* This allows us to delete `using namespace llvm::support::endian` and simplify D68323. This change adds runtime config->endianness check but the overhead should be negligible. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D68561 llvm-svn: 373884
* [LLD] [COFF] Always demangle the __imp_ prefix to __declspec(dllimport)Martin Storsjo2019-10-045-6/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D68017 llvm-svn: 373781
* Revert r371732: "lld-link: Fix tests that do not run on macOS after r371729."Martin Storsjo2019-10-041-1/+1
| | | | | | This commit should be reverted along with r371729. llvm-svn: 373713
* [ELF] Use union-find set and doubly linked list in Call-Chain Clustering ↵Fangrui Song2019-10-041-52/+62
| | | | | | | | | | | | | | | | | (C³) heuristic Before, SecToClusters[*] was used to track the belonged cluster. During a merge (From -> Into), every element of From has to be updated. Use a union-find set to speed up this use case. Also, replace `std::vector<int> Sections;` with a doubly-linked pointers: int Next, Prev; Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D46228 llvm-svn: 373708
* [MinGW] Add --reproduce optionRui Ueyama2019-10-043-0/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D68382 llvm-svn: 373705
* Add /reproduce option to lld/COFFRui Ueyama2019-10-043-6/+35
| | | | | | | | | | | This patch adds /reproduce:<path> option to lld/COFF. This is an lld-specific option, so we can name it freely. I chose /reproduce over other names (e.g. /lldlinkrepro) for consistency with other lld ports. Differential Revision: https://reviews.llvm.org/D68381 llvm-svn: 373704
* Revert r371729: lld-link: Make /linkrepro: take a filename, not a directory.Rui Ueyama2019-10-045-16/+13
| | | | | | | | | | This reverts commit r371729 because /linkrepro option also exists in Microsoft link.exe and their linker takes not a filename but a directory name as an argument for /linkrepro. Differential Revision: https://reviews.llvm.org/D68378 llvm-svn: 373703
* [llvm-objdump] Further rearrange llvm-objdump sections for compatabilityJordan Rupprecht2019-10-0341-233/+233
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: rL371826 rearranged some output from llvm-objdump for GNU objdump compatability, but there still seem to be some more. I think this rearrangement is a little closer. Overview of the ordering which matches GNU objdump: * Archive headers * File headers * Section headers * Symbol table * Dwarf debugging * Relocations (if `--disassemble` is not used) * Section contents * Disassembly Reviewers: jhenderson, justice_adams, grimar, ychen, espindola Reviewed By: jhenderson Subscribers: aprantl, emaste, arichardson, jrtc27, atanasyan, seiya, llvm-commits, MaskRay Tags: #llvm Differential Revision: https://reviews.llvm.org/D68066 llvm-svn: 373671
* [mips] Use llvm-readobj `-A` flag in test cases. NFCSimon Atanasyan2019-10-0336-72/+69
| | | | llvm-svn: 373589
* Add missing REQUIRES: arm.Peter Collingbourne2019-10-011-0/+1
| | | | llvm-svn: 373357
* ELF: Add .interp synthetic sections first in createSyntheticSections().Peter Collingbourne2019-10-015-13/+43
| | | | | | | | | | | | | | | | | | | | | | Our .interp section is not a SyntheticSection. As a result, it terminates the loop in removeUnusedSyntheticSections(). This has at least two consequences: - The synthetic .bss and .bss.rel.ro sections are always present in dynamically linked executables, even when they are not needed. - The synthetic .ARM.exidx (and possibly other) sections are always present in partitions other than the last one, even when not needed. .ARM.exidx in particular is problematic because it assumes that its list of code sections is non-empty in getLinkOrderDep(), which can lead to a crash if the partition does not have any code sections. Fix these problems by moving the creation of the .interp sections to the top of createSyntheticSections(). While here, make the code a little less error-prone by changing the add() lambdas to take a SyntheticSection instead of an InputSectionBase. Differential Revision: https://reviews.llvm.org/D68256 llvm-svn: 373347
* ELF: Don't merge SHF_LINK_ORDER sections for different output sections in ↵Peter Collingbourne2019-09-302-18/+78
| | | | | | | | | | | | | | | | | | | | | relocatable links. Merging SHF_LINK_ORDER sections can affect semantics if the sh_link fields point to different sections. Specifically, for SHF_LINK_ORDER sections, the sh_link field acts as a reverse dependency from the linked section, causing the SHF_LINK_ORDER section to be included if the linked section is included. Merging sections with different sh_link fields will cause the entire contents of the SHF_LINK_ORDER section to be associated with a single (arbitrarily chosen) output section, whereas the correct semantics are for the individual pieces of the SHF_LINK_ORDER section to be associated with their linked output sections. As a result we can end up incorrectly dropping SHF_LINK_ORDER section contents or including the wrong section contents, depending on which linked sections were chosen. Differential Revision: https://reviews.llvm.org/D68094 llvm-svn: 373255
* Revert "[MC] Emit unused undefined symbol even if its binding is not set"Nico Weber2019-09-302-6/+6
| | | | | | This reverts r373168. It caused PR43511. llvm-svn: 373242
* [ELF][test] Change llvm-readobj --arm-attributes to --arch-specific after ↵Fangrui Song2019-09-301-3/+3
| | | | | | r373125 llvm-svn: 373178
* [MC] Emit unused undefined symbol even if its binding is not setFangrui Song2019-09-292-6/+6
| | | | | | | | | | | | | | | | | | | | | | | For the following two cases, we currently suppress the symbols. This patch emits them (compatible with GNU as). * `test2_a = undef`: if `undef` is otherwise unused. * `.hidden hidden`: if `hidden` is unused. This is the main point of the patch, because omitting the symbol would cause a linker semantic difference. It causes a behavior change that is not compatible with GNU as: .weakref foo1, bar1 When neither foo1 nor bar1 is used, we now emit bar1, which is arguably more consistent. Another change is that we will emit .TOC. for .TOC.@tocbase . For this directive, suppressing .TOC. can be seen as a size optimization, but we choose to drop it for simplicity and consistency. llvm-svn: 373168
* [LLD] [test] Add a forgotten comment. NFC.Martin Storsjo2019-09-281-0/+2
| | | | | | | This was requested in https://reviews.llvm.org/D68014, but I forgot to add it before pushing the commit. llvm-svn: 373145
* [LLD] Simplify the demangleItanium function. NFC.Martin Storsjo2019-09-275-17/+9
| | | | | | | | | Instead of returning an optional, just return the input string if demangling fails, as that's what all callers use anyway. Differential Revision: https://reviews.llvm.org/D68015 llvm-svn: 373077
* [LLD] Convert demangleItanium to use the higher level llvm::demangle ↵Martin Storsjo2019-09-272-6/+9
| | | | | | | | | | | | | function. NFC. This avoids a few lines of boilerplate of dealing with C string allocations. Add a testcase for a case where demangling shouldn't happen. Differential Revision: https://reviews.llvm.org/D68014 llvm-svn: 373076
* [LLD] [COFF] Use the unified llvm demangle frontend function. NFC.Martin Storsjo2019-09-276-33/+26
| | | | | | | | Add test cases for some cases where we don't want demangling to happen. Differential Revision: https://reviews.llvm.org/D67301 llvm-svn: 373075
* [ELF] Set SectionBase::partition in processSectionCommandsFangrui Song2019-09-262-3/+12
| | | | | | | | | | | | | | | | | Fixes PR43461 (regression caused by D67504) The partition field of a SECTIONS-specified section is not set after D67504. The 0 value affects findSection() which checks if the partition field is 1. So `Out::initArray = findSection(".init_array")` is null, and DT_INIT_ARRAYSZ is not set. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D68087 llvm-svn: 372996
* [lld][mach-o] Avoid segfaulting when handling an empty section list.Matt Davis2019-09-262-6/+17
| | | | | | | | | | | | | | | | | Summary: The following patch avoids segfaulting if the section list is empty when writing a mach-o MH_OBJECT. I ran into this case from a more complicated example trying to dead_strip while using '-r' in lld. I'm not sure if having empty sections is a legal mach-o, but it does seem that other llvm-binutils tools can ingest such a boring object with out issue. Would it be better to emit an error, emit a warning, or do nothing? It seems that adding a warning diagnostic might be helpful to users, as I did not expect to have a section-less object when the linker was done. Reviewers: kledzik, ruiu Subscribers: llvm-commits, jrm Tags: #lld, #llvm Differential Revision: https://reviews.llvm.org/D67735 llvm-svn: 372995
* [mips] Relax jalr/jr instructions using R_MIPS_JALR relocationSimon Atanasyan2019-09-262-9/+65
| | | | | | | | | | | The R_MIPS_JALR relocation denotes jalr/jr instructions in position independent code. Both these instructions take a target's address from the $25 register. If offset to the target symbol fits into the 18-bits, it's more efficient to replace jalr/jr by bal/b instructions. Differential Revision: https://reviews.llvm.org/D68057 llvm-svn: 372951
* [LLD] Fix testcase from SVN r372843 if executed on windowsMartin Storsjo2019-09-251-2/+2
| | | | | | | This should fix buildbot errors like this one: http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/10997 llvm-svn: 372852
* [LLD] [COFF] Resolve source locations for undefined references using dwarfMartin Storsjo2019-09-256-4/+138
| | | | | | | | This fixes PR42407. Differential Revision: https://reviews.llvm.org/D67053 llvm-svn: 372843
* [ELF] Add -z separate-loadable-segments to complement separate-code and ↵Fangrui Song2019-09-256-14/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | noseparate-code D64906 allows PT_LOAD to have overlapping p_offset ranges. In the default R RX RW RW layout + -z noseparate-code case, we do not tail pad segments when transiting to another segment. This can save at most 3*maxPageSize bytes. a) Before D64906, we tail pad R, RX and the first RW. b) With -z separate-code, we tail pad R and RX, but not the first RW (RELRO). In some cases, b) saves one file page. In some cases, b) wastes one virtual memory page. The waste is a concern on Fuchsia. Because it uses compressed binaries, it doesn't benefit from the saved file page. This patch adds -z separate-loadable-segments to restore the behavior before D64906. It can affect section addresses and can thus be used as a debugging mechanism (see PR43214 and ld.so partition bug in crbug.com/998712). Reviewed By: jakehehrlich, ruiu Differential Revision: https://reviews.llvm.org/D67481 llvm-svn: 372807
* [ELF] accept thinlto options without --plugin-opt= prefixBob Haarman2019-09-257-22/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: When support for ThinLTO was first added to lld, the options that control it were prefixed with --plugin-opt= for compatibility with an existing implementation as a linker plugin. This change enables shorter versions of the options to be used, as follows: New Existing -thinlto-emit-imports-files --plugin-opt=thinlto-emit-imports-files -thinlto-index-only --plugin-opt=thinlto-index-only -thinlto-index-only= --plugin-opt=thinlto-index-only= -thinlto-object-suffix-replace= --plugin-opt=thinlto-object-suffix-replace= -thinlto-prefix-replace= --plugin-opt=thinlto-prefix-replace= -lto-obj-path= --plugin-opt=obj-path= The options with the --plugin-opt= prefix have been retained as aliases for the shorter variants so that they continue to be accepted. Reviewers: tejohnson, ruiu, espindola Reviewed By: ruiu Subscribers: emaste, arichardson, MaskRay, steven_wu, dexonsmith, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67782 llvm-svn: 372798
* [ELF][ARM] Fix crash when discarding InputSections that have .ARM.exidxPeter Smith2019-09-244-10/+38
| | | | | | | | | | | | When /DISCARD/ is used on an input section, that input section may have a .ARM.exidx metadata section that depends on it. As the discard handling comes after the .ARM.exidx synthetic section is created we need to make sure that we account for the case where the .ARM.exidx output section should be removed because there are no more live input sections. Differential Revision: https://reviews.llvm.org/D67848 llvm-svn: 372781
* [lld][WebAssembly] Fix static linking of -fPIC code with external undefined ↵Sam Clegg2019-09-247-34/+68
| | | | | | | | functions Differential Revision: https://reviews.llvm.org/D66784 llvm-svn: 372779
* [NFC][COFF] fix typo in comment ("algortihm" -> "algorithm")Bob Haarman2019-09-241-1/+1
| | | | llvm-svn: 372776
* [LLD][ELF][MIPS] - Inline the short helper function. NFC.George Rimar2019-09-241-10/+8
| | | | | | It was requested in a post-commit comment for r372570. llvm-svn: 372747
* [ELF] Delete SectionBase::assignedFangrui Song2019-09-242-22/+9
| | | | | | | | | | | | | D67504 removed uses of `assigned` from OutputSection::addSection, which makes `assigned` purely used in processSectionCommands() and its callees. By replacing its references with `parent`, we can remove `assigned`. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D67531 llvm-svn: 372735
* [ELF] Make MergeInputSection merging aware of output sectionsFangrui Song2019-09-2412-152/+207
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes PR38748 mergeSections() calls getOutputSectionName() to get output section names. Two MergeInputSections may be merged even if they are made different by SECTIONS commands. This patch moves mergeSections() after processSectionCommands() and addOrphanSections() to fix the issue. The new pass is renamed to OutputSection::finalizeInputSections(). processSectionCommands() and addorphanSections() are changed to add sections to InputSectionDescription::sectionBases. finalizeInputSections() merges MergeInputSections and migrates `sectionBases` to `sections`. For the -r case, we drop an optimization that tries keeping sh_entsize non-zero. This is for the simplicity of addOrphanSections(). The updated merge-entsize2.s reflects the change. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D67504 llvm-svn: 372734
* [lld][WebAssembly] Preserve symbol flags in --relocatable outputSam Clegg2019-09-235-28/+14
| | | | | | | | Fixes https://github.com/emscripten-core/emscripten/issues/8879 Differential Revision: https://reviews.llvm.org/D67729 llvm-svn: 372660
* [mips] Support elf32btsmipn32_fbsd / elf32ltsmipn32_fbsd emulationsSimon Atanasyan2019-09-232-1/+8
| | | | | | Patch by Kyle Evans. llvm-svn: 372651
* [mips] Add tests to check MIPS FreeBSD emulations. NFCSimon Atanasyan2019-09-231-0/+36
| | | | llvm-svn: 372650
* [mips] Reformat test case to simplify addition new tests. NFCSimon Atanasyan2019-09-231-27/+48
| | | | llvm-svn: 372649
* [LLD][ELF] - Simplify getFlagsFromEmulation(). NFCI.George Rimar2019-09-231-12/+2
| | | | | | A straightforward simplification. llvm-svn: 372570
* [mips] Deduce MIPS specific ELF header flags from `emulation`Simon Atanasyan2019-09-222-1/+44
| | | | | | | | | In case of linking binary blobs which do not have any ELF headers, we can deduce MIPS ABI ELF header flags from an `emulation` option. Patch by Kyle Evans. llvm-svn: 372513
* [ELF] Error if the linked-to section of a SHF_LINK_ORDER section is discardedFangrui Song2019-09-202-4/+51
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: If st_link(A)=B, and A has the SHF_LINK_ORDER flag, we may dereference a null pointer if B is garbage collected (PR43147): 1. In Wrter.cpp:compareByFilePosition, `aOut->sectionIndex` or `bOut->sectionIndex` 2. In OutputSections::finalize, `d->getParent()->sectionIndex` Simply error and bail out to avoid null pointer dereferences. ld.bfd has a similar error: sh_link of section `.bar' points to discarded section `.foo0' of `a.o' ld.bfd is more permissive in that it just checks whether the linked-to section of the first input section is discarded. This is likely because it sets sh_link of the output section according to the first input section. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D67761 llvm-svn: 372400
OpenPOWER on IntegriCloud