summaryrefslogtreecommitdiffstats
path: root/lld/test
Commit message (Collapse)AuthorAgeFilesLines
...
* lld-link: Take /SUBSYSTEM into account for automatic /ENTRY detection.Nico Weber2018-08-073-4/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [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-061-0/+18
| | | | | | | | | | | | | | | | | | 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-062-0/+107
| | | | | | | | | | | | | | | | | | | 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-061-0/+9
| | | | | | | | 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-062-0/+40
| | | | | | | | | | | 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-061-0/+50
| | | | | | | | | | | --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-062-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] 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-041-17/+0
| | | | | | | | | | 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-041-0/+17
| | | | | | | | 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] - Fix bug when reporting memory intersections.George Rimar2018-08-041-2/+2
| | | | | | | rangeToString() takes addres and length, previously it was called incorrectly. llvm-svn: 338956
* [WebAssembly] Don't error when --undefined symbols are not foundSam Clegg2018-08-0412-43/+40
| | | | | | | | | | | | | | | 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: Fix subsystem inference for non-console apps on 32-bit, and fix ↵Nico Weber2018-08-033-2/+119
| | | | | | | | | | | | | | | | | | | | | | | 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
* [LLD] Update split stack support to handle more generic prologues. Improve ↵Jordan Rupprecht2018-08-024-26/+31
| | | | | | | | | | 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] 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] Do not overwrite LMAOffset of PT_LOAD headerGeorge Rimar2018-08-022-0/+39
| | | | | | | | | | | | 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
* [LLD] Only increase LMARegion if different from MemRegionGeorge Rimar2018-08-022-0/+35
| | | | | | | | | | | | Patch by Konstantin Schwarz! If both the MemRegion and LMARegion are set for an output section in a linker script, we should only increase the LMARegion if it is different from the MemRegion. Otherwise, we reserve the memory twice. Differential revision: https://reviews.llvm.org/D50065 llvm-svn: 338684
* [LLD] - Improve handling of AT> linker script commandsGeorge Rimar2018-08-022-0/+41
| | | | | | | | | | | | | Patch by Konstantin Schwarz! The condition to create a new phdr must also check the usage of "AT>" linker script command, and create a new PT_LOAD header if a new LMARegion is used. This fixes PR38307 Differential revision: https://reviews.llvm.org/D50052 llvm-svn: 338679
* Re-submit r338596 with a bug fix and a test.Rui Ueyama2018-08-011-0/+1
| | | | llvm-svn: 338647
* lld-link: Remove /msvclto optionNico Weber2018-08-013-85/+0
| | | | | | | | | | | This was useful for LTO bringup in lld-link while lld couldn't write PDBs. Now that it can, this should no longer be needed. Hopefully the flag is obscure enough and recent enough, that nobody uses it – but if somebody should use it, they should be able to just stop passing it and things should continue to work. https://reviews.llvm.org/D50139 llvm-svn: 338615
* Allow oformat to accept format starting with elf as acceptable format. ↵Rumeet Dhindsa2018-07-311-0/+2
| | | | | | | | | | isOutputFormatBinary returns false in such case. Example: --oformat elf64-x86-64 Differential Revision: https://reviews.llvm.org/D50105 llvm-svn: 338445
* [lld] Fix test RUN commands so they don't fail when run in a read-only ↵David L. Jones2018-07-311-6/+6
| | | | | | | | | | filesystem. Some test setups run tests in a read-only path, which means that opening the default output path (a.out) for write will fail. This change adds appropriate -o flags so the tests will not fail spuriously. llvm-svn: 338440
* ELF: Add libcall symbols to the link when LTO is being used.Peter Collingbourne2018-07-312-0/+26
| | | | | | | | | | | | If any of our inputs are bitcode files, the LTO code generator may create references to certain library functions that might not be explicit in the bitcode file's symbol table. If any of those library functions are defined in a bitcode file in an archive member, we need to arrange to use LTO to compile those archive members by adding them to the link beforehand. Differential Revision: https://reviews.llvm.org/D50017 llvm-svn: 338434
* [LLD][ELF] - ICF: Check we do not fold sections which relocations reffering ↵George Rimar2018-07-312-0/+24
| | | | | | | | | | | to absolute symbols with a different values. This adds a test for the following uncovered piece of code: https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp#L263 Without that lines we would crash. llvm-svn: 338379
* [ELF][ARM] Implement support for Tag_ABI_VFP_argsPeter Smith2018-07-318-0/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Tag_ABI_VFP_args build attribute controls the procedure call standard used for floating point parameters on ARM. The values are: 0 - Base AAPCS (FP Parameters passed in Core (Integer) registers 1 - VFP AAPCS (FP Parameters passed in FP registers) 2 - Toolchain specific (Neither Base or VFP) 3 - Compatible with all (No use of floating point parameters) If the Tag_ABI_VFP_args build attribute is missing it has an implicit value of 0. We use the attribute in two ways: - Detect a clash in calling convention between Base, VFP and Toolchain. we follow ld.bfd's lead and do not error if there is a clash between an implicit Base AAPCS caused by a missing attribute. Many projects including the hard-float (VFP AAPCS) version of glibc contain assembler files that do not use floating point but do not have Tag_ABI_VFP_args. - Set the EF_ARM_ABI_FLOAT_SOFT or EF_ARM_ABI_FLOAT_HARD ELF header flag for Base or VFP AAPCS respectively. This flag is used by some ELF loaders. References: - Addenda to, and Errata in, the ABI for the ARM Architecture for Tag_ABI_VFP_args - Elf for the ARM Architecture for ELF header flags Fixes PR36009 Differential Revision: https://reviews.llvm.org/D49993 llvm-svn: 338377
* [LLD][ELF] - ICF: add test case testing we do not fold sections with the ↵George Rimar2018-07-311-0/+15
| | | | | | | | | | | different flags. NFCI. Previously the following condition was not tested at all: https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp#L300 Patch adds a test for `A->Flags != B->Flags` part. llvm-svn: 338375
* [AArch64] Support execute-only LOAD segments.David Bolvansky2018-07-302-0/+36
| | | | | | | | | | | | | | | | | | | Summary: This adds an LLD flag to mark executable LOAD segments execute-only for AArch64 targets. In AArch64 the expectation is that code is execute-only compatible, so this just adds a linker option to enforce this. Patch by: ivanlozano (Ivan Lozano) Reviewers: srhines, echristo, peter.smith, eugenis, javed.absar, espindola, ruiu Reviewed By: ruiu Subscribers: dokyungs, emaste, arichardson, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D49456 llvm-svn: 338271
* [ELF] - Implement SHT_SYMTAB_SHNDX (.symtab_shndxr) section.George Rimar2018-07-302-12/+30
| | | | | | | | | | | | | | | | This is relative to https://bugs.llvm.org//show_bug.cgi?id=38119. SHT_SYMTAB section is able to keep symbols with output section indices up to 0xff00 (SHN_LORESERVE). But if we have indices that are greater than that (PR shows that it might happen), we need to use SHT_SYMTAB_SHNDX extended section. It was not supported by LLD. Description of the SHT_SYMTAB_SHNDX section is here: https://docs.oracle.com/cd/E19683-01/817-3677/chapter6-94076/index.html. Differential revision: https://reviews.llvm.org/D49541 llvm-svn: 338247
* [ELF][HEXAGON] Add R_HEX_32_6_X and R_HEX_12_XSid Manning2018-07-291-0/+7
| | | | | | And add a test. llvm-svn: 338213
* Reland r338088, "ELF: Make --print-icf-sections output deterministic."Peter Collingbourne2018-07-271-24/+24
| | | | | | | | | | | | | | | | | | | | The xxHash64 function has been made unsigned-char-independent, so we can reland this change now. Original commit message: > The icf-safe.s test currently fails on 32-bit platforms because it uses > the --print-icf-sections flag and depends on the output appearing in > a specific order. However, this flag causes the output to depend on > the order of the sections in the Sections array, which depends on the > hash values returned from hash_combine, which happen to be different > for that test between 32-bit and 64-bit platforms. > > This change makes the output deterministic by using xxHash64 instead of > hash_combine. Differential Revision: https://reviews.llvm.org/D49877 llvm-svn: 338153
* Revert "ELF: Make --print-icf-sections output deterministic."Ilya Biryukov2018-07-271-20/+20
| | | | | | | This reverts commit r338088. To unbreak our integrate. The resulting lld output is different if compiled with '-funsigned-char'. llvm-svn: 338110
* ELF: Make --print-icf-sections output deterministic.Peter Collingbourne2018-07-261-20/+20
| | | | | | | | | | | | | | | | The icf-safe.s test currently fails on 32-bit platforms because it uses the --print-icf-sections flag and depends on the output appearing in a specific order. However, this flag causes the output to depend on the order of the sections in the Sections array, which depends on the hash values returned from hash_combine, which happen to be different for that test between 32-bit and 64-bit platforms. This change makes the output deterministic by using xxHash64 instead of hash_combine. Differential Revision: https://reviews.llvm.org/D49877 llvm-svn: 338088
* [COFF] Handle comdat sections without leader symbolsMartin Storsjo2018-07-261-0/+21
| | | | | | | | | | | | | | | | | Discard them unless they have been associated by other means (yet uimplemented). According to MS link.exe, such sections are illegal, but MinGW setups use them in their take on associative comdats. This avoids leaving references to the bogus SectionChunk* PendingComdat, which cannot be dereferenced. This fixes PR38183. Differential Revision: https://reviews.llvm.org/D49653 llvm-svn: 338064
* [ELF] Fix linker-script-in-search-path.sFangrui Song2018-07-251-3/+3
| | | | llvm-svn: 337983
* [ELF] Make linker-script-in-search-path.s robust per r337972Fangrui Song2018-07-251-2/+2
| | | | llvm-svn: 337975
* Make a test more robust.Rui Ueyama2018-07-251-3/+3
| | | | | | | Previously, this test fails if there's other test that happens to create "t.script" in the current directory. llvm-svn: 337972
* [ELF] Use search paths for --version-script=Fangrui Song2018-07-251-0/+10
| | | | | | | | | | | | Summary: This behavior matches ld.bfd -Ld --version-script=t.script a.o Reviewers: ruiu, espindola Subscribers: emaste, arichardson, llvm-commits Differential Revision: https://reviews.llvm.org/D49820 llvm-svn: 337969
* ELF: Do not ICF SHF_LINK_ORDER sections.Peter Collingbourne2018-07-251-0/+18
| | | | | | | | | | | | | | | | | | We are already ICF'ing these sections as a unit with their dependent sections, so they don't need to be considered for ICF individually. This change also "fixes" slowness caused by our quadratic-in-group-size relocation segregation algorithm on 32-bit ARM platforms with unwind data and ICF on rodata. In this scenario almost every function's .ARM.exidx is identical except for the targets of the relocations that refer to the function and its .ARM.extab, which causes almost all of the program's .ARM.exidx sections to be initially added to the same class, which causes us to compare every such section with every other such section. Differential Revision: https://reviews.llvm.org/D49716 llvm-svn: 337967
* Fix error messages for bad symbols.Rui Ueyama2018-07-241-0/+34
| | | | | | | | | Previously, the error messages didn't contain symbol name because we didn't read a symbol name for these error messages. Differential Revision: https://reviews.llvm.org/D49762 llvm-svn: 337863
* [ELF][HEXAGON] Add R_HEX_B15_PCREL_X relocationSid Manning2018-07-241-0/+5
| | | | | | | | Update testcase Differential Revision: https://reviews.llvm.org/D49567 llvm-svn: 337829
* [ELF][MIPS] Fix primary GOT sometimes overflowing by one or two wordsSimon Atanasyan2018-07-242-0/+88
| | | | | | | | | | | | | | | | If we fail to merge a secondary GOT with the primary GOT but so far only one merged GOT has been created (the primary one), the final element in MergedGots is the primary GOT. Thus we should not try to merge with this final element passing IsPrimary=false, since this will ignore the fact that the destination GOT does in fact need a header, and those extra two entries can be enough to allow the merge to incorrectly occur. Instead we should check for this case before attempting the second merge. Patch by James Clarke. Differential revision: https://reviews.llvm.org/D49422 llvm-svn: 337810
* [WebAssembly] Add support for --whole-archive.Sam Clegg2018-07-231-0/+34
| | | | | | | | Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D49706 llvm-svn: 337777
* Revert r337638, "ELF: Make sections with KeepUnique bit eligible for ICF."Peter Collingbourne2018-07-231-4/+1
| | | | | | | | | | | | | | | | | | The gold behaviour with regard to --keep-unique is arguably a bug. I also noticed a bug in my patch, which is that we mislink the following program with --icf=safe by merging f3 and f4: void f1() {} void f2() {} __attribute__((weak)) void* f3() { return f1; } __attribute__((weak)) void* f4() { return f2; } int main() { printf("%p %p\n", f3(), f4()); } llvm-svn: 337729
* [LLD] Add llvm-objcopy to test dependencies. NFC.Andrew Ng2018-07-231-3/+3
| | | | | | | | Dependency on llvm-objcopy was introduced by r337429. Also sorted the list of dependencies. llvm-svn: 337693
OpenPOWER on IntegriCloud