Skip to content

Commit 4dc4c64

Browse files
committed
Adjust ASM_CONST indexes when building with -s RELOCATABLE
For reloctable code (i.e. MAIN_MODULE) ASM_CONST offsets are relative to the GLOBAL_BASE.
1 parent 62090e3 commit 4dc4c64

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

emscripten.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,6 +2413,11 @@ def create_asm_consts_wasm(forwarded_json, metadata):
24132413
str(int(sync_proxy)) +
24142414
', code, sigPtr, argbuf); }')
24152415

2416+
if shared.Settings.RELOCATABLE:
2417+
# TODO(sbc): remove this conidtion after
2418+
# https://github.com/WebAssembly/binaryen/pull/2408 lands
2419+
preamble += '\n if (code > %s) code -= %s;\n' % (shared.Settings.GLOBAL_BASE, shared.Settings.GLOBAL_BASE)
2420+
24162421
asm_const_funcs.append(r'''
24172422
function %s(code, sigPtr, argbuf) {%s
24182423
var args = readAsmConstArgs(sigPtr, argbuf);

0 commit comments

Comments
 (0)