This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj/obj2yaml] - Do not trigger llvm_unreachable when dumping/parsing relocations and e_machine is unsupported.
ClosedPublic

Authored by grimar on Sep 17 2019, 6:23 AM.

Details

Summary

Currently when e_machine is set to something that is not supported by YAML lib,
then tools fail with llvm_unreachable. Though this situation is valid.

In this patch I suggest to allow them to handle relocations in this case.
It can be used to dump and create objects for broken or unsupported targets.

Diff Detail

Event Timeline

grimar created this revision.Sep 17 2019, 6:23 AM
MaskRay accepted this revision.EditedSep 19 2019, 10:43 PM

Though this situation is valid.

I would argue 0x1234 is an invalid case, but valid e_machine numbers are "unsupported" cases. Anyhow this is nice for testing purposes.

test/tools/obj2yaml/relocation-unsupported-machine.yaml
1

machine type -> the machine type
Or
e_machine

I find that the ELF spec describes e_machine as:

This member's value specifies the required architecture for an individual file.

"require architecture", not "machine type" as I thought.. So for the term used here, I have a slight preference for the literal e_machine now.

test/tools/yaml2obj/relocation-unsupported-machine.yaml
1

an unknown e_machine

This revision is now accepted and ready to land.Sep 19 2019, 10:43 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 20 2019, 2:17 AM
Herald added a subscriber: hiraditya. · View Herald Transcript