summaryrefslogtreecommitdiffstats
path: root/lld/test/wasm
Commit message (Collapse)AuthorAgeFilesLines
...
* [WebAssembly] Relax signature checking for undefined functions that are not ↵Sam Clegg2019-05-241-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | called directly When function signatures don't match and the undefined function is not called directly (i.e. only has its address taken) we don't issue a warning or create a runtime thunk for the undefined function. Instead in this case we simply use the defined version of the function. This is possible since checking signatures of dynamic calls happens at runtime so any invalid usage will still result in a runtime error. This is needed to allow C++ programs to link without generating warnings. Its not uncommon in C++ for vtables to be populated by function address whee the signature of the function is not known in the compilation unit. In this case clang declares the method as void(void) and relies on the vtable caller casting the data back to the correct signature. Fixes: https://bugs.llvm.org/show_bug.cgi?id=40412 Differential Revision: https://reviews.llvm.org/D62153 llvm-svn: 361678
* [WebAssebmly] Add support for --wrapSam Clegg2019-05-241-0/+40
| | | | | | | | | | | The code for implementing this features is taken almost verbatim from the ELF backend. Fixes: https://bugs.llvm.org/show_bug.cgi?id=41681 Differential Revision: https://reviews.llvm.org/D62380 llvm-svn: 361639
* [lld] Trace all references with lld --trace-symbolSam Clegg2019-05-241-7/+12
| | | | | | | | | | | Previously undefined symbol references were only traced if they were seen before that definition. Fixes https://bugs.llvm.org/show_bug.cgi?id=41878 Differential Revision: https://reviews.llvm.org/D61929 llvm-svn: 361636
* [WebAssembly] Add support for -emit-relocsSam Clegg2019-05-241-0/+39
| | | | | | | | | | This can be useful for post-link tools and for testing. Sometimes it can be useful to produces a regular executable but with relocations preserved. Differential Revision: https://reviews.llvm.org/D62378 llvm-svn: 361635
* Reland: [WebAssembly] Add __start_/_stop_ symbols for data sectionsSam Clegg2019-05-231-0/+57
| | | | | | | | | | This is a reland of rL361235. Fixes https://bugs.llvm.org/show_bug.cgi?id=41565 Differential Revision: https://reviews.llvm.org/D61876 llvm-svn: 361476
* Fix test to put its outputs into the temp directory.Richard Smith2019-05-211-2/+2
| | | | llvm-svn: 361297
* Revert "[WebAssembly] Add __start_/_stop_ symbols for data sections"Sam Clegg2019-05-211-57/+0
| | | | | | | | | This reverts commit 7804dbddccba412087a15cab8db4412939700952. This change broke a bunch of tests of the WebAssembly waterfall. Will hopefully reland with increased test coverage. llvm-svn: 361273
* Fix test failure.Rui Ueyama2019-05-211-1/+1
| | | | | | I forgot to submit a last-minute change to the last patch. llvm-svn: 361249
* [WebAssembly] Add --reproduce.Rui Ueyama2019-05-211-0/+27
| | | | | | | | | | | | | | | --reproduce is a convenient option for debugging. If you invoke lld with `--reproduce=repro.tar`, it creates `repro.tar` with all input files and the command line options given to the linker, so that it is very easy to run lld with the exact same inputs. ELF and Windows lld have this option. This patch add that option to lld/wasm. Differential Revision: https://reviews.llvm.org/D62170 llvm-svn: 361244
* [WebAssembly] Add __start_/_stop_ symbols for data sectionsSam Clegg2019-05-211-0/+57
| | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=41565 Differential Revision: https://reviews.llvm.org/D61876 llvm-svn: 361236
* [WebAssembly] Don't generate empty type sections.Sam Clegg2019-05-161-0/+10
| | | | | | Differential Revision: https://reviews.llvm.org/D61991 llvm-svn: 360940
* [lld] Remove 2>&1 from --trace-symbol testsSam Clegg2019-05-151-2/+2
| | | | | | | | | | | | | The tracing goes to stdout so this is not needed. Also remove the "not" from the final check in ELF/trace-symbols.s. According the comment the check is that we don't crash, so we should be checking for success here. Previously this step is error'ing with undefined symbols because it didn't include all the needed objects. Differential Revision: https://reviews.llvm.org/D61928 llvm-svn: 360794
* [WebAssembly] LTO: Honor comdat groups when loading bitcode filesSam Clegg2019-05-151-0/+15
| | | | | | | | | But don't apply comdat groups when loading the LTO object files. This is basically the same logic used by the ELF linker. Differential Revision: https://reviews.llvm.org/D61924 llvm-svn: 360782
* [WebAssembly] Don't assume that strongly defined symbols are DSO-localSam Clegg2019-05-102-9/+14
| | | | | | | | | | | | | | | | The current PIC model for WebAssembly is more like ELF in that it allows symbol interposition. This means that more functions end up being addressed via the GOT and fewer directly added to the wasm table. One effect is a reduction in the number of wasm table entries similar to the previous attempt in https://reviews.llvm.org/D61539 which was reverted. Differential Revision: https://reviews.llvm.org/D61772 llvm-svn: 360402
* Revert "[WebAssembly] Don't generate unused table entries."Sam Clegg2019-05-092-6/+6
| | | | | | | | This reverts commit b33fdb7768e5de5fbeb23f65d8d455e7ca88b021. This change apparently broke am emscripten test. llvm-svn: 360367
* [WebAssembly] Don't generate unused table entries.Sam Clegg2019-05-072-6/+6
| | | | | | | | | | | | | | When generating PIC output only relocations of type R_WASM_TABLE_INDEX_REL_SLEB should generate table entries. R_WASM_TABLE_INDEX_I32 get resolved at runtime via the auto-generated __wasm_apply_relocs functions. R_WASM_TABLE_INDEX_SLEB are not allowed in PIC code. Differential Revision: https://reviews.llvm.org/D61539 llvm-svn: 360165
* [WebAssembly] Add more test coverage for reloctions against section symbolsSam Clegg2019-05-071-0/+51
| | | | | | | | | | | | | The only known user of this relocation type and symbol type is the debug info sections, but we were not testing the `--relocatable` output path. This change adds a minimal test case to cover relocations against section symbols includes `--relocatable` output. Differential Revision: https://reviews.llvm.org/D61623 llvm-svn: 360110
* [test] Change llvm-readobj -long-option to --long-option or well-known short ↵Fangrui Song2019-05-013-3/+3
| | | | | | | | | | | | options. NFC Also change some options that have different semantics (cause confusion) in llvm-readelf mode: -s => -S -t => --symbols -sd => --section-data llvm-svn: 359651
* [WebAssembly] Always take into account added when applying runtime relocationsSam Clegg2019-04-251-3/+14
| | | | | | | | | | | The code we generate for applying data relocations at runtime omitted the symbols with GOT entries. Also refactor the code to reduce duplication. Differential Revision: https://reviews.llvm.org/D61111 llvm-svn: 359207
* [WebAssembly] Fix typo in relocation checkingSam Clegg2019-04-231-0/+53
| | | | | | | | | | | Runtime relocation are generated for relocations of type R_WASM_MEMORY_ADDR_I32 when in PIC mode (either -shared or -pie). Followup on https://reviews.llvm.org/D60882. Differential Revision: https://reviews.llvm.org/D60992 llvm-svn: 358995
* [WebAssembly] Error on relocations against undefined data symbols.Sam Clegg2019-04-221-2/+4
| | | | | | | | | | | | | | | | | We can't (currently) meaningfully resolve certain types of relocations against undefined data symbols. Previously when `--allow-undefined` was used we were treating such relocation much like weak data symbols and simply inserting zeros. This change turns such use cases in to an error. This means that `--allow-undefined` is no longer effective for data symbols. Fixes https://bugs.llvm.org/show_bug.cgi?id=40364 Differential Revision: https://reviews.llvm.org/D60882 llvm-svn: 358899
* [WebAssembly] Emit the DataCount section when bulk memory is enabledThomas Lively2019-04-191-0/+16
| | | | | | | | | | | | | | | | | | Summary: The DataCount section is necessary for the bulk memory operations memory.init and data.drop to validate, but it is not recognized by engines that do not support bulk memory, so emit the section only if bulk-memory is enabled. Reviewers: aheejin, dschuff, sbc100 Subscribers: jgravelle-google, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60637 llvm-svn: 358798
* [WebAssembly] Assign GOT entries symbols used in data relocationsSam Clegg2019-04-101-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D60492 llvm-svn: 358090
* [WebAssembly] Ensure ArchiveName is set even in the presence of --whole-archive.Sam Clegg2019-04-091-0/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D60431 llvm-svn: 357966
* [WebAssembly] Include function in wasm table when used in ↵Sam Clegg2019-04-051-5/+12
| | | | | | | | | | | | R_WASM_TABLE_INDEX_REL_SLEB This should have been part of rL357710 but was overlooked because in our test code the function in question was also used in other relocations that caused it to be added to the table anyway. Differential Revision: https://reviews.llvm.org/D60296 llvm-svn: 357737
* [WebAssembly] Apply data relocations at runtime in shared objectsSam Clegg2019-04-042-4/+25
| | | | | | | | | | | | | See: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md Data section relocations in wasm shared libraries are applied by the library itself at static constructor time. This change adds a new synthetic function that applies relocations to relevant memory locations on startup. Differential Revision: https://reviews.llvm.org/D59278 llvm-svn: 357715
* Re-land "[WebAssembly] Improve invalid relocation error message""Sam Clegg2019-03-291-1/+1
| | | | | | | | | | See https://reviews.llvm.org/D59860 The initial version of this change effected more than just the error message. This version is scoped down to only effect the error itself. llvm-svn: 357328
* [WebAssembly] "atomics" feature requires shared memoryThomas Lively2019-03-292-0/+135
| | | | | | | | | | | | | | | | | | Summary: Makes it a linker error if the "atomics" feature is used but the user does not opt in to shared memory or if "atomics" is disallowed but the user does opt in to shared memory. Also check that an appropriate max memory size is supplied if shared memory is used. Reviewers: sbc100, aheejin Subscribers: dschuff, jgravelle-google, sunfish, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59281 llvm-svn: 357310
* Revert "[WebAssembly] Improve invalid relocation error message"Derek Schuff2019-03-291-1/+1
| | | | | | This reverts commit 0805ec5f7b5c80474352531a99e721c30e73e77f. llvm-svn: 357225
* [WebAssembly] Improve invalid relocation error messageSam Clegg2019-03-281-1/+1
| | | | | | | | This message now matches the equivalent message in the ELF linker. Differential Revision: https://reviews.llvm.org/D59860 llvm-svn: 357143
* [LLD] Restore tests that use "-" as outputAndrew Ng2019-03-274-34/+18
| | | | | | | | | | No longer require workarounds for output to "-" (stdout) for Windows. These workarounds were just hiding the actual problem which has been fixed in r357058. Differential Revision: https://reviews.llvm.org/D59824 llvm-svn: 357072
* [WebAssembly] Initial implementation of PIC code generationSam Clegg2019-03-261-11/+27
| | | | | | | | | | | | | | | | | | | | | | | | This change implements lowering of references global symbols in PIC mode. This change implements lowering of global references in PIC mode using a new @GOT reference type. @GOT references can be used with function or data symbol names combined with the get_global instruction. In this case the linker will insert the wasm global that stores the address of the symbol (either in memory for data symbols or in the wasm table for function symbols). For now I'm continuing to use the R_WASM_GLOBAL_INDEX_LEB relocation type for this type of reference which means that this relocation type can refer to either a global or a function or data symbol. We could choose to introduce specific relocation types for GOT entries in the future. See the current dynamic linking proposal: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md Differential Revision: https://reviews.llvm.org/D54647 llvm-svn: 357022
* Reland "[WebAssembly] Add linker options to control feature checking"Thomas Lively2019-03-264-15/+173
| | | | | | | | | Do not pipe binary data between processes in lit tests this time, since it turns out that can break on Windows. This reverts commit 84c8652fc3085155d0f9c355455e5a797c6d9db6. llvm-svn: 356975
* Revert "[WebAssembly] Add linker options to control feature checking"Thomas Lively2019-03-254-149/+3
| | | | | | This reverts commit 5991328c96b6146999cfa74ede42901f8c01f2fa. llvm-svn: 356932
* [WebAssembly] Add linker options to control feature checkingThomas Lively2019-03-224-3/+149
| | | | | | | | | | | | | | | | | | | | | Summary: Adds --check-features and --no-check-features. The default for now is to enable the checking, but this might change in the future. Also adds --features=foo,bar for precisely controlling the features used in the output binary. Depends on D59173. Reviewers: sbc100, aheejin Subscribers: dschuff, jgravelle-google, sunfish, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59274 llvm-svn: 356805
* Fix lld wasm tests after r356610Reid Kleckner2019-03-213-9/+15
| | | | | | | Apparently stdout is not opened in binary mode, so the executable gets corrupted when piping to obj2yaml. llvm-svn: 356694
* [WebAssembly] Target features sectionThomas Lively2019-03-207-0/+194
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Implements a new target features section in assembly and object files that records what features are used, required, and disallowed in WebAssembly objects. The linker uses this information to ensure that all objects participating in a link are feature-compatible and records the set of used features in the output binary for use by optimizers and other tools later in the toolchain. The "atomics" feature is always required or disallowed to prevent linking code with stripped atomics into multithreaded binaries. Other features are marked used if they are enabled globally or on any function in a module. Future CLs will add linker flags for ignoring feature compatibility checks and for specifying the set of allowed features, implement using the presence of the "atomics" feature to control the type of memory and segments in the linked binary, and add front-end flags for relaxing the linkage policy for atomics. Reviewers: aheejin, sbc100, dschuff Subscribers: jgravelle-google, hiraditya, sunfish, mgrang, jfb, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59173 llvm-svn: 356610
* [WebAssembly] Error on R_WASM_MEMORY_ADDR relocations against undefined data ↵Sam Clegg2019-03-162-11/+29
| | | | | | | | | | | | | | symbols. For these types of relocations an absolute memory address is required which is not possible for undefined data symbols. For symbols that can be undefined at link time (i.e. external data symbols in shared libraries) a different type of relocation (i.e. via a GOT) will be needed. Differential Revision: https://reviews.llvm.org/D59337 llvm-svn: 356310
* [WebAssembly] Improve support for "needed" list in dylink sectionSam Clegg2019-03-132-0/+40
| | | | | | | | | | | This change adds basic support for shared library dependencies via the dylink section. See https://github.com/WebAssembly/tool-conventions/pull/77 Differential Revision: https://reviews.llvm.org/D59237 llvm-svn: 356102
* [WebAssembly] Handle undefined data symbols in shared librariesSam Clegg2019-03-121-5/+14
| | | | | | | | | | | | When linking shared libraries, we import a mutable wasm global to represent the address of each undefined data symbol. This is a step towards supporting dynamic linking and shared libraries. Differential Revision: https://reviews.llvm.org/D59270 llvm-svn: 355988
* [WebAssembly] LTO: Don't include bitcode-only symbols in the symtabSam Clegg2019-03-071-0/+27
| | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=40654 Differential Revision: https://reviews.llvm.org/D59012 llvm-svn: 355577
* [WebAssembly] Test change after disabling MachineBlockPlacementHeejin Ahn2019-03-051-1/+1
| | | | | | | | | | | | | | | | Summary: We disabled MachineBlockPlacement pass in D58953, and this test result changes as the result of it. Reviewers: kripken Subscribers: dschuff, sbc100, jgravelle-google, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58954 llvm-svn: 355438
* [WebAssembly] Fix crash when __wasm_call_ctor is GCd in programs containing ↵Sam Clegg2019-03-021-0/+48
| | | | | | | | | | | | static init/fini Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58864 llvm-svn: 355263
* [WebAssebmly] Allow __wasm_call_ctors to be GC'edSam Clegg2019-03-0127-470/+216
| | | | | | Differential Revision: https://reviews.llvm.org/D58806 llvm-svn: 355240
* [WebAssembly] Remove uses of ThreadModelThomas Lively2019-02-282-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In the clang UI, replaces -mthread-model posix with -matomics as the source of truth on threading. In the backend, replaces -thread-model=posix with the atomics target feature, which is now collected on the WebAssemblyTargetMachine along with all other used features. These collected features will also be used to emit the target features section in the future. The default configuration for the backend is thread-model=posix and no atomics, which was previously an invalid configuration. This change makes the default valid because the thread model is ignored. A side effect of this change is that objects are never emitted with passive segments. It will instead be up to the linker to decide whether sections should be active or passive based on whether atomics are used in the final link. Reviewers: aheejin, sbc100, dschuff Subscribers: mehdi_amini, jgravelle-google, hiraditya, sunfish, steven_wu, dexonsmith, rupprecht, jfb, jdoerfert, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D58742 llvm-svn: 355112
* [WebAssembly] Don't generate invalid modules when function signatures mismatchSam Clegg2019-02-204-14/+85
| | | | | | | | | | | | Previously we could emit a warning and generate a potentially invalid wasm module (due to call sites and functions having conflicting signatures). Now, rather than create invalid binaries we handle such cases by creating stub functions containing unreachable, effectively turning these into runtime errors rather than validation failures. Differential Revision: https://reviews.llvm.org/D57909 llvm-svn: 354528
* [WebAssembly] Update MC for bulk memoryThomas Lively2019-02-1912-36/+36
| | | | | | | | | | | | | | | | | | Summary: Rename MemoryIndex to InitFlags and implement logic for determining data segment layout in ObjectYAML and MC. Also adds a "passive" flag for the .section assembler directive although this cannot be assembled yet because the assembler does not support data sections. Reviewers: sbc100, aardappel, aheejin, dschuff Subscribers: jgravelle-google, hiraditya, sunfish, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57938 llvm-svn: 354397
* [WebAssembly] Refactor handling of weak undefined functions. NFC.Sam Clegg2019-02-074-7/+7
| | | | | | | | | | Also add to the docs. This is refactor in preparation for https://reviews.llvm.org/D57909 Differential Revision: https://reviews.llvm.org/D57920 llvm-svn: 353478
* [WebAssembly] Fix imported function symbol names that differ from their ↵Dan Gohman2019-02-071-0/+27
| | | | | | | | | | | | import names in the .o format Add a flag to allow symbols to have a wasm import name which differs from the linker symbol name, allowing the linker to link code using the import_module attribute. Differential Revision: https://reviews.llvm.org/D57632 llvm-svn: 353473
* [WebAssembly] Honor WASM_SYMBOL_EXPORT symbol flagSam Clegg2019-02-071-1/+22
| | | | | | | | | | | | This flag means that symbol should be exported in the final binary. The reason for this change is to allow source level annotations to trigger a given symbol to be exported: https://github.com/emscripten-core/emscripten/issues/7702 Differential Revision: https://reviews.llvm.org/D57869 llvm-svn: 353364
OpenPOWER on IntegriCloud