[llvm-bugs] [Bug 41726] New: wasm-ld does not link globals
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 3 06:57:22 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41726
Bug ID: 41726
Summary: wasm-ld does not link globals
Product: lld
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: unassignedbugs at nondot.org
Reporter: mail at joachim-breitner.de
CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org
Consider this example:
$ cat a.c
int foo = '!';
int get_foo_a() { return foo; };
$ cat b.c
extern int foo;
int get_foo_b() { return foo; };
$ clang-9 --compile -fpic --target=wasm32-unknown-unknown-wasm a.c
$ clang-9 --compile -fpic --target=wasm32-unknown-unknown-wasm b.c
$ wasm-ld-9 --import-memory --shared --no-entry a.o b.o -o foo.wasm --export
get_foo_a --export get_foo_b
I would now expect both functions to use the same value for foo. But the
resulting file still has an unresolved import of GOT.mem.foo:
$ wasm-dis foo.wasm
(module
(type $0 (func))
(type $1 (func (result i32)))
(import "env" "memory" (memory $0 0))
(import "env" "__indirect_function_table" (table 0 anyfunc))
(import "env" "__memory_base" (global $gimport$2 i32))
(import "env" "__table_base" (global $gimport$3 i32))
(import "GOT.mem" "foo" (global $gimport$4 i32))
(data (get_global $gimport$2) "!\00\00\00")
(export "get_foo_a" (func $get_foo_a))
(export "get_foo_b" (func $get_foo_b))
(func $__wasm_call_ctors (; 0 ;) (type $0)
(call $__wasm_apply_relocs)
)
(func $__wasm_apply_relocs (; 1 ;) (type $0)
)
(func $get_foo_a (; 2 ;) (type $1) (result i32)
(local $var$0 i32)
(local $var$1 i32)
(local $var$2 i32)
(local $var$3 i32)
(set_local $var$0
(i32.const 0)
)
(set_local $var$1
(get_global $gimport$2)
)
(set_local $var$2
(i32.add
(get_local $var$1)
(get_local $var$0)
)
)
(set_local $var$3
(i32.load
(get_local $var$2)
)
)
(return
(get_local $var$3)
)
)
(func $get_foo_b (; 3 ;) (type $1) (result i32)
(local $var$0 i32)
(local $var$1 i32)
(set_local $var$0
(get_global $gimport$4)
)
(set_local $var$1
(i32.load
(get_local $var$0)
)
)
(return
(get_local $var$1)
)
)
;; custom section "dylink", size 5
;; custom section "producers", size 52
)
Is this intended behaviour?
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190503/69cba11e/attachment.html>
More information about the llvm-bugs
mailing list