diff --git a/llvm/utils/extract_symbols.py b/llvm/utils/extract_symbols.py index 43f603963a205..6f01cd12fcd81 100755 --- a/llvm/utils/extract_symbols.py +++ b/llvm/utils/extract_symbols.py @@ -53,7 +53,12 @@ def nm_get_symbols(lib): process.stdin.close() for line in process.stdout: # Look for external symbols that are defined in some section - match = re.match("^(\S+)\s+[BDGRSTVW]\s+\S+\s+\S+$", line) + # The POSIX format is: + # name type value size + # The -P flag displays the size field for symbols only when applicable, + # 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. + match = re.match("^(\S+)\s+[BDGRSTVW]\s+\S+\s+\S*$", line) if match: yield match.group(1) process.wait()