1 |
commit: a74b692444927eb366c1d057204a124b38af5143 |
2 |
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Dec 26 21:43:20 2012 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Dec 26 21:43:20 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=a74b6924 |
7 |
|
8 |
misc/link_map.py: place class in its own module |
9 |
|
10 |
--- |
11 |
misc/{link_maps => link_map.py} | 61 +++++++++++---------------------------- |
12 |
misc/link_map_test | 61 +++++++++++++++++++++++++++++++++++++++ |
13 |
2 files changed, 78 insertions(+), 44 deletions(-) |
14 |
|
15 |
diff --git a/misc/link_maps b/misc/link_map.py |
16 |
similarity index 83% |
17 |
rename from misc/link_maps |
18 |
rename to misc/link_map.py |
19 |
index 508af24..5b0e822 100755 |
20 |
--- a/misc/link_maps |
21 |
+++ b/misc/link_map.py |
22 |
@@ -1,12 +1,24 @@ |
23 |
#!/usr/bin/env python |
24 |
+# |
25 |
+# LinkMap.py: this file is part of the elfix package |
26 |
+# Copyright (C) 2011 Anthony G. Basile |
27 |
+# |
28 |
+# This program is free software: you can redistribute it and/or modify |
29 |
+# it under the terms of the GNU General Public License as published by |
30 |
+# the Free Software Foundation, either version 3 of the License, or |
31 |
+# (at your option) any later version. |
32 |
+# |
33 |
+# This program is distributed in the hope that it will be useful, |
34 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of |
35 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
36 |
+# GNU General Public License for more details. |
37 |
+# |
38 |
+# You should have received a copy of the GNU General Public License |
39 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>. |
40 |
|
41 |
-import os |
42 |
-import sys |
43 |
import re |
44 |
-import pax |
45 |
import portage |
46 |
|
47 |
- |
48 |
class LinkMap: |
49 |
|
50 |
def __init__(self): |
51 |
@@ -22,6 +34,7 @@ class LinkMap: |
52 |
|
53 |
See /usr/lib/portage/bin/misc-functions.sh ~line 520 |
54 |
""" |
55 |
+ |
56 |
vardb = portage.db[portage.root]["vartree"].dbapi |
57 |
|
58 |
self.pkgs = [] |
59 |
@@ -183,43 +196,3 @@ class LinkMap: |
60 |
|
61 |
return ( object_linkings, object_reverse_linkings, library2soname, soname2library ) |
62 |
|
63 |
- |
64 |
-def main(): |
65 |
- |
66 |
- # Run as root to be able to real all files |
67 |
- uid = os.getuid() |
68 |
- if uid != 0: |
69 |
- print('RUN AS ROOT: cannot read all flags') |
70 |
- sys.exit(0) |
71 |
- |
72 |
- link_maps = LinkMap() |
73 |
- ( object_linkings, object_reverse_linkings, library2soname, soname2library ) = link_maps.get_maps() |
74 |
- |
75 |
- layout = "{0:<30} => {1:<30}" |
76 |
- |
77 |
- #Print out all ELF objects and the NEEDED sonames and full library paths |
78 |
- for abi in object_linkings: |
79 |
- for elf in object_linkings[abi]: |
80 |
- sonames = object_linkings[abi][elf] |
81 |
- print('%s: %s' % (abi,elf)) |
82 |
- for soname in sorted(object_linkings[abi][elf]): |
83 |
- try: |
84 |
- print('\t%s' % layout.format(soname, soname2library[(soname,abi)])) |
85 |
- except KeyError: |
86 |
- print('\t%s' % layout.format(soname, '***' )) |
87 |
- print('') |
88 |
- |
89 |
- # Print out all ELF objects and the NEEDED sonames and full library paths |
90 |
- for abi in object_linkings: |
91 |
- for soname in object_reverse_linkings[abi]: |
92 |
- try: |
93 |
- print('%s: %s' % (abi, layout.format(soname, soname2library[(soname,abi)]))) |
94 |
- except KeyError: |
95 |
- print('%s: %s' % (abi, layout.format(soname, '***' ))) |
96 |
- for elf in sorted(object_reverse_linkings[abi][soname]): |
97 |
- print('\t%s' % elf) |
98 |
- print('') |
99 |
- |
100 |
- |
101 |
-if __name__ == '__main__': |
102 |
- main() |
103 |
|
104 |
diff --git a/misc/link_map_test b/misc/link_map_test |
105 |
new file mode 100755 |
106 |
index 0000000..9a1af8e |
107 |
--- /dev/null |
108 |
+++ b/misc/link_map_test |
109 |
@@ -0,0 +1,61 @@ |
110 |
+#!/usr/bin/env python |
111 |
+# |
112 |
+# link_map_test: this file is part of the elfix package |
113 |
+# Copyright (C) 2011 Anthony G. Basile |
114 |
+# |
115 |
+# This program is free software: you can redistribute it and/or modify |
116 |
+# it under the terms of the GNU General Public License as published by |
117 |
+# the Free Software Foundation, either version 3 of the License, or |
118 |
+# (at your option) any later version. |
119 |
+# |
120 |
+# This program is distributed in the hope that it will be useful, |
121 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of |
122 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
123 |
+# GNU General Public License for more details. |
124 |
+# |
125 |
+# You should have received a copy of the GNU General Public License |
126 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>. |
127 |
+ |
128 |
+import os |
129 |
+import sys |
130 |
+from link_map import LinkMap |
131 |
+ |
132 |
+def main(): |
133 |
+ |
134 |
+ # Run as root to be able to real all files |
135 |
+ uid = os.getuid() |
136 |
+ if uid != 0: |
137 |
+ print('RUN AS ROOT: cannot read all flags') |
138 |
+ sys.exit(0) |
139 |
+ |
140 |
+ link_map = LinkMap() |
141 |
+ ( object_linkings, object_reverse_linkings, library2soname, soname2library ) = link_map.get_maps() |
142 |
+ |
143 |
+ layout = "{0:<30} => {1:<30}" |
144 |
+ |
145 |
+ #Print out all ELF objects and the NEEDED sonames and full library paths |
146 |
+ for abi in object_linkings: |
147 |
+ for elf in object_linkings[abi]: |
148 |
+ sonames = object_linkings[abi][elf] |
149 |
+ print('%s: %s' % (abi,elf)) |
150 |
+ for soname in sorted(object_linkings[abi][elf]): |
151 |
+ try: |
152 |
+ print('\t%s' % layout.format(soname, soname2library[(soname,abi)])) |
153 |
+ except KeyError: |
154 |
+ print('\t%s' % layout.format(soname, '***' )) |
155 |
+ print('') |
156 |
+ |
157 |
+ # Print out all ELF objects and the NEEDED sonames and full library paths |
158 |
+ for abi in object_linkings: |
159 |
+ for soname in object_reverse_linkings[abi]: |
160 |
+ try: |
161 |
+ print('%s: %s' % (abi, layout.format(soname, soname2library[(soname,abi)]))) |
162 |
+ except KeyError: |
163 |
+ print('%s: %s' % (abi, layout.format(soname, '***' ))) |
164 |
+ for elf in sorted(object_reverse_linkings[abi][soname]): |
165 |
+ print('\t%s' % elf) |
166 |
+ print('') |
167 |
+ |
168 |
+ |
169 |
+if __name__ == '__main__': |
170 |
+ main() |