Skip to content

LLD doesn't implement --rpath-link; doesn't error for an versioned symbol error from a transitive DSO #157987

@Kartatz

Description

@Kartatz

Steps to reproduce

Step 1

Create a versioned libfoo:

echo 'void foo(void) {}' > foo.c

cat << code > 'libfoo.ver'
VERSION_1.0 {
    global:
        foo;
    local:
        *;
};
code

gcc foo.c -shared -o libfoo.so -Wl,--version-script=libfoo.ver

Step 2

Now create a library that depends on libfoo (libbar):

cat << code > bar.c
void foo(void);                                      
void bar(void) { foo(); }
code

gcc bar.c -shared -o libbar.so -lfoo -L.

Step 3

Finally, create an executable that depends on libbar:

cat << code > main.c
void bar(void);
int main(void) { bar(); }
code

Step 4

Confirm that linking with both BFD and LLD works:

$ gcc main.c -o main -lbar -L. -fuse-ld=bfd
<succeeds>
$ gcc main.c -o main -lbar -L. -fuse-ld=lld
<succeeds>

Step 5

Now recompile libfoo, this time without symbol versioning:

$ gcc foo.c -shared -o libfoo.so

Linking with BFD now reports an undefined symbol (expected behavior):

$ gcc main.c -o main -lbar -L. -fuse-ld=bfd
ld: ./libbar.so: undefined reference to `foo@VERSION_1.0'
collect2: error: ld returned 1 exit status

LLD, however, links without reporting any errors (unexpected behavior):

$ gcc main.c -o main -lbar -L. -fuse-ld=lld
<succeeds>

LLD version

$ ld.lld --version
LLD 21.1.0 (compatible with GNU linkers)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions