summaryrefslogtreecommitdiffstats
path: root/lld/ELF
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF] Fallback to sh_link=0 if neither .dynsym nor .symtab existsFangrui Song2018-10-301-5/+9
| | | | | | | | | | | | | | Summary: .rela.plt may only contain R_*_{,I}RELATIVE relocations and not need a symbol table link. bfd/gold fallbacks to sh_link=0 in this case. Without this patch, ld.lld --strip-all caused lld to dereference a null pointer. Reviewers: ruiu, grimar, espindola Reviewed By: ruiu Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D53881 llvm-svn: 345648
* [PPC64] Handle powerpc64 in OUTPUT_FORMAT.Sean Fertile2018-10-301-0/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D53652 llvm-svn: 345604
* [ELF][PPC64]Workaround bogus Visual Studio build warningJames Henderson2018-10-301-1/+2
| | | | | | | | | | | | | | | | | Visual Studio has a bug where it converts the integer literal 2147483648 into an unsigned int instead of a long long (i.e. it follows C89 rules). The bug has been reported as: https://developercommunity.visualstudio.com/content/problem/141813/-2147483648-c4146-error.html. Because of this bug, we were getting a signed/unsigned comparison warning in VS2015 from the old code (the subsequent unary negation had no effect on the type). Reviewed by: sfertile Differential Revision: https://reviews.llvm.org/D53821 llvm-svn: 345579
* Rename warnUnorderableSymbol maybeWarnUnorderableSymbol because the function ↵Rui Ueyama2018-10-264-4/+4
| | | | | | doesn't always emit a warning. llvm-svn: 345393
* Refactor readCallGraph() and readCallGraphFromObjectFiles(). NFC.Rui Ueyama2018-10-261-21/+28
| | | | llvm-svn: 345392
* [ELF] Add --{,no-}call-graph-profile-sort (enabled by default)Fangrui Song2018-10-253-4/+13
| | | | | | | | | | | | | | Summary: Add an option to disable sorting sections with call graph profile Reviewers: ruiu, Bigcheese, espindola Reviewed By: Bigcheese Subscribers: grimar, emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D53683 llvm-svn: 345332
* [ELF] Don't check if symbols in .llvm.call-graph-profile are unorderableFangrui Song2018-10-251-16/+0
| | | | | | | | | | | | | | Summary: There are too many reasonable cases that would be considered unorderable. Reviewers: ruiu, espindola, Bigcheese Reviewed By: ruiu Subscribers: grimar, emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D53669 llvm-svn: 345322
* Remove full stops from error messages for consistency.Rui Ueyama2018-10-251-4/+4
| | | | llvm-svn: 345294
* Do not call computeIsPreemptible() if its result is discarded. NFC.Rui Ueyama2018-10-241-1/+3
| | | | llvm-svn: 345208
* Add more blank lines so that code doesn't look too dense. NFC.Rui Ueyama2018-10-241-13/+31
| | | | llvm-svn: 345205
* Add a comment for PPC64 .toc and GNU relro.Rui Ueyama2018-10-241-0/+5
| | | | llvm-svn: 345204
* Include input section name and output section name in an error message.Rui Ueyama2018-10-241-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D53645 llvm-svn: 345172
* Refactor assignFileOffsets. NFC.Rui Ueyama2018-10-241-30/+29
| | | | llvm-svn: 345154
* Split a function. NFC.Rui Ueyama2018-10-241-11/+17
| | | | llvm-svn: 345143
* Add parenthese around a bitand.Rui Ueyama2018-10-241-1/+1
| | | | llvm-svn: 345139
* Make a local variable scope narrower. NFC.Rui Ueyama2018-10-241-3/+3
| | | | llvm-svn: 345138
* [ELF] Remove a superfluous semicolon, fixing warnings. NFC.Martin Storsjo2018-10-241-1/+1
| | | | llvm-svn: 345116
* Move forward declarations to the top of the file and sort.Rui Ueyama2018-10-231-4/+4
| | | | llvm-svn: 345094
* Move a function out of a class because it doesn't depend on any class ↵Rui Ueyama2018-10-232-18/+14
| | | | | | member. NFC. llvm-svn: 345093
* Factor out code to a new function. NFC.Rui Ueyama2018-10-231-27/+52
| | | | llvm-svn: 345088
* Simplify. NFC.Rui Ueyama2018-10-231-34/+29
| | | | | | A higher order function `applySyntehtic` can be replaced with a simpler function. llvm-svn: 345081
* Remove a global variable that is set but not used.Rui Ueyama2018-10-233-11/+3
| | | | llvm-svn: 345080
* Add a comment.Rui Ueyama2018-10-231-0/+4
| | | | llvm-svn: 345062
* Remove a global variable that we can live without.Rui Ueyama2018-10-234-4/+1
| | | | | | | | | | Out::DebugInfo was used only by GdbIndex class to determine if we need to create a .gdb_index section, but we can do the same check without it. Added a test that this patch doesn't change the existing behavior. llvm-svn: 345058
* Don't mess up RelIplt symbols during relocatable processingDimitry Andric2018-10-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: During upgrading of the FreeBSD source tree with lld 7.0.0, I noticed that it started complaining about `crt1.o` having an "index past the end of the symbol table". Such a symbol table looks approximately like this, viewed with `readelf -s` (note the `Ndx` field being messed up): ``` Symbol table '.symtab' contains 4 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000000 0 SECTION LOCAL DEFAULT 1 2: 00000000 0 NOTYPE WEAK HIDDEN RSV[0xffff] __rel_iplt_end 3: 00000000 0 NOTYPE WEAK HIDDEN RSV[0xffff] __rel_iplt_start ``` At first, it seemed that recent ifunc relocation work had caused this: <https://reviews.freebsd.org/rS339351>, but it turned out that it was due to incorrect processing of the object files by lld, when using `-r` (a.k.a. --relocatable). Bisecting showed that rL324421 ("Convert a use of Config->Static") was the commit where this new behavior began. Simply reverting it solved the issue, and the `__rel_iplt` symbols had an index of `UND` again. Looking at Rafael's commit message, I think he simply missed the possibility of `--relocatable` being in effect, so I have added an additional check for it. I also added a simple regression test case. Reviewers: grimar, ruiu, emaste, espindola Reviewed By: ruiu Subscribers: arichardson, krytarowski, llvm-commits Differential Revision: https://reviews.llvm.org/D53515 llvm-svn: 345002
* [ELF] Handle elf32-littlearm in OUTPUT_FORMATShoaib Meenai2018-10-221-0/+2
| | | | | | | | | 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-221-12/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-221-2/+27
| | | | | | | | | | | | | | | | | | | | | | 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
* Use llvm::arrayRefFromStringRefSam Clegg2018-10-221-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D53432 llvm-svn: 344888
* 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
* [PPC64] Fix offset checks on rel24 call relocations.Sean Fertile2018-10-181-1/+2
| | | | | | | | | | | | 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
* Reland "[PPC64] Add split - stack support."Sean Fertile2018-10-168-12/+146
| | | | | | | | | | | | | | 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-158-146/+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-158-12/+146
| | | | | | | | | | | | | 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-151-2/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D53204 llvm-svn: 344518
* [LLD][ELF] - Check options before processing the -v/-version options.George Rimar2018-10-151-7/+8
| | | | | | | | | | | | | | | 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
* [lld] Add more complete support for the INCLUDE command.Rui Ueyama2018-10-121-5/+13
| | | | | | | | | | | | | 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
* [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-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [ELF] - Set sh_info and sh_link for .rela.plt sections.George Rimar2018-10-111-3/+6
| | | | | | | | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud