This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj] - Don't crash when `FileHeader` declares an empty `Flags` key in specific situations.
ClosedPublic

Authored by grimar on Aug 18 2020, 5:58 AM.

Details

Summary

We currently call the llvm_unreachable for the following YAML:

--- !ELF
FileHeader:
  Class:   ELFCLASS32
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_NONE
  Flags:   [ ]

it happens because the Flags key is present, though EM_NONE is a
machine type that has no known EF_* values and we call llvm_unreachable by mistake.

Diff Detail

Event Timeline

grimar created this revision.Aug 18 2020, 5:58 AM
Herald added a project: Restricted Project. · View Herald Transcript
grimar requested review of this revision.Aug 18 2020, 5:58 AM
jhenderson accepted this revision.Aug 18 2020, 6:00 AM

LGTM. Is there testing for the other flags discussed in that function? If not, we might want to add it.

This revision is now accepted and ready to land.Aug 18 2020, 6:00 AM

LGTM. Is there testing for the other flags discussed in that function? If not, we might want to add it.

There is nothing yet, except the mips-eflags.yaml test for obj2yaml that does it for mips. Though I'd expect to see
a test for yaml2obj that uses something different, like llvm-readobj. So, yes, we might want to add more testing for all kind of EF_*.