/ tools / i386-map
i386-map
 1  #!/usr/bin/env python
 2  
 3  import fileinput
 4  import subprocess
 5  import sys, os
 6  
 7  devnull = open(os.devnull, 'wb') 
 8  
 9  for line in fileinput.input():
10      line = line.rstrip()
11      orig_line = line
12      fixed = False
13  
14      while True:
15          proc = subprocess.Popen("readelf -Ws /home/lubos/Projects/darling-root/lib32/darling/libstdcxx.so | grep " + line + "@@", shell=True, stdout=devnull, stderr=devnull)
16          proc.wait()
17  
18          if proc.returncode != 0:
19              pos = line.rfind('m')
20              if pos == -1:
21                  break
22              ll = list(line)
23              ll[pos] = 'j'
24              line = "".join(ll)
25          else:
26              fixed = True
27              break
28  
29      if fixed:
30          print orig_line + ' = ' + line + ';'
31      else:
32          sys.stderr.write('Cannot fix ' + orig_line + '\n')
33  
34