File: dump_symbols.py

package info (click to toggle)
python-ocp 7.8.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 64,724 kB
  • sloc: cpp: 362,337; pascal: 33; python: 23; makefile: 4
file content (33 lines) | stat: -rwxr-xr-x 731 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import lief
import sys

from logzero import logger

libs = sys.argv[-1].split(';')
name = {'win32' : 'win', 'darwin' : 'mac', 'linux' : 'linux'}[sys.platform]


exported_symbols = []

for lib in libs:

    logger.info(f'Analyzing {lib}')

    p = lief.parse(lib)

    if p is None:
        continue

    if name=='linux':
        for s in p.exported_symbols:
            exported_symbols.append(f'{s.name}\n')
    elif name=='mac':
        for s in p.symbols:
            if s.raw_type>1:
                exported_symbols.append(f'{s.name}\n')
    else:
        for s in p.exported_functions:
            exported_symbols.append(f'{s.name}\n')

with open(f'symbols_mangled_{name}.dat','w') as f:
    f.writelines(exported_symbols)