1 |
On Mon, 26 Dec 2016 20:37:39 -0800 |
2 |
Zac Medico <zmedico@g.o> wrote: |
3 |
|
4 |
> When support for parsing ELF headers in order to compute multilib |
5 |
> category was added in commit f1c1b8a77eebf7713b32e5f9945690f60f4f46de, |
6 |
> the LinkageMapELF class was not updated to do the same for preserved |
7 |
> libraries. This has resulted in incorrect preserve-libs handling |
8 |
> as reported in bug 598080, for ABIs including x32 where the |
9 |
> _approx_multilib_categories mapping is insufficient. This patch fixes |
10 |
> LinkageMapELF to compute the multilib category for each preserved |
11 |
> library, in the same way as the _post_src_install_soname_symlinks |
12 |
> function, so that the LinkageMapELF.findConsumers method will operate |
13 |
> correctly with preserved libraries of all ABIs. |
14 |
> |
15 |
> Fixes: f1c1b8a77eeb ("Generate soname dependency metadata (bug |
16 |
> 282639)") X-Gentoo-bug: 598080 |
17 |
> X-Gentoo-bug-url: https://bugs.gentoo.org/598080 |
18 |
> --- |
19 |
> pym/portage/util/_dyn_libs/LinkageMapELF.py | 33 |
20 |
> +++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 |
21 |
> deletions(-) |
22 |
> |
23 |
> diff --git a/pym/portage/util/_dyn_libs/LinkageMapELF.py |
24 |
> b/pym/portage/util/_dyn_libs/LinkageMapELF.py index 0b09fe5..a063621 |
25 |
> 100644 --- a/pym/portage/util/_dyn_libs/LinkageMapELF.py |
26 |
> +++ b/pym/portage/util/_dyn_libs/LinkageMapELF.py |
27 |
> @@ -4,6 +4,7 @@ |
28 |
> import errno |
29 |
> import logging |
30 |
> import subprocess |
31 |
> +import sys |
32 |
> |
33 |
> import portage |
34 |
> from portage import _encodings |
35 |
> @@ -12,6 +13,7 @@ from portage import _unicode_decode |
36 |
> from portage import _unicode_encode |
37 |
> from portage.cache.mappings import slot_dict_class |
38 |
> from portage.const import EPREFIX |
39 |
> +from portage.dep.soname.multilib_category import |
40 |
> compute_multilib_category from portage.exception import |
41 |
> CommandNotFound, InvalidData from portage.localization import _ |
42 |
> from portage.util import getlibpaths |
43 |
> @@ -20,6 +22,12 @@ from portage.util import normalize_path |
44 |
> from portage.util import varexpand |
45 |
> from portage.util import writemsg_level |
46 |
> from portage.util._dyn_libs.NeededEntry import NeededEntry |
47 |
> +from portage.util.elf.header import ELFHeader |
48 |
> + |
49 |
> +if sys.hexversion >= 0x3000000: |
50 |
> + _unicode = str |
51 |
> +else: |
52 |
> + _unicode = unicode |
53 |
> |
54 |
> # Map ELF e_machine values from NEEDED.ELF.2 to approximate multilib |
55 |
> # categories. This approximation will produce incorrect results on |
56 |
> x32 @@ -283,15 +291,26 @@ class LinkageMapELF(object): |
57 |
> l = l[3:].rstrip("\n") |
58 |
> if not l: |
59 |
> continue |
60 |
> - fields = l.split(";") |
61 |
> - if len(fields) < 5: |
62 |
> - |
63 |
> writemsg_level(_("\nWrong number of fields " \ |
64 |
> - "returned |
65 |
> from scanelf: %s\n\n") % (l,), |
66 |
> + try: |
67 |
> + entry = |
68 |
> NeededEntry.parse("scanelf", l) |
69 |
> + except InvalidData as e: |
70 |
> + |
71 |
> writemsg_level("\n%s\n\n" % (e,), level=logging.ERROR, noiselevel=-1) |
72 |
> continue |
73 |
> - fields[1] = |
74 |
> fields[1][root_len:] |
75 |
> - owner = plibs.pop(fields[1], |
76 |
> None) |
77 |
> - lines.append((owner, |
78 |
> "scanelf", ";".join(fields))) |
79 |
> + try: |
80 |
> + with |
81 |
> open(_unicode_encode(entry.filename, |
82 |
> + |
83 |
> encoding=_encodings['fs'], |
84 |
> + |
85 |
> errors='strict'), 'rb') as f: |
86 |
> + elf_header = |
87 |
> ELFHeader.read(f) |
88 |
> + except EnvironmentError as e: |
89 |
> + if e.errno != |
90 |
> errno.ENOENT: |
91 |
> + raise |
92 |
> + # File removed |
93 |
> concurrently. |
94 |
> + continue |
95 |
> + entry.multilib_category = |
96 |
> compute_multilib_category(elf_header) |
97 |
> + entry.filename = |
98 |
> entry.filename[root_len:] |
99 |
> + owner = |
100 |
> plibs.pop(entry.filename, None) |
101 |
> + lines.append((owner, |
102 |
> "scanelf", _unicode(entry))) proc.wait() |
103 |
> proc.stdout.close() |
104 |
> |
105 |
|
106 |
looks fine |
107 |
|
108 |
-- |
109 |
Brian Dolbec <dolsen> |