summaryrefslogtreecommitdiffstats
path: root/lld/ELF
Commit message (Collapse)AuthorAgeFilesLines
...
* lld: add -z interpose supportEd Maste2018-09-143-3/+8
| | | | | | | | | | | -z interpose sets the DF_1_INTERPOSE flag, marking the object as an interposer. Via FreeBSD PR 230604, linking Valgrind with lld failed. Differential Revision: https://reviews.llvm.org/D52094 llvm-svn: 342239
* [ELF] Guard --fix-cortex-a53-843419 against --just-symsPeter Smith2018-09-131-1/+1
| | | | | | | | | | | | | | If --just-syms is used the mapping symbols from the ELF file will be absolute symbols with no section. The code to process mapping symbols in --fix-cortex-a53-843419 assumes that these symbols have a defining section so a crash will result when --just-syms is used. The simple fix is to not process the symbol when it doesn't have a section. Fixes PR37971 Differential Revision: https://reviews.llvm.org/D52038 llvm-svn: 342146
* [ELF] Revert "Also demote lazy symbols."Chih-Hung Hsieh2018-09-113-30/+21
| | | | | | | | | This reverts commit https://reviews.llvm.org/rL330869 for a regression to link Android dex2oatds. Differential Revision: https://reviews.llvm.org/D51892 llvm-svn: 342007
* Simplify.Rui Ueyama2018-09-112-23/+15
| | | | | | Instead of Map<StringRef, bool>, we can simply use Set<StringRef>. llvm-svn: 341948
* Style fix.Rui Ueyama2018-09-111-4/+2
| | | | llvm-svn: 341937
* [ELF] Don't emit .relr.dyn section if there are no relocsPetr Hosek2018-09-101-0/+1
| | | | | | | | This resolves PR38875. Differential Revision: https://reviews.llvm.org/D51834 llvm-svn: 341870
* [ELF] Check if LinkSec is nullptr when initializing SHF_LINK_ORDER sectionsFangrui Song2018-09-071-2/+4
| | | | | | | | | | | | | | Summary: This protects lld from a null pointer dereference when a faulty input file has such invalid sh_link fields. Reviewers: ruiu, espindola Reviewed By: ruiu Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D51743 llvm-svn: 341611
* When a relocation to an undefined symbol is an R_X86_64_PC32, an inputSterling Augustine2018-09-041-1/+1
| | | | | | | | | | | | section will not have an input file. Don't crash under those circumstances. Neither clang nor llvm-mc generates R_X86_64_PC32 relocations due to https://reviews.llvm.org/D43383, which makes it hard to write a test case. However, gcc does generate such relocations. I want to get a fix in now, but will figure out a way to actually exercise this code path as soon as I can. llvm-svn: 341408
* [LLD] Check too large offsets into merge sections earlierBen Dunbobbin2018-08-311-21/+10
| | | | | | | | | | | | | | | | | This patch moves the checking for too large offsets into merge sections earlier. Without this change the large offset generated in the added test-case will cause an assert (as it happens to be a value reserved as a "tombstone" in the DenseMap implementation) when OffsetMap is queried in getSectionPiece(). To simplify the code and avoid future mistakes I have refactored so that there is only one function that looks up offsets in the OffsetMap. Differential Revision: https://reviews.llvm.org/D51180 llvm-svn: 341206
* [ELF] [ARM] Don't mix 'ip' and 'r12' as names for the same register in ↵Martin Storsjo2018-08-311-4/+4
| | | | | | comments. NFC. llvm-svn: 341179
* ELF: Don't examine values of linker script symbols during ICF.Peter Collingbourne2018-08-293-2/+11
| | | | | | | | | These symbols are declared early with the same value, so they otherwise appear identical to ICF. Differential Revision: https://reviews.llvm.org/D51376 llvm-svn: 340998
* Always add a .note.GNU-stack section if -r.Rui Ueyama2018-08-292-0/+17
| | | | | | | | | | | | With this patch, lld creates a .note.GNU_stack and adds that to an output file if it is creating a re-linkable object file (i.e. if -r is given). If we don't do this, and if you use GNU linkers as a final linker, they create an executable whose stack area is executable, which is considered pretty bad these days. Differential Revision: https://reviews.llvm.org/D51400 llvm-svn: 340902
* [PPC64] Fix DQ-form instruction handling and emit error for misalignment.Sean Fertile2018-08-281-7/+35
| | | | | | | | | | | | | Relanding r340564, original commit message: Fixes the handling of *_DS relocations used on DQ-form instructions where we were overwriting some of the extended opcode bits. Also adds an alignment check so that the user will receive a diagnostic error if the value we are writing is not properly aligned. Differential Revision: https://reviews.llvm.org/D51124 llvm-svn: 340832
* [LLD][ELF] - Simplify Call-Chain Clustering implementation a bit.George Rimar2018-08-281-16/+10
| | | | | | | | | | Looking at the current implementation and algorithm description, it does not seem we need to keep vector with all edges for each cluster and can just remember the best one. This is NFC change. Differential revision: https://reviews.llvm.org/D50609 llvm-svn: 340806
* [LLD][ELD] - Do not reject INFO output section type when used with a start ↵George Rimar2018-08-283-21/+36
| | | | | | | | | | | | | | | | | | | | address. This is https://bugs.llvm.org/show_bug.cgi?id=38625 LLD accept this: ".stack (INFO) : {", but not this: ".stack address_expression (INFO) :" The patch fixes it. Differential revision: https://reviews.llvm.org/D51027 llvm-svn: 340804
* [LLF][ELF] - Support -z global.George Rimar2018-08-283-4/+8
| | | | | | | | -z global is a flag used on Android (see D49198). Differential revision: https://reviews.llvm.org/D49374 llvm-svn: 340802
* [ELF][HEXAGON] Add R_HEX_11/10/9_X supportSid Manning2018-08-271-0/+15
| | | | | | Differential Revision: https://reviews.llvm.org/D51225 llvm-svn: 340739
* Handle identifying AMDGPU bitcode filesMatt Arsenault2018-08-271-0/+3
| | | | llvm-svn: 340738
* Rename a function to follow the LLVM coding style.Rui Ueyama2018-08-271-1/+1
| | | | llvm-svn: 340716
* [ELF][HEXAGON] Add R_HEX_B13_PCREL relocation supportSid Manning2018-08-251-0/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D51166 llvm-svn: 340693
* [ELF][HEXAGON] Add R_HEX_B9_PCREL and R_HEX_B9_PCREL_X relocation supportSid Manning2018-08-251-0/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D51045 llvm-svn: 340692
* Revert "[PPC64] Fix DQ-form instruction handling and emit error for misalign..."Sean Fertile2018-08-231-35/+7
| | | | | | | | This reverts commit 5125b44dbb5d06b715213e4bec75c7346bfcc7d3. ppc64-dq.s and ppc64-error-missaligned-dq.s fail on several of the build-bots. Reverting to investigate. llvm-svn: 340568
* [PPC64] Fix DQ-form instruction handling and emit error for misalignment.Sean Fertile2018-08-231-7/+35
| | | | | | | | | | | Fixes the handling of *_DS relocations used on DQ-form instructions where we were overwriting some of the extended opcode bits. Also adds an alignment check so that the user will receive a diagnostic error if the value we are writing is not properly aligned. Differential Revision: https://reviews.llvm.org/D51124 llvm-svn: 340564
* win: Omit ".exe" from lld warning and error messages.Nico Weber2018-08-221-1/+1
| | | | | | | | | | | This is a minor follow-up to https://reviews.llvm.org/D49189. On Windows, lld used to print "lld-link.exe: error: ...". Now it just prints "lld-link: error: ...". This matches what link.exe does (it prints "LINK : ...") and makes lld's output less dependent on the host system. https://reviews.llvm.org/D51133 llvm-svn: 340487
* [ELF][HEXAGON] Add R_HEX_16_X relocationSid Manning2018-08-221-0/+18
| | | | | | | | This relocation has only 6-bits the remaining are in the extender. Differential Revision: https://reviews.llvm.org/D50603 llvm-svn: 340413
* Change how we handle -wrap.Rui Ueyama2018-08-225-76/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have an issue with -wrap that the option doesn't work well when renamed symbols get PLT entries. I'll explain what is the issue and how this patch solves it. For one -wrap option, we have three symbols: foo, wrap_foo and real_foo. Currently, we use memcpy to overwrite wrapped symbols so that they get the same contents. This works in most cases but doesn't when the relocation processor sets some flags in the symbol. memcpy'ed symbols are just aliases, so they always have to have the same contents, but the relocation processor breaks that assumption. r336609 is an attempt to fix the issue by memcpy'ing again after processing relocations, so that symbols that are out of sync get the same contents again. That works in most cases as well, but it breaks ASan build in a mysterious way. We could probably fix the issue by choosing symbol attributes that need to be copied after they are updated. But it feels too complicated to me. So, in this patch, I fixed it once and for all. With this patch, we no longer memcpy symbols. All references to renamed symbols point to new symbols after wrapSymbols() is done. Differential Revision: https://reviews.llvm.org/D50569 llvm-svn: 340387
* [ELF] -thinlto-object-suffix-replace=: don't error if the path does not end ↵Fangrui Song2018-08-211-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with old suffix Summary: For -thinlto-object-suffix-replace=old\;new, in tools/gold/gold-plugin.cpp, the thinlto object filename is Path minus optional old suffix. static std::string getThinLTOObjectFileName(StringRef Path, StringRef OldSuffix, StringRef NewSuffix) { if (OldSuffix.empty() && NewSuffix.empty()) return Path; StringRef NewPath = Path; NewPath.consume_back(OldSuffix); std::string NewNewPath = NewPath; NewNewPath += NewSuffix; return NewNewPath; } Currently lld will error that the path does not end with old suffix. This patch makes lld accept such paths but only add new suffix if Path ends with old suffix. This fixes a link error where bitcode members in an archive are regular LTO objects without old suffix. Acording to tejohnson, this will "enable supporting mix and match of minimized ThinLTO bitcode files with normal ThinLTO bitcode files in a single link (where we want to apply the suffix replacement to the minimized files, and just ignore it for the normal ThinLTO files)." Reviewers: ruiu, pcc, tejohnson, espindola Reviewed By: tejohnson Subscribers: emaste, inglorion, arichardson, eraman, steven_wu, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D51055 llvm-svn: 340364
* [PPC64] Add TLS initial exec to local exec relaxationZaara Syeda2018-08-213-3/+108
| | | | | | | | | This patch adds the target call back relaxTlsIeToLe to support TLS relaxation from initial exec to local exec model. Differential Revision: https://reviews.llvm.org/D48091 llvm-svn: 340281
* [LLD][ELF] - Check the architecture of lazy objects earlier.George Rimar2018-08-212-18/+2
| | | | | | | | | | | | | | | | | | | | | | Our code in LazyObjFile::parse() has an ELFT switch and adds a lazy object by its ELFT kind. Though it might be possible to add a file using a different architecture and make LLD to silently accept it (if the file is empty or contains only week symbols). That itself, not a huge issue perhaps (because the error would be reported later if the file is fetched), but still does not look clean and correct. It is possible to report an error earlier and clean up the code. That is what the patch does. Ideally, we might want to reuse isCompatible from SymbolTable.cpp, but it is static and accepts a file as an argument, what is not convenient. Since such a situation should be rare, I think it should be OK to go with the way chosen in this patch. Differential revision: https://reviews.llvm.org/D50899 llvm-svn: 340257
* [LLD][ELF] - Fix warning.George Rimar2018-08-201-1/+2
| | | | | | | | | This fixes the following warning when compiling with gcc version 8.0.1 20180319 (experimental) (GCC): /home/umb/LLVM/llvm/tools/lld/ELF/SyntheticSections.cpp:1951:46: warning: enumeral and non-enumeral type in conditional expression [-Wextra] return OS->SectionIndex >= SHN_LORESERVE ? SHN_XINDEX : OS->SectionIndex; llvm-svn: 340164
* [ELF] Add support for Armv5 and Armv6 compatible ThunksPeter Smith2018-08-208-54/+170
| | | | | | | | | | | | | | | | Older Arm architectures do not support the MOVT and MOVW instructions so we must use an alternative sequence of instructions to transfer control to the destination. Assuming at least Armv5 this patch adds support for Thunks that load or add to the program counter. Note that there are no Armv5 Thumb Thunks as there is no Thumb branch instruction in Armv5 that supports Thunks. These thunks will not work for Armv4t (arm7tdmi) as this architecture cannot change state from using the LDR or ADD instruction. Differential Revision: https://reviews.llvm.org/D50077 llvm-svn: 340160
* [ELF] Add support for older Arm Architectures with smaller branch rangePeter Smith2018-08-202-6/+24
| | | | | | | | | | | | | | The Thumb BL and BLX instructions on older Arm Architectures such as v5 and v6 have a constrained encoding J1 and J2 must equal 1, later Architectures relaxed this restriction allowing J1 and J2 to be used to calculate a larger immediate. This patch adds support for the old encoding, it is used when the build attributes for the input objects only contain older architectures. Differential Revision: https://reviews.llvm.org/D50076 llvm-svn: 340159
* Remove unnecessary applyMask() application.Rui Ueyama2018-08-201-1/+1
| | | | | | applyMask(0xffffffff, x) is an identity function. llvm-svn: 340152
* [LLD][ELF] - Remove dead code. NFC.George Rimar2018-08-171-4/+0
| | | | | | These lines were unused. llvm-svn: 340011
* [ELF] mergeSections: remove non-alive MergeInputSectionFangrui Song2018-08-161-1/+3
| | | | | | | | | | | | | | Summary: This makes it conform to what the comment says. Otherwise when getErrPlace() is called afterwards, cast<InputSection>(D) will cause incompatible cast as MergeInputSection is not a subclass of InputSection. Reviewers: ruiu, grimar, espindola, pcc Reviewed By: grimar Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D50742 llvm-svn: 339904
* [LLD][ELF] - Handle SHT_GROUP more carefully. NFCI.George Rimar2018-08-151-1/+5
| | | | | | | | | | | | This patch solves 2 problems: 1) It adds a test to check the line below: https://github.com/llvm-mirror/lld/blob/master/ELF/InputFiles.cpp#L334 Test case contains SHT_GROUP section with a broken (0xFF) flag. 2) The patch fixes the case when we silently accepted such broken groups in the case when there were no other objects with the same group signature. llvm-svn: 339765
* [LLD][ELF] - Eliminate dead code from OffsetGetter::get().George Rimar2018-08-141-1/+1
| | | | | | | | | We have a dead piece of code there which is impossible to trigger using regular objects I believe. Patch removes it and adds a test case showing how this condition can be triggered with use of a broken object and crash the linker. llvm-svn: 339680
* [ELF][HEXAGON] Add R_HEX_32 supportSid Manning2018-08-141-0/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D50657 llvm-svn: 339677
* [LLD][ELF] - Remove UnresolvedPolicy::IgnoreAll and relative code. NFC.George Rimar2018-08-143-7/+1
| | | | | | | | The code involved was simply dead. `IgnoreAll` value is used in `maybeReportUndefined` only which is never called for -r. And at the same time `IgnoreAll` was set only for -r. llvm-svn: 339672
* Support shared objects for split stack.Sterling Augustine2018-08-131-9/+13
| | | | llvm-svn: 339626
* [LLD][ELF] - Remove dead code from handleTlsRelocation. NFC.George Rimar2018-08-131-2/+0
| | | | | | | | Code is dead because R_TLSDESC_CALL is already handled in the following block of the code: https://github.com/llvm-mirror/lld/blob/master/ELF/Relocations.cpp#L231 llvm-svn: 339566
* [LLD][ELF] - Remove dead code from handleTlsRelocation. NFC.George Rimar2018-08-131-3/+0
| | | | | | | | | | That piece of code is really very old and "protected" from TLS relocations against symbol in non-allocatable sections. It is useless because normally non-alloc sections have relocations with allocatable targets, but not the reverse. And so the code was simply dead. llvm-svn: 339553
* [LLF][ELF] - Simplify. NFC.George Rimar2018-08-121-3/+3
| | | | llvm-svn: 339510
* [ELF][HEXAGON] Add R_HEX_8_X relocationSid Manning2018-08-101-0/+11
| | | | | | Differential Revision: https://reviews.llvm.org/D50577 llvm-svn: 339477
* [ELF] - Get rid of SyntheticSection::postThunkContents(). NFCI.George Rimar2018-08-103-15/+13
| | | | | | | | | | | | It turns out that postThunkContents() is only used for sorting symbols in .symtab. Though we can instead move the logic to SymbolTableBaseSection::finalizeContents(), postpone calling it and then get rid of postThunkContents completely. Differential revision: https://reviews.llvm.org/D49547 llvm-svn: 339413
* [LLD][ELF] - Fix crash when using empty --defsym.George Rimar2018-08-101-1/+4
| | | | | | | | | | | | | | | | | | | | We have a crash issue when handling the empty -defsym. For parsing this option we are using ScriptParser class which is used generally for reading the linker script. For empty defsym case, we pass the empty memory buffer and crash in the place removed in https://reviews.llvm.org/rL336436. But reverting of the above patch would not help here (we would still crash but a bit later). And even after fixing the crash we would report something like "lld.exe: error: -defsym:1: unexpected EOF" It is probably not the appropriate message because mentions EOF. I think the issue should be handled on a higher level like this patch does. So we do not want to pass the empty memory buffer first of all I believe. Differential revision: https://reviews.llvm.org/D50498 llvm-svn: 339412
* [ELF][HEXAGON] Add R_HEX_HI16/R_HEX_LO16 relocationsSid Manning2018-08-091-0/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D50520 llvm-svn: 339371
* Support RISC-VRui Ueyama2018-08-0912-1/+355
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by PkmX. This patch makes lld recognize RISC-V target and implements basic relocation for RV32/RV64 (and RVC). This should be necessary for static linking ELF applications. The ABI documentation for RISC-V can be found at: https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md. Note that the documentation is far from complete so we had to figure out some details from bfd. The patch should be pretty straightforward. Some highlights: - A new relocation Expr R_RISCV_PC_INDIRECT is added. This is needed as the low part of a PC-relative relocation is linked to the corresponding high part (auipc), see: https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md#pc-relative-symbol-addresses - LLVM's MC support for RISC-V is very incomplete (we are working on this), so tests are given in objectyaml format with the original assembly included in the comments. Once we have complete support for RISC-V in MC, we can switch to llvm-as/llvm-objdump. - We don't support linker relaxation for now as it requires greater changes to lld that is beyond the scope of this patch. Once this is accepted we can start to work on adding relaxation to lld. Differential Revision: https://reviews.llvm.org/D39322 llvm-svn: 339364
* Add R_HEX_6_X relocation supportSid Manning2018-08-091-0/+44
| | | | | | | | | This is a larger patch. This relocation has irregular immediate masks that require a lookup to find the correct mask. Differential Revision: https://reviews.llvm.org/D50450 llvm-svn: 339332
* ELF: Only add libcall symbols to the link if defined in bitcode.Peter Collingbourne2018-08-083-3/+40
| | | | | | | | | | | | | | | | | Adding all libcall symbols to the link can have undesired consequences. For example, the libgcc implementation of __sync_val_compare_and_swap_8 on 32-bit ARM pulls in an .init_array entry that aborts the program if the Linux kernel does not support 64-bit atomics, which would prevent the program from running even if it does not use 64-bit atomics. This change makes it so that we only add libcall symbols to the link before LTO if we have to, i.e. if the symbol's definition is in bitcode. Any other required libcall symbols will be added to the link after LTO when we add the LTO object file to the link. Differential Revision: https://reviews.llvm.org/D50475 llvm-svn: 339301
OpenPOWER on IntegriCloud