Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/utils/extract_symbols.py
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | for line in process.stdout: | ||||
# so the last field is optional. There's no space after the value field, | # so the last field is optional. There's no space after the value field, | ||||
# but \s+ match newline also, so \s+\S* will match the optional size field. | # but \s+ match newline also, so \s+\S* will match the optional size field. | ||||
match = re.match("^(\S+)\s+[BDGRSTVW]\s+\S+\s+\S*$", line) | match = re.match("^(\S+)\s+[BDGRSTVW]\s+\S+\s+\S*$", line) | ||||
if match: | if match: | ||||
yield match.group(1) | yield match.group(1) | ||||
process.wait() | process.wait() | ||||
def readobj_get_symbols(lib): | def readobj_get_symbols(lib): | ||||
process = subprocess.Popen(['llvm-readobj','-symbols',lib], bufsize=1, | process = subprocess.Popen(['llvm-readobj','--symbols',lib], bufsize=1, | ||||
stdout=subprocess.PIPE, stdin=subprocess.PIPE, | stdout=subprocess.PIPE, stdin=subprocess.PIPE, | ||||
universal_newlines=True) | universal_newlines=True) | ||||
process.stdin.close() | process.stdin.close() | ||||
for line in process.stdout: | for line in process.stdout: | ||||
# When looking through the output of llvm-readobj we expect to see Name, | # When looking through the output of llvm-readobj we expect to see Name, | ||||
# Section, then StorageClass, so record Name and Section when we see | # Section, then StorageClass, so record Name and Section when we see | ||||
# them and decide if this is a defined external symbol when we see | # them and decide if this is a defined external symbol when we see | ||||
# StorageClass. | # StorageClass. | ||||
Show All 37 Lines | output = subprocess.check_output(['objdump','-f',lib], | ||||
universal_newlines=True) | universal_newlines=True) | ||||
for line in output: | for line in output: | ||||
match = re.match('.+file format (\S+)', line) | match = re.match('.+file format (\S+)', line) | ||||
if match: | if match: | ||||
return (match.group(1) == 'pe-i386') | return (match.group(1) == 'pe-i386') | ||||
return False | return False | ||||
def readobj_is_32bit_windows(lib): | def readobj_is_32bit_windows(lib): | ||||
output = subprocess.check_output(['llvm-readobj','-file-headers',lib], | output = subprocess.check_output(['llvm-readobj','--file-header',lib], | ||||
universal_newlines=True) | universal_newlines=True) | ||||
for line in output: | for line in output: | ||||
match = re.match('Format: (\S+)', line) | match = re.match('Format: (\S+)', line) | ||||
if match: | if match: | ||||
return (match.group(1) == 'COFF-i386') | return (match.group(1) == 'COFF-i386') | ||||
return False | return False | ||||
# On AIX, there isn't an easy way to detect 32-bit windows objects with the system toolchain, | # On AIX, there isn't an easy way to detect 32-bit windows objects with the system toolchain, | ||||
▲ Show 20 Lines • Show All 390 Lines • Show Last 20 Lines |