[MC] Set SHT_MIPS_DWARF section type for all .debug_* sections on MIPS

All MIPS .debug_* sections should be marked with ELF type SHT_MIPS_DWARF
accordingly the specification [1]. Also the same section type is assigned
to these sections by GNU tools.

[1] ftp.software.ibm.com/software/os390/czos/dwarf/mips_extensions.pdf

Differential Revision: https://reviews.llvm.org/D29789

llvm-svn: 297447
This commit is contained in:
Simon Atanasyan 2017-03-10 08:22:20 +00:00
parent 50a486e76f
commit 0544b76d15
4 changed files with 38 additions and 24 deletions

View File

@ -705,6 +705,7 @@ enum : unsigned {
SHT_MIPS_REGINFO = 0x70000006, // Register usage information SHT_MIPS_REGINFO = 0x70000006, // Register usage information
SHT_MIPS_OPTIONS = 0x7000000d, // General options SHT_MIPS_OPTIONS = 0x7000000d, // General options
SHT_MIPS_DWARF = 0x7000001e, // DWARF debugging section.
SHT_MIPS_ABIFLAGS = 0x7000002a, // ABI information. SHT_MIPS_ABIFLAGS = 0x7000002a, // ABI information.
SHT_HIPROC = 0x7fffffff, // Highest processor arch-specific type. SHT_HIPROC = 0x7fffffff, // Highest processor arch-specific type.

View File

@ -507,30 +507,39 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T) {
COFFDebugSymbolsSection = nullptr; COFFDebugSymbolsSection = nullptr;
COFFDebugTypesSection = nullptr; COFFDebugTypesSection = nullptr;
unsigned DebugSecType = ELF::SHT_PROGBITS;
// MIPS .debug_* sections should have SHT_MIPS_DWARF section type
// to distinguish among sections contain DWARF and ECOFF debug formats.
// Sections with ECOFF debug format are obsoleted and marked by SHT_PROGBITS.
if (T.getArch() == Triple::mips || T.getArch() == Triple::mipsel ||
T.getArch() == Triple::mips64 || T.getArch() == Triple::mips64el)
DebugSecType = ELF::SHT_MIPS_DWARF;
// Debug Info Sections. // Debug Info Sections.
DwarfAbbrevSection = DwarfAbbrevSection =
Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_abbrev", DebugSecType, 0);
DwarfInfoSection = Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0); DwarfInfoSection = Ctx->getELFSection(".debug_info", DebugSecType, 0);
DwarfLineSection = Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0); DwarfLineSection = Ctx->getELFSection(".debug_line", DebugSecType, 0);
DwarfFrameSection = Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0); DwarfFrameSection = Ctx->getELFSection(".debug_frame", DebugSecType, 0);
DwarfPubNamesSection = DwarfPubNamesSection =
Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_pubnames", DebugSecType, 0);
DwarfPubTypesSection = DwarfPubTypesSection =
Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_pubtypes", DebugSecType, 0);
DwarfGnuPubNamesSection = DwarfGnuPubNamesSection =
Ctx->getELFSection(".debug_gnu_pubnames", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_gnu_pubnames", DebugSecType, 0);
DwarfGnuPubTypesSection = DwarfGnuPubTypesSection =
Ctx->getELFSection(".debug_gnu_pubtypes", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_gnu_pubtypes", DebugSecType, 0);
DwarfStrSection = DwarfStrSection =
Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS, Ctx->getELFSection(".debug_str", DebugSecType,
ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, ""); ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
DwarfLocSection = Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0); DwarfLocSection = Ctx->getELFSection(".debug_loc", DebugSecType, 0);
DwarfARangesSection = DwarfARangesSection =
Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_aranges", DebugSecType, 0);
DwarfRangesSection = DwarfRangesSection =
Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_ranges", DebugSecType, 0);
DwarfMacinfoSection = DwarfMacinfoSection =
Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_macinfo", DebugSecType, 0);
// DWARF5 Experimental Debug Info // DWARF5 Experimental Debug Info
@ -546,27 +555,27 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T) {
// Fission Sections // Fission Sections
DwarfInfoDWOSection = DwarfInfoDWOSection =
Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_info.dwo", DebugSecType, 0);
DwarfTypesDWOSection = DwarfTypesDWOSection =
Ctx->getELFSection(".debug_types.dwo", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_types.dwo", DebugSecType, 0);
DwarfAbbrevDWOSection = DwarfAbbrevDWOSection =
Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_abbrev.dwo", DebugSecType, 0);
DwarfStrDWOSection = DwarfStrDWOSection =
Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS, Ctx->getELFSection(".debug_str.dwo", DebugSecType,
ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, ""); ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
DwarfLineDWOSection = DwarfLineDWOSection =
Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_line.dwo", DebugSecType, 0);
DwarfLocDWOSection = DwarfLocDWOSection =
Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_loc.dwo", DebugSecType, 0);
DwarfStrOffDWOSection = DwarfStrOffDWOSection =
Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_str_offsets.dwo", DebugSecType, 0);
DwarfAddrSection = Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0); DwarfAddrSection = Ctx->getELFSection(".debug_addr", DebugSecType, 0);
// DWP Sections // DWP Sections
DwarfCUIndexSection = DwarfCUIndexSection =
Ctx->getELFSection(".debug_cu_index", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_cu_index", DebugSecType, 0);
DwarfTUIndexSection = DwarfTUIndexSection =
Ctx->getELFSection(".debug_tu_index", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_tu_index", DebugSecType, 0);
StackMapSection = StackMapSection =
Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC); Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);

View File

@ -141,6 +141,10 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
OS << "progbits"; OS << "progbits";
else if (Type == ELF::SHT_X86_64_UNWIND) else if (Type == ELF::SHT_X86_64_UNWIND)
OS << "unwind"; OS << "unwind";
else if (Type == ELF::SHT_MIPS_DWARF)
// Print hex value of the flag while we do not have
// any standard symbolic representation of the flag.
OS << "0x7000001e";
else else
report_fatal_error("unsupported type 0x" + Twine::utohexstr(Type) + report_fatal_error("unsupported type 0x" + Twine::utohexstr(Type) +
" for section " + getSectionName()); " for section " + getSectionName());

View File

@ -1,7 +1,7 @@
; RUN: llc -mtriple mips-linux-gnu -O2 %s -o - | FileCheck %s ; RUN: llc -mtriple mips-linux-gnu -O2 %s -o - | FileCheck %s
; Check struct X for dead variable xyz from inlined function foo. ; Check struct X for dead variable xyz from inlined function foo.
; CHECK: .section .debug_info,"",@progbits ; CHECK: .section .debug_info,"",@0x7000001e
; CHECK: DW_TAG_structure_type ; CHECK: DW_TAG_structure_type
; CHECK-NEXT: info_string ; CHECK-NEXT: info_string