summaryrefslogtreecommitdiff
path: root/src/wasm-linker.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove s2wasm (#1607)Sam Clegg2018-06-281-342/+0
| | | | s2wasm is no longer used my emscripten and as far as I know now as no other users.
* Decouple wasm-linker from Emscripten glue (#1293)Jacob Gravelle2017-11-151-16/+22
|
* Make header guards consistent (#997)Sam Clegg2017-05-041-4/+4
|
* Wasm h to cpp (#926)jgravelle-google2017-03-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | * Move WasmType function implementations to wasm.cpp * Move Literal methods to wasm.cpp * Reorder wasm.cpp shared constants back to top * Move expression functions to wasm.cpp * Finish moving things to wasm.cpp * Split out Literal into its own .h/.cpp. Also factor out common wasm-type module * Remove unneeded/transitive includes from wasm.h * Add comment to try/check methods * Rename tryX/checkX methods to getXOrNull * Add missing include that should fix appveyor build breakage * More appveyor
* Fully handle EM_ASM in s2wasm (#910)jgravelle-google2017-02-231-0/+1
| | | | | | | | | | | | * Fully handle EM_ASM in s2wasm * Iterate with size_ts, remember to erase from importsMap as well * Fix dot_s test EM_ASM signatures * Move Name out to its own file, support/name.h * Move removeImportsWithSubstring out of Module class
* Generate global imports separately from emscripten glue (#852)jgravelle-google2016-12-011-1/+2
|
* Handle importing globals in s2wasm (#843)jgravelle-google2016-11-301-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Handle importing globals in s2wasm * Make importedGlobals a set of Names, make Names hashable * Revert "Make importedGlobals a set of Names, make Names hashable" This reverts commit 1d0ca7a5e3839b15ca60593330979864c9c3ed60. * Refactor relocation parsing to handle expressions directly * PR Feedback - Move comment where it belongs - Add comment about ownership to addRelocation - Remove do-nothing parseImportGlobal * Reword "imported globals" to "imported objects" - Flip isObjectImported to isObjectImplemented, for consistency * Add tests for s2wasm globals. Also implement import relocation expression handling * Simplify globals.s test * Fix memory leak of relocation * Use unique_ptr instead of delete in getRelocatableExpression
* Import memory instead of defining/exporting it when using emscripten glue (#777)Derek Schuff2016-10-141-12/+15
| | | | | The emscripten JS module code creates the memory using the native wasm APIs, and imports that into the wasm module.
* More binary updates for 0xc (#733)Derek Schuff2016-10-031-1/+1
| | | | | | | | | | | | | | | Refine tables to explicitly exist or not. Previously they were printed or encoded if it had any segments, or an initial or max size. However tables can be defined but empty, so we had a special hack that defined an empty segment when we really just wanted an empty table. Now, just make the existence explicit. Update Function table encoding for 0xc (Table and Element sections) Add end opcodes after function bodies (these are consumed by getMaybeBlock with the same behavior that it had before when it reached the function end, so no explicit decode) Update call_indirect encoding for 0xc (no arity, call target is last)
* Refactor Import::Kind and Export::Kind into an ExternalKind enum class (#725)Alon Zakai2016-10-031-1/+1
|
* Add flag to s2wasm to export __growWasmMemory function (#696)jgravelle-google2016-09-091-20/+4
| | | | | | | | | | | | | | | | | | | | | * Add a flag to s2wasm to export grow_memory Binaryen's wasm.js-post.js calls back in to wasm in order to grow the linear memory, via a function that asm2wasm exports called __growWasmMemory. This changes exposes that method through s2wasm when invoked with a flag. * Move AsmConstWalker from wasm-linker to wasm-emscripten * Add test for memory growth in s2wasm * Move makeDynCallThunks into wasm-emscripten module * Move mutation in getTableSegment into a separate method * Move emscripten metadata generation into wasm-emscripten Also make AsmConstWalker internal to the wasm-emscripten module, as it's only used for the metadata pass.
* export kindsAlon Zakai2016-09-071-0/+1
|
* offset support in tableAlon Zakai2016-08-151-0/+4
|
* support expressions in segment offsetsAlon Zakai2016-08-121-2/+2
|
* Create a dummy function to prevent NULL miscomparisons, if necessary (#658)Dominic Chen2016-08-031-0/+11
| | | Resolves WebAssembly/spec#312
* support pre-assigning indexes for functions that are called indirectly (#616)Dominic Chen2016-08-021-2/+10
| | | This patch adds support for an ".indidx" primitive that pre-assigns table indexes for functions that are called indirectly. It is used by the upstream LLVM WebAssembly backend to support fine-grained control-flow integrity for indirect function calls by emitting instrumentation at each indirect call site to check that the destination index is within certain ranges that correspond to disjoint equivalence classes of indirect call targets. The reason that this primitive is necessary is because the layout of the table section isn't determined until the WebAssembly linker is executed, but indirect function to table index mappings need to be known when opt is executed to generate the correct range checking in the LLVM IR.
* add support for symbol assignments, closes #4422 (#615)Dominic Chen2016-07-111-8/+21
| | | Adds support for aliases to objects, to go along with the existing support for aliases to functions.
* Do not generate duplicate import thunks at link time. (#569)Derek Schuff2016-06-031-1/+1
| | | | | Previously every address-take of an import would cause a new thunk to be generated. Now check in getImportThunk if the thunk exists already and just return it if so.
* Generate thunks for address-taken imports (#554)Derek Schuff2016-06-021-0/+16
| | | | | | | | | | | Under emscripten, C code can take the address of a function implemented in Javascript (which is exposed via an import in wasm). Because imports do not have linear memory address in wasm, we need to generate a thunk to be the target of the indirect call; it call the import directly. This is facilited by a new .s directive (.functype) which declares the types of functions which are declared but not defined. Fixes https://github.com/WebAssembly/binaryen/issues/392
* Use a class with implicit overflow checks for Address (#486)Derek Schuff2016-05-121-4/+2
| | | | It includes implicit conversion from u64 and implicit conversion to address_t. This makes it easier to use without ugly casting and but still gets the overflow checks.
* Introduce a separate type for linear memory addresses (#477)Derek Schuff2016-05-111-20/+22
| | | | | | | We've been using size_t (and other things) for addresses, which is generally wrong because it depends on the host, when it should in fact depend on the target. This is a partial fix for #278 (i.e. it's the right fix, I don't think it's applied quite everywhere yet).
* [Linker] Handle archive filesDerek Schuff2016-05-051-1/+8
| | | | | | | | Add a class to parse archive files. Support linking archive files, with archive semantics (i.e. an archive member is linked in if it satisfies an undefined reference). Archive files must be gnu-format archives containing .s files. Add tests for linking semantics.
* just use a simple vector in data segmentsAlon Zakai2016-04-271-0/+5
|
* allocate only expressions in arenas - functions, imports, exports, function ↵Alon Zakai2016-04-271-1/+1
| | | | types, can more simply be held by unique_ptrs on the owning module. this avoids need to coordinate arena allocation for their elements, and only the far more plentiful expression nodes are a perf factor anyhow
* Split construction, scanning, and building phases of S2WasmBuilder (#400)Derek Schuff2016-04-271-14/+34
| | | | | | | | | | | Instead of doing all of the S2Wasm work in the constructor, split construction, scanning (to determine implemented functions) and building of the wasm module. This allows the linker to get the symbol information (e.g. implemented functions) without having to build an entire module (which will be useful for archives) and to allow the linker to link a new object into the existing one by building the wasm module in place on the existing module.
* Defer creation of CallImports to link time (#395)Derek Schuff2016-04-261-0/+7
| | | s2wasm currently creates a Call AST node if the target is implemented in the current object (thus far assumed to be the final executable) and a CallImport node if not. In preparation for adding additional objects to the link before layout time, we make only Call nodes until link time, and then convert them to CallImport if they are undefined at that time.
* Separate LinkerObject from Linker (#383)Derek Schuff2016-04-251-70/+98
| | | | | Create the LinkerObject class, which has a wasm Module and represents the module plus the information needed to relocate and lay it out. Each Linker owns a "main executable" LinkerObject, and S2WasmBuilder requires a LinkerObject instead of just a Module because LLVM asm files require relocation/linking before they represent a full wasm module. No merging support yet, but the real functionality for #370 is coming soon.
* Simplify statics, segments, and relocations (#380)Derek Schuff2016-04-221-18/+38
| | | | Also defer address assignment until layout time in preparation for separating linker objects out from Linker
* Move wasm-linker into its own cpp file (#375)Derek Schuff2016-04-211-249/+6
| | | | | | | Still making things nicer for #370 Pulling wasm-linker into its own file also necessitated pulling asm_v_wasm.h into a cpp file. It goes into a new lib directory, src/asmjs. No actual code changes in this PR.
* Move Fatal into utilities.h (#376)Derek Schuff2016-04-211-18/+0
| | | | | Follow-on from #372. Probably we should do even better for error handling, and that might mean a cpp file in support, but for now this is a small improvement.
* Factor linker-related functionality of S2WasmBuilder into its own class (#372)Derek Schuff2016-04-211-0/+463
This is the first of a couple of refactorings in for #370 No functionality change, and minimal code change to make it work.