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

YAMAMOTO Takashi via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 1 09:03:41 PDT 2024


================
@@ -0,0 +1,29 @@
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.lib.o %p/Inputs/ret32.s
+# RUN: wasm-ld -m wasm32 --experimental-pic -shared --no-entry %t.lib.o -o %t.lib.so
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
+# RUN: wasm-ld -m wasm32 -Bdynamic %t.o %t.lib.so -o %t.wasm
----------------
yamt wrote:

`ctx.isPic` is not set as neither of pie or shared is set.

the following is the generated output. it looks reasonable to me.
```
(module $dylink-non-pie.s.tmp.wasm
  (type (;0;) (func (param f32) (result i32)))
  (type (;1;) (func))
  (import "env" "ret32" (func $ret32 (type 0)))
  (import "GOT.func" "ret32" (global $ret32 (mut i32)))
  (func $__wasm_apply_data_relocs (type 1)
    i32.const 1024
    global.get $ret32
    i32.store)
  (func $_start (type 1)
    i32.const 1024
    drop)
  (table (;0;) 1 1 funcref)
  (memory (;0;) 2)
  (global $__stack_pointer (mut i32) (i32.const 66576))
  (export "memory" (memory 0))
  (export "_start" (func $_start))
  (export "__wasm_apply_data_relocs" (func $__wasm_apply_data_relocs))
  (data $.data (i32.const 1024) "\00\00\00\00"))
```



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


More information about the llvm-commits mailing list