[csw-devel] SF.net SVN: gar:[19263] csw/mgar/gar/v2-yann/lib/python

chninkel at users.sourceforge.net chninkel at users.sourceforge.net
Sat Sep 22 00:52:12 CEST 2012


Revision: 19263
          http://gar.svn.sourceforge.net/gar/?rev=19263&view=rev
Author:   chninkel
Date:     2012-09-21 22:52:11 +0000 (Fri, 21 Sep 2012)
Log Message:
-----------
some simplification

Modified Paths:
--------------
    csw/mgar/gar/v2-yann/lib/python/dependency_checks.py
    csw/mgar/gar/v2-yann/lib/python/inspective_package.py

Modified: csw/mgar/gar/v2-yann/lib/python/dependency_checks.py
===================================================================
--- csw/mgar/gar/v2-yann/lib/python/dependency_checks.py	2012-09-21 13:58:33 UTC (rev 19262)
+++ csw/mgar/gar/v2-yann/lib/python/dependency_checks.py	2012-09-21 22:52:11 UTC (rev 19263)
@@ -190,7 +190,8 @@
     # bound to because that definitely means that -B direct or -z direct was used.
     directly_bound = set()
     for syminfo in pkg_data["binaries_elf_info"][binary_info["path"]]['symbol table']:
-      if syminfo['external'] and syminfo['flags'] and 'D' in syminfo['flags'] and 'B' in syminfo['flags']:
+      if (syminfo['shndx'] == 'UNDEF' and syminfo['flags']
+          and 'D' in syminfo['flags'] and 'B' in syminfo['flags']):
           directly_bound.add(syminfo['soname'])
     not_directly_bound = directly_bound.symmetric_difference(binary_info["needed sonames"])
 

Modified: csw/mgar/gar/v2-yann/lib/python/inspective_package.py
===================================================================
--- csw/mgar/gar/v2-yann/lib/python/inspective_package.py	2012-09-21 13:58:33 UTC (rev 19262)
+++ csw/mgar/gar/v2-yann/lib/python/inspective_package.py	2012-09-21 22:52:11 UTC (rev 19263)
@@ -268,12 +268,12 @@
       binary_info['syminfo'] = binary_info['symbol table']
 
       # The list of fields we want to retrieve in the elfdump output by section
-      # if the field is a tuple, it means we will map the original field name
+      # If the field is a tuple, it means we will map the original field name
       # to another name in the final data structure
       elf_fields = {'version definition': ['version', 'dependency'],
                     'version needed': [('file', 'soname'), 'version'],
                     'symbol table': [('name', 'symbol'), ('ver', 'version'),
-                                     'bind', ('shndx', 'external')],
+                                     'bind', 'shndx'],
                     'syminfo': [('library', 'soname'), 'symbol', 'flags']}
 
       cur_section = None
@@ -295,16 +295,10 @@
         # we merge symbol table and syminfo informations so we have to check
         # if the symbol has not already been added
         if cur_section in ('symbol table', 'syminfo'):
-          if not elf_info['symbol']:
-            continue
-          if elf_info['symbol'] in symbols:
-            symbols[elf_info['symbol']].update(elf_info)
-            continue
-          else:
-            symbols[elf_info['symbol']] = elf_info
+          symbols.setdefault(elf_info['symbol'], {}).update(elf_info)
+        else:
+          binary_info[cur_section].append(elf_info)
 
-        binary_info[cur_section].append(elf_info)
-
       # elfdump doesn't repeat the name of the soname in the version section
       # if it's the same on two contiguous line, so we have to make sure
       # the information is present in each entry
@@ -319,28 +313,8 @@
 
       # To not rely of the section order output of elfdump, we resolve symbol version
       # informations here after having parsed all elfdump output
-      nb_versions_definition = len(binary_info['version definition'])
-      for sym_info in binary_info['symbol table']:
-        version_index = int(sym_info['version']) - 2
-        if version_index > 1:
-          if version_index < nb_versions_definition:
-            version = binary_info['version definition'][version_index]
-          else:
-            version = binary_info['version needed'][version_index - nb_versions_definition]
-          sym_info['version'] = version['version']
-          sym_info['soname'] = version['soname']
-        else:
-          sym_info['version'] = None
+      binary_info['symbol table'] = self._ResolveSymbolsVersionInfo (symbols.values(), binary_info)
 
-        if sym_info['external'] == 'UNDEF':
-          sym_info['external'] = True
-        else:
-          sym_info['external'] = False
-
-        # we make sure the field are present even if the syminfo section is not
-        sym_info.setdefault('soname')
-        sym_info.setdefault('flags')
-
       binaries_elf_info[binary] = binary_info
 
     return binaries_elf_info
@@ -391,6 +365,24 @@
     sym = { 'address': fields[0], 'type': fields[1], 'name': fields[2] }
     return sym
 
+  def _ResolveSymbolsVersionInfo(self, symbols, binary_info):
+
+    version_info = binary_info['version definition'] + binary_info['version needed']
+
+    for sym_info in symbols:
+      version_index = int(sym_info['version']) - 2
+      if version_index > 1:
+        version = version_info[version_index]
+        sym_info['version'] = version['version']
+        sym_info['soname'] = version['soname']
+
+      # we make sure the field are present even if the syminfo section is not
+      sym_info.setdefault('version')
+      sym_info.setdefault('soname')
+      sym_info.setdefault('flags')
+
+    return symbols
+
   def _ParseElfdumpLine(self, line, section=None):
 
     headers_re = (
@@ -419,6 +411,7 @@
       'version needed': (r"""
         \s*(?:\[(?P<index>\d+)\]\s+)?     # index might be not present
                                           # if no version binding is enabled
+
         (?:(?P<file>\S+)\s+               # file can be absent if the same as
          (?!\[\s(?:INFO|WEAK)\s\]))?      # the previous line, we make sure
                                           # version is not confused with file

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list