[llvm] e5d9146 - [extract_symbols.py] Be more permissive when examining nm output

John Brawn via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 11:48:30 PST 2023


Author: John Brawn
Date: 2023-02-13T19:47:54Z
New Revision: e5d914672233cd055cda564eee2803a0a1c78c36

URL: https://github.com/llvm/llvm-project/commit/e5d914672233cd055cda564eee2803a0a1c78c36
DIFF: https://github.com/llvm/llvm-project/commit/e5d914672233cd055cda564eee2803a0a1c78c36.diff

LOG: [extract_symbols.py] Be more permissive when examining nm output

The regex which checks for undefined symbols in the nm output was
written assuming GNU nm, but other versions of nm (e.g. llvm-nm) have
slightly different output. Make the regex more permissive to account
for this.

Added: 
    

Modified: 
    llvm/utils/extract_symbols.py

Removed: 
    


################################################################################
diff  --git a/llvm/utils/extract_symbols.py b/llvm/utils/extract_symbols.py
index 1d057cd3a51a5..2bd71e3afbf00 100755
--- a/llvm/utils/extract_symbols.py
+++ b/llvm/utils/extract_symbols.py
@@ -62,8 +62,9 @@ def nm_get_symbols(lib):
         match = re.match("^(\S+)\s+[^AU]\s+\S+\s+\S*$", line)
         if match:
             yield (match.group(1), True)
-        # Look for undefined symbols, which have only name and type (which is U).
-        match = re.match("^(\S+)\s+U\s+$", line)
+        # Look for undefined symbols, which have type U and may or may not
+        # (depending on which nm is being used) have value and size.
+        match = re.match("^(\S+)\s+U\s+(\S+\s+\S*)?$", line)
         if match:
             yield (match.group(1), False)
     process.wait()


        


More information about the llvm-commits mailing list