summaryrefslogtreecommitdiffstats
path: root/lld/test
Commit message (Collapse)AuthorAgeFilesLines
...
* [ELF][MIPS] Improve testsFangrui Song2019-07-2529-466/+466
| | | | | | | | | | * Add --no-show-raw-insn to llvm-objdump -d tests * When linking an executable with %t.so, the path %t.so will be recorded in the DT_NEEDED entry if %t.so doesn't have DT_SONAME. .dynstr will have varying lengths on different systems. Add -soname to make tests more robust. llvm-svn: 366988
* [WebAssembly] Set __tls_align to 1 when there is no TLSGuanzhong Chen2019-07-241-0/+41
| | | | | | | | | | | | | | | | | | Summary: We want the tool conventions to state that `__tls_align` will be a power of 2. It makes sense to not have an exception for when there is no TLS. Reviewers: tlively, sunfish Reviewed By: tlively Subscribers: dschuff, sbc100, jgravelle-google, aheejin, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65177 llvm-svn: 366948
* [LLD] Do not print additional newlines after reaching error limitAlexander Richardson2019-07-241-0/+24
| | | | | | | | | | | | | | | | | | | | Summary: This could previously happen if errors that are emitted after reaching the error limit. In that case, the flag inside the newline() function will be set to true which causes the next call to print a newline even though the actual message will be discarded. Reviewers: ruiu, grimar, MaskRay, espindola Reviewed By: ruiu Subscribers: emaste, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D65198 llvm-svn: 366944
* ld.lld: Demangle symbols from archives in diagnosticsNico Weber2019-07-231-6/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | This ports r366573 from COFF to ELF. There are now to toString(Archive::Symbol), one doing MSVC demangling in COFF and one doing Itanium demangling in ELF, so rename these two to toCOFFString() and to toELFString() to not get a duplicate symbol. Nothing ever passes a raw Archive::Symbol to CHECK(), so these not being part of the normal toString() machinery seems ok. There are two code paths in the ELF linker that emits this type of diagnostic: 1. The "normal" one in InputFiles.cpp. This is covered by the tweaked test. 2. An additional one that's only used for libcalls if there's at least one bitcode in the link, and if the libcall symbol is lazy, and lazily loaded from an archive (i.e. not from a lazy .o file). (This code path was added in r339301.) Since all libcall names so far are C symbols and never mangled, the change there is not observable and hence not covered by tests. Differential Revision: https://reviews.llvm.org/D65095 llvm-svn: 366836
* [test] Fix the test from the previous commit when run on windows. NFC.Martin Storsjo2019-07-232-2/+11
| | | | | | | Apparently the escaped dollar sign didn't work the same way in "echo -e" on windows buildbots. llvm-svn: 366784
* [COFF] Unbreak sorting of mingw comdat .tls sections after SVN r363457Martin Storsjo2019-07-231-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | Code built for mingw with -fdata-sections will store each TLS variable in a comdat section, named .tls$$<varname>. Normal TLS variables are stored in sections named .tls$ with a trailing dollar, which are sorted after a starter marker (in a later linked object file) in a section named ".tls" (with no dollar suffix), before an ending marker in a section named ".tls$ZZZ". The mingw comdat section suffix stripping introduced in SVN r363457 broke sorting of such tls sections, ending up sorting the stripped .tls$$<varname> sections (stripped to ".tls") before the start marker in the section named ".tls". We could add exceptions to the section name suffix stripping for .tls (and .CRT, where suffixes always should be honored), but the more conservative option is probably the reverse; to only apply the stripping for the normal sections where sorting shouldn't have any effect. Differential Revision: https://reviews.llvm.org/D65018 llvm-svn: 366780
* [ARM][test] Improve testsFangrui Song2019-07-2246-253/+249
| | | | | | | Delete trailing 2>&1 that is not piped to another command. Add --no-show-raw-insn to objdump -d commands. llvm-svn: 366676
* [ELF] Support explicitly overriding relocation model in LTOPetr Hosek2019-07-201-0/+9
| | | | | | | | lld currently selects the relocation model automatically depending on the link flags specified, but in some cases it'd be useful to allow explicitly overriding the relocation model using a flag. llvm-svn: 366644
* [WebAssembly] Compute and export TLS block alignmentGuanzhong Chen2019-07-192-0/+78
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add immutable WASM global `__tls_align` which stores the alignment requirements of the TLS segment. Add `__builtin_wasm_tls_align()` intrinsic to get this alignment in Clang. The expected usage has now changed to: __wasm_init_tls(memalign(__builtin_wasm_tls_align(), __builtin_wasm_tls_size())); Reviewers: tlively, aheejin, sbc100, sunfish, alexcrichton Reviewed By: tlively Subscribers: dschuff, jgravelle-google, hiraditya, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D65028 llvm-svn: 366624
* lld-link: Demangle symbols from archives in diagnosticsNico Weber2019-07-192-0/+45
| | | | | | | | | Also add test coverage for thin archives (which are the only way I could come up with to test at least some of the diagnostic changes). Differential Revision: https://reviews.llvm.org/D64927 llvm-svn: 366573
* [ELF][test] Fix aarch64-condb-reloc.sFangrui Song2019-07-191-1/+1
| | | | llvm-svn: 366534
* [ELF][AArch64] Improve some aarch64-*.s testsFangrui Song2019-07-1913-244/+188
| | | | | | | | | * Delete aarch64-tls-static.s: it is covered by aarch64-tlsdesc.c * Add --no-show-raw-insn to llvm-objdump -d tests * When linking an executable with %t.so, the path %t.so will be recorded in the DT_NEEDED entry if %t.so doesn't have DT_SONAME. The DT_NEEDED has varying lengths on different systems. Add -soname to make tests more robust. This issue will become outstanding if we allow overlapping PT_LOAD (D64930). llvm-svn: 366532
* [WebAssembly] Use passive segments by default when memory is sharedThomas Lively2019-07-185-22/+19
| | | | | | | | | | | | | | | | | | Summary: This change makes it so that passing --shared-memory is all a user needs to do to get proper multithreaded code. This default can still be explicitly overridden for any reason using --passive-segments and --active-segments. Reviewers: sbc100, quantum Subscribers: dschuff, jgravelle-google, aheejin, sunfish, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64950 llvm-svn: 366504
* [WebAssembly] fix bug in finding .tdata segmentGuanzhong Chen2019-07-181-3/+3
| | | | | | | | | | | | | | | | Summary: Fix bug in `wasm-ld`'s `Writer::createInitTLSFunction` that only finds `.tdata` if it's the first section. Reviewers: tlively, aheejin, sbc100 Reviewed By: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64947 llvm-svn: 366500
* ELF: Add support for remaining R_AARCH64_MOVW* relocations.Peter Collingbourne2019-07-182-0/+107
| | | | | | Differential Revision: https://reviews.llvm.org/D64685 llvm-svn: 366466
* ELF: Simplify test. NFCI.Peter Collingbourne2019-07-182-10/+6
| | | | | | | | | | Avoid splitting the test into multiple files and use zero for the value of the symbol with addends at relocations so that it's clear what value is being used at relocations. Differential Revision: https://reviews.llvm.org/D64684 llvm-svn: 366463
* ELF: Allow forward references to linked sections.Peter Collingbourne2019-07-181-0/+23
| | | | | | | | | | | It's possible to create IR that uses !associated to refer to a global that appears later in the module, which can result in these types of forward references being generated. Unfortunately our assembler does not currently accept the resulting .s so I needed to use yaml2obj to test this. Differential Revision: https://reviews.llvm.org/D64880 llvm-svn: 366460
* [ELF][PPC] Delete ppc64-dynamic-relocations.sFangrui Song2019-07-181-50/+0
| | | | | | I forgot to delete it in r366424. llvm-svn: 366445
* [ELF][PPC] Refactor some ppc64 testsFangrui Song2019-07-189-619/+307
| | | | | | | | Merge ppc64-dynamic-relocations.s into ppc64-plt-stub.s Add ppc64-tls-ie.s: covers ppc64-initial-exec-tls.s and ppc64-tls-ie-le.s Add ppc64-tls-gd.s: covers ppc64-general-dynamic-tls.s, ppc64-gd-to-ie.s, ppc64-tls-gd-le.s, and ppc64-tls-gd-le-small.s llvm-svn: 366424
* [lld] Fix vs-diagnostics-version-script test. NFC.Chris Jackson2019-07-181-5/+2
| | | | | | Removed unnecessary llvm-mc call. llvm-svn: 366418
* Fixup r366333 (require x86 in test)Diana Picus2019-07-181-0/+1
| | | | | | Seems to be required for the other added tests too. llvm-svn: 366416
* [ELF][test] Merge/rename some basic*.s testsFangrui Song2019-07-183-239/+40
| | | | | | | | | | basic64be.s is a big-endian powerpc64 test that just duplicates what basic-ppc64.s does. Extend basic-ppc64.s to add big-endian tests. Delete basic64be.s Rename basic32.s to basic-i386.s llvm-svn: 366401
* [lld][WebAssembly] Fix handling of comdat functions in init array.Sam Clegg2019-07-173-12/+20
| | | | | | | | | | | | | | | | | When hidden symbols are discarded by comdat rules we still want to create a local defined symbol, otherwise `Symbol::isDiscarded()` relies on begin able to check `getChunk->discarded`. This is a followup on rL362769. The comdat.ll test was previously GC'ing the `__wasm_call_ctors` functions so `do_init` was not actually being included in the link. Once that function was included in triggered the crash bug that this change addresses. Fixes: https://github.com/emscripten-core/emscripten/issues/8981 Differential Revision: https://reviews.llvm.org/D64872 llvm-svn: 366358
* [lld] Add Visual Studio compatible diagnosticsChris Jackson2019-07-178-0/+215
| | | | | | | | | | | | Summary: Add a --vs-diagnostics flag that alters the format of diagnostic output to enable source hyperlinks in Visual Studio. Differential Revision: https://reviews.llvm.org/D58484 Reviewed by: ruiu llvm-svn: 366333
* Add REQUIRES: x86 to safeseh-no.s test for x86Reid Kleckner2019-07-161-0/+1
| | | | llvm-svn: 366273
* [WebAssembly] Implement thread-local storage (local-exec model)Guanzhong Chen2019-07-162-5/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Thread local variables are placed inside a `.tdata` segment. Their symbols are offsets from the start of the segment. The address of a thread local variable is computed as `__tls_base` + the offset from the start of the segment. `.tdata` segment is a passive segment and `memory.init` is used once per thread to initialize the thread local storage. `__tls_base` is a wasm global. Since each thread has its own wasm instance, it is effectively thread local. Currently, `__tls_base` must be initialized at thread startup, and so cannot be used with dynamic libraries. `__tls_base` is to be initialized with a new linker-synthesized function, `__wasm_init_tls`, which takes as an argument a block of memory to use as the storage for thread locals. It then initializes the block of memory and sets `__tls_base`. As `__wasm_init_tls` will handle the memory initialization, the memory does not have to be zeroed. To help allocating memory for thread-local storage, a new compiler intrinsic is introduced: `__builtin_wasm_tls_size()`. This instrinsic function returns the size of the thread-local storage for the current function. The expected usage is to run something like the following upon thread startup: __wasm_init_tls(malloc(__builtin_wasm_tls_size())); Reviewers: tlively, aheejin, kripken, sbc100 Subscribers: dschuff, jgravelle-google, hiraditya, sunfish, jfb, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D64537 llvm-svn: 366272
* Mark new test as requiring an x86 backend for LTO native object generationReid Kleckner2019-07-161-0/+2
| | | | llvm-svn: 366245
* Fix linkrepro.test after safeseh:no changeReid Kleckner2019-07-161-0/+6
| | | | | | Add the @feat.00 flag to the input. llvm-svn: 366244
* [COFF] Implement /safeseh:no and check @feat.00 flags by defaultReid Kleckner2019-07-1629-53/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fixes PR41828. Before this, LLD always emitted SafeSEH chunks and defined __safe_se_handler_table & size. Now, /safeseh:no leaves those undefined. Additionally, we were checking for the safeseh @feat.00 flag in two places: once to emit errors, and once during safeseh table construction. The error was set up to be off by default, but safeseh is supposed to be on by default. I combined the two checks, so now LLD emits an error if an input object lacks @feat.00 and safeseh is enabled. This caused the majority of 32-bit LLD tests to fail, since many test input object files lack @feat.00 symbols. I explicitly added -safeseh:no to those tests to preserve behavior. Finally, LLD no longer sets IMAGE_DLL_CHARACTERISTICS_NO_SEH if any input file wasn't compiled for safeseh. Reviewers: mstorsjo, ruiu, thakis Reviewed By: ruiu, thakis Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63570 llvm-svn: 366238
* [NFC][test] Fix for riscv tests.Puyan Lotfi2019-07-164-16/+16
| | | | | | Following tests need updating for: https://reviews.llvm.org/D55277 llvm-svn: 366183
* [ELF] Fix variable names in comments after VariableName -> variableName changeFangrui Song2019-07-163-9/+9
| | | | | | Also fix some typos. llvm-svn: 366181
* Reland "[COFF] Add null check in case of symbols defined in LTO blobs"Reid Kleckner2019-07-153-0/+140
| | | | | | | | | | This reverts r365990 (git commit 1a6053ebc61cb0b8146f5ca27b74859a9a91e0a3) The test no longer depends on the Visual C++ libraries. I confirmed that the crash still reproduces with the new test case if I remove the null check. llvm-svn: 366095
* Revert "[COFF] Add null check in case of symbols defined in LTO blobs"Petr Hosek2019-07-133-141/+0
| | | | | | This reverts commit r365979: COFF/undefined-symbol-lto.test is failing. llvm-svn: 365990
* [COFF] Add null check in case of symbols defined in LTO blobsReid Kleckner2019-07-133-0/+141
| | | | | | | | | The test case could probably be improved further if the failure path was better understood. Fixes PR42536 llvm-svn: 365979
* [WebAssembly] i32.const operands should be signedThomas Lively2019-07-121-10/+21
| | | | | | | | | | | | | | | | Summary: This was causing large addresses to be emitted as negative numbers, which rightfully caused crashes in binaryen. Reviewers: aheejin, dschuff Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64612 llvm-svn: 365930
* [mips] Simplify test case. NFCSimon Atanasyan2019-07-111-13/+5
| | | | | | | | Before rL295040 the linker just crashed when a GOT relocation (R_MIPS_GOT16) comes from a merge section. To ensure that this bug still fixed it's enough to check that the linker does not crash and create GOT entries. llvm-svn: 365834
* [COFF] Share the tail in delayimport symbol thunksMartin Storsjo2019-07-115-51/+51
| | | | | | | | | | | | | E.g. for x86_64, previously each symbol's thunk was 87 bytes. Now there's a 12 byte thunk per symbol, plus a shared 83 byte tail function. This is similar to what both MS link.exe and GNU tools do for delay imports. Differential Revision: https://reviews.llvm.org/D64288 llvm-svn: 365823
* [lld-link] implement -thinlto-{prefix,object-suffix}-replaceBob Haarman2019-07-112-0/+76
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Adds the following two options to lld-link: -thinlto-prefix-replace: allows replacing a prefix in paths generated for ThinLTO. This can be used to ensure index files and native object files are stored in unique directories, allowing multiple distributed ThinLTO links to proceed concurrently. -thinlto-object-suffix-replace: allows replacing a suffix in object file paths involved in ThinLTO. This allows minimized index files to be used for the thin link while storing the paths to the full bitcode files for subsequent steps (code generation and final linking). Reviewers: ruiu, tejohnson, pcc, rnk Subscribers: mehdi_amini, steven_wu, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64542 llvm-svn: 365807
* [lld-link] implement -thinlto-index-onlyBob Haarman2019-07-114-0/+119
| | | | | | | | | | | | | | | | | | | | | | | Summary: This implements -thinlto-index-only, -thinlto-index-only:, and -thinlto-emit-imports-files options in lld-link. They are analogous to their counterparts in ld.lld: -thinlto-index-only causes us to perform ThinLTO's thin link and write index files, but not perform code generation. -thinlto-index-only: does the same, but also writes a text file listing the native object files expected to be generated. -thinlto-emit-imports-files creates a text file next to each index file, listing the files to import from. Reviewers: ruiu, tejohnson, pcc, rnk Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64461 llvm-svn: 365800
* [WebAssembly] Import __stack_pointer when building -pie binariesSam Clegg2019-07-111-0/+5
| | | | | | | | | | | | | The -pie binary doesn't know that layout ahead of time so needs to import the stack pointer from the embedder, just like we do already for shared libraries. This change is needed in order to address: https://github.com/emscripten-core/emscripten/issues/8915 Differential Revision: https://reviews.llvm.org/D64516 llvm-svn: 365771
* [ELF] Handle non-glob patterns before glob patterns in version scripts & fix ↵Fangrui Song2019-07-112-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a corner case of --dynamic-list This fixes PR38549, which is silently accepted by ld.bfd. This seems correct because it makes sense to let non-glob patterns take precedence over glob patterns. lld issues an error because `assignWildcardVersion(ver, VER_NDX_LOCAL);` is processed before `assignExactVersion(ver, v.id, v.name);`. Move all assignWildcardVersion() calls after assignExactVersion() calls to fix this. Also, move handleDynamicList() to the bottom. computeBinding() called by includeInDynsym() has this cryptic rule: if (versionId == VER_NDX_LOCAL && isDefined() && !isPreemptible) return STB_LOCAL; Before the change: * foo's version is set to VER_NDX_LOCAL due to `local: *` * handleDynamicList() is called - foo.computeBinding() is STB_LOCAL - foo.includeInDynsym() is false - foo.isPreemptible is not set (wrong) * foo's version is set to V1 After the change: * foo's version is set to VER_NDX_LOCAL due to `local: *` * foo's version is set to V1 * handleDynamicList() is called - foo.computeBinding() is STB_GLOBAL - foo.includeInDynsym() is true - foo.isPreemptible is set (correct) Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D64550 llvm-svn: 365760
* [ELF] Warn rather than error when duplicate version assignments occurFangrui Song2019-07-112-6/+31
| | | | | | | | | | | | | | | | | | | | | | In lvm2, libdevmapper.so is linked with a version script with duplicate version assignments: DM_1_02_138 { global: ... dm_bitset_parse_list; ... }; DM_1_02_129 { global: ... dm_bitset_parse_list; ... }; ld.bfd silently accepts this while gold issues a warning. We currently error, thus inhibit producing the executable. Change the error to warning to allow this case, and improve the message. There are some cases where ld.bfd error `anonymous version tag cannot be combined with other version tags` but we just warn. It is probably OK for now. Reviewed By: grimar, ruiu Differential Revision: https://reviews.llvm.org/D64549 llvm-svn: 365759
* Revert "[ELF] Update test case due to llvm r365618"Nikola Prica2019-07-101-7/+13
| | | | | | | | Reverting du to reverting r365618 This reverts commit b1e76d1d41c2303f70b53e352bdefbff2a2a9d37. llvm-svn: 365686
* ELF: Add support for R_AARCH64_ADR_PREL_PG_HI21_NC relocation.Peter Collingbourne2019-07-102-0/+10
| | | | | | Differential Revision: https://reviews.llvm.org/D64456 llvm-svn: 365662
* [LLD][ELF] - Linkerscript: fix FILL() expressions handling.George Rimar2019-07-102-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | D64130 introduced a bug described in the following message: https://reviews.llvm.org/D64130#1571560 The problem can happen with the following script: SECTIONS { .out : { ... FILL(0x10101010) *(.aaa) ... } The current code tries to read (0x10101010) as an expression and does not break when meets *, what results in a script parsing error. In this patch, I verify that FILL command's expression always wrapped in (). And at the same time =<fillexp> expression can be both wrapped or unwrapped. I checked it matches to bfd/gold. Differential revision: https://reviews.llvm.org/D64476 llvm-svn: 365635
* [ELF] Update test case due to llvm r365618Nikola Prica2019-07-101-13/+7
| | | | llvm-svn: 365619
* [lld][WebAssembly] Report undefined symbols during scanRelocationsSam Clegg2019-07-092-4/+4
| | | | | | | | | | | | | | | | This puts handling of undefined symbols in a single location. Its also more in line with the ELF backend which only reports undefined symbols based on relocations. One side effect is that we no longer report undefined symbols that are only referenced in GC'd sections. This also fixes a crash reported in the emscripten toolchain: https://github.com/emscripten-core/emscripten/issues/8930. Differential Revision: https://reviews.llvm.org/D64280 llvm-svn: 365553
* [ELF][test] Rename tail-merge-string-align2.s to merge-string-align2.sFangrui Song2019-07-091-0/+0
| | | | | | | | | | This test was added by D64200/r365139 to check we don't merge SHF_MERGE|SHF_STRINGS sections with different alignments (that wastes space and can make MergeTailAlignment::Builder out of sync). It has nothing to do with tail merge (-O2), so rename it. llvm-svn: 365442
* Let unaliased Args track which Alias they were created from, and use that in ↵Nico Weber2019-07-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Arg::getAsString() for diagnostics With this, `clang-cl /source-charset:utf-16 test.cc` now prints `invalid value 'utf-16' in '/source-charset:utf-16'` instead of `invalid value 'utf-16' in '-finput-charset=utf-16'` before, and several other clang-cl flags produce much less confusing output as well. Fixes PR29106. Since an arg and its alias can have different arg types (joined vs not) and different values (because of AliasArgs<>), I chose to give the Alias its own Arg object. For convenience, I just store the alias directly in the unaliased arg – there aren't many arg objects at runtime, so that seems ok. Finally, I changed Arg::getAsString() to use the alias's representation if it's present – that function was already documented as being the suitable function for diagnostics, and most callers already used it for diagnostics. Implementation-wise, Arg::accept() previously used to parse things as the unaliased option. The core of that switch is now extracted into a new function acceptInternal() which parses as the _aliased_ option, and the previously-intermingled unaliasing is now done as an explicit step afterwards. (This also changes one place in lld that didn't use getAsString() for diagnostics, so that that one place now also prints the flag as the user wrote it, not as it looks after it went through unaliasing.) Differential Revision: https://reviews.llvm.org/D64253 llvm-svn: 365413
* [lld] Use -o /dev/null in test when output is not needed.Sam Clegg2019-07-081-1/+1
| | | | | | Fix for feedback nit from rL364998 llvm-svn: 365310
OpenPOWER on IntegriCloud