For dynamic libraries, infer an implicit DT_SONAME setting from the
file basename, which is consistent with dynamic linking behavior in
practice. This makes it possible to resolve soname dependencies for
musl's libc.so which lacks a DT_SONAME setting.

Bug: https://bugs.gentoo.org/715162
Signed-off-by: Zac Medico <zmed...@gentoo.org>
---
 lib/portage/package/ebuild/doebuild.py      | 3 +++
 lib/portage/util/_dyn_libs/LinkageMapELF.py | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/lib/portage/package/ebuild/doebuild.py 
b/lib/portage/package/ebuild/doebuild.py
index 2bff94cb1..dd4a34a74 100644
--- a/lib/portage/package/ebuild/doebuild.py
+++ b/lib/portage/package/ebuild/doebuild.py
@@ -35,6 +35,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
        'portage.package.ebuild._ipc.QueryCommand:QueryCommand',
        'portage.dep._slot_operator:evaluate_slot_operator_equal_deps',
        'portage.package.ebuild._spawn_nofetch:spawn_nofetch',
+       'portage.util.elf.constants:ET_DYN',
        'portage.util.elf.header:ELFHeader',
        'portage.dep.soname.multilib_category:compute_multilib_category',
        'portage.util._desktop_entry:validate_desktop_entry',
@@ -2399,6 +2400,8 @@ def _post_src_install_soname_symlinks(mysettings, out):
 
                # Compute the multilib category and write it back to the file.
                entry.multilib_category = compute_multilib_category(elf_header)
+               if not entry.soname and elf_header.e_type == ET_DYN:
+                       entry.soname = os.path.basename(entry.filename)
                needed_file.write(_unicode(entry))
 
                if entry.multilib_category is None:
diff --git a/lib/portage/util/_dyn_libs/LinkageMapELF.py 
b/lib/portage/util/_dyn_libs/LinkageMapELF.py
index 70bec116a..fa17d8f4d 100644
--- a/lib/portage/util/_dyn_libs/LinkageMapELF.py
+++ b/lib/portage/util/_dyn_libs/LinkageMapELF.py
@@ -25,6 +25,7 @@ from portage.util import normalize_path
 from portage.util import varexpand
 from portage.util import writemsg_level
 from portage.util._dyn_libs.NeededEntry import NeededEntry
+from portage.util.elf.constants import ET_DYN
 from portage.util.elf.header import ELFHeader
 
 if sys.hexversion >= 0x3000000:
@@ -313,6 +314,8 @@ class LinkageMapELF(object):
                                                continue
                                        entry.multilib_category = 
compute_multilib_category(elf_header)
                                        entry.filename = 
entry.filename[root_len:]
+                                       if not entry.soname and 
elf_header.e_type == ET_DYN:
+                                               entry.soname = 
os.path.basename(entry.filename)
                                        owner = plibs.pop(entry.filename, None)
                                        lines.append((owner, "scanelf", 
_unicode(entry)))
                                proc.wait()
-- 
2.24.1


Reply via email to