mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[swift-reflection-dump] Make ObjC interoperability configurable.
This addresses a FIXME in the code. This allows running swift-reflection-dump on macOS to dump the contents of an ELF binary.
This commit is contained in:
@@ -78,6 +78,12 @@ static llvm::cl::opt<std::string>
|
||||
Architecture("arch",
|
||||
llvm::cl::desc("Architecture to inspect in the binary"),
|
||||
llvm::cl::Required);
|
||||
|
||||
#if SWIFT_OBJC_INTEROP
|
||||
static llvm::cl::opt<bool> DisableObjCInterop(
|
||||
"no-objc-interop",
|
||||
llvm::cl::desc("Disable Objective-C interoperability support"));
|
||||
#endif
|
||||
} // end namespace options
|
||||
|
||||
static int doDumpReflectionSections(ArrayRef<std::string> BinaryFilenames,
|
||||
@@ -109,7 +115,12 @@ static int doDumpReflectionSections(ArrayRef<std::string> BinaryFilenames,
|
||||
ObjectFiles.push_back(O);
|
||||
}
|
||||
|
||||
auto context = makeReflectionContextForObjectFiles(ObjectFiles);
|
||||
#if SWIFT_OBJC_INTEROP
|
||||
bool ObjCInterop = !options::DisableObjCInterop;
|
||||
#else
|
||||
bool ObjCInterop = false;
|
||||
#endif
|
||||
auto context = makeReflectionContextForObjectFiles(ObjectFiles, ObjCInterop);
|
||||
auto &builder = context->Builder;
|
||||
|
||||
switch (Action) {
|
||||
@@ -117,17 +128,21 @@ static int doDumpReflectionSections(ArrayRef<std::string> BinaryFilenames,
|
||||
// Dump everything
|
||||
switch (context->PointerSize) {
|
||||
case 4:
|
||||
// FIXME: This could/should be configurable.
|
||||
#if SWIFT_OBJC_INTEROP
|
||||
builder.dumpAllSections<WithObjCInterop, 4>(stream);
|
||||
if (!options::DisableObjCInterop)
|
||||
builder.dumpAllSections<WithObjCInterop, 4>(stream);
|
||||
else
|
||||
builder.dumpAllSections<NoObjCInterop, 4>(stream);
|
||||
#else
|
||||
builder.dumpAllSections<NoObjCInterop, 4>(stream);
|
||||
#endif
|
||||
break;
|
||||
case 8:
|
||||
// FIXME: This could/should be configurable.
|
||||
#if SWIFT_OBJC_INTEROP
|
||||
builder.dumpAllSections<WithObjCInterop, 8>(stream);
|
||||
if (!options::DisableObjCInterop)
|
||||
builder.dumpAllSections<WithObjCInterop, 8>(stream);
|
||||
else
|
||||
builder.dumpAllSections<NoObjCInterop, 8>(stream);
|
||||
#else
|
||||
builder.dumpAllSections<NoObjCInterop, 8>(stream);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user