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-21 13:22:40 -0800
commitd84d1135d80c1dead6564347943ba56eed5aac3b (patch)
tree34629f910521816b1fe21f4937ffc130f768a99b /llvm/lib/MC/MCObjectFileInfo.cpp
parent4f8ea3c84f3de6ddb754ad339c4672c7e3b7fc74 (diff)
downloadllvm-d84d1135d80c1dead6564347943ba56eed5aac3b.zip
llvm-d84d1135d80c1dead6564347943ba56eed5aac3b.tar.gz
llvm-d84d1135d80c1dead6564347943ba56eed5aac3b.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 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;
}