summaryrefslogtreecommitdiffstats
path: root/lld/wasm/InputFiles.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [lld] Fix trivial typos in commentsKazuaki Ishizaki2020-01-061-2/+1
| | | | | | Reviewed By: ruiu, MaskRay Differential Revision: https://reviews.llvm.org/D72196
* [lld][WebAssebmly] Preserve custom import attributes with LTOSam Clegg2019-10-171-2/+2
| | | | | | | | | | | | | | | | | | | Undefined symbols in WebAssembly can come with custom `import-module` and `import-field` attributes. However when reading symbols from bitcode object files during LTO those curtom attributes are not available. Once we compile the LTO object and read in the symbol table from the object file we have access to these custom attributes. In this case, when undefined symbols are added and a symbol already exists in the SymbolTable we can't simple return it, we may need to update the symbol's attributes. Fixes: PR43211 Differential Revision: https://reviews.llvm.org/D68959 llvm-svn: 375081
* [lld][WebAssembly] Fix for weak references to data symbols in archivesSam Clegg2019-10-171-1/+1
| | | | | | | | | | | | | Fix a bug where were not handling relocations against weakly undefined data symbol. Add a test for this case. Also ensure that the weak references to data symbols are not pulled in from archive files by default (but are if `-u <name>` is added to the command line). Fixes: PR43696 Differential Revision: https://reviews.llvm.org/D69073 llvm-svn: 375077
* [WebAssembly] Wrap definitions in namespace lld { namespace wasm {. NFCFangrui Song2019-10-101-16/+19
| | | | | | | | | | Similar to D68323, but for wasm. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D68759 llvm-svn: 374279
* [lld][WebAssembly] Fix static linking of -fPIC code with external undefined ↵Sam Clegg2019-09-241-2/+7
| | | | | | | | functions Differential Revision: https://reviews.llvm.org/D66784 llvm-svn: 372779
* [lld][WebAssembly] Preserve symbol flags in --relocatable outputSam Clegg2019-09-231-1/+2
| | | | | | | | Fixes https://github.com/emscripten-core/emscripten/issues/8879 Differential Revision: https://reviews.llvm.org/D67729 llvm-svn: 372660
* [WebAssembly][lld] Fix crash when applying relocations to debug sectionsSam Clegg2019-08-201-1/+1
| | | | | | | | | | | | | | Debug sections are special in that they can contain relocations against symbols that are not present in the final output (i.e. not live). However it is also possible to have R_WASM_TABLE_INDEX relocations against symbols that don't have a table index assigned (since they are not address taken by actual code. Fixes: https://github.com/emscripten-core/emscripten/issues/9023 Differential Revision: https://reviews.llvm.org/D66435 llvm-svn: 369423
* [lld][WebAssembly] Fix handling of comdat functions in init array.Sam Clegg2019-07-171-6/+4
| | | | | | | | | | | | | | | | | 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
* [WebAssembly] Rename variale references in comments after VariableName -> ↵Fangrui Song2019-07-161-1/+1
| | | | | | variableName change llvm-svn: 366192
* [Coding style change][lld] Rename variables for non-ELF portsRui Ueyama2019-07-111-281/+281
| | | | | | | | | | | This patch does the same thing as r365595 to other subdirectories, which completes the naming style change for the entire lld directory. With this, the naming style conversion is complete for lld. Differential Revision: https://reviews.llvm.org/D64473 llvm-svn: 365730
* [lld][WebAssembly] Report undefined symbols during scanRelocationsSam Clegg2019-07-091-16/+2
| | | | | | | | | | | | | | | | 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
* [WebAssembly] Fix accidental omission from rLLD364367Keno Fischer2019-06-261-0/+1
| | | | | | | | There was another place where handling for this relocation was missing that was accidentally omitted from rLLD364367, causing the newly added test to fail on the buildbots. llvm-svn: 364371
* [lld/WebAssembly] Slightly nicer error message for malformed input filesKeno Fischer2019-06-261-1/+2
| | | | | | | | | | | | | | | | | | | Summary: Before: ``` wasm-ld: error: Relocations not in offset order ``` After ``` wasm-ld: error: While processing `libjulia.so`: Relocations not in offset order ``` At least this way you get to find out which input file is malformed. Reviewers: sbc100 Differential Revision: https://reviews.llvm.org/D63694 llvm-svn: 364368
* [WebAssembly] Fix for discarded init functionsSam Clegg2019-06-071-14/+24
| | | | | | | | | When a function is excluded via comdat we shouldn't add it to the final list of init functions. Differential Revision: https://reviews.llvm.org/D62983 llvm-svn: 362769
* [WebAssembly] Handle object parsing more like the ELF backendSam Clegg2019-06-051-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D62886 llvm-svn: 362626
* [lld] Explicitly ignore comdat groups when parsing LTO object(s)Sam Clegg2019-06-051-9/+5
| | | | | | | | | | | | | Any symbols defined in the LTO object are by definition the ones we want in the final output so we skip the comdat group checking in those cases. This change makes the ELF code more explicit about this and means that wasm and ELF do this in the same way. Differential Revision: https://reviews.llvm.org/D62884 llvm-svn: 362625
* [WebAssembly] Move direct call tracking from member to local. NFC.Sam Clegg2019-05-291-3/+10
| | | | | | | | | | | This data structure is only needed temporarily while symbols are being created. This is a followup on rL361678. Differential Revision: https://reviews.llvm.org/D62548 llvm-svn: 361977
* [WebAssembly] Relax signature checking for undefined functions that are not ↵Sam Clegg2019-05-241-12/+22
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* [WebAssembly] Add --reproduce.Rui Ueyama2019-05-211-0/+6
| | | | | | | | | | | | | | | --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] Refactor synthetic sections and relocation processing. NFC.Sam Clegg2019-05-211-2/+5
| | | | | | | | | | | Major refactor to better match the structure of the ELF linker. - Split out relocation processing into scanRelocations - Split out synthetic sections into their own classes. Differential Revision: https://reviews.llvm.org/D61811 llvm-svn: 361233
* [WebAssembly] LTO: Honor comdat groups when loading bitcode filesSam Clegg2019-05-151-10/+22
| | | | | | | | | 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-101-0/+2
| | | | | | | | | | | | | | | | 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-091-2/+0
| | | | | | | | This reverts commit b33fdb7768e5de5fbeb23f65d8d455e7ca88b021. This change apparently broke am emscripten test. llvm-svn: 360367
* [WebAssembly] Don't generate unused table entries.Sam Clegg2019-05-071-0/+2
| | | | | | | | | | | | | | 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] Fix typo in relocation checkingSam Clegg2019-04-231-1/+3
| | | | | | | | | | | 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-14/+32
| | | | | | | | | | | | | | | | | 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] Fix R_WASM_FUNCTION_OFFSET_I32 relocation warningsSam Clegg2019-04-221-6/+7
| | | | | | | | | | | | | | | We were incorrectly used the symbol table version of the function rather than the object-local version when checking the existing relocation value. This was causing erroneous warnings for comat symbols defined in multiple object.s Fixes: https://bugs.llvm.org/show_bug.cgi?id=40503 Differential Revision: https://reviews.llvm.org/D60928 llvm-svn: 358871
* [WebAssembly] Ensure ArchiveName is set even in the presence of --whole-archive.Sam Clegg2019-04-091-5/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D60431 llvm-svn: 357966
* [WebAssembly] Add new explicit relocation types for PIC relocationsSam Clegg2019-04-041-2/+6
| | | | | | | | See https://github.com/WebAssembly/tool-conventions/pull/106 Differential Revision: https://reviews.llvm.org/D59907 llvm-svn: 357710
* [WebAssembly] Initial implementation of PIC code generationSam Clegg2019-03-261-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | 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
* [WebAssembly] Target features sectionThomas Lively2019-03-201-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Improve support for "needed" list in dylink sectionSam Clegg2019-03-131-1/+6
| | | | | | | | | | | 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] Fix imported function symbol names that differ from their ↵Dan Gohman2019-02-071-3/+7
| | | | | | | | | | | | 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] clang-tidy (NFC)Heejin Ahn2019-02-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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-041-28/+28
| | | | | | Differential Revision: https://reviews.llvm.org/D57698 llvm-svn: 353066
* [WebAssembly] Support imports from custom module namesSam Clegg2019-02-011-2/+3
| | | | | | | | | | | | | 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
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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] Merge producers sectionThomas Lively2019-01-171-0/+2
| | | | llvm-svn: 351412
* Revert "[WebAssembly] Merge producers section"Thomas Lively2019-01-171-2/+0
| | | | | | | 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-161-0/+2
| | | | | | | | | | Reviewers: sbc100, aheejin, dschuff Subscribers: jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D56807 llvm-svn: 351400
* [WebAssembly] Add support for the event sectionHeejin Ahn2018-12-081-3/+23
| | | | | | | | | | | | | | | | | Summary: This adds support for the 'event section' specified in the exception handling proposal. Wasm exception handling binary model spec: https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md#changes-to-the-binary-model Reviewers: sbc100, ruiu Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54875 llvm-svn: 348703
* [WebAssembly] Fix inaccurate comments / assertion messagesHeejin Ahn2018-11-191-1/+1
| | | | | | | | | | Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D54688 llvm-svn: 347273
* [WebAssembly] Move .debug_line section address of dead function outside ↵Yury Delendik2018-09-241-2/+3
| | | | | | | | | | | | | | | | | | | | | | section range Summary: Currently we are pointing all debug information that refer removed function code to the beginning of the code section (offset = 0). A debugger may want to resolve code offset to the debug information, which will collide with offsets of the live functions. Moving offsets of dead functions outside code section range. Reviewers: sbc100 Reviewed By: sbc100 Subscribers: dblaikie, ruiu, alexcrichton, dschuff, aprantl, jgravelle-google, aheejin, sunfish, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D49446 llvm-svn: 342930
* [WebAssembly] clang-format (NFC)Heejin Ahn2018-08-291-15/+15
| | | | | | | | | | | | Summary: This patch runs clang-format on all wasm-only files. Reviewers: sbc100 Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D51449 llvm-svn: 340970
* [WebAssembly] Optimise relocation processing. NFC.Sam Clegg2018-08-221-12/+40
| | | | | | | | | | | | | | | | | This is a rebased version https://reviews.llvm.org/D42176 which is patch by Nicolas Wilson. Addresses issue: https://github.com/WebAssembly/tool-conventions/issues/32, and https://bugs.llvm.org/show_bug.cgi?id=38650 Previously, for each function/segment we iterated over every relocation to find the relevant ones, which is an n^2 operation. Now, we just make a single pass. Differential Revision: https://reviews.llvm.org/D51063 llvm-svn: 340428
* [WebAssembly] Add support for --whole-archive.Sam Clegg2018-07-231-12/+12
| | | | | | | | Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D49706 llvm-svn: 337777
* [WebAssembly] Fix archive member display in error messagesSam Clegg2018-07-181-4/+4
| | | | | | | | | Add a test for this by causing a symbol collision between archive members. Differential Revision: https://reviews.llvm.org/D49343 llvm-svn: 337426
* [WebAssembly] Add support for bitcode archive membersSam Clegg2018-06-281-2/+8
| | | | | | | | | | This change effects the behavior of --export-all. Previously --export-all would only effect symbols that survived GC. Now --export-all will prevent any non-local symbols from being GCed. Differential Revision: https://reviews.llvm.org/D48673 llvm-svn: 335878
* [WebAssembly] Initial support for LTOSam Clegg2018-05-301-0/+42
| | | | | | Differential Revision: https://reviews.llvm.org/D47162 llvm-svn: 333570
* [WebAssembly] Fix crash when relocation synbol is not liveSam Clegg2018-05-231-1/+2
| | | | | | | | | | | | | | | | When a symbol is GC'd it can still be references by relocations in the debug sections, but such symbols are not assigned virtual addresses. This change adds a new global data symbol which gets GC'd but should still appears in the output debug info, albeit with a 0 address. Fixes 37555 Differential Revision: https://reviews.llvm.org/D47238 llvm-svn: 333047
OpenPOWER on IntegriCloud