[lld] [lld][WebAssembly] Fix non-pie dynamic-linking executable (PR #108146)

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 23:07:55 PDT 2024


================
@@ -0,0 +1,35 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.lib.o %p/Inputs/lib.s
+# RUN: wasm-ld -m wasm32 --experimental-pic -shared --no-entry %t.lib.o -o %t.lib.so
+# RUN: llvm-mc -filetype=obj -mattr=+reference-types -triple=wasm32-unknown-unknown -o %t.o %s
+# RUN: wasm-ld -m wasm32 --features=mutable-globals -Bdynamic --export-table --growable-table --export-memory --export=__stack_pointer --export=__heap_base --export=__heap_end --entry=_start %t.o %t.lib.so -o %t.wasm
+# RUN: obj2yaml %t.wasm | FileCheck %s
+
+	.tabletype	__indirect_function_table, funcref
+	.globaltype	__memory_base, i32, immutable
+
+	.functype	f () -> ()
+	.functype	_start () -> ()
+	.globl	_start
+	.type	_start, at function
+_start:
+	.functype	_start () -> ()
+	global.get	__memory_base
+	i32.const	f_p at MBREL
+	i32.add
+	i32.load	0
+	call_indirect	 __indirect_function_table, () -> ()
----------------
sbc100 wrote:

You don't need the `__indirect_function_table` symbol to make this test work.    You can just do `i32.const	f_p` followed by `drop` I think.

https://github.com/llvm/llvm-project/pull/108146


More information about the llvm-commits mailing list