summaryrefslogtreecommitdiffstats
path: root/lld/wasm
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix a crash bug caused by a nested call of parallelForEach.Rui Ueyama2019-04-171-6/+6
| | | | | | | | | | | | parallelForEach is not reentrant. We use parallelForEach to call each section's writeTo(), so calling the same function within writeTo() is not safe. Fixes https://bugs.llvm.org/show_bug.cgi?id=41508 Differential Revision: https://reviews.llvm.org/D60757 llvm-svn: 358547
* [WebAssembly] Assign GOT entries symbols used in data relocationsSam Clegg2019-04-102-9/+21
| | | | | | 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-095-11/+17
| | | | | | Differential Revision: https://reviews.llvm.org/D60431 llvm-svn: 357966
* [WebAssembly] Include function in wasm table when used in ↵Sam Clegg2019-04-051-1/+2
| | | | | | | | | | | | 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-048-39/+164
| | | | | | | | | | | | | 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
* [WebAssembly] Add new explicit relocation types for PIC relocationsSam Clegg2019-04-042-2/+10
| | | | | | | | See https://github.com/WebAssembly/tool-conventions/pull/106 Differential Revision: https://reviews.llvm.org/D59907 llvm-svn: 357710
* Re-land "[WebAssembly] Improve invalid relocation error message""Sam Clegg2019-03-293-10/+11
| | | | | | | | | | 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-291-3/+11
| | | | | | | | | | | | | | | | | | 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
* [ELF][MachO][wasm] Simplify range-style std::find{,_if} with STLExtras.h ↵Fangrui Song2019-03-291-4/+4
| | | | | | utilities. NFC llvm-svn: 357269
* Revert "[WebAssembly] Improve invalid relocation error message"Derek Schuff2019-03-293-20/+13
| | | | | | This reverts commit 0805ec5f7b5c80474352531a99e721c30e73e77f. llvm-svn: 357225
* Revert "[WebAssembly] Improve invalid relocation error message"Derek Schuff2019-03-293-5/+5
| | | | | | | | | | | | | Also Revert "[WebAssembly] Fix typo from rL357143" This reverts commit 0805ec5f7b5c80474352531a99e721c30e73e77f and a9958fc30d0c6d4c140be892c5a824b827d2eb5d (rL357143 and rL357144) They cause failures with address-taken extern (JS) functions in emscripten. llvm-svn: 357224
* Make helper functions static. NFC.Benjamin Kramer2019-03-281-1/+2
| | | | llvm-svn: 357187
* [WebAssembly] Fix typo from rL357143Sam Clegg2019-03-283-5/+5
| | | | llvm-svn: 357144
* [WebAssembly] Improve invalid relocation error messageSam Clegg2019-03-283-13/+20
| | | | | | | | This message now matches the equivalent message in the ELF linker. Differential Revision: https://reviews.llvm.org/D59860 llvm-svn: 357143
* [WebAssembly] Initial implementation of PIC code generationSam Clegg2019-03-266-32/+56
| | | | | | | | | | | | | | | | | | | | | | | | 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-4/+51
| | | | | | | | | 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-51/+4
| | | | | | This reverts commit 5991328c96b6146999cfa74ede42901f8c01f2fa. llvm-svn: 356932
* [WebAssembly] Add linker options to control feature checkingThomas Lively2019-03-224-4/+51
| | | | | | | | | | | | | | | | | | | | | 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
* [WebAssembly] Target features sectionThomas Lively2019-03-203-5/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-161-25/+41
| | | | | | | | | | | | | | 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-135-2/+24
| | | | | | | | | | | 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-123-2/+25
| | | | | | | | | | | | 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] Don't mark lazy symbols as `IsUsedInRegularObj`Sam Clegg2019-03-083-6/+12
| | | | | | | | | | | This matches the ELF does. Update the comment in ELF/Symbols.h and duplicate it in wasm/Symbols.h This a followup on rL355580 and rL355577. Differential Revision: https://reviews.llvm.org/D59075 llvm-svn: 355737
* [WebAssembly] Fix build after rL355577Sam Clegg2019-03-071-1/+1
| | | | | | | | Turns own that IsUsedInRegularObject is set for lazy (archive) symbols. Differential Revision: https://reviews.llvm.org/D59074 llvm-svn: 355580
* [WebAssembly] LTO: Don't include bitcode-only symbols in the symtabSam Clegg2019-03-071-1/+1
| | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=40654 Differential Revision: https://reviews.llvm.org/D59012 llvm-svn: 355577
* [WebAssembly] Fix crash when __wasm_call_ctor is GCd in programs containing ↵Sam Clegg2019-03-021-0/+3
| | | | | | | | | | | | 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-012-9/+23
| | | | | | Differential Revision: https://reviews.llvm.org/D58806 llvm-svn: 355240
* [WebAssembly] Remove uses of ThreadModelThomas Lively2019-02-281-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Remove redundant code added in rL354538. NFC.Sam Clegg2019-02-211-36/+4
| | | | | | | | | The code for encoding the symbols signature into its name was not actually being used in the final version of this change. Differential Revision: https://reviews.llvm.org/D58482 llvm-svn: 354539
* Fix unused variable warning.Richard Trieu2019-02-211-2/+2
| | | | llvm-svn: 354535
* [WebAssembly] Don't generate invalid modules when function signatures mismatchSam Clegg2019-02-205-73/+267
| | | | | | | | | | | | 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] Refactor handling of weak undefined functions. NFC.Sam Clegg2019-02-074-50/+66
| | | | | | | | | | 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-077-24/+59
| | | | | | | | | | | | 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/+1
| | | | | | | | | | | | 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
* [WebAssembly] Implement --trace and --trace-symbolSam Clegg2019-02-067-14/+88
| | | | | | Differential Revision: https://reviews.llvm.org/D57725 llvm-svn: 353264
* [WebAssembly] clang-tidy (NFC)Heejin Ahn2019-02-046-18/+18
| | | | | | | | | | | | | | | | | | | | | | Summary: This patch fixes clang-tidy warnings on wasm-only files. The list of checks used is: `-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming,modernize-*` (LLVM's default .clang-tidy list is the same except it does not have `modernize-*`.) The list of fixes are: - Variable names start with an uppercase letter - Function names start with a lowercase letter - Use `auto` when you use casts so the type is evident Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D57499 llvm-svn: 353076
* [WebAssembly] Update relocation naming to match llvm change. NFC.Sam Clegg2019-02-044-75/+75
| | | | | | Differential Revision: https://reviews.llvm.org/D57698 llvm-svn: 353066
* [WebAssembly] Support imports from custom module namesSam Clegg2019-02-018-14/+27
| | | | | | | | | | | | | Fixes: https://bugs.llvm.org/show_bug.cgi?id=37168 This is only a first pass at supporting these custom import modules. In the long run we most likely want to treat these kinds of symbols very differently. For example, it should not be possible to resolve such as symbol at static link type. Differential Revision: https://reviews.llvm.org/D45796 llvm-svn: 352828
* Fix names of functions in TargetOptionsCommandFlags.h. NFC.Sam Clegg2019-02-011-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D57555 llvm-svn: 352825
* [LTO] Set CGOptLevel in LTO config.Sam Clegg2019-01-301-0/+2
| | | | | | | | | Previously we were never setting this which means it was always being set to Default (-O2/-Os). Differential Revision: https://reviews.llvm.org/D57422 llvm-svn: 352667
* [WebAssembly] Fix crash with LTO + relocatable + undefined symbolsSam Clegg2019-01-301-28/+30
| | | | | | | | | | | | Change the way we create the symbol table to be closer to how its done on ELF. Now the output symbol table matches the internal symtab order and includes local and undefined symbols. Fixes PR40204 Differential Revision: https://reviews.llvm.org/D56947 llvm-svn: 352645
* [WebAssembly] Fix undefined weak function symbols in LTO buildsSam Clegg2019-01-301-3/+5
| | | | | | | | | | Summary: Fixes PR40219 Subscribers: dschuff, mehdi_amini, inglorion, jgravelle-google, aheejin, sunfish, steven_wu, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D57420 llvm-svn: 352575
* [WebAssembly] Don't load weak undefined symbols from archive filesSam Clegg2019-01-293-16/+66
| | | | | | | | | | Summary: Fixes PR40494 Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D57370 llvm-svn: 352554
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1923-92/+69
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [WebAssembly] Fix windows compiler warning by using explicit 64bit shift. NFC.Sam Clegg2019-01-172-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D56874 llvm-svn: 351488
* [WebAssembly] Merge producers sectionThomas Lively2019-01-173-2/+51
| | | | llvm-svn: 351412
* Revert "[WebAssembly] Merge producers section"Thomas Lively2019-01-173-50/+2
| | | | | | | This reverts commit 71eaf61c6c121c8c3bcaf3490557e92cf81599cb. One of the lld tests was breaking, so revert this change until it is fixed. llvm-svn: 351409
* [WebAssembly] Merge producers sectionThomas Lively2019-01-163-2/+50
| | | | | | | | | | Reviewers: sbc100, aheejin, dschuff Subscribers: jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D56807 llvm-svn: 351400
* [WebAssembly] Store section alignment as a power of 2Sam Clegg2019-01-162-3/+3
| | | | | | | | | | | This change bumps for version number of the wasm object file metadata. See https://github.com/WebAssembly/tool-conventions/pull/92 Differential Revision: https://reviews.llvm.org/D56762 llvm-svn: 351287
* [WebAssembly] Instruction renamingThomas Lively2019-01-083-6/+6
| | | | | | | | | | | | Summary: Associated with D56338. Reviewers: aheejin, aardappel Subscribers: dschuff, sbc100, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D56339 llvm-svn: 350610
OpenPOWER on IntegriCloud