public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/_dyn_libs/
Date: Tue, 27 Dec 2016 21:43:17 +0000 (UTC)	[thread overview]
Message-ID: <1482873906.cbaee3c3b28f52947c142da8df24d6b0817962f9.zmedico@gentoo> (raw)

commit:     cbaee3c3b28f52947c142da8df24d6b0817962f9
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 27 04:17:01 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Dec 27 21:25:06 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=cbaee3c3

LinkageMapELF: compute multilib category for preserved libs (bug 598080)

When support for parsing ELF headers in order to compute multilib
category was added in commit f1c1b8a77eebf7713b32e5f9945690f60f4f46de,
the LinkageMapELF class was not updated to do the same for preserved
libraries. This has resulted in incorrect preserve-libs handling
as reported in bug 598080, for ABIs including x32 where the
_approx_multilib_categories mapping is insufficient. This patch fixes
LinkageMapELF to compute the multilib category for each preserved
library, in the same way as the _post_src_install_soname_symlinks
function, so that the LinkageMapELF.findConsumers method will operate
correctly with preserved libraries of all ABIs.

Fixes: f1c1b8a77eeb ("Generate soname dependency metadata (bug 282639)")
X-Gentoo-bug: 598080
X-Gentoo-bug-url: https://bugs.gentoo.org/598080
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>

 pym/portage/util/_dyn_libs/LinkageMapELF.py | 33 +++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/pym/portage/util/_dyn_libs/LinkageMapELF.py b/pym/portage/util/_dyn_libs/LinkageMapELF.py
index 0b09fe5..a063621 100644
--- a/pym/portage/util/_dyn_libs/LinkageMapELF.py
+++ b/pym/portage/util/_dyn_libs/LinkageMapELF.py
@@ -4,6 +4,7 @@
 import errno
 import logging
 import subprocess
+import sys
 
 import portage
 from portage import _encodings
@@ -12,6 +13,7 @@ from portage import _unicode_decode
 from portage import _unicode_encode
 from portage.cache.mappings import slot_dict_class
 from portage.const import EPREFIX
+from portage.dep.soname.multilib_category import compute_multilib_category
 from portage.exception import CommandNotFound, InvalidData
 from portage.localization import _
 from portage.util import getlibpaths
@@ -20,6 +22,12 @@ 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.header import ELFHeader
+
+if sys.hexversion >= 0x3000000:
+	_unicode = str
+else:
+	_unicode = unicode
 
 # Map ELF e_machine values from NEEDED.ELF.2 to approximate multilib
 # categories. This approximation will produce incorrect results on x32
@@ -283,15 +291,26 @@ class LinkageMapELF(object):
 					l = l[3:].rstrip("\n")
 					if not l:
 						continue
-					fields = l.split(";")
-					if len(fields) < 5:
-						writemsg_level(_("\nWrong number of fields " \
-							"returned from scanelf: %s\n\n") % (l,),
+					try:
+						entry = NeededEntry.parse("scanelf", l)
+					except InvalidData as e:
+						writemsg_level("\n%s\n\n" % (e,),
 							level=logging.ERROR, noiselevel=-1)
 						continue
-					fields[1] = fields[1][root_len:]
-					owner = plibs.pop(fields[1], None)
-					lines.append((owner, "scanelf", ";".join(fields)))
+					try:
+						with open(_unicode_encode(entry.filename,
+							encoding=_encodings['fs'],
+							errors='strict'), 'rb') as f:
+							elf_header = ELFHeader.read(f)
+					except EnvironmentError as e:
+						if e.errno != errno.ENOENT:
+							raise
+						# File removed concurrently.
+						continue
+					entry.multilib_category = compute_multilib_category(elf_header)
+					entry.filename = entry.filename[root_len:]
+					owner = plibs.pop(entry.filename, None)
+					lines.append((owner, "scanelf", _unicode(entry)))
 				proc.wait()
 				proc.stdout.close()
 


             reply	other threads:[~2016-12-27 21:43 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-27 21:43 Zac Medico [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-05-25 16:12 [gentoo-commits] proj/portage:master commit in: pym/portage/util/_dyn_libs/ Zac Medico
2018-01-02 23:04 Zac Medico
2016-06-06 16:03 Zac Medico
2015-06-02  3:48 Zac Medico
2015-04-24 17:53 Zac Medico
2013-03-18 23:43 Zac Medico
2013-03-18 23:35 Zac Medico
2013-02-22 18:52 Arfrever Frehtes Taifersar Arahesis
2012-03-22 15:24 Zac Medico
2012-03-21 21:24 Zac Medico
2012-03-05  7:32 Zac Medico
2012-02-18  3:11 Zac Medico
2012-02-18  2:06 Zac Medico
2012-02-01  2:04 Zac Medico
2011-07-24  2:58 Zac Medico
2011-07-24  2:58 Zac Medico
2011-07-24  2:15 Zac Medico
2011-07-23  6:23 Zac Medico
2011-07-22 20:38 Zac Medico
2011-07-22  8:03 Zac Medico
2011-07-20  8:05 Zac Medico
2011-07-20  4:51 Zac Medico
2011-07-01  4:02 Zac Medico
2011-07-01  4:02 Zac Medico
2011-07-01  1:37 Zac Medico
2011-06-30 10:17 Zac Medico
2011-06-30 10:01 Zac Medico
2011-05-08 21:31 Zac Medico
2011-05-08  7:10 Zac Medico
2011-05-08  5:02 Zac Medico
2011-05-07 17:25 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1482873906.cbaee3c3b28f52947c142da8df24d6b0817962f9.zmedico@gentoo \
    --to=zmedico@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox