aboutsummaryrefslogtreecommitdiff
path: root/lld
AgeCommit message (Collapse)AuthorFilesLines
2020-09-15Revert "[DebugInfo] Remove dots from getFilenameByIndex return value"Petr Hosek4-13/+13
This is failing on Windows bots due to path separator normalization. This reverts commit 042c23506869b4ae9a49d2c4bc5ea6e6baeabe78.
2020-09-15[LLD][PowerPC] Add support for R_PPC64_TPREL34 used in TLS Local ExecStefan Pintilie2-1/+59
Add Thread Local Storage Local Exec support to LLD. This is to support PC Relative addressing of Local Exec. The patch teaches LLD to handle: ``` paddi r9, r13, x1@tprel ``` The relocation is: ``` R_PPC_TPREL34 ``` Reviewed By: NeHuang, MaskRay Differential Revision: https://reviews.llvm.org/D86608
2020-09-15[lld][WebAssembly] Fix --export-all when __stack_pointer is presentSam Clegg3-17/+63
With https://reviews.llvm.org/D87537 we made it an error to import or export a mutable global with the +mutable-globals feature present. However the scan was of the entire symbol table rather than just the imports or exports and the filter didn't match exaclyt meaning the `__stack_pointer` (a mutable global) was always triggering with error when the `--export-all` flag was used. This also revealed that we didn't have any test coverage for the `--export-all` flag. This change fixes the current breakage on the emscripten-releases roller. Differential Revision: https://reviews.llvm.org/D87663
2020-09-15[NFC][DebugInfo] Use consistent regex group spellingPetr Hosek2-5/+5
This is a follow up to c1f2fb5184ca.
2020-09-15[lib/Object] - Refine interface of ELFFile<ELFT>. NFCI.Georgii Rymar10-29/+29
`ELFFile<ELFT>` has many methods that take pointers, though they assume that arguments are never null and hence could take references instead. This patch performs such clean-up. Differential revision: https://reviews.llvm.org/D87385
2020-09-15[DebugInfo] Support both forward and backward slashes in testsPetr Hosek4-13/+13
This addresses test failure revealed by 042c23506869.
2020-09-15[LLD] Allow configuring default ld.lld backendMateusz Mikuła2-0/+11
The motivation for this is ld.lld --help targeting MinGW which currently prints help for the ELF backend unless -m i386pe{,p} is added. This confuses build systems that grep through linker help to find supported flags. This matches LD from Binutils which always prints help for MinGW when configured to target it. After this change, the backend can still be overridden to any supported ELF/MinGW target by using correct -m <arch>. Differential Revision: https://reviews.llvm.org/D87418
2020-09-14[lld][WebAssembly] Allow globals imports via import_name/import_moduleSam Clegg2-4/+9
This feature already exists but was limited to function symbols. Differential Revision: https://reviews.llvm.org/D87666
2020-09-14[ELF] Add documentation for --warn-backrefs: a GNU ld compatibility checking ↵Fangrui Song2-0/+100
tool (and lesser of layering detection) Differential Revision: https://reviews.llvm.org/D86762
2020-09-14[ELF] Define a reportRangeError() overload for thunks and tidy up recent ↵Fangrui Song4-4/+21
PPC64 thunk range errors Prefer `errorOrWarn` to `fatal` for recoverable errors and graceful degradation when --noinhibit-exec is specified. Mention the destination symbol, otherwise the diagnostic is not really actionable. Two errors are not tested but the patch does not intend to add the coverage. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D87486
2020-09-12[lld][WebAssembly] Add initial support for -Map/--print-mapSam Clegg14-10/+268
Differential Revision: https://reviews.llvm.org/D77187
2020-09-12[lld][WebAssembly] Error on import/export of mutable global without ↵Sam Clegg7-9/+45
`mutable-globals` feature Also add the +mutable-globals features in clang when building with `-fPIC` since the linker will generate mutable globals imports and exports in that case. Differential Revision: https://reviews.llvm.org/D87537
2020-09-11[lld][WebAssembly] Convert a objyaml-using test to assemblySam Clegg4-144/+98
Differential Revision: https://reviews.llvm.org/D87536
2020-09-11[WebAssembly] Add assembly syntax for mutable globalsSam Clegg1-3/+13
This adds and optional ", immutable" to the end of a `.globaltype` declaration. I would have prefered to match the `.wat` syntax where immutable is the default and `mut` is the signifier for mutable globals. Sadly changing the default would break backwards compat with existing assembly in the wild so I think its best to stick with this approach. Differential Revision: https://reviews.llvm.org/D87515
2020-09-11[ELF][PowerPC] Define NOP as 0x60000000 to tidy up code. NFCFangrui Song1-12/+14
Reviewed By: nemanjai Differential Revision: https://reviews.llvm.org/D87483
2020-09-10[ELF] Make two PPC64.cpp variables constexpr. NFCFangrui Song1-2/+2
Why are they mutable? :)
2020-09-09[lit] Use correct variable name for libxml2Petr Hosek1-1/+1
This addresses an issue introduced in c4d7536136b3.
2020-09-09[CMake] Simplify CMake handling for libxml2Petr Hosek3-4/+4
This matches the changes made to handling of zlib done in 10b1b4a where we rely on find_package and the imported target rather than manually appending the library and include paths. The use of LLVM_LIBXML2_ENABLED has been replaced by LLVM_ENABLE_LIBXML2 thus reducing the number of variables. Differential Revision: https://reviews.llvm.org/D84563
2020-09-08[LLD][ELF] Fix performance of MarkLive::scanEhFrameSectionAndrew Ng1-3/+3
MarkLive::scanEhFrameSection is used to retain personality/LSDA functions when --gc-sections is enabled. Improve its performance by only iterating over the .eh_frame relocations that need to be resolved for an EhSectionPiece. This optimization makes the same assumption as elsewhere in LLD that the .eh_frame relocations are sorted by r_offset. This appears to be a performance regression introduced in commit e6c24299d237 (https://reviews.llvm.org/D59800). This change has been seen to reduce link time by up to ~50%. Differential Revision: https://reviews.llvm.org/D87245
2020-09-08[CMake] Remove dead FindPythonInterp codeRaul Tambre1-29/+10
LLVM has bumped the minimum required CMake version to 3.13.4, so this has become dead code. Reviewed By: #libc, ldionne Differential Revision: https://reviews.llvm.org/D87189
2020-09-07[ELF] --symbol-ordering-file: optimize a loopFangrui Song1-3/+5
2020-09-05[ELF] Handle SHT_RISCV_ATTRIBUTES similarly to SHT_ARM_ATTRIBUTESJessica Clarke3-16/+72
Currently we treat SHT_RISCV_ATTRIBUTES like a normal section and concatenate all such input sections, yielding invalid output unless only a single attributes section is present in the input. Instead, pick the first as with SHT_ARM_ATTRIBUTES. We do not currently need to condition our behaviour on the contents, unlike Arm. In future, we should both do stricter validation of the input and merge all sections together to ensure we have, for example, the full arch string requirement, but this rudimentary implementation is good enough for most common cases. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D86309
2020-09-04[lld] Test corrections after 3f1a9b7eca0 added segment names to objdump outputDaniel Sanders8-15/+15
2020-09-03[LLD][PowerPC][test] Fix out-of-memory issue running ↵Victor Huang1-10/+11
ppc64-pcrel-long-branch-error.s Following 97febb1, fix the out-of-memory error associated with buffering the output in-memory by writing to an allocated file with the minimum offset and running it on ppc system-linux only. Peer reviewed by: nemanjai
2020-09-02Add code owners of new MachO portGreg McGary1-1/+5
2020-08-31[LLD] [COFF] Error out if creating a DLL with too many exported symbolsMartin Storsjö3-2/+24
The PE/DLL format has a limit on 64k exported symbols per DLL; make sure to check this. Differential Revision: https://reviews.llvm.org/D86701
2020-08-29[LLD][PowerPC][test] Disable ELF/ppc64-pcrel-long-branch-error.sHubert Tong1-0/+4
Following 0becc27ebfec, `ppc64-pcrel-long-branch-error.s` fails in some environments with out-of-memory errors associated with buffering the output in-memory. Since the alternative of writing to an allocated file is also known to cause problems, we will disable the test unconditionally (pending a mechanism to disable the test selectively).
2020-08-28[LLD][PowerPC] Remove redundant file write out in the test casesVictor Huang2-6/+6
Fix the time out test failure on lld-x86_64-freebsd build bot. Peer reviewed by: stefanp, nemanjai
2020-08-28[LLD][PowerPC] Add a pc-rel based long branch thunkVictor Huang3-5/+136
In this patch, a pc-rel based long branch thunk is added for the local call protocol that caller and callee does not use TOC. Reviewed By: sfertile, nemanjai Differential Revision: https://reviews.llvm.org/D86706
2020-08-27[lld-macho][NFC] Define isHidden() in LinkEditSectionJez Ng2-28/+9
Since it's always true Reviewed By: #lld-macho, smeenai Differential Revision: https://reviews.llvm.org/D86749
2020-08-27[lld-macho] Weak locals should be relaxed tooJez Ng4-4/+22
Reviewed By: #lld-macho, smeenai Differential Revision: https://reviews.llvm.org/D86746
2020-08-27[lld-macho] Support GOT relocations to __dso_handleJez Ng2-3/+10
Found such a relocation while testing some real world programs. Reviewed By: #lld-macho, smeenai Differential Revision: https://reviews.llvm.org/D86642
2020-08-27[lld-macho] Implement GOT_LOAD relaxationJez Ng3-5/+41
We can have GOT_LOAD relocations that reference `__dso_handle`. However, our binding opcode encoder doesn't support binding to the DSOHandle symbol. Instead of adding support for that, I decided it would be cleaner to implement GOT_LOAD relaxation since `__dso_handle`'s location is always statically known. Reviewed By: #lld-macho, smeenai Differential Revision: https://reviews.llvm.org/D86641
2020-08-27[lld-macho] Emit binding opcodes for defined symbols that override weak dysymsJez Ng7-16/+137
These opcodes tell dyld to coalesce the overridden weak dysyms to this particular symbol definition. Reviewed By: #lld-macho, smeenai Differential Revision: https://reviews.llvm.org/D86575
2020-08-27[lld-macho] Emit the right header flags for weak bindings/symbolsJez Ng4-7/+55
Reviewed By: #lld-macho, smeenai Differential Revision: https://reviews.llvm.org/D86574
2020-08-27[lld-macho] Implement weak binding for branch relocationsJez Ng8-67/+143
Since there is no "weak lazy" lookup, function calls to weak symbols are always non-lazily bound. We emit both regular non-lazy bindings as well as weak bindings, in order that the weak bindings may overwrite the non-lazy bindings if an appropriate symbol is found at runtime. However, the bound addresses will still be written (non-lazily) into the LazyPointerSection. Reviewed By: #lld-macho, smeenai Differential Revision: https://reviews.llvm.org/D86573
2020-08-27[lld-macho] Disable invalid/stub-link.s test for MacJez Ng2-1/+4
It seems to be failing on some Google Buildbots. This diff also includes a minor fix for the install name of one of libSystem's re-exports. I don't think it's the cause of the test failure, though. The wrong install name just meant that the symbol lookup failure would still happen, but it would have been caused by the re-export not being found, instead of the arch failing to match. Differential Revision: https://reviews.llvm.org/D86728
2020-08-27[LLD] [COFF] Check the aux section definition size for ↵Martin Storsjö5-8/+107
IMAGE_COMDAT_SELECT_SAME_SIZE Binutils generated sections seem to be padded to a multiple of 16 bytes, but the aux section definition contains the original, unpadded section length. The size check used for IMAGE_COMDAT_SELECT_SAME_SIZE previously only checked the size of the section itself. When checking the currently processed object file against the previously chosen comdat section, we easily have access to the aux section definition of the currently processed section, but we have to iterate over the symbols of the previously selected object file to find the section definition of the previously picked section. (We don't want to inflate SectionChunk to carry more data, for something that is only needed in corner cases.) Only do this when the mingw flag is set. This fixes statically linking clang-built C++ object files against libstdc++ built with GCC, if the object files contain e.g. typeinfo. Differential Revision: https://reviews.llvm.org/D86659
2020-08-27[LLD] [MinGW] Enable dynamicbase by defaultMartin Storsjö3-10/+15
This matches lld-link's own default. Add a new command line option --no-dynamicbase for disabling it. (Unfortunately, GNU ld doesn't yet have a matching --no-dynamicbase option, as that's the default there.) Differential Revision: https://reviews.llvm.org/D86654
2020-08-27[ELF][test] Add test coverage of TLS to gc-sections.sAndrew Ng1-2/+37
Differential Revision: https://reviews.llvm.org/D86639
2020-08-27[lld][ELF][test] Expand testing of symbols in mergeable sectionsJames Henderson2-10/+47
Whilst reviewing some internal testing, I noticed a couple of holes in coverage of mergeable sections containing symbols. This patch addresses these holes: 1) Show that mid-piece symbols have their values updated properly when pieces are merged. 2) Show the behaviour of symbols in mergeable pieces when --gc-sections is enabled. Reviewed by: grimar, MaskRay Differential Revision: https://reviews.llvm.org/D86543
2020-08-26[lld-macho] Fix objc.s testJez Ng1-1/+1
Summary: It was passing on my local machine due to previously-written files cached in the test output folder.
2020-08-26[lld-macho] Implement -all_loadJez Ng3-2/+15
Differential Revision: https://reviews.llvm.org/D86640
2020-08-26[lld-macho] Implement weak bindings for GOT/TLVJez Ng8-55/+276
Previously, we were only emitting regular bindings to weak dynamic symbols; this diff adds support for the weak bindings too, which can overwrite the regular bindings at runtime. We also treat weak defined global symbols similarly -- since they can also be interposed at runtime, they need to be treated as potentially dynamic symbols. Note that weak bindings differ from regular bindings in that they do not specify the dylib to do the lookup in (i.e. weak symbol lookup happens in a flat namespace.) Differential Revision: https://reviews.llvm.org/D86572
2020-08-26[lld-macho][NFC] Handle GOT bindings and regular bindings more uniformlyJez Ng6-73/+81
Previously, the BindingEntry struct could only store bindings to offsets within InputSections. Since the GOTSection and TLVPointerSections are OutputSections, I handled those in a separate code path. However, this makes it awkward to support weak bindings properly without code duplication. This diff allows BindingEntries to point directly to OutputSections, simplifying the upcoming weak binding implementation. Along the way, I also converted a bunch of functions taking references to symbols to take pointers instead. Given how much casting we do for Symbol (especially in the upcoming weak binding diffs), it's cleaner this way. Differential Revision: https://reviews.llvm.org/D86571
2020-08-26[lld-macho] Implement -ObjCJez Ng8-30/+187
It's roughly like -force_load with some filtering. Differential Revision: https://reviews.llvm.org/D86181
2020-08-26[lld-macho] Handle TAPI and regular re-exports uniformlyJez Ng13-25/+212
The re-exports list in a TAPI document can either refer to other inlined TAPI documents, or to on-disk files (which may themselves be TBD or regular files.) Similarly, the re-exports of a regular dylib can refer to a TBD file. Differential Revision: https://reviews.llvm.org/D85404
2020-08-26[lld-macho] Make it possible to re-export .tbd filesJez Ng5-8/+39
Two things needed fixing for that to work: 1. getName() no longer returns null for DylibFiles constructed from TAPIs 2. markSubLibrary() now accepts .tbd as a possible extension Differential Revision: https://reviews.llvm.org/D86180
2020-08-26[lld-macho] Fall back to raw path if we don't find anything under syslibrootJez Ng2-11/+17
This matches ld64's behavior Differential Revision: https://reviews.llvm.org/D85992
2020-08-26[LLD][MinGW] Handle allow-multiple-definition flagMateusz Mikuła3-0/+15
Basically copied from ELF driver. Differential Revision: https://reviews.llvm.org/D86512