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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to