This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj] - Fix the issues with SectionHeaderTable when Sections key is empty.
AbandonedPublic

Authored by grimar on Jun 10 2020, 9:06 AM.

Details

Summary

We have an issue currently. The following YAML piece just ignores the Excluded key.

SectionHeaderTable:
  Sections: []
  Excluded:
    - Name: .foo

The code checks that the Sections key is empty and doesn't catch/check
invalid/duplicated/missed "Excluded" entries.

Also there is no way to exclude all sections except the first null section.
I suggest the simple fix that makes the next logic to work properly:

  1. When there is a "Sections: []", but no "Excluded" key, we omit all section headers.
  2. When there is a "Sections: []" and non-empty "Excluded", then the latter is validated properly and must list all sections. This can be used to create an objects which has no section headers except the null section.

Diff Detail

Event Timeline

grimar created this revision.Jun 10 2020, 9:06 AM
Herald added a project: Restricted Project. · View Herald Transcript
MaskRay added a comment.EditedJun 10 2020, 9:23 AM

Is it possible to use an omitted Sections (rather than an empty (Sections: [])) to represent that all section headers except Excluded should be present?
For Sections: [], a reader may expect that there is no section header.

grimar planned changes to this revision.EditedJun 11 2020, 2:14 AM

Is it possible to use an omitted Sections (rather than an empty (Sections: [])) to represent that all section headers except Excluded should be present?

The current logic is that all sections must be included either in "Sections" or in "Excluded" list. We error out when them are not.
It was done because of implicit sections, like .strtab, .shstrtab which are easy to forget about. I think we should keep this rule.

< there was a suggestion here, but I removed it, because need to think more about it >

grimar abandoned this revision.Jun 11 2020, 3:41 AM

I'll suggest a different approach.

I suggest to go with D81655 instead.