Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/lib/libdylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,14 +617,13 @@ var LibraryDylink = {
dbg('loadWebAssemblyModule:', libName);
#endif
var metadata = getDylinkMetadata(binary);
currentModuleWeakSymbols = metadata.weakImports;
#if ASSERTIONS
var originalTable = wasmTable;
#endif

// loadModule loads the wasm module after all its dependencies have been loaded.
// can be called both sync/async.
function loadModule() {
#if ASSERTIONS
var originalTable = wasmTable;
#endif
#if PTHREADS
// The first thread to load a given module needs to allocate the static
// table and memory regions. Later threads re-use the same table region
Expand Down Expand Up @@ -744,6 +743,7 @@ var LibraryDylink = {
}
};
var proxy = new Proxy({}, proxyHandler);
currentModuleWeakSymbols = metadata.weakImports;
var info = {
'GOT.mem': new Proxy({}, GOTHandler),
'GOT.func': new Proxy({}, GOTHandler),
Expand Down
4 changes: 2 additions & 2 deletions test/code_size/test_codesize_hello_dylink.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.out.js": 26969,
"a.out.js.gz": 11478,
"a.out.js.gz": 11479,
"a.out.nodebug.wasm": 18567,
"a.out.nodebug.wasm.gz": 9199,
"total": 45536,
"total_gz": 20677,
"total_gz": 20678,
"sent": [
"__heap_base",
"__indirect_function_table",
Expand Down
31 changes: 31 additions & 0 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5278,6 +5278,37 @@ def test_dylink_weak(self):
def test_dylink_weak_undef(self):
self.dylink_testf(test_file('core/test_dylink_weak_undef.c'))

@needs_dylink
def test_dylink_weak_multilib(self):
create_file('liba.c', '''
#include <stdio.h>

extern int globalA __attribute__((weak));

void LibBFunc();

void LibAFunc() {
LibBFunc();
printf("globalA %p\\n", &globalA);
}
''')
create_file('libb.c', '''
#include <stdio.h>

void LibBFunc() {
printf("Hello from b\\n");
}
''')
create_file('main.c', '''
void LibAFunc();
int main() {
LibAFunc();
}
''')
self.run_process([EMCC, 'libb.c', '-o', 'libb.so', '-sSIDE_MODULE'] + self.get_cflags())
self.run_process([EMCC, 'liba.c', '-o', 'liba.so', '-sSIDE_MODULE', 'libb.so'] + self.get_cflags())
self.do_runf('main.c', 'Hello from b\n', cflags=['-sMAIN_MODULE=2', '-L.', 'liba.so'])

@node_pthreads
@needs_dylink
def test_dylink_tls(self):
Expand Down