summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] Handle elf32-littlearm in OUTPUT_FORMATShoaib Meenai2018-10-222-1/+32
| | | | | | | | | We need this to support 32-bit ARM. Add test cases for emulation handling for this architecture as well. Differential Revision: https://reviews.llvm.org/D53539 llvm-svn: 344976
* [ELF] Don't warn on two legitimate cases when reading .llvm.call-graph-profileFangrui Song2018-10-223-19/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Before, superfluous warnings were emitted for the following two cases: 1) When from symbol was in a discarded section. The profile should be thought of as affiliated to the section. It makes sense to ignore the profile if the section is discarded. 2) When to symbol was in a shared object. The object file containing the profile may not know about the to symbol, which can reside in another object file (useful profile) or a shared object (not useful as symbols in the shared object are fixed and unorderable). It makes sense to ignore the profile from the object file. Note, the warning when to symbol was undefined was suppressed in D53044, which is still useful for --symbol-ordering-file= This patch silences the warnings. The check is actually more relaxed (no warnings if either From or To is not Defined) for simplicity and I don't see a compelling reason to warn on more cases. Reviewers: ruiu, davidxl, espindola, Bigcheese Reviewed By: ruiu Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D53470 llvm-svn: 344974
* Add OUTPUT_FORMAT linker script directive support.Rui Ueyama2018-10-225-12/+56
| | | | | | | | | | | | | | | | | | | | | | This patch adds a support for OUTPUT_FORMAT linker script directive. Since I'm not 100% confident with BFD names you can use in the directive for all architectures, I added only a few in this patch. We can add other names for other archtiectures later. We still do not support triple-style OUTPUT_FORMAT directive, namely, OUTPUT_FORMAT(bfdname, big, little). If you pass -EL (little endian) or -EB (big endian) to the linker, GNU linkers pick up big or little as a BFD name, correspondingly, so that you can use a single linker script for bi-endian processor. I'm not sure if we really need to support that, so I'll leave it alone for now. Note that -m takes precedence over OUTPUT_FORAMT, but we always parse a BFD name given to OUTPUT_FORMAT for error checking. You cannot write an invalid name in the OUTPUT_FORMAT directive. Differential Revision: https://reviews.llvm.org/D53495 llvm-svn: 344952
* [ELF][PPC64] Fix a split-stack comment in rLLD344622Fangrui Song2018-10-221-1/+1
| | | | | | The blt- instruction (predicted not to be taken) uses cr7, not the default cr0. llvm-svn: 344948
* [ELF] Format PPC64.cpp, NFCFangrui Song2018-10-221-12/+10
| | | | | | Mainly two mis-indented places. The changes are local so should not interfere with in-review revisions llvm-svn: 344932
* Fix typo in a test file name.Rui Ueyama2018-10-221-0/+0
| | | | llvm-svn: 344899
* Use llvm::arrayRefFromStringRefSam Clegg2018-10-223-5/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D53432 llvm-svn: 344888
* [WebAssembly] Simplify --help messageSam Clegg2018-10-221-9/+7
| | | | | | | | Update wasm to match ELF changes made rL333596. Differential Revision: https://reviews.llvm.org/D53421 llvm-svn: 344887
* Add an addAbsolute static function to Writer.cppAlexander Richardson2018-10-201-8/+8
| | | | | | | | | | | | | | | | | Summary: SymbolTable::addAbsolute() was removed in rL344305. To me this is more readable than the lambda named `Add` and in our out-of-tree CHERI target we use addAbsolute() in another function. Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: kristina, emaste, llvm-commits Differential Revision: https://reviews.llvm.org/D53393 llvm-svn: 344842
* [COFF] Fix error handling on duplicates for import library symbolsMartin Storsjo2018-10-192-0/+47
| | | | | | | | | Normally one wouldn't run into that case, but it is possible with a little creative ordering of special libraries. Differential Revision: https://reviews.llvm.org/D53388 llvm-svn: 344776
* [PPC64] Fix offset checks on rel24 call relocations.Sean Fertile2018-10-182-1/+68
| | | | | | | | | | | | Adjusted the range check on a call instruction from 24 bits signed to 26 bits signed. While the instruction only encodes 24 bits, the target is assumed to be 4 byte aligned, and the value that is encoded in the instruction gets shifted left by 2 to form the offset. Also added a check that the offset is indeed at least 4 byte aligned. Differential Revision: https://reviews.llvm.org/D53401 llvm-svn: 344747
* [NewPM] teach -passes= to emit meaningful error messagesFedor Sergeev2018-10-171-2/+2
| | | | | | | | | | | | | | All the PassBuilder::parse interfaces now return descriptive StringError instead of a plain bool. It allows to make -passes/aa-pipeline parsing errors context-specific and thus less confusing. TODO: ideally we should also make suggestions for misspelled pass names, but that requires some extensions to PassBuilder. Reviewed By: philip.pfaffe, chandlerc Differential Revision: https://reviews.llvm.org/D53246 llvm-svn: 344685
* Reland "[PPC64] Add split - stack support."Sean Fertile2018-10-1613-12/+601
| | | | | | | | | | | | | | Recommitting https://reviews.llvm.org/rL344544 after fixing undefined behavior from left-shifting a negative value. Original commit message: This support is slightly different then the X86_64 implementation in that calls to __morestack don't need to get rewritten to calls to __moresatck_non_split when a split-stack caller calls a non-split-stack callee. Instead the size of the stack frame requested by the caller is adjusted prior to the call to __morestack. The size the stack-frame will be adjusted by is tune-able through a new --split-stack-adjust-size option. llvm-svn: 344622
* Revert "[PPC64] Add split - stack support."Sean Fertile2018-10-1513-601/+12
| | | | | | | | This reverts commit https://reviews.llvm.org/rL344544, which causes failures on a undefined behaviour sanitizer bot --> lld/ELF/Arch/PPC64.cpp:849:35: runtime error: left shift of negative value -1 llvm-svn: 344551
* [PPC64] Add split - stack support.Sean Fertile2018-10-1513-12/+601
| | | | | | | | | | | | | This support is slightly different then the X86_64 implementation in that calls to __morestack don't need to get rewritten to calls to __moresatck_non_split when a split-stack caller calls a non-split-stack callee. Instead the size of the stack frame requested by the caller is adjusted prior to the call to __morestack. The size the stack-frame will be adjusted by is tune-able through a new --split-stack-adjust-size option. Differential Revision: https://reviews.llvm.org/D52099 llvm-svn: 344544
* [ELF][HEXAGON] Let input determine e_flag.Sid Manning2018-10-152-2/+20
| | | | | | Differential Revision: https://reviews.llvm.org/D53204 llvm-svn: 344518
* [LLD][ELF] - Check options before processing the -v/-version options.George Rimar2018-10-152-7/+11
| | | | | | | | | | | | | | | This is https://bugs.llvm.org/show_bug.cgi?id=39289. Currently both gold and bfd report errors about invalid options values even with -v/-versions. But LLD does not. This makes complicated to check the options available when LLD is used. Patch makes LLD behavior to be consistent with GNU linkers. Differential revision: https://reviews.llvm.org/D53278 llvm-svn: 344514
* Simplify. NFC.Rui Ueyama2018-10-121-11/+8
| | | | | | | | - Removed redundant `llvm::` - Typedef a long type name - Initialize members by member initializers llvm-svn: 344427
* Remove `Type` parameter from SymbolTable::insert(). NFC.Rui Ueyama2018-10-125-20/+37
| | | | | | | | | `Type` parameter was used only to check for TLS attribute mismatch, but we can do that when we actually replace symbols, so we don't need to type as an argument. This change should simplify the interface of the symbol table a bit. llvm-svn: 344394
* Better support for POSIX paths in PDBs.Zachary Turner2018-10-123-33/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This a resubmission of a patch which was previously reverted due to breaking several lld tests. The issues causing those failures have been fixed, so the patch is now resubmitted. ---Original Commit Message--- While it doesn't make a *ton* of sense for POSIX paths to be in PDBs, it's possible to occur in real scenarios involving cross compilation. The tools need to be able to handle this, because certain types of debugging scenarios are possible without a running process and so don't necessarily require you to be on a Windows system. These include post-mortem debugging and binary forensics (e.g. using a debugger to disassemble functions and examine symbols without running the process). There's changes in clang, LLD, and lldb in this patch. After this the cross-platform disassembly and source-list tests pass on Linux. Furthermore, the behavior of LLD can now be summarized by a much simpler rule than before: Unless you specify /pdbsourcepath and /pdbaltpath, the PDB ends up with paths that are valid within the context of the machine that the link is performed on. Differential Revision: https://reviews.llvm.org/D53149 llvm-svn: 344377
* [lld] Add more complete support for the INCLUDE command.Rui Ueyama2018-10-124-5/+98
| | | | | | | | | | | | | Patch by Ian Tessier. This change adds INCLUDE support to the MEMORY and SECTION commands, and to output sections, as per: https://sourceware.org/binutils/docs/ld/File-Commands.html#File-Commands Differential Revision: https://reviews.llvm.org/D52951 llvm-svn: 344368
* Make YAML quote forward slashes.Zachary Turner2018-10-124-7/+7
| | | | | | | | | | | | | | | | | If you have the string /usr/bin, prior to this patch it would not be quoted by our YAML serializer. But a string like C:\src would be, due to the presence of a backslash. This makes the quoting rules of basically every single file path different depending on the path syntax (posix vs. Windows). While technically not required by the YAML specification to quote forward slashes, when the behavior of paths is inconsistent it makes it difficult to portably write FileCheck lines that will work with either kind of path. Differential Revision: https://reviews.llvm.org/D53169 llvm-svn: 344359
* Revert "Make YAML quote forward slashes."Zachary Turner2018-10-124-7/+7
| | | | | | | | | | This reverts commit b86c16ad8c97dadc1f529da72a5bb74e9eaed344. This is being reverted because I forgot to write a useful commit message, so I'm going to resubmit it with an actual commit message. llvm-svn: 344358
* Make YAML quote forward slashes.Zachary Turner2018-10-124-7/+7
| | | | llvm-svn: 344357
* [ELF] - Remove unused variable. NFC.George Rimar2018-10-121-2/+0
| | | | | | | It triggered a bot failture somehow today: http://lab.llvm.org:8011/builders/lld-perf-testsuite/builds/7993 llvm-svn: 344344
* [ELF] - Remove dead declaration. NFC.George Rimar2018-10-121-2/+0
| | | | | | | MipsGotSection::FileGot::isOverflow() was a dead declararion. llvm-svn: 344342
* Remove SymbolTable::addAbsolute().Rui Ueyama2018-10-113-14/+8
| | | | | | addAbsolute() could be implemented as a non-member function. llvm-svn: 344305
* Remove `else` after `return`.Rui Ueyama2018-10-111-2/+1
| | | | llvm-svn: 344302
* [ELF] Fix link failure with Android compressed relocation support.Eli Friedman2018-10-112-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Android uses a compressed relocation format, which means the size of the relocation section isn't predictable based on the number of relocations, and can vary if the layout changes in any way. To deal with this, the linker normally runs multiple passes until the layout converges. The layout should converge if the size of the compressed relocation section increases monotonically: if the size of an encoded offset increases by one byte, the larget value which can be encoded is multiplied by 128, so the representable offsets grow much faster than the size of the section itself. The problem here is that there is no code to ensure the size of the section doesn't decrease. If the size of the relocation section decreases, the relative offsets can increase due to alignment restrictions, so that can force the size of the relocation section to increase again. The end result is an infinite loop; the loop gets cut off after 10 iterations with the message "thunk creation not converged". To avoid this issue, this patch adds padding to the end of the relocation section if its size would decrease. The extra padding is harmless because of the way the format is defined: decoding stops after it reaches the number of relocations specified in the section's header. Differential Revision: https://reviews.llvm.org/D53003 llvm-svn: 344300
* Rename SymbolTable::addRegular -> SymbolTable::addDefined.Rui Ueyama2018-10-114-9/+9
| | | | | | | We have addAbsolute, addBitcode, addCommon, etc. addRegular looked a bit inconsistent. llvm-svn: 344294
* Remove unused default arguments.Rui Ueyama2018-10-111-3/+1
| | | | llvm-svn: 344292
* Remove SymbolTable::addUndefined<ELF32LE>(StringRef).Rui Ueyama2018-10-113-16/+10
| | | | | | Because we can implement the function as a non-member function. llvm-svn: 344290
* Revert SymbolFileNativePDB plugin.Zachary Turner2018-10-111-13/+18
| | | | | | | | | This was originally causing some test failures on non-Windows platforms, which required fixes in the compiler and linker. After those fixes, however, other tests started failing. Reverting temporarily until I can address everything. llvm-svn: 344279
* Better support for POSIX paths in PDBs.Zachary Turner2018-10-111-18/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | While it doesn't make a *ton* of sense for POSIX paths to be in PDBs, it's possible to occur in real scenarios involving cross compilation. The tools need to be able to handle this, because certain types of debugging scenarios are possible without a running process and so don't necessarily require you to be on a Windows system. These include post-mortem debugging and binary forensics (e.g. using a debugger to disassemble functions and examine symbols without running the process). There's changes in clang, LLD, and lldb in this patch. After this the cross-platform disassembly and source-list tests pass on Linux. Furthermore, the behavior of LLD can now be summarized by a much simpler rule than before: Unless you specify /pdbsourcepath and /pdbaltpath, the PDB ends up with paths that are valid within the context of the machine that the link is performed on. Differential Revision: https://reviews.llvm.org/D53149 llvm-svn: 344269
* [COFF] Add and use a Wordsize field in Config. NFCI.Martin Storsjo2018-10-116-19/+18
| | | | | | Differential Revision: https://reviews.llvm.org/D53143 llvm-svn: 344265
* [COFF] Set proper pointer size alignment for LocalImportChunkMartin Storsjo2018-10-112-1/+27
| | | | | | | | | | | When these are accessed with load/store instructions on ARM64, it becomes strictly necessary to have them properly aligned. This fixes PR39228. Differential Revision: https://reviews.llvm.org/D53128 llvm-svn: 344264
* [ELF] - Set sh_info and sh_link for .rela.plt sections.George Rimar2018-10-115-10/+18
| | | | | | | | | | | | | | | | | | | | This is https://bugs.llvm.org/show_bug.cgi?id=37538, Currently, LLD may set both sh_link and sh_info for .rela.plt section to zero when we have only .rela.iplt section part used. ELF spec (https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-94076/index.html) says that for SHT_REL and SHT_RELA, sh_link references the associated symbol table and sh_info the "section to which the relocation applies." When we set the sh_link field, for the regular case we use the .dynsym index. For .rela.iplt sections, it is unclear what is the associated symbol table, because R_*_RELATIVE relocations do not use symbol names and we might have no .dynsym section at all so this patch uses .symtab section index. Differential revision: https://reviews.llvm.org/D52830 llvm-svn: 344226
* Eliminate dependency to formatv(). NFC.Fangrui Song2018-10-111-3/+3
| | | | llvm-svn: 344212
* Make a member function private and rename it to avoid function overloading.Rui Ueyama2018-10-102-5/+6
| | | | llvm-svn: 344196
* [ELF] Don't warn on undefined symbols if UnresolvedPolicy::Ignore is usedFangrui Song2018-10-103-8/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add a condition UnresolvedPolicy::Ignore to elf::warnUnorderedSymbol to suppress Sym->isUndefined() warnings from both 1) --symbol-ordering-file= 2) .llvm.call-graph-profile If --unresolved-symbols=ignore-all is used, no "undefined symbol" error/warning is emitted. It makes sense to not warn unorderable symbols. Otherwise, If an executable is linked, the default policy UnresolvedPolicy::ErrorOrWarn will issue a "undefined symbol" error. The unorderable symbol warning is redundant. If a shared object is linked, it is possible that only part of object files are used and some symbols are left undefined. The warning is not very necessary. In particular for .llvm.call-graph-profile, when linking a shared object, a call graph profile may contain undefined symbols. This case generated a warning before but it will be suppressed by this patch. Reviewers: ruiu, davidxl, espindola Reviewed By: ruiu Subscribers: grimar, emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D53044 llvm-svn: 344195
* Eliminate dependency to formatv(). NFC.Rui Ueyama2018-10-103-11/+9
| | | | llvm-svn: 344177
* [COFF] Look for libfoo.a if foo.lib is specified, for MinGWMartin Storsjo2018-10-103-1/+27
| | | | | | | | | | | | This allows using #pragma comment(lib, "foo") in MinGW built code, if built with -fms-extensions. (This works for system libraries and static libraries only, as it doesn't try to look for .dll.a. As ld.bfd doesn't support embedded defaultlib directives, this isn't in widespread use among mingw users.) Differential Revision: https://reviews.llvm.org/D53017 llvm-svn: 344124
* [MinGW] Pass libpath to the COFF linkerMartin Storsjo2018-10-102-1/+6
| | | | | | | | | This is necessary for handling defaultlib directives embedded in object files, unless they use an absolute path. Differential Revision: https://reviews.llvm.org/D53015 llvm-svn: 344123
* Adapt OptTable::PrintHelp change in D51009Fangrui Song2018-10-104-7/+17
| | | | | | | | | | | | | | Summary: Before, OptTable::PrintHelp append "[options] <inputs>" to its parameter `Help`. It is more flexible to change its semantic to `Usage` and let user customize the usage line. Reviewers: rupprecht, ruiu, espindola Reviewed By: rupprecht Subscribers: emaste, sbc100, arichardson, aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D53054 llvm-svn: 344099
* Merge two overloaded functions into one function. NFC.Rui Ueyama2018-10-091-8/+3
| | | | llvm-svn: 344089
* Return early. NFC.Rui Ueyama2018-10-091-15/+14
| | | | llvm-svn: 344088
* Attempt to fix ubsan.Rui Ueyama2018-10-091-8/+11
| | | | | | | | | | | | | | | | | | Previously, we cast a pointer to Elf{32,64}_Chdr like this auto *Hdr = reinterpret_cast<const ELF64_Chdr>(Ptr); and read from its members like this read32(&Hdr->ch_size); I was thinking that this does not violate alignment requirement, since &Hdr->ch_size doesn't really access memory, but seems like it is a violation in terms of C++ spec (?) In this patch, I use a different struct that allows unaligned access. llvm-svn: 344083
* Calculate an offset only once. NFC.Rui Ueyama2018-10-091-4/+5
| | | | llvm-svn: 344076
* Remove redundant `Symtab->`.Rui Ueyama2018-10-091-7/+7
| | | | | | | | | `SymbolTable` is a singleton class and is a global variable for the unique instance, so we can always refer the symtab by `Symtab->`. However, we don't need to use the global varaible from member functions of SymbolTable class. llvm-svn: 344075
* Simplify. NFC.Rui Ueyama2018-10-092-12/+4
| | | | llvm-svn: 344074
OpenPOWER on IntegriCloud