[llvm] fe82d3a - [dsymutil] Don't emit N_AST symbol entries in the Mach-O companion file
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 08:42:26 PDT 2020
Author: Jonas Devlieghere
Date: 2020-06-05T08:42:18-07:00
New Revision: fe82d3a3ae32843069349eace204593520403964
URL: https://github.com/llvm/llvm-project/commit/fe82d3a3ae32843069349eace204593520403964
DIFF: https://github.com/llvm/llvm-project/commit/fe82d3a3ae32843069349eace204593520403964.diff
LOG: [dsymutil] Don't emit N_AST symbol entries in the Mach-O companion file
Treat N_AST symbol table entries like other debug entries and don't emit
them in the linked binary.
Differential revision: https://reviews.llvm.org/D81205
Added:
Modified:
llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
llvm/tools/dsymutil/MachOUtils.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test b/llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
index 55fe2c314a6a..0ba86800f7bd 100644
--- a/llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
+++ b/llvm/test/tools/dsymutil/X86/swift-ast-x86_64.test
@@ -18,3 +18,6 @@ READOBJ-NEXT: |.|
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
diff --git a/llvm/tools/dsymutil/MachOUtils.cpp b/llvm/tools/dsymutil/MachOUtils.cpp
index 3f736115d7f5..0f38525e45c2 100644
--- a/llvm/tools/dsymutil/MachOUtils.cpp
+++ b/llvm/tools/dsymutil/MachOUtils.cpp
@@ -163,7 +163,15 @@ static bool transferSymbol(NListTy NList, bool IsLittleEndian,
if ((NList.n_type & MachO::N_TYPE) == MachO::N_UNDF)
return false;
+ // Do not transfer N_AST symbols as their content is copied into a section of
+ // the Mach-O companion file.
+ if (NList.n_type == MachO::N_AST)
+ return false;
+
StringRef Name = StringRef(Strings.begin() + NList.n_strx);
+
+ // An N_SO with a filename opens a debugging scope and another one without a
+ // name closes it. Don't transfer anything in the debugging scope.
if (InDebugNote) {
InDebugNote =
(NList.n_type != MachO::N_SO) || (!Name.empty() && Name[0] != '\0');
More information about the llvm-commits
mailing list