[llvm-bugs] [Bug 40494] New: [Wasm] Symbol linked in despite no strong references

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 28 05:21:06 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40494

            Bug ID: 40494
           Summary: [Wasm] Symbol linked in despite no strong references
           Product: lld
           Version: unspecified
          Hardware: Other
                OS: other
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: dan433584 at gmail.com
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org,
                    sbc at chromium.org

An extern weak alias appears to be pulling in otherwise unneeded definitions
from archive files. This is inconsistent with ELF platforms, at least.

$ cat test_start.c
extern void foo(void) __attribute__((weak));

void _start(void) {
    if (&foo) {
        foo();
    }
}
$ cat foo.c
void foo(void) {}
$ clang --target=wasm32-unknown-unknown -nostdlib test_start.c
$ wasm2wat a.out  |grep foo
  (func $undefined_function_foo (type 0)
      call $undefined_function_foo
$ clang --target=wasm32-unknown-unknown -c foo.c
$ llvm-ar crus libfoo.a foo.o
$ clang --target=wasm32-unknown-unknown test_start.c  -nostdlib -L. -lfoo
$ wasm2wat a.out  |grep foo
      call $foo
  (func $foo (type 0)
  (elem (;0;) (i32.const 1) $foo))
$ 

So even though there's no strong reference to foo, whole-archive mode is not
enabled, adding -lfoo is enough to cause function foo to be linked in.

-- 
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/20190128/8b3c2de0/attachment.html>


More information about the llvm-bugs mailing list