public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:master commit in: misc/
Date: Sun, 23 Dec 2012 03:49:33 +0000 (UTC)	[thread overview]
Message-ID: <1356234519.84caac5ffcf2ca15f0a899f5b651a24cdaad56a6.blueness@gentoo> (raw)

commit:     84caac5ffcf2ca15f0a899f5b651a24cdaad56a6
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 23 02:33:53 2012 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sun Dec 23 03:48:39 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=84caac5f

misc/alt-revdep-pax: add print all reverse linkings (-r)

---
 misc/alt-revdep-pax |  149 +++++++++++++++++++++++++++-----------------------
 1 files changed, 80 insertions(+), 69 deletions(-)

diff --git a/misc/alt-revdep-pax b/misc/alt-revdep-pax
index b46fe23..6fb88fa 100755
--- a/misc/alt-revdep-pax
+++ b/misc/alt-revdep-pax
@@ -128,37 +128,47 @@ def get_soname_needed( object_needed, library2soname ):
 		try:
 			soname = library2soname[elf]
 			soname_needed[soname] = object_needed[elf]
-			#soname_needed[soname] = copy(object_needed[elf]) #copy the list
 		except KeyError:
 			continue  # no soname, its probably an executable
 
 	return soname_needed
 
-
+"""
+Run through the entire chain of sonameX -> sonameY ... -> sonameZ chain.
+We do this by continuously expanding the list pointed to by the dictionary
+entry until there are no new soname's found.
+"""
 def get_soname_linkings( soname_needed, soname2library ):
+
 	for soname in soname_needed:
 		while True:
-			count = 0
-			for s in soname_needed[soname]:
+			found_new_soname = False
+			for s in soname_needed[soname]:					# For all the next links ...
 				try:
-					for sf in soname_needed[s]:
-						if sf in soname_needed[soname]:		# Skip it if we already included it
+					for sf in soname_needed[s]:			# ... go one step ahead in the chain
+						if sf in soname_needed[soname]:		# ... skip it if we already included it
 							continue
-						if not sf in soname2library:		#Skip if its a vdso
+						if not sf in soname2library:		# ... skip if its a vdso
 							continue
-						# This appends to the object_needed and soname_needed list.
-						#  No copy was done so its the same list in memory for both.
-						soname_needed[soname].append(sf)
-						count = 1
-				except KeyError:
+						# This appends to the object_needed
+						# and soname_needed lists.  No copy
+						# was done so its the same lists in
+						# memory for both, and its modified
+						# for both.
+						soname_needed[soname].append(sf)	# ... otherwise collapse it back into
+						found_new_soname = True			# first node of the chain.
+
+				except KeyError:					# Not all nodes in the chain have a next node
 					continue
 
-			if count == 0:
-				break
-	return
+			if not found_new_soname:					# We're done, that last iteration found
+				break							# no new nodes
+
+
 
 
 def get_object_linkings():
+
 	object_needed = get_object_needed()
 	( library2soname, soname2library ) = get_libraries()
 	soname_needed = get_soname_needed( object_needed, library2soname )
@@ -166,21 +176,22 @@ def get_object_linkings():
 	return ( object_needed, soname2library )
 
 
-def get_object_reverse_linkings( object_linkings ):
-	object_reverse_linkings = {}
-
-	for elf in object_linkings:
-		for soname in object_linkings[elf]:
-			object_reverse_linkings.setdefault(soname,[]).append(elf)
+def print_problems( elfs_without_flags, sonames_without_flags, sonames_missing_library):
 
-	return object_reverse_linkings
+	elfs_without_flags = set(elfs_without_flags)
+	print('\n**** ELF objections without any PAX flags ****\n')
+	for m in elfs_without_flags:
+		print('\t%s' % m)
 
+	sonames_without_flags = set(sonames_without_flags)
+	print('\n**** SONAMEs with library files without PAX flags ****\n')
+	for m in sonames_without_flags:
+		print('\t%s' % m)
 
-#XXXXXXXXXXXXXXXX
-def invert_linkings( forward_linkings ):
-	reverse_linkings = {}
-	return reverse_linkings 
-#XXXXXXXXXXXXXXXX
+	sonames_missing_library = set(sonames_missing_library)
+	print('\n**** SONAMES without any library files ****\n')
+	for m in sonames_missing_library:
+		print('\t%s' % m)
 
 
 def print_object_linkings( object_linkings, soname2library, verbose ):
@@ -223,59 +234,65 @@ def print_object_linkings( object_linkings, soname2library, verbose ):
 			if count != 0:
 				print('%s\n\n' % s)
 
-	elfs_without_flags = set(elfs_without_flags)
-	print('\n**** ELF objections without any PAX flags ****')
-	for m in elfs_without_flags:
-		print('\t%s' % m)
-
-	sonames_without_flags = set(sonames_without_flags)
-	print('\n**** SONAMEs with library files without PAX flags ****')
-	for m in sonames_without_flags:
-		print('\t%s' % m)
+	print_problems( elfs_without_flags, sonames_without_flags, sonames_missing_library)
 
-	sonames_missing_library = set(sonames_missing_library)
-	print('\n**** SONAMES without any library files ****')
-	for m in sonames_missing_library:
-		print('\t%s' % m)
 
 
 def run_forward(verbose):
+
 	( object_linkings, soname2library ) = get_object_linkings()
 	print_object_linkings( object_linkings, soname2library, verbose)
 
 
-def print_reverse_linkings( reverse_linkings, so2library_mappings, verbose, executable_only ):
+
+
+def get_object_reverse_linkings( object_linkings ):
+
+	object_reverse_linkings = {}
+
+	for elf in object_linkings:
+		for soname in object_linkings[elf]:
+			object_reverse_linkings.setdefault(soname,[]).append(elf)
+
+	return object_reverse_linkings
+
+
+def print_object_reverse_linkings( object_reverse_linkings, soname2library, verbose, executable_only):
+
 	shell_path = path = os.getenv('PATH').split(':')
-	missing_sonames = []
-	missing_links = []
 
-	for soname in reverse_linkings:
+	elfs_without_flags = []
+	sonames_without_flags = []
+	sonames_missing_library = []
+
+	for soname in object_reverse_linkings:
 		try:
-			library = so2library_mappings[soname]
+			library = soname2library[soname]
 			( library_str_flags, library_bin_flags ) = pax.getflags(library)
 			sv = '%s\t%s ( %s )\n' % ( soname, library, library_str_flags )
 			s = sv
+		except KeyError:
+			sonames_missing_library.append(soname)
 		except pax.PaxError:
-			missing_sonames.append(soname)
-			continue
+			sonames_without_flags.append(soname)
 
 		count = 0
-		for binary in reverse_linkings[soname]:
+		for elf in object_reverse_linkings[soname]:
 			try:
-				( binary_str_flags, binary_bin_flags ) = pax.getflags(binary)
+				( elf_str_flags, elf_bin_flags ) = pax.getflags(elf)
 				if executable_only:
-					if os.path.dirname(binary) in shell_path:	
-						sv = '%s\n\t%s ( %s )' % ( sv, binary, binary_str_flags )
-						if library_str_flags != binary_str_flags:
-							s = '%s\n\t%s ( %s )' % ( s, binary, binary_str_flags )
+					if os.path.dirname(elf) in shell_path:
+						sv = '%s\n\t%s ( %s )' % ( sv, elf, elf_str_flags )
+						if library_str_flags != elf_str_flags:
+							s = '%s\n\t%s ( %s )' % ( s, elf, elf_str_flags )
 							count = count + 1
 				else:
-					sv = '%s\n\t%s ( %s )' % ( sv, binary, binary_str_flags )
-					if library_str_flags != binary_str_flags:
-						s = '%s\n\t%s ( %s )' % ( s, binary, binary_str_flags )
+					sv = '%s\n\t%s ( %s )' % ( sv, elf, elf_str_flags )
+					if library_str_flags != elf_str_flags:
+						s = '%s\n\t%s ( %s )' % ( s, elf, elf_str_flags )
 						count = count + 1
 			except pax.PaxError:
-				missing_links.append(binary)
+				elfs_without_flags.append(elf)
 
 		if verbose:
 			print('%s\n' % sv)
@@ -287,21 +304,15 @@ def print_reverse_linkings( reverse_linkings, so2library_mappings, verbose, exec
 			if count != 0:
 				print('%s\n\n' % s)
 
-	missing_sonames = set(missing_sonames)
-	print('\n**** Missing sonames ****\n')
-	for m in missing_sonames:
-		print('\t%s\n' % m)
-
-	missing_links = set(missing_links)
-	print('\n**** Missing reverse linkings ****\n')
-	for m in missing_links:
-		print('\t%s\n' % m)
+	print_problems( elfs_without_flags, sonames_without_flags, sonames_missing_library)
 
 
 def run_reverse(verbose, executable_only):
-	( forward_linkings, so2library_mappings ) = get_object_linkings()
-	reverse_linkings = invert_linkings( forward_linkings )
-	print_reverse_linkings( reverse_linkings, so2library_mappings, verbose, executable_only)
+	( object_linkings, soname2library ) = get_object_linkings()
+	object_reverse_linkings = get_object_reverse_linkings( object_linkings )
+	print_object_reverse_linkings( object_reverse_linkings, soname2library, verbose, executable_only)
+
+
 
 
 def migrate_flags(importer, exporter_str_flags, exporter_bin_flags):


             reply	other threads:[~2012-12-23  3:50 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-23  3:49 Anthony G. Basile [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-02-13 21:38 [gentoo-commits] proj/elfix:master commit in: misc/ Anthony G. Basile
2014-02-13 19:07 Anthony G. Basile
2013-05-21 15:21 Anthony G. Basile
2013-02-09 21:50 Anthony G. Basile
2012-12-27  3:11 Anthony G. Basile
2012-12-26 21:43 Anthony G. Basile
2012-12-26 21:23 Anthony G. Basile
2012-12-26  3:42 Anthony G. Basile
2012-12-25 14:22 Anthony G. Basile
2012-12-24 23:26 Anthony G. Basile
2012-12-24 21:44 Anthony G. Basile
2012-12-24 21:08 Anthony G. Basile
2012-12-24  2:18 Anthony G. Basile
2012-12-24  1:54 Anthony G. Basile
2012-12-23 11:51 Anthony G. Basile
2012-12-23  4:53 Anthony G. Basile
2012-12-23  3:49 Anthony G. Basile
2012-12-23  3:49 Anthony G. Basile
2012-12-23  3:47 Anthony G. Basile
2012-12-23  2:36 Anthony G. Basile
2012-12-23  2:36 Anthony G. Basile
2012-12-23  2:34 Anthony G. Basile
2012-12-23  1:02 Anthony G. Basile
2012-12-22 14:44 Anthony G. Basile
2012-12-22  4:21 Anthony G. Basile
2012-12-22  3:58 Anthony G. Basile
2012-12-22  1:06 Anthony G. Basile
2012-12-19  3:52 Anthony G. Basile
2011-07-08  1:32 Anthony G. Basile

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=1356234519.84caac5ffcf2ca15f0a899f5b651a24cdaad56a6.blueness@gentoo \
    --to=blueness@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