Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How does shared library work in NEEDED section#28952

Unanswered
JinhangZhang asked this question inQ&A
Discussion options

Hi,

I have two questions regarding to the shared library stated in the NEEDED section for a .so file.
For example

# readelf --dynamic /usr/lib64/libssl.soDynamic section at offset 0xdfbb0 contains 31 entries:  Tag        Type                         Name/Value 0x0000000000000001 (NEEDED)             Shared library: [libcrypto.so.3] 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6] 0x000000000000000e (SONAME)             Library soname: [libssl.so.3]...

libssl.so needed a shared library named libcrypto.so.3, my first question is: Im not sure is that libcrypto.so.3 a SONAME or a filename? If it is a SONAME how does the libssl.so know where to find it?

Another question

# readelf --dynamic /usr/lib64/libcrypto.soDynamic section at offset 0x5117a0 contains 31 entries:  Tag        Type                         Name/Value 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1] 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6] 0x000000000000000e (SONAME)             Library soname: [libcrypto.so.3]... # readelf --dynamic /usr/lib64/libcrypto.so.3Dynamic section at offset 0x5117a0 contains 31 entries:  Tag        Type                         Name/Value 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1] 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6] 0x000000000000000e (SONAME)             Library soname: [libcrypto.so.3]...

I can see both libcrypto.so and libcrypto.so.3 have the same SONAME, how does other file knows which one should be called?

You must be logged in to vote

Replies: 1 comment 2 replies

Comment options

If you want to read all the gory details, theman-page for ld.so is the place to look.

In short, theNEEDED tag gives an SONAME, which is also taken as a file name, so whatever the value is, is whatld.so will search for.

File names likelibssl.so are mainly there forbuilding, and is usually a symbolic link to the appropriate SONAME named file. For example, on my laptop:

ls -l /usr/lib/x86_64-linux-gnu/lib{crypto,ssl}.*-rw-r--r-- 1 root root 11945002 sep 30 21:54 /usr/lib/x86_64-linux-gnu/libcrypto.alrwxrwxrwx 1 root root       14 sep 30 21:54 /usr/lib/x86_64-linux-gnu/libcrypto.so -> libcrypto.so.3-rw-r--r-- 1 root root  6373952 sep 30 21:54 /usr/lib/x86_64-linux-gnu/libcrypto.so.3-rw-r--r-- 1 root root  2095014 sep 30 21:54 /usr/lib/x86_64-linux-gnu/libssl.alrwxrwxrwx 1 root root       11 sep 30 21:54 /usr/lib/x86_64-linux-gnu/libssl.so -> libssl.so.3-rw-r--r-- 1 root root  1101760 sep 30 21:54 /usr/lib/x86_64-linux-gnu/libssl.so.3
You must be logged in to vote
2 replies
@JinhangZhang
Comment options

Hi@levitte , thanks for your reply.

In short, the NEEDED tag gives an SONAME, which is also taken as a file name, so whatever the value is, is what ld.so will search for.

Im wondering a special case that:

  1. there is a shared library file named libcrypto.so.3, whose SONAME is libcrypto.so
  2. there is another shared library file named libcrypto.so whose SONAME is libcrypto.so.3

which one is NEEDED for libssl.so?

@levitte
Comment options

  1. there is a shared library file named libcrypto.so.3, whose SONAME is libcrypto.so

That sounds wrong. Its SONAME should be libcrypto.so.3

Have you checked whether any of those files are symbolic links?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@JinhangZhang@levitte

[8]ページ先頭

©2009-2025 Movatter.jp