Back to index

enigmail  1.4.3
Public Member Functions | Public Attributes | Static Private Member Functions
expandlibs_exec.SectionFinder Class Reference

List of all members.

Public Member Functions

def __init__
def getSections

Public Attributes

 mapping

Static Private Member Functions

def _normalize
def _getSymbols

Detailed Description

Instances of this class allow to map symbol names to sections in
object files.

Definition at line 245 of file expandlibs_exec.py.


Constructor & Destructor Documentation

def expandlibs_exec.SectionFinder.__init__ (   self,
  objs 
)
Creates an instance, given a list of object files.

Definition at line 249 of file expandlibs_exec.py.

00249 
00250     def __init__(self, objs):
00251         '''Creates an instance, given a list of object files.'''
00252         if not conf.EXPAND_LIBS_ORDER_STYLE in ['linkerscript', 'section-ordering-file']:
00253             raise Exception('EXPAND_LIBS_ORDER_STYLE "%s" is not supported' % conf.EXPAND_LIBS_ORDER_STYLE)
00254         self.mapping = {}
00255         for obj in objs:
00256             if not isObject(obj) and os.path.splitext(obj)[1] != conf.LIB_SUFFIX:
00257                 raise Exception('%s is not an object nor a static library' % obj)
00258             for symbol, section in SectionFinder._getSymbols(obj):
00259                 sym = SectionFinder._normalize(symbol)
00260                 if sym in self.mapping:
00261                     if not section in self.mapping[sym]:
00262                         self.mapping[sym].append(section)
00263                 else:
00264                     self.mapping[sym] = [section]


Member Function Documentation

def expandlibs_exec.SectionFinder._getSymbols (   obj) [static, private]
Returns a list of (symbol, section) contained in the given object
file.

Definition at line 284 of file expandlibs_exec.py.

00284 
00285     def _getSymbols(obj):
00286         '''Returns a list of (symbol, section) contained in the given object
00287         file.'''
00288         proc = subprocess.Popen(['objdump', '-t', obj], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
00289         (stdout, stderr) = proc.communicate()
00290         syms = []
00291         for line in stdout.splitlines():
00292             # Each line has the following format:
00293             # <addr> [lgu!][w ][C ][W ][Ii ][dD ][FfO ] <section>\t<length> <symbol>
00294             tmp = line.split(' ',1)
00295             # This gives us ["<addr>", "[lgu!][w ][C ][W ][Ii ][dD ][FfO ] <section>\t<length> <symbol>"]
00296             # We only need to consider cases where "<section>\t<length> <symbol>" is present,
00297             # and where the [FfO] flag is either F (function) or O (object).
00298             if len(tmp) > 1 and len(tmp[1]) > 6 and tmp[1][6] in ['O', 'F']:
00299                 tmp = tmp[1][8:].split()
00300                 # That gives us ["<section>","<length>", "<symbol>"]
00301                 syms.append((tmp[-1], tmp[0]))
00302         return syms

def expandlibs_exec.SectionFinder._normalize (   symbol) [static, private]
For normal symbols, return the given symbol. For thunks, return
the corresponding normal symbol.

Definition at line 276 of file expandlibs_exec.py.

00276 
00277     def _normalize(symbol):
00278         '''For normal symbols, return the given symbol. For thunks, return
00279         the corresponding normal symbol.'''
00280         if re.match('^_ZThn[0-9]+_', symbol):
00281             return re.sub('^_ZThn[0-9]+_', '_Z', symbol)
00282         return symbol

def expandlibs_exec.SectionFinder.getSections (   self,
  symbol 
)
Given a symbol, returns a list of sections containing it or the
corresponding thunks. When the given symbol is a thunk, returns the
list of sections containing its corresponding normal symbol and the
other thunks for that symbol.

Definition at line 265 of file expandlibs_exec.py.

00265 
00266     def getSections(self, symbol):
00267         '''Given a symbol, returns a list of sections containing it or the
00268         corresponding thunks. When the given symbol is a thunk, returns the
00269         list of sections containing its corresponding normal symbol and the
00270         other thunks for that symbol.'''
00271         sym = SectionFinder._normalize(symbol)
00272         if sym in self.mapping:
00273             return self.mapping[sym]
00274         return []


Member Data Documentation

Definition at line 253 of file expandlibs_exec.py.


The documentation for this class was generated from the following file: