File: nmutil.py

package info (click to toggle)
liquid-dsp 1.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,216 kB
  • sloc: ansic: 115,859; sh: 3,513; makefile: 1,350; python: 274; asm: 11
file content (34 lines) | stat: -rwxr-xr-x 1,128 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
34
#!/usr/bin/env python3
'''Compare symbols within two object (or archive) files'''
import argparse, subprocess

#lib_old = '/usr/local/lib/libliquid.ar'
lib_old = '../liquid-dsp-1.3.2/libliquid.ar'
lib_new = 'libliquid.ar'
opts = '-A'

def nmparse(lib,opts='-A',filt='T'):
    '''run command-line 'nm' program and parse results, filtering out unwanted symbols'''
    out = subprocess.check_output(['nm',opts,lib]).decode('utf-8').split('\n')[:-1]
    out = filter(lambda v: v.split()[-2] in filt, out)
    return set(v.split()[-1] for v in out)

syms_old = nmparse(lib_old)
syms_new = nmparse(lib_new)

# compute removed & added symbols
syms_removed = syms_old.difference(syms_new)
syms_added   = syms_new.difference(syms_old)

# print basic report
print('%32s [old] : %u symbols' % (lib_old,  len(syms_old)))
print('%32s [new] : %u symbols' % (lib_new,  len(syms_new)))
print('      %32s : %u symbols' % ('removed',len(syms_removed)))
print('      %32s : %u symbols' % ('added',  len(syms_added)))

#print('removed:', syms_removed)
#print('added:', syms_added)

print('removed:')
for s in sorted(syms_removed):
    print(' ',s)