Lines 11-16
Link Here
|
11 |
""" |
11 |
""" |
12 |
|
12 |
|
13 |
import argparse |
13 |
import argparse |
|
|
14 |
import io |
14 |
import os |
15 |
import os |
15 |
import subprocess |
16 |
import subprocess |
16 |
import sys |
17 |
import sys |
Lines 18-29
Link Here
|
18 |
import wrapper_utils |
19 |
import wrapper_utils |
19 |
|
20 |
|
20 |
|
21 |
|
|
|
22 |
def read_as_utf8(fileno): |
23 |
fp = io.open(fileno, mode="r", encoding="utf-8", closefd=False) |
24 |
content = fp.read() |
25 |
fp.close() |
26 |
return content |
27 |
|
21 |
def CollectSONAME(args): |
28 |
def CollectSONAME(args): |
22 |
"""Replaces: readelf -d $sofile | grep SONAME""" |
29 |
"""Replaces: readelf -d $sofile | grep SONAME""" |
23 |
toc = '' |
30 |
toc = '' |
24 |
readelf = subprocess.Popen(wrapper_utils.CommandToRun( |
31 |
readelf = subprocess.Popen(wrapper_utils.CommandToRun( |
25 |
[args.readelf, '-d', args.sofile]), stdout=subprocess.PIPE, bufsize=-1) |
32 |
[args.readelf, '-d', args.sofile]), stdout=subprocess.PIPE, bufsize=-1) |
26 |
for line in readelf.stdout: |
33 |
for line in read_as_utf8(readelf.stdout.fileno()): |
27 |
if 'SONAME' in line: |
34 |
if 'SONAME' in line: |
28 |
toc += line |
35 |
toc += line |
29 |
return readelf.wait(), toc |
36 |
return readelf.wait(), toc |
Lines 35-41
Link Here
|
35 |
nm = subprocess.Popen(wrapper_utils.CommandToRun([ |
42 |
nm = subprocess.Popen(wrapper_utils.CommandToRun([ |
36 |
args.nm, '--format=posix', '-g', '-D', args.sofile]), |
43 |
args.nm, '--format=posix', '-g', '-D', args.sofile]), |
37 |
stdout=subprocess.PIPE, bufsize=-1) |
44 |
stdout=subprocess.PIPE, bufsize=-1) |
38 |
for line in nm.stdout: |
45 |
for line in read_as_utf8(nm.stdout.fileno()): |
39 |
toc += ' '.join(line.split(' ', 2)[:2]) + '\n' |
46 |
toc += ' '.join(line.split(' ', 2)[:2]) + '\n' |
40 |
return nm.wait(), toc |
47 |
return nm.wait(), toc |
41 |
|
48 |
|