summaryrefslogtreecommitdiffstats
path: root/lld
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF][HEXAGON] Add R_HEX_8_X relocationSid Manning2018-08-102-0/+24
| | | | | | 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-102-1/+10
| | | | | | | | | | | | | | | | | | | | 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-092-0/+14
| | | | | | Differential Revision: https://reviews.llvm.org/D50520 llvm-svn: 339371
* Support RISC-VRui Ueyama2018-08-0919-1/+1013
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [LLD][ELF] - Add a test for elf::getPriority(StringRef S)George Rimar2018-08-091-2/+4
| | | | | | | It covers the following line with a test: https://github.com/llvm-mirror/lld/blob/master/ELF/OutputSections.cpp#L383 llvm-svn: 339348
* [COFF] Make the relocation scanning for CFG more discriminatingHans Wennborg2018-08-093-7/+176
| | | | | | | | | link.exe ignores REL32 relocations on 32-bit x86, as well as relocations against non-function symbols such as labels. This makes lld do the same. Differential Revision: https://reviews.llvm.org/D50430 llvm-svn: 339345
* [LLD][ELF] - Add a test for ScriptParser::readPhdrType().George Rimar2018-08-091-0/+4
| | | | | | This adds a test for https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L1289. llvm-svn: 339342
* [LLD][ELF] - Add a test for ScriptParser::readOutputSectionDescription.George Rimar2018-08-091-0/+5
| | | | | | | This covers the following line: https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L415 llvm-svn: 339333
* Add R_HEX_6_X relocation supportSid Manning2018-08-092-0/+166
| | | | | | | | | 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
* [LLD][ELF] - Add a test for ScriptParser::readPhdrs(). NFCI.George Rimar2018-08-091-0/+4
| | | | | | | This covers the following line with a test: https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L415 llvm-svn: 339327
* [LLD][ELF] - Add a test case for parsing -defsym.George Rimar2018-08-091-2/+5
| | | | | | | This adds a coverage for the following line of the code: https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L274 llvm-svn: 339326
* ELF: Only add libcall symbols to the link if defined in bitcode.Peter Collingbourne2018-08-085-4/+47
| | | | | | | | | | | | | | | | | 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
* [WebAssembly] Group rodata into a single output segmentSam Clegg2018-08-082-34/+19
| | | | | | Differential Revision: https://reviews.llvm.org/D50424 llvm-svn: 339279
* Add missing REQUIRES x86 to tests.Peter Smith2018-08-086-0/+6
| | | | | | | | Add REQUIRES to tests that fail when an x86 backend is not present. Differential Revision: https://reviews.llvm.org/D50440 llvm-svn: 339253
* lld-link: Take /SUBSYSTEM into account for automatic /ENTRY detection.Nico Weber2018-08-074-44/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If /subsystem:windows is passed, link.exe only looks for WinMain and wWinMain, and if /subsystem:console is passed it only looks for main and wmain. lld-link used to look for all 4 in both cases. This patch makes lld-link match link.exe's behavior. This requires that the subsystem is known by the time findDefaultEntry() gets called. findDefaultEntry() is called before the main link loop, so that the loop can mark the entry point as undefined. That means inferSubsystem() has to be called above the main loop as well. This in turn means /subsystem: from .drectve sections only has an effect on entry point inference for obj files passed to lld-link directly (and not in obj files found later in .lib files). link.exe seems to ignore /subsystem: for obj files from lib files completely (while in lld it's ignored only for entry point detection but it still overrides /subsystem: flags passed on the command line for the value that gets written in the output file). Also, if the subsytem isn't needed (e.g. when only writing a /def: lib file and not writing a coff file), link.exe doesn't complain if the subsystem isn't known, so both subsystem and entry point handling should be below the early return lld has for that case. Fixes PR36523. https://reviews.llvm.org/D50316 llvm-svn: 339165
* [LLD][ELF] - Add test cases for ScriptParser::readDynamicList(). NFCI.George Rimar2018-08-072-0/+14
| | | | | | | | This 2 test cases covers the following code: https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L185 https://github.com/llvm-mirror/lld/blob/master/ELF/ScriptParser.cpp#L189 llvm-svn: 339137
* [LLD][ELF] - Added test case for non-nullterminated wide strings.George Rimar2018-08-071-0/+19
| | | | | | | This covers the following line: https://github.com/llvm-mirror/lld/blob/master/ELF/InputSection.cpp#L1032 llvm-svn: 339124
* [LLD][ELF] - Add a test case for code in Archive::fetch(). NFCI.George Rimar2018-08-071-0/+15
| | | | | | | | | This covers the following piece with a test. https://github.com/llvm-mirror/lld/blob/master/ELF/InputFiles.cpp#L830 Thanks to Peter Collingbourne for providing the reproducer sample! llvm-svn: 339114
* [COFF] Fix a comment about automatic resolving of dllimports from within a ↵Martin Storsjo2018-08-071-2/+2
| | | | | | | | module. NFC. Differential Revision: https://reviews.llvm.org/D50357 llvm-svn: 339100
* [ELF] Use MathExtras.h llvm::SignExtend64Fangrui Song2018-08-061-7/+3
| | | | | | | | | | | | Summary: To be consistent with other files where only SignExtend64 is used. Reviewers: ruiu, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D50366 llvm-svn: 339083
* [lit, python] Always add quotes around the python path in litStella Stamenova2018-08-063-3/+3
| | | | | | | | | | | | | | | Summary: The issue with the python path is that the path to python on Windows can contain spaces. To make the tests always work, the path to python needs to be surrounded by quotes. This is a companion change to: https://reviews.llvm.org/D50206 Reviewers: asmith, zturner, espindola Subscribers: emaste, sbc100, arichardson, aheejin, steven_wu, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D50282 llvm-svn: 339075
* Add TARGET(foo) linker script directive.Rui Ueyama2018-08-065-6/+42
| | | | | | | | | | | | | | | | | | GNU ld's manual says that TARGET(foo) is basically an alias for `--format foo` where foo is a BFD target name such as elf64-x86-64. Unlike GNU linkers, lld doesn't allow arbitrary BFD target name for --format. We accept only "default", "elf" or "binary". This makes situation a bit tricky because we can't simply make TARGET an alias for --target. A quick code search revealed that the usage number of TARGET is very small, and the only meaningful usage is to switch to the binary mode. Thus, in this patch, we handle only TARGET(elf.*) and TARGET(binary). Differential Revision: https://reviews.llvm.org/D48153 llvm-svn: 339060
* [COFF] Treat .xdata/.pdata$<sym> as implicitly associative to <sym> for MinGWMartin Storsjo2018-08-064-6/+172
| | | | | | | | | | | | | | | | | | | MinGW configurations don't use associative comdats, as GNU ld doesn't support that. Instead they produce normal comdats named .text$sym, .xdata$sym and .pdata$sym. GNU ld doesn't discard any comdats starting with .xdata or .pdata, even if --gc-sections is used (while it does discard other unreferenced comdats), regardless of what symbol name is used after the $ separator. For LLD, treat any such comdat as implicitly associative to the base symbol. This requires maintaining a map from symbol name to section number, but that is only maintained when the MinGW flag has been enabled. Differential Revision: https://reviews.llvm.org/D49700 llvm-svn: 339058
* ELF: Enable address-significance tables during LTO.Peter Collingbourne2018-08-062-1/+11
| | | | | | | | This allows safe ICF to work when linking with LTO. Differential Revision: https://reviews.llvm.org/D50221 llvm-svn: 339050
* [COFF] Remove a superfluous warning about aligncomm for non-common symbolsMartin Storsjo2018-08-063-3/+43
| | | | | | | | | | | It's not an error if a common symbol (uninitialized data, with alignment specified via the aligncomm directive) is replaced with a regular one with initialized data (with alignment specified via the section chunk). Differential Revision: https://reviews.llvm.org/D50268 llvm-svn: 339049
* [WebAssembly] --export should fetch lazy symbolsSam Clegg2018-08-062-10/+61
| | | | | | | | | | | --export now implies --undefined This is really a requirement from emscripten but I think it makes sense in general too. Differential Revision: https://reviews.llvm.org/D50287 llvm-svn: 339047
* [ELF] Don't copy STT_TLS in copy relocationFangrui Song2018-08-063-1/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During copy relocation of a variable defined in a DSO, if a TLS variable in that DSO happens to have the same st_value, it would also be copied. This was unnecessary because the addresses of TLS variables are relative to TLS segment. They don't interfere with non-TLS variables. This copying behavior can be harmful in the following scenario: For function-scope thread-local variables with non-trivial constructors, they have guard variables. In the case of x86_64 general-dynamic model: template <int N> void foo() { thread_local std::string a; } GOT[n] R_X86_64_DTPMOD64 guard variable for a GOT[n+1] R_X86_64_DTPOFF64 guard variable for a GOT[n+2] R_X86_64_DTPMOD64 a GOT[n+3] R_X86_64_DTPOFF64 a a and its guard variable are both represented as TLS variables, which should be within the same module. If one is copy relocated to the main module while the other is not, their module ID will mismatch and can cause access without prior construction. Reviewers: ruiu, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D50289 llvm-svn: 339042
* [ELF] - Remove dead code from LinkerScript::assignOffsets(). NFC-ihope.George Rimar2018-08-061-14/+2
| | | | | | | | | | | | | | | | | | Some parts of the code changed are a bit old. I found traces in 2016. Initiall commits has test cases and perhaps reasonable comments. For example, we had segfaults earlier and had the code to fix them. Now, in 2018, I think it is excessive to have these parts, because we do not have segfaults and our code was changed a lot (softly saying). I reviewed the current sources and I think that at this point of the execution flow, we should never face with the conditions checked and so I removing them in this patch. This helps to cleanup the code. llvm-svn: 339003
* [ELF] Test undefined weak symbol for Thumb narrow branchPeter Smith2018-08-061-0/+50
| | | | | | | | | | Add a test for the R_ARM_THM_JUMP11 relocation to an undefined symbol. We have to use yaml2obj as llvm-mc relaxes the narrow branch to a b.w which uses the R_ARM_THM_JUMP24 relocation instead. Differential Revision: https://reviews.llvm.org/D50234 llvm-svn: 338999
* Fix one test for changed opt remarks formatDavid Bolvansky2018-08-051-4/+6
| | | | | | | | | | | | | | | | | Summary: Optimization remark format is slightly changed by LLVM patch D49412. One test is fixed with expected messages changed. Frankly speaking I have not tested this change yet. I will test when manage to setup the project. Reviewers: xbolva00, espindola Reviewed By: xbolva00 Subscribers: emaste, arichardson, steven_wu, dexonsmith Differential Revision: https://reviews.llvm.org/D50242 llvm-svn: 338970
* [LLD][ELD] - Revert r338959 "[LLD][ELF] - Added file name and a test for ↵George Rimar2018-08-042-19/+1
| | | | | | | | | | case when we fail to write the output." It broke BB: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/34382/steps/test/logs/stdio http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/21932/steps/test_lld/logs/stdio llvm-svn: 338960
* [LLD][ELF] - Added file name and a test for case when we fail to write the ↵George Rimar2018-08-042-1/+19
| | | | | | | | output. We did not report the file name and had no test for that case. llvm-svn: 338959
* [LLD][ELF] - Remove excessive requirement from the test.George Rimar2018-08-041-1/+1
| | | | | | It feels "shell" is excessive. Lets try without it. llvm-svn: 338958
* [LLD][ELF] - Removed dead code from rangeToString(). NFC.George Rimar2018-08-041-5/+3
| | | | | | | This change removes the dead code and makes cosmetic change showing why it was dead. llvm-svn: 338957
* [LLD][ELF] - Fix bug when reporting memory intersections.George Rimar2018-08-042-3/+3
| | | | | | | rangeToString() takes addres and length, previously it was called incorrectly. llvm-svn: 338956
* [ELF] - Refactor readCallGraph().George Rimar2018-08-041-21/+16
| | | | | | | | | | | This simplifies the code a bit. It is NFC except that it removes early exit for Count == 0 which does not seem to be useful (we have no such tests either). Differential revision: https://reviews.llvm.org/D49136 llvm-svn: 338953
* [WebAssembly] Don't error when --undefined symbols are not foundSam Clegg2018-08-0414-93/+71
| | | | | | | | | | | | | | | This matches the behavior of the ELF linker where -u/--undefined means symbols will get pulled in from archives but won't result in link error if they are missing. Also, don't actually great symbol table entries for the undefined symbols, again matching more closely the ELF linker. This also results in simplification of the code. Differential Revision: https://reviews.llvm.org/D50279 llvm-svn: 338938
* lld-link: Simplify LinkerDriver::findDefaultEntry()Nico Weber2018-08-031-13/+4
| | | | | | | | | No intended behavior change. Not repeating the CRTStartup names makes fixing PR36523 simpler. https://reviews.llvm.org/D50253 llvm-svn: 338911
* lld-link: Fix subsystem inference for non-console apps on 32-bit, and fix ↵Nico Weber2018-08-035-17/+136
| | | | | | | | | | | | | | | | | | | | | | | entry point inference on 32-bit with /nodefaultlib LinkerDriver::inferSubsystem() used to do Symtab->findUnderscore("WinMain"), but WinMain is stdcall in 32-bit and is hence is called _WinMain@16. Instead, Symtab->findMangle(mangle("WinMain")) needs to be called. But since LinkerDriver::inferSubsystem() and LinkerDriver::findDefaultEntry() both need to call this, introduce a common helper function for this and call it from both places. (Also call it for "main" for consistency, even though findUnderscore() is enough for main since that's __cdecl on 32-bit). This also exposed a bug for /nodefaultlib entrypoint inference: The code here called findMangle(Sym) instead of findMangle(mangle(Sym)), again doing the wrong thing on 32-bit. Fix that too. While here, make Driver::mangle() a static free function. https://reviews.llvm.org/D50184 llvm-svn: 338877
* Set IsUsedInRegularObj in a consistent manor between COFF, ELF and wasm. NFCSam Clegg2018-08-024-64/+47
| | | | | | Differential Revision: https://reviews.llvm.org/D49147 llvm-svn: 338767
* [LLD] Update split stack support to handle more generic prologues. Improve ↵Jordan Rupprecht2018-08-026-48/+66
| | | | | | | | | | error handling. Add test file for better code-coverage. Update tests to be more complete. Submitting patch on behalf of saugustine. Differential Revision: https://reviews.llvm.org/D49926 llvm-svn: 338750
* [LLD][ELF] - Remove dead check from adjustSplitStackFunctionPrologues().George Rimar2018-08-021-6/+1
| | | | | | | In according to the comment, undefined symbol should never reach there. So, should be able to remove the check. I am assuming this is NFC. llvm-svn: 338723
* [LLD][ELF] - An attemp to fix BB after rL338718.George Rimar2018-08-021-1/+2
| | | | | | | BB is unhappy :`-( http://lab.llvm.org:8011/builders/lld-perf-testsuite/builds/5632 llvm-svn: 338722
* [LLD][ELF] - Remove excessive cases from getRelocTargetVA(). NFC.George Rimar2018-08-021-5/+0
| | | | | | | There is no point to explicitly proccess the expressions this patch removes. We already have a llvm_unreachable for the default case. llvm-svn: 338718
* [LLD][ELF] - Remove dead code. NFC.George Rimar2018-08-021-6/+0
| | | | | | | | | | | It does not seem that this code is alive. I seems was needed previously but we fixed it. If it is still needed, it needs new tests, but for now I do not know how to trigger it, and so I removed it. llvm-svn: 338713
* [LLD][ELF] - Remove redundant code. NFC.George Rimar2018-08-021-2/+1
| | | | | | | | Code was never executed with our test cases, though it is valid and I think we can always run it. This improves code coverage. llvm-svn: 338708
* [lld] Make tests calling llvm-ar more robustChris Jackson2018-08-0219-1/+20
| | | | | | | | | | | Some lit tests that call llvm-ar use the 'r' flag. If the target archive already exists and is in a corrupt state, this can cause the test to fail. We have added 'rm -f' calls before the llvm-ar calls to increase the robustness of the tests. Differential revision: https://reviews.llvm.org/D49184 llvm-svn: 338705
* [LLD][ELF] - Simplify. NFC.George Rimar2018-08-021-6/+1
| | | | | | | | isHeaderSection can be useful I believe, but probably not right now and not for this case. llvm-svn: 338699
* [LLD] Do not overwrite LMAOffset of PT_LOAD headerGeorge Rimar2018-08-023-8/+55
| | | | | | | | | | | | Patch by Konstantin Schwarz! If more than a single output section is added to a PT_LOAD header, only the first section should set the LMAOffset of the segment. Otherwise, we get a load-address overlap error Differential revision: https://reviews.llvm.org/D50133 llvm-svn: 338697
OpenPOWER on IntegriCloud