From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:elfix-0.7.x commit in: misc/
Date: Mon, 24 Dec 2012 10:59:06 +0000 (UTC) [thread overview]
Message-ID: <1356346677.9e550cd560524ded70d854f38f2118d236be4061.blueness@gentoo> (raw)
commit: 9e550cd560524ded70d854f38f2118d236be4061
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 22 14:44:14 2012 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Mon Dec 24 10:57:57 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=9e550cd5
misc/alt-revdep-pax: remove soname list copy, add get_object_reverse_linkings()
---
misc/alt-revdep-pax | 91 +++++++++++++++++++++++++++++++--------------------
1 files changed, 55 insertions(+), 36 deletions(-)
diff --git a/misc/alt-revdep-pax b/misc/alt-revdep-pax
index 181b57e..a6adacd 100755
--- a/misc/alt-revdep-pax
+++ b/misc/alt-revdep-pax
@@ -13,16 +13,17 @@ import os
import sys
import re
import pax
-#from copy import copy
-def get_object_needed():
- """
- Return object_needed dictionary which has structure
- { full_path_to_ELF_object : [ soname1, soname2, ... ], ... }
+"""
+Return object_needed dictionary which has structure
- Here the sonames were obtained from the ELF object by readelf -d
- """
+ { full_path_to_ELF_object : [ soname1, soname2, ... ], ... }
+
+Here the sonames were obtained from the ELF object by scanelf -nm
+(like readelf -d) during emerge.
+"""
+def get_object_needed():
var_db_pkg = '/var/db/pkg'
@@ -47,16 +48,17 @@ def get_object_needed():
return object_needed
-def get_library():
- """
- Return library2soname dictionary which has structure
+"""
+Return library2soname dictionary which has structure
- { full_path_to_library : soname, ... }
+ { full_path_to_library : soname, ... }
- and its inverse which has structure
+and its inverse which has structure
+
+ { soname : full_path_to_library, ... }
+"""
+def get_libraries():
- { soname : full_path_to_library, ... }
- """
var_db_pkg = '/var/db/pkg'
library2soname = {}
@@ -84,14 +86,15 @@ def get_library():
return ( library2soname, soname2library )
-def get_soname_needed( object_needed, library2soname ):
- """
- Return get_soname_needed dictionary which has structure:
+"""
+Return get_soname_needed dictionary which has structure:
- { soname : [ soname1, soname2, ... ], .... }
+ { soname : [ soname1, soname2, ... ], .... }
- Here the soname1,2,... were obtained from soname's corresponding ELF library by readelf -d
- """
+Here the soname1, soname2,... were obtained from soname's corresponding
+ELF object by scanelf -n during emerge.
+"""
+def get_soname_needed( object_needed, library2soname ):
soname_needed = {}
@@ -107,29 +110,36 @@ def get_soname_needed( object_needed, library2soname ):
def get_soname_linkings( soname_needed, soname2library ):
- soname_linkings = {}
for soname in soname_needed:
- needed = soname_needed[soname]
- #needed = copy(soname_needed[soname]) #copy the list
while True:
count = 0
- for s in needed:
+ for s in soname_needed[soname]:
try:
for sf in soname_needed[s]:
- if not sf in needed and sf in soname2library:
- # This appends to the object_needed and
- # soname_needed list. No copy was done
- needed.append(sf)
- count = 1
+ if sf in soname_needed[soname]: # Skip it if we already included it
+ continue
+ 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:
continue
if count == 0:
break
+ return
+
- soname_linkings[soname] = needed
+def get_object_reverse_linkings( object_linkings ):
+ object_reverse_linkings = {}
- return soname_linkings
+ for elf in object_linkings:
+ for soname in object_linkings[elf]:
+ object_reverse_linkings.setdefault(soname,[]).append(elf)
+
+ return object_reverse_linkings
def main():
@@ -141,14 +151,22 @@ def main():
sys.exit(0)
object_needed = get_object_needed()
- ( library2soname, soname2library ) = get_library()
+ ( library2soname, soname2library ) = get_libraries()
soname_needed = get_soname_needed( object_needed, library2soname )
- soname_linkings = get_soname_linkings( soname_needed, soname2library )
- # After the appending in get_soname_linkings, forward_needed has
- # been extended through the entire chain of linking.:w
+ # After the appending to needed in get_soname_linkings(), forward_needed
+ # and soname_needed have been extended through the entire chain of linking.
+ # If we want to keep only the object_needed and soname_needed, then do
+ # a copy before calling get_soname_linkings().
+ get_soname_linkings( soname_needed, soname2library )
+
object_linkings = object_needed
+ object_needed = None
+ soname_linkings = soname_needed
+ soname_needed = None
+
+ object_reverse_linkings = get_object_reverse_linkings( object_linkings )
""" Print out all ELF objects and their PaX flags
for elf in object_needed:
@@ -170,7 +188,7 @@ def main():
"""
- """ Print out all ELF objects and the NEEDED sonames and full library paths """
+ """ Print out all ELF objects and the NEEDED sonames and full library paths
for elf in object_needed:
sonames = object_needed[elf]
print("%s" % elf)
@@ -180,6 +198,7 @@ def main():
except KeyError:
print("\t%s\t=> ****" % soname)
print("\n\n")
+ """
""" Print out all the soname to soname NEEDED
for soname in soname_needed:
next reply other threads:[~2012-12-24 11:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-24 10:59 Anthony G. Basile [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-12-29 1:29 [gentoo-commits] proj/elfix:elfix-0.7.x commit in: misc/ Anthony G. Basile
2012-12-29 1:16 Anthony G. Basile
2012-12-29 1:16 Anthony G. Basile
2012-12-29 1:16 Anthony G. Basile
2012-12-29 1:16 Anthony G. Basile
2012-12-29 1:16 Anthony G. Basile
2012-12-29 1:16 Anthony G. Basile
2012-12-29 1:16 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 Anthony G. Basile
2012-12-24 10:59 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=1356346677.9e550cd560524ded70d854f38f2118d236be4061.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