[lld] Fix SEGFAULT in wasm-ld when importing wrapped symbol (PR #169656)
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 26 10:30:33 PST 2025
================
@@ -0,0 +1,36 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
+# RUN: wasm-ld -emit-relocs -wrap nosuchsym -wrap foo -allow-undefined -o %t.wasm %t.o
+# RUN: obj2yaml %t.wasm | FileCheck %s
+
+.globl foo
+.globl _start
+
+foo:
+ .functype foo () -> (i32)
+ i32.const 1
+ end_function
+
+_start:
+ .functype _start () -> ()
+ call foo
+ drop
+ end_function
+
+# CHECK: - Type: IMPORT
+# CHECK-NEXT: Imports:
+# CHECK-NEXT: - Module: env
+# CHECK-NEXT: Field: __wrap_foo
+# CHECK-NEXT: Kind: FUNCTION
+# CHECK-NEXT SigIndex: 0
+
+# CHECK: - Type: CODE
+# CHECK-NEXT: Relocations:
+# CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
+# CHECK-NEXT: Index: 1
----------------
sbc100 wrote:
Is this the right value here for the relocation? Shouldn't it be function zero (i.e. the __wrap_foo import) that is called here? It is this index 1 in the symbol table? If so you we should probably show the symbol table here too. (or just drop the Relocations and emit-relocs flag completely?)
Could be a bug in --emit-relocs maybe?
https://github.com/llvm/llvm-project/pull/169656
More information about the llvm-commits
mailing list