def parse_ldd_output(output):
 expr_linux = re.compile('\\s(?P<lib>\\S?/\\S+)\\s+\\((?P<addr>0x.+)\\)')
 expr_openbsd = re.compile('^\\s+(?P<addr>[0-9a-f]+)\\s+[0-9a-f]+\\s+\\S+\\s+[01]\\s+[0-9]+\\s+[0-9]+\\s+(?P<lib>\\S+)$')
 libs = {}
 for s in output.split('\n'):
  match = (expr_linux.search(s) or expr_openbsd.search(s))
  if (not match):
   continue
  (lib, addr) = (match.group('lib'), match.group('addr'))
  libs[lib] = int(addr, 16)
 return libs

def parse_ldd_output ( output ) : expr_linux = re . compile ( '\\s(?P<lib>\\S?/\\S+)\\s+\\((?P<addr>0x.+)\\)' ) expr_openbsd = re . compile ( '^\\s+(?P<addr>[0-9a-f]+)\\s+[0-9a-f]+\\s+\\S+\\s+[01]\\s+[0-9]+\\s+[0-9]+\\s+(?P<lib>\\S+)$' ) libs = { } for s in output . split ( '\n' ) : match = ( expr_linux . search ( s ) or expr_openbsd . search ( s ) ) if ( not match ) : continue ( lib , addr ) = ( match . group ( 'lib' ) , match . group ( 'addr' ) ) libs [ lib ] = int ( addr , 16 ) return libs
parses the output from a run of ldd on a binary .