1 |
For dynamic libraries, infer an implicit DT_SONAME setting from the |
2 |
file basename, which is consistent with dynamic linking behavior in |
3 |
practice. This makes it possible to resolve soname dependencies for |
4 |
musl's libc.so which lacks a DT_SONAME setting. |
5 |
|
6 |
Bug: https://bugs.gentoo.org/715162 |
7 |
Signed-off-by: Zac Medico <zmedico@g.o> |
8 |
--- |
9 |
[PATCH v2] Use file command to distinguish shared library from PIE executable |
10 |
|
11 |
bin/misc-functions.sh | 6 ++++++ |
12 |
lib/portage/util/_dyn_libs/LinkageMapELF.py | 16 ++++++++++++++++ |
13 |
2 files changed, 22 insertions(+) |
14 |
|
15 |
diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh |
16 |
index 4f8a4112d..9efe99b87 100755 |
17 |
--- a/bin/misc-functions.sh |
18 |
+++ b/bin/misc-functions.sh |
19 |
@@ -183,6 +183,12 @@ install_qa_check() { |
20 |
soname=${l%%;*}; l=${l#*;} |
21 |
rpath=${l%%;*}; l=${l#*;}; [ "${rpath}" = " - " ] && rpath="" |
22 |
needed=${l%%;*}; l=${l#*;} |
23 |
+ |
24 |
+ # Infer implicit soname from basename (bug 715162). |
25 |
+ if [[ -z ${soname} && $(file "${D%/}${obj}") == *"SB shared object"* ]]; then |
26 |
+ soname=${obj##*/} |
27 |
+ fi |
28 |
+ |
29 |
echo "${obj} ${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED |
30 |
echo "${arch:3};${obj};${soname};${rpath};${needed}" >> "${PORTAGE_BUILDDIR}"/build-info/NEEDED.ELF.2 |
31 |
done } |
32 |
diff --git a/lib/portage/util/_dyn_libs/LinkageMapELF.py b/lib/portage/util/_dyn_libs/LinkageMapELF.py |
33 |
index 70bec116a..2d4929445 100644 |
34 |
--- a/lib/portage/util/_dyn_libs/LinkageMapELF.py |
35 |
+++ b/lib/portage/util/_dyn_libs/LinkageMapELF.py |
36 |
@@ -311,6 +311,22 @@ class LinkageMapELF(object): |
37 |
raise |
38 |
# File removed concurrently. |
39 |
continue |
40 |
+ |
41 |
+ # Infer implicit soname from basename (bug 715162). |
42 |
+ if not entry.soname: |
43 |
+ try: |
44 |
+ proc = subprocess.Popen([b'file', |
45 |
+ _unicode_encode(entry.filename, |
46 |
+ encoding=_encodings['fs'], errors='strict')], |
47 |
+ stdout=subprocess.PIPE) |
48 |
+ out, err = proc.communicate() |
49 |
+ proc.wait() |
50 |
+ except EnvironmentError: |
51 |
+ pass |
52 |
+ else: |
53 |
+ if b'SB shared object' in out: |
54 |
+ entry.soname = os.path.basename(entry.filename) |
55 |
+ |
56 |
entry.multilib_category = compute_multilib_category(elf_header) |
57 |
entry.filename = entry.filename[root_len:] |
58 |
owner = plibs.pop(entry.filename, None) |
59 |
-- |
60 |
2.24.1 |