aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCObjectFileInfo.cpp
diff options
context:
space:
mode:
authorShubham Sandeep Rastogi <srastogi22@apple.com>2021-11-17 15:05:58 -0800
committerShubham Sandeep Rastogi <srastogi22@apple.com>2022-01-26 14:14:17 -0800
commit50f50f2582993a079dbcfb8e7ba48920f41e6be0 (patch)
treeca4fa5c16636ad28f7dc341d4bd990fef73e10b5 /llvm/lib/MC/MCObjectFileInfo.cpp
parenta5257ae277732261dc3b9de210b8d49cca2cf021 (diff)
downloadllvm-50f50f2582993a079dbcfb8e7ba48920f41e6be0.zip
llvm-50f50f2582993a079dbcfb8e7ba48920f41e6be0.tar.gz
llvm-50f50f2582993a079dbcfb8e7ba48920f41e6be0.tar.bz2
Emit swift5 reflection section data in dsym bundle generated by dsymutil in the Dwarf section.
Add support for Swift reflection metadata to dsymutil. This patch adds support for copying Swift reflection metadata (__swift5_.* sections) from .o files to into the symbol-rich binary in the output .dSYM. The functionality is automatically enabled only if a .o file has reflection metadata sections and the binary doesn't. When copying dsymutil moves the section from the __TEXT segment to the __DWARF segment. rdar://76973336 Differential Revision: https://reviews.llvm.org/D115007
Diffstat (limited to 'llvm/lib/MC/MCObjectFileInfo.cpp')
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index d7f85f7..77b0b0e 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -299,6 +299,17 @@ void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) {
RemarksSection = Ctx->getMachOSection(
"__LLVM", "__remarks", MachO::S_ATTR_DEBUG, SectionKind::getMetadata());
+ // The architecture of dsymutil makes it very difficult to copy the Swift
+ // reflection metadata sections into the __TEXT segment, so dsymutil creates
+ // these sections in the __DWARF segment instead.
+ if (!Ctx->getSwift5ReflectionSegmentName().empty()) {
+#define HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF) \
+ Swift5ReflectionSections[llvm::swift::Swift5ReflectionSectionKind::KIND] = \
+ Ctx->getMachOSection(Ctx->getSwift5ReflectionSegmentName().data(), \
+ MACHO, 0, SectionKind::getMetadata());
+#include "llvm/BinaryFormat/Swift.def"
+ }
+
TLSExtraDataSection = TLSTLVSection;
}