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