[libcxx-commits] [libcxx] 0de9fd1 - [libc++] accept ELF Tool Chain readelf format in tooling

Ed Maste via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 20 06:41:20 PST 2022


Author: Ed Maste
Date: 2022-12-20T09:39:24-05:00
New Revision: 0de9fd1c2790504487b3dbed38a6ff712249fa65

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

LOG: [libc++] accept ELF Tool Chain readelf format in tooling

ELF Tool Chain provides alternatives to most GNU binutils tools,
including readelf.  These tools are currently used by FreeBSD.

ELF Tool Chain's readelf currently emits headings for symbol table
information in a slightly different format compared to GNU or LLVM
readelf.  Accept both formats.

Reviewed by: philnik
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D140313

Added: 
    

Modified: 
    libcxx/utils/libcxx/sym_check/extract.py

Removed: 
    


################################################################################
diff  --git a/libcxx/utils/libcxx/sym_check/extract.py b/libcxx/utils/libcxx/sym_check/extract.py
index 33411e2ee165..c563720c7485 100644
--- a/libcxx/utils/libcxx/sym_check/extract.py
+++ b/libcxx/utils/libcxx/sym_check/extract.py
@@ -175,10 +175,16 @@ def get_dynsym_table(self, out):
         start = -1
         end = -1
         for i in range(len(lines)):
-            if lines[i].startswith("Symbol table '.dynsym'"):
+            # Accept both GNU and ELF Tool Chain readelf format.  Some versions
+            # of ELF Tool Chain readelf use ( ) around the symbol table name
+            # instead of ' ', and omit the blank line before the heading.
+            if re.match(r"Symbol table ['(].dynsym[')]", lines[i]):
                 start = i + 2
-            if start != -1 and end == -1 and not lines[i].strip():
-                end = i + 1
+            elif start != -1 and end == -1:
+                if not lines[i].strip():
+                    end = i + 1
+                if lines[i].startswith("Symbol table ("):
+                    end = i
         assert start != -1
         if end == -1:
             end = len(lines)


        


More information about the libcxx-commits mailing list