[llvm-bugs] [Bug 37779] New: RTLD_LAZY does not work if compiled with clang

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 12 04:19:45 PDT 2018


            Bug ID: 37779
           Summary: RTLD_LAZY does not work if compiled with clang
           Product: clang
           Version: 6.0
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Driver
          Assignee: unassignedclangbugs at nondot.org
          Reporter: tom.ty89 at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20421
  --> https://bugs.llvm.org/attachment.cgi?id=20421&action=edit

Supposedly with RTLD_LAZY, symbols will only be resolved as the code references
them are executed. However, when compiled with clang, undefined symbols are
being resolved before dlopen() returns, as if RTLD_NOW is used.

Here's the difference when the attached example is compiled with gcc and clang

$ make
cc -shared libshared.c -o libshared.so                                         
   cc -shared libplugin.c -o libplugin.so
cc main.c -ldl -o executable
$ ./executable
plugin: value = 42
$ make clean
rm -f executable libshared.so libplugin.so
$ make CC=clang
clang -shared libshared.c -o libshared.so
clang -shared libplugin.c -o libplugin.so
clang main.c -ldl -o executable
$ ./executable
dlopen failed: ./libplugin.so: undefined symbol: libshared_get_value

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/20180612/fe73c01d/attachment-0001.html>

More information about the llvm-bugs mailing list