-
Notifications
You must be signed in to change notification settings - Fork 0
/
dupsymbols.py
62 lines (48 loc) · 1.29 KB
/
dupsymbols.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
'''
dupsymbols a1
内部可能有符号冲突,关闭Strip Dead Code选项后会出现编译器错误
'''
import sys
import os
from pathlib import Path
import shutil
import subprocess as sp
import re
a1 = sys.argv[1]
class file(object):
def __init__(self, a):
self.symbol = set()
self.name = a
def add(self, sym):
self.symbol.add(sym)
def test(self, file):
comm = (file.symbol & self.symbol)
if len(comm) > 0:
print(file.name, "<->", self.name)
for n in comm:
print(n)
pass
def ar_symbol(path):
proc = sp.Popen(['nm', '-g', '-arch', 'arm64', path], stdout=sp.PIPE,
stderr=sp.DEVNULL, universal_newlines=True)
files = []
for line in proc.stdout:
m = re.search('(?<=\\().+(?=\\))', line)
if m:
afile = file(m.group())
files.append(afile)
continue
m = re.search('(?<=[TD] ).*', line)
if m:
if afile != None:
afile.add(m.group())
return files
def run(path):
files = ar_symbol(path)
print(files)
for i in range(len(files)-1):
for j in range(i+1, len(files)):
files[i].test(files[j])
run(a1)