summaryrefslogtreecommitdiff
path: root/src/wasm-linker.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-linker.h')
-rw-r--r--src/wasm-linker.h38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/wasm-linker.h b/src/wasm-linker.h
index 2129f4fd3..89f1cb718 100644
--- a/src/wasm-linker.h
+++ b/src/wasm-linker.h
@@ -33,6 +33,18 @@ namespace wasm {
class S2WasmBuilder;
+inline void exportFunction(Module& wasm, Name name, bool must_export) {
+ if (!wasm.getFunctionOrNull(name)) {
+ assert(!must_export);
+ return;
+ }
+ if (wasm.getExportOrNull(name)) return; // Already exported
+ auto exp = new Export;
+ exp->name = exp->value = name;
+ exp->kind = ExternalKind::Function;
+ wasm.addExport(exp);
+}
+
// An "object file" for linking. Contains a wasm module, plus the associated
// information needed for linking/layout.
class LinkerObject {
@@ -156,6 +168,10 @@ class LinkerObject {
return wasm.functions.empty();
}
+ std::vector<Name> const& getInitializerFunctions() const {
+ return initializerFunctions;
+ }
+
friend class Linker;
Module wasm;
@@ -246,10 +262,6 @@ class Linker {
// function table.
void layout();
- // Support for emscripten integration: generates dyncall thunks, emits
- // metadata for asmConsts, staticBump and initializer functions.
- void emscriptenGlue(std::ostream& o);
-
// Add an object to the link by constructing it in-place with a builder.
// Returns false if an error occurred.
bool linkObject(S2WasmBuilder& builder);
@@ -259,6 +271,12 @@ class Linker {
// Returns false if an error occurred.
bool linkArchive(Archive& archive);
+ // Returns the address of the stack pointer.
+ Address getStackPointerAddress() const;
+
+ // Returns the total size of all static allocations.
+ Address getStaticBump() const;
+
private:
// Allocate a static variable and return its address in linear memory
Address allocateStatic(Address allocSize, Address alignment, Name name) {
@@ -294,18 +312,6 @@ class Linker {
return (size + Memory::kPageSize - 1) & Memory::kPageMask;
}
- void exportFunction(Name name, bool must_export) {
- if (!out.wasm.getFunctionOrNull(name)) {
- assert(!must_export);
- return;
- }
- if (out.wasm.getExportOrNull(name)) return; // Already exported
- auto exp = new Export;
- exp->name = exp->value = name;
- exp->kind = ExternalKind::Function;
- out.wasm.addExport(exp);
- }
-
Function* getImportThunk(Name name, const FunctionType* t);
// The output module (linked executable)