Skip to content

Commit 7157f82

Browse files
committed
a2lib uses dumpbin instead of nm
1 parent 3562768 commit 7157f82

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

a2lib.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@
1111
from subprocess import Popen, PIPE
1212

1313
def gen(dll,lib,d):
14-
output = Popen(["nm", lib], stdout=PIPE).communicate()[0]
14+
output = Popen(["dumpbin", "-exports", dll], stdout=PIPE).communicate()[0]
1515
with open(d, "wb") as f:
1616
f.write(b"EXPORTS\n")
17-
for line in output.split(b"\r\n"):
18-
if (re.match(b".* T _|.* I __nm", line)): #|.* I __imp
19-
line = re.sub(b"^.* T _|^.* I __nm__", b"", line) #|^.* I _
20-
# msvcrt.dll on windows misses secure versions of common CRT functions
21-
if not ("msvcrt.dll" == dll and line.endswith(b"_s")):
22-
f.write(line + b"\n")
17+
lines = output.splitlines()
18+
for line in lines[19:]:
19+
if line != "" and line[0] == " ":
20+
cols = line.split()
21+
if len(cols)==4 and cols[0].isdigit():
22+
# msvcrt.dll on windows misses secure versions of common CRT functions
23+
if not ("msvcrt.dll" == dll and cols[3].endswith(b"_s")):
24+
f.write(cols[3] + b"\n")
2325
f.write(str.encode("LIBRARY %s\n" % dll))
2426

2527
def walk(root):
@@ -34,7 +36,7 @@ def walk(root):
3436
if not os.path.exists(d):
3537
print("Working on %s to produce %s\n" % (f, d))
3638
lib = "lib%s.dll.a" % name
37-
gen(f, lib, d)
39+
gen(join(root, f), lib, d)
3840
Popen(["lib", "/def:%s" % d, "/name:%s" % f]).communicate()
3941

4042
def get_parser():

0 commit comments

Comments
 (0)