summaryrefslogtreecommitdiffstats
path: root/lld/wasm/SymbolTable.h
Commit message (Collapse)AuthorAgeFilesLines
* [lld][WebAssembly] Add optional symbols after input file handlingSam Clegg2019-08-081-2/+1
| | | | | | | | | | | | | | This allows undefined references in input files be resolved by the optional symbols. Previously we were doing this before input file reading which means it was working only for command line symbols references (i.e. -u or --export). Also use addOptionalDataSymbol for __dso_handle and make all optional symbols hidden by default. Differential Revision: https://reviews.llvm.org/D65920 llvm-svn: 368310
* [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-49/+49
| | | | | | | | | | | 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-2/+0
| | | | | | | | | | | | | | | | 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] Don't export __data_end and __heap_base by default.Sam Clegg2019-05-311-2/+2
| | | | | | | | These can still be exported via --export if needed. Differential Revision: https://reviews.llvm.org/D62744 llvm-svn: 362276
* [WebAssembly] Relax signature checking for undefined functions that are not ↵Sam Clegg2019-05-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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-6/+9
| | | | | | | | | | | 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
* Reland: [WebAssembly] Add __start_/_stop_ symbols for data sectionsSam Clegg2019-05-231-0/+2
| | | | | | | | | | 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
* Revert "[WebAssembly] Add __start_/_stop_ symbols for data sections"Sam Clegg2019-05-211-2/+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
* [WebAssembly] Add __start_/_stop_ symbols for data sectionsSam Clegg2019-05-211-0/+2
| | | | | | | | Fixes https://bugs.llvm.org/show_bug.cgi?id=41565 Differential Revision: https://reviews.llvm.org/D61876 llvm-svn: 361236
* [WebAssembly] LTO: Honor comdat groups when loading bitcode filesSam Clegg2019-05-151-1/+4
| | | | | | | | | 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] Ensure ArchiveName is set even in the presence of --whole-archive.Sam Clegg2019-04-091-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D60431 llvm-svn: 357966
* [WebAssembly] Improve support for "needed" list in dylink sectionSam Clegg2019-03-131-0/+1
| | | | | | | | | | | 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] Don't generate invalid modules when function signatures mismatchSam Clegg2019-02-201-0/+9
| | | | | | | | | | | | 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-071-1/+6
| | | | | | | | | | 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-3/+5
| | | | | | | | | | | | 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] Implement --trace and --trace-symbolSam Clegg2019-02-061-1/+8
| | | | | | Differential Revision: https://reviews.llvm.org/D57725 llvm-svn: 353264
* [WebAssembly] Support imports from custom module namesSam Clegg2019-02-011-2/+2
| | | | | | | | | | | | | 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] Add support for the event sectionHeejin Ahn2018-12-081-0/+2
| | | | | | | | | | | | | | | | | 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] Remove `using` statements from header files. NFC.Sam Clegg2018-11-271-5/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D54758 llvm-svn: 347621
* Set IsUsedInRegularObj in a consistent manor between COFF, ELF and wasm. NFCSam Clegg2018-08-021-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D49147 llvm-svn: 338767
* [WebAssembly] Initial support for LTOSam Clegg2018-05-301-0/+6
| | | | | | Differential Revision: https://reviews.llvm.org/D47162 llvm-svn: 333570
* [WebAssembly] Avoid COMDAT hashmap lookup for each symbol. NFCNicholas Wilson2018-03-141-3/+3
| | | | | | | | | This reduces the number of lookups to one per COMDAT group, rather than one per symbol in a COMDAT group. Differential Revision: https://reviews.llvm.org/D44344 llvm-svn: 327523
* [WebAssembly] Refactor order of creation for SyntheticFunctionNicholas Wilson2018-03-091-3/+4
| | | | | | | | | | Previously we created __wasm_call_ctors with null InputFunction, and added the InputFunction later. Now we create the SyntheticFunction with null body, and set the body later. Differential Revision: https://reviews.llvm.org/D44206 llvm-svn: 327149
* [WebAssembly] Run clang-format. NFCNicholas Wilson2018-03-071-1/+1
| | | | llvm-svn: 326896
* [WebAssembly] Simplify COMDAT handling.Rui Ueyama2018-03-011-3/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D43966 llvm-svn: 326509
* [WebAssembly] Do not use default arguments for SymbolTable.Rui Ueyama2018-02-281-5/+5
| | | | | | Differential Revision: https://reviews.llvm.org/D43727 llvm-svn: 326282
* [WebAssembly] Separate addUndefined into addUndefined{Function,Data,Global}.Rui Ueyama2018-02-281-7/+10
| | | | | | | | | | | | | | | Previously, one function adds all types of undefined symbols. That doesn't fit to the wasm's undefined symbol semantics well because different types of undefined symbols are very different in wasm. As a result, separate control flows merge in this addUndefined function and then separate again for each type. That wasn't easy to read. This patch separates the function into three functions. Now it is pretty clear what we are doing for each undefined symbol type. Differential Revision: https://reviews.llvm.org/D43697 llvm-svn: 326271
* Remove dead code.Rui Ueyama2018-02-231-2/+0
| | | | llvm-svn: 325955
* [WebAssembly] Add explicit symbol tableSam Clegg2018-02-231-1/+11
| | | | | | | | | | | | | | | | | | This change modified lld to in response the llvm change which moved to a more explicit symbol table in the object format. Based on patches by Nicholas Wilson: 1. https://reviews.llvm.org/D41955 2. https://reviews.llvm.org/D42585 The primary difference that we see in the test output is that for relocatable (-r) output we now have symbol table which replaces exports/imports and globals. See: https://github.com/WebAssembly/tool-conventions/issues/38 Differential Revision: https://reviews.llvm.org/D43264 llvm-svn: 325861
* [WebAssembly] Rename GlobalSymbol types. NFC.Sam Clegg2018-02-201-4/+3
| | | | | | | | | | | | | | | Purely a rename in preparation for adding new global symbol type. We want to use GlobalSymbol to represent real wasm globals and DataSymbol for pointers to things in linear memory (what ELF would call STT_OBJECT). This reduces the size the patch to add the explicit symbol table which is coming soon! Differential Revision: https://reviews.llvm.org/D43476 llvm-svn: 325645
* Consistent (non) use of empty lines in include blocksSam Clegg2018-02-201-1/+0
| | | | | | | | | The profailing style in lld seem to be to not include such empty lines. Clang-tidy/clang-format seem to handle this just fine. Differential Revision: https://reviews.llvm.org/D43528 llvm-svn: 325629
* [WebAssembly] Split addDefined into two different methods. NFC.Sam Clegg2018-02-201-4/+5
| | | | | | | | Subscribers: jfb, dschuff, jgravelle-google, aheejin, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D43496 llvm-svn: 325613
* [WebAssembly] Use a Symbol class heirarchy. NFC.Sam Clegg2018-02-141-4/+5
| | | | | | | | | This brings wasm into line with ELF and COFF in terms of symbol types are represented. Differential Revision: https://reviews.llvm.org/D43112 llvm-svn: 325150
* [WebAssembly] Cleanup methods for add synthetic symbols to symbtab. NFC.Sam Clegg2018-02-131-3/+3
| | | | | | | | | | | | These were duplicating (incorrectly) some of the logic for handling conflicts, but since they are only ever added right at the start we can assume no existing symbols. Also rename these methods for clarity. Differential Revision: https://reviews.llvm.org/D43252 llvm-svn: 325045
* clang formatSam Clegg2018-01-281-2/+2
| | | | llvm-svn: 323622
* [WebAssemly] Associate symbol with InputChunk in which they are defined. NFC.Sam Clegg2018-01-281-2/+2
| | | | | | | | | | | | | | | | Summary: Rather than explicit Function or InputSegment points store a pointer to the base class (InputChunk) and use llvm dynamic casts when we need a subtype. This change is useful for add the upcoming gc-section support wants to deal with all input chunks. Subscribers: aheejin, llvm-commits Differential Revision: https://reviews.llvm.org/D42625 llvm-svn: 323621
* [WebAssembly] Add COMDAT supportSam Clegg2018-01-121-0/+3
| | | | | | | | | | | | | | | | | | See https://bugs.llvm.org/show_bug.cgi?id=35533, and D40844 Things covered: * Removing duplicate data segments (as determined by COMDATs emitted by the frontend) * Removing duplicate globals and functions in COMDATs * Checking that each time a COMDAT is seen it has the same symbols as at other times (ie it's a stronger check than simply giving all the symbols in the COMDAT weak linkage) Patch by Nicholas Wilson! Differential Revision: https://reviews.llvm.org/D40845 llvm-svn: 322415
* [WebAssembly] Create synthetic __wasm_call_ctors functionSam Clegg2018-01-121-0/+2
| | | | | | | | | | | This change create a new synthetic function in the final output binary which calls the static constructors in sequence. See: https://github.com/WebAssembly/tool-conventions/issues/25 Differential Revision: https://reviews.llvm.org/D41893 llvm-svn: 322388
* [WebAssembly] Refactor symbol and symbol table to remove WasmSymbol referencesSam Clegg2018-01-101-6/+5
| | | | | | | | | | | | | | | This WasmSymbol types comes directly from the input objects but we want to be able to represent synthetic symbols too. This is more in line with how the ELF linker represents symbols. This change also removes the logic from Symbol::getVirtualAddress for finding the global address and instead has the InputFile provide this. Differential Revision: https://reviews.llvm.org/D41426 llvm-svn: 322145
* [WebAssembly] Output functions individuallySam Clegg2018-01-091-2/+4
| | | | | | | | | | | | | The code section is now written out one function at a time rather than all the functions in a given objects being serialized at once. This change lays the groundwork for supporting --gc-sections. Differential Revision: https://reviews.llvm.org/D41315 llvm-svn: 322138
* [WebAssembly] Remove used member from SymbolTableSam Clegg2017-12-191-1/+0
| | | | | | Patch by Nicholas Wilson llvm-svn: 321096
* [WebAssembly] Fix symbol exports under -r/--relocatableSam Clegg2017-12-071-0/+2
| | | | | | | | | | | | | | | This change cleans up the way wasm exports and globals are generated, particualrly for -r/--relocatable where globals need to be created and exported in order for output relocations which reference them. Remove the need for a per file GlobalIndexOffset and instead set the output index for each symbol directly. This simplifies the code in several places. Differential Revision: https://reviews.llvm.org/D40859 llvm-svn: 320001
* [WebAssembly] Allow function signature checking at link timeSam Clegg2017-11-301-1/+2
| | | | | | | | | | | | | | This change allows checking of function signatures but does not yes enable it by default. In this mode, linking two objects that were compiled with a different signatures for the same function will produce a link error. New options for enabling and disabling this feature have been added: (--check-signatures/--no-check-signatures). Differential Revision: https://reviews.llvm.org/D40371 llvm-svn: 319396
* Rename `Symtab` private memory to avoid confusion with global `Symtab`Sam Clegg2017-11-271-1/+1
| | | | | | | | | | | This is also consistent with SymVector that exists in COFF port and soon to be added to the wasm port. Split off as part of https://reviews.llvm.org/D40371 Differential Revision: https://reviews.llvm.org/D40525 llvm-svn: 319113
* [WebAssembly] Initial wasm linker implementationSam Clegg2017-11-171-0/+69
This linker backend is still a work in progress but is enough to link simple programs including linking against library archives. Differential Revision: https://reviews.llvm.org/D34851 llvm-svn: 318539
OpenPOWER on IntegriCloud