[extract_symbols.py] Adjust how the output of nm is interpreted
authorJohn Brawn <john.brawn@arm.com>
Fri, 10 Feb 2023 14:51:54 +0000 (14:51 +0000)
committerJohn Brawn <john.brawn@arm.com>
Fri, 10 Feb 2023 15:55:45 +0000 (15:55 +0000)
When looking for defined symbols, look for symbols that aren't of a
type that we don't want, instead of having specific list of symbol
types that we do want. This fixes a problem where (when using GNU
nm at least) there were some symbol types that we want to export but
which weren't in the list.

llvm/utils/extract_symbols.py

index f64e3d1..7270f59 100755 (executable)
@@ -52,13 +52,14 @@ def nm_get_symbols(lib):
                                    universal_newlines=True)
     process.stdin.close()
     for line in process.stdout:
-        # Look for external symbols that are defined in some section
+        # Look for external symbols that are defined in some section, i.e.
+        # symbols that aren't absolute, local, or undefined.
         # 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)
+        match = re.match("^(\S+)\s+[^AabdtU]\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).