[llvm-bugs] [Bug 26222] New: [ELF] wrong functions are called when linking against DSO

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 20 09:23:21 PST 2016


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

            Bug ID: 26222
           Summary: [ELF] wrong functions are called when linking against
                    DSO
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: grimar at accesssoftek.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Consider the following code. We have Test1 and Test2 defined in DSO and the
functions with the same name in executable. When they are called from inside
DSO I believe exe versions should be used, but lld uses DSO versions of them.

-- code start --
main.cpp:
#include <stdio.h>
void Test1() { printf("main-test1\n"); }
void Test2() { printf("main-test2\n"); }
void Do();

int main()
{
  Do();
  Test2();
}

shared.cpp:
#include <stdio.h>
void Test1() { printf("dso-test1\n"); }
void Test2() { printf("dso-test2\n"); }

void Do()
{ 
  Test1();
  Test2();
}
-- code end--

If it is linked with lld:
clang -fuse-ld=lld main.cpp -c -o main.o
clang -fuse-ld=lld main.o shared.so -o main
Output is:
dso-test1
dso-test2
main-test2

But when linking with default linker ouput is different:
main-test1
main-test2
main-test2

And the last one I think is correct.

-- 
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/20160120/0be8280c/attachment.html>


More information about the llvm-bugs mailing list