-
-
Notifications
You must be signed in to change notification settings - Fork 526
Closed
Description
Consider following chain of dependencies (libbar<-libfoo<-libtest):
libbar is standalone and has no dependencies:
$ gcc -fuse-ld=mold -o libbar.so -shared -x c - <<EOF
void bar() { }
EOFlibfoo needs libbar:
$ gcc -fuse-ld=mold -o libfoo.so -shared -x c - -Wl,--as-needed -L. -lbar <<EOF
void bar();void foo() { bar(); }
EOF
$ readelf -a libfoo.so|grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [libbar.so]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x0000000000000001 (NEEDED) Shared library: [ld-linux-aarch64.so.1]libtest needs libfoo but has no direct dependency on libbar:
$ gcc -fuse-ld=mold -o libtest.so -shared -x c - -Wl,--as-needed -L. -lfoo -lbar <<EOF
void foo();void test() { foo(); }
EOFResult for mold 1.11.0:
$ readelf -a libtest.so|grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [libfoo.so]
0x0000000000000001 (NEEDED) Shared library: [libbar.so]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x0000000000000001 (NEEDED) Shared library: [ld-linux-aarch64.so.1]Result for both bfd and lld:
$ readelf -a libtest.so|grep NEEDED
0x0000000000000001 (NEEDED) Shared library: [libfoo.so]
Since libtest does not have dependencies on libbar and libfoo requires libbar already I consider bfd and lld output to be correct.
Metadata
Metadata
Assignees
Labels
No labels