From 8acb74e01f1095f028bb19d3cd157687ddf173cc Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 1 Aug 2018 12:53:06 +0000 Subject: [MC] Report fatal error for DWARF types for non-ELF object files Getting the DWARF types section is only implemented for ELF object files. We already disabled emitting debug types in clang (r337717), but now we also report an fatal error (rather than crashing) when trying to obtain this section in MC. Additionally we ignore the generate debug types flag for unsupported target triples. See PR38190 for more information. Differential revision: https://reviews.llvm.org/D50057 llvm-svn: 338527 --- llvm/lib/MC/MCObjectFileInfo.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'llvm/lib/MC/MCObjectFileInfo.cpp') diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index 29d34a8..d4223126 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -950,8 +950,18 @@ void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC, } MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const { - return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP, - 0, utostr(Hash)); + switch (TT.getObjectFormat()) { + case Triple::ELF: + return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP, + 0, utostr(Hash)); + case Triple::MachO: + case Triple::COFF: + case Triple::Wasm: + case Triple::UnknownObjectFormat: + report_fatal_error("Cannot get DWARF types section for this object file " + "format: not implemented."); + break; + } } MCSection * -- cgit v1.1