This is an archive of the discontinued LLVM Phabricator instance.

[MC][ELF] Do not error on parsing .debug_* section directive for MIPS
ClosedPublic

Authored by atanasyan on Aug 7 2021, 10:30 PM.

Details

Summary

MIPS .debug_* sections should have SHT_MIPS_DWARF section type to distinguish among sections contain DWARF and ECOFF debug formats, but in assembly files these sections have SHT_PROGBITS (@progbits) type. Now assembler shows 'changed section type for ...' error when parsing .section .debug_*,"",@progbits directive for MIPS targets.

The same problem exists for x86-64 target and this patch extends workaround implemented in D76151. The patch adds one more case when assembler ignore section types mismatch after SwitchSection() call.

Diff Detail

Event Timeline

atanasyan created this revision.Aug 7 2021, 10:30 PM
atanasyan requested review of this revision.Aug 7 2021, 10:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 7 2021, 10:30 PM
arichardson added inline comments.Aug 8 2021, 12:58 AM
llvm/lib/MC/MCParser/ELFAsmParser.cpp
518

Should this be restricted to Section->getName().startsWith (".debug")?

MaskRay added a comment.EditedAug 8 2021, 9:55 AM

MIPS .debug_* sections should have SHT_MIPS_DWARF section type to distinguish among sections contain DWARF and ECOFF debug formats

If SHT_PROGBITS is a valid value, now what's the value keeping using SHT_MIPS_DWARF?

I know the ELF spirit is preferring section types to section names, but the reality with at least the 32-bit DWARF format is that architectures should just stick with SHT_PROGBITS.
For compatibility, consumers need to keep recognizing SHT_MIPS_DWARF but producers can switch the type anytime.

That said, the patch LG.

atanasyan added inline comments.Aug 8 2021, 12:25 PM
llvm/lib/MC/MCParser/ELFAsmParser.cpp
518

Good point. I'll fix this.

MIPS .debug_* sections should have SHT_MIPS_DWARF section type to distinguish among sections contain DWARF and ECOFF debug formats

If SHT_PROGBITS is a valid value, now what's the value keeping using SHT_MIPS_DWARF?

As usual for MIPS the main reason is compatibility with other tools.

atanasyan updated this revision to Diff 365040.Aug 8 2021, 12:29 PM
  • Check section name prefix .debug_ instead of section type. This approach is closer to other MIPS toolchains.
MaskRay accepted this revision.Aug 8 2021, 9:21 PM

Looks great!

This revision is now accepted and ready to land.Aug 8 2021, 9:21 PM

Thanks for review.