[LLVMbugs] [Bug 23035] New: lld reports "Undefined symbol" for shared lib's dependencies

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Mar 26 10:31:58 PDT 2015


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

            Bug ID: 23035
           Summary: lld reports "Undefined symbol" for shared lib's
                    dependencies
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: davide at freebsd.org
          Reporter: emaste at freebsd.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

When a .so depends on another .so, but the 2nd .so is not a direct dependency
of the binary and is not specified on the command line, lld fails due to
"Undefined symbol" errors on the first .so.

[ main.c ]
#include <stdio.h>

int fn1(int);

int
main(int argc, char *argv[])
{
        printf("fn1(argc) = %d\n", fn1(argc));
        return 0;
}

[ lib1.c ]
int fn2(int);

int
fn1(int a)
{
        return fn2(a + 1);
}

[ lib2.c ]
int
fn2(int a)
{
        return a + 2;
}

Build the shared libs and main.o:
% clang -Wall -g -fPIC -shared -o lib2.so lib2.c
% clang -Wall -g -fPIC -shared -o lib1.so ./lib2.so lib1.c
% clang -Wall -g -o main.o -c main.c

Link with bfd ld:
% clang -Wall -g -rpath . -o main main.o lib1.so
% ./main
fn1(argc) = 4

Link with lld:
% clang -B. -Wall -g -rpath . -o main main.o lib1.so
warning: ignoring unknown argument: --enable-new-dtags
Undefined symbol: lib1.so: fn2
symbol(s) not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

-- 
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/20150326/94d56485/attachment.html>


More information about the llvm-bugs mailing list