[PATCH] D81205: [dsymutil] Don't emit N_AST symbol entries in the Mach-O companion file

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 17:09:21 PDT 2020


JDevlieghere created this revision.
JDevlieghere added reviewers: aprantl, friss.
Herald added a project: LLVM.
JDevlieghere marked an inline comment as done.
JDevlieghere added inline comments.


================
Comment at: llvm/tools/dsymutil/MachOUtils.cpp:167
+  // Do not transfer AST or OSO symbols as they're only needed by dsymutil.
+  if (NList.n_type == MachO::N_AST || NList.n_type == MachO::N_OSO)
+    return false;
----------------
Previously the code below would filter out `N_OSO` entries, relying on the fact that `N_OSO` entries come after `N_SO` entries. That means that technically the `N_OSO` could be omitted here, but I think this is much clearer. 


Treat N_AST symbol table entries like N_OSO entries and don't emit them in the linked binary.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81205

Files:
  llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
  llvm/tools/dsymutil/MachOUtils.cpp


Index: llvm/tools/dsymutil/MachOUtils.cpp
===================================================================
--- llvm/tools/dsymutil/MachOUtils.cpp
+++ llvm/tools/dsymutil/MachOUtils.cpp
@@ -163,6 +163,10 @@
   if ((NList.n_type & MachO::N_TYPE) == MachO::N_UNDF)
     return false;
 
+  // Do not transfer AST or OSO symbols as they're only needed by dsymutil.
+  if (NList.n_type == MachO::N_AST || NList.n_type == MachO::N_OSO)
+    return false;
+
   StringRef Name = StringRef(Strings.begin() + NList.n_strx);
   if (InDebugNote) {
     InDebugNote =
Index: llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
===================================================================
--- llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
+++ llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
@@ -18,3 +18,6 @@
 
 RUN: dsymutil -oso-prepend-path %p/.. %p/../Inputs/swift-ast.macho.x86_64 -no-output -verbose 2>&1 | FileCheck %s --check-prefix=TIMESTAMP
 TIMESTAMP: warning: Timestamp mismatch
+
+RUN: dsymutil -s %T/swift-ast.dSYM/Contents/Resources/DWARF/swift-ast.macho.x86_64 | FileCheck %s --check-prefix=NAST
+NAST-NOT: N_AST


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81205.268625.patch
Type: text/x-patch
Size: 1131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200605/8b0531ed/attachment-0001.bin>


More information about the llvm-commits mailing list