diff --git a/llvm/test/tools/dsymutil/ARM/firmware.test b/llvm/test/tools/dsymutil/ARM/firmware.test new file mode 100644 index 0000000000000..128faa50a0ca3 --- /dev/null +++ b/llvm/test/tools/dsymutil/ARM/firmware.test @@ -0,0 +1,11 @@ +$ cat test.c +int main() { + return 0; +} + +$ xcrun clang -O0 -target arm64-apple-unknown-macho test.c -c -o test.o +$ xcrun ld -arch arm64 -o test.out test.o -platform_version firmware 0 0 + +RUN: dsymutil -oso-prepend-path %p/../Inputs %p/../Inputs/private/tmp/firmware/test.out -o %t.dSYM +RUN: llvm-objdump -h %t.dSYM/Contents/Resources/DWARF/test.out | FileCheck %s +CHECK: file format mach-o arm64 diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/firmware/test.o b/llvm/test/tools/dsymutil/Inputs/private/tmp/firmware/test.o new file mode 100644 index 0000000000000..3bc83ca4bba59 Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/firmware/test.o differ diff --git a/llvm/test/tools/dsymutil/Inputs/private/tmp/firmware/test.out b/llvm/test/tools/dsymutil/Inputs/private/tmp/firmware/test.out new file mode 100755 index 0000000000000..21fe4d27ba2ee Binary files /dev/null and b/llvm/test/tools/dsymutil/Inputs/private/tmp/firmware/test.out differ diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp index 677dfc44c54a4..7246ba45d5afc 100644 --- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp +++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp @@ -857,7 +857,9 @@ bool DwarfLinkerForBinary::linkImpl( return error(toString(std::move(E))); } - if (Map.getTriple().isOSDarwin() && !Map.getBinaryPath().empty() && + auto MapTriple = Map.getTriple(); + if ((MapTriple.isOSDarwin() || MapTriple.isOSBinFormatMachO()) && + !Map.getBinaryPath().empty() && ObjectType == Linker::OutputFileType::Object) return MachOUtils::generateDsymCompanion( Options.VFS, Map, *Streamer->getAsmPrinter().OutStreamer, OutFile,