[llvm-bugs] [Bug 49915] New: LLD emits corrupt version for weak symbol when using version script

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 10 13:04:51 PDT 2021


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

            Bug ID: 49915
           Summary: LLD emits corrupt version for weak symbol when using
                    version script
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: aaronpuchert at alice-dsl.net
                CC: llvm-bugs at lists.llvm.org, smithp352 at googlemail.com

When linking against a lld-linked libLLVM.so with ld.bfd I got the following
error:

/usr/bin/ld: /usr/lib64/libLLVM.so: __morestack: invalid needed version 2
/usr/bin/ld: /usr/lib64/libLLVM.so: error adding symbols: bad value
clang-12.0: error: linker command failed with exit code 1 (use -v to see
invocation)

Indeed:

> readelf --wide --dyn-syms /usr/lib64/libLLVM.so.12 | grep morestack
332: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __morestack@@<corrupt>

This is coming from
llvm/lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp. I've managed to
build a small reproducer that should work with 12.0.0rc5:

> cat morestack.cpp
extern "C" __attribute__((__weak__)) void __morestack();

unsigned long f() {
  return (unsigned long)&__morestack;
}
> cat script.map
LLVM_13 { global: *; };
> clang -c -fPIC -g morestack.cpp
> clang -fuse-ld=lld -shared -o test.so -Wl,--version-script,script.map morestack.o
> readelf --wide --dyn-syms test.so | grep __morestack
     5: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND
__morestack@@<corrupt>

Without -fuse-ld=lld, i.e. with ld.bfd I get

     2: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __morestack

Now lld itself seems to fine with the corrupt version, so maybe binutils are
just overly sensitive? I don't know.

-- 
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/20210410/97845c90/attachment.html>


More information about the llvm-bugs mailing list