Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wasm-study
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
wasm-study
Commits
1ec95cd5
Commit
1ec95cd5
authored
Nov 07, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linking to libk_so works
wasm@deco:~/trydynlib$ node prog.js prog! libk.kfunc1 -> 12
parent
36f52cc1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
5 deletions
+10
-5
dso.h
dso.h
+2
-2
libk_so.js
libk_so.js
+8
-1
prog.js
prog.js
+0
-2
No files found.
dso.h
View file @
1ec95cd5
...
...
@@ -2,8 +2,8 @@
#define _DSO_H
// DSO_EXPORT marks a symbol as exported from currently-compiled DSO.
//
XXX + attr(used) ? (emscripten does this)
#define DSO_EXPORT __attribute__((visibility("default")))
//
NOTE attr(used) is important for emscripten - otherwise the symbol is not exported via Module
#define DSO_EXPORT __attribute__((
used)) __attribute__((
visibility("default")))
// XXX stub (__declspec(dllimport) on mingw)
#define DSO_IMPORT
...
...
libk_so.js
View file @
1ec95cd5
...
...
@@ -197,16 +197,23 @@ function runPostSets() {
// EMSCRIPTEN_END_FUNCS
return
{
establishStackSpace
:
establishStackSpace
,
runPostSets
:
runPostSets
,
setThrew
:
setThrew
,
stackAlloc
:
stackAlloc
,
stackRestore
:
stackRestore
,
stackSave
:
stackSave
};
return
{
_kfunc1
:
_kfunc1
,
establishStackSpace
:
establishStackSpace
,
runPostSets
:
runPostSets
,
setThrew
:
setThrew
,
stackAlloc
:
stackAlloc
,
stackRestore
:
stackRestore
,
stackSave
:
stackSave
};
})
// EMSCRIPTEN_END_ASM
(
Module
.
asmGlobalArg
,
Module
.
asmLibraryArg
,
buffer
);
var
real__kfunc1
=
asm
[
"
_kfunc1
"
];
asm
[
"
_kfunc1
"
]
=
function
()
{
assert
(
runtimeInitialized
,
'
you need to wait for the runtime to be ready (e.g. wait for main() to be called)
'
);
assert
(
!
runtimeExited
,
'
the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)
'
);
return
real__kfunc1
.
apply
(
null
,
arguments
);
};
var
real_setThrew
=
asm
[
"
setThrew
"
];
asm
[
"
setThrew
"
]
=
function
()
{
assert
(
runtimeInitialized
,
'
you need to wait for the runtime to be ready (e.g. wait for main() to be called)
'
);
assert
(
!
runtimeExited
,
'
the runtime was exited (use NO_EXIT_RUNTIME to keep it alive after main() exits)
'
);
return
real_setThrew
.
apply
(
null
,
arguments
);
};
var
_kfunc1
=
Module
[
"
_kfunc1
"
]
=
asm
[
"
_kfunc1
"
];
var
runPostSets
=
Module
[
"
runPostSets
"
]
=
asm
[
"
runPostSets
"
];
var
setThrew
=
Module
[
"
setThrew
"
]
=
asm
[
"
setThrew
"
];
...
...
prog.js
View file @
1ec95cd5
...
...
@@ -325,7 +325,6 @@ var asm2wasmImports = { // special asm2wasm imports
var loadedDynamicLibraries = [];
function loadDynamicLibrary(lib) {
console.log("loading", lib)
var libModule;
var src = Module['read'](lib);
libModule = eval(src)(
...
...
@@ -334,7 +333,6 @@ function loadDynamicLibrary(lib) {
);
// add symbols into global namespace TODO: weak linking etc.
for (var sym in libModule) {
console.log("symbol", sym)
if (!Module.hasOwnProperty(sym)) {
Module[sym] = libModule[sym];
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment