llvm-project/llvm/test/tools/yaml2obj
Georgii Rymar ec4e68e667 [yaml2obj] - Introduce the "NoHeaders" key for "SectionHeaderTable"
We have an issue currently. The following YAML piece just ignores the `Excluded` key.

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

Currently the meaning is: exclude the whole table.

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,
because `Sections: []` currently just excludes the whole the sections header table.

To fix it, I suggest a change of the behavior.

1) A new `NoHeaders` key is added. It provides an explicit syntax to drop the whole table.
2) The meaning of the following is changed:

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

```
Assuming there are 2 sections in the object (a null section and `.foo`), with this patch it
means: exclude the `.foo` section, keep the null section. The null section is an implicit
section and I think it is reasonable to make "Sections: []" to mean it is implicitly added.
It will be consistent with the global "Sections" tag that is used to describe sections.

3) `SectionHeaderTable->Sections` is now optional. No `Sections` is the same as
   `Sections: []` (I think it avoids a confusion).
4) Using of `NoHeaders` together with `Sections`/`Excluded` is not allowed.
5) It is possible to use the `Excluded` key without the `Sections` key now (in this case
   `Excluded` must contain all sections).
6) `SectionHeaderTable:` or `SectionHeaderTable: []` is not allowed.
7) When the `SectionHeaderTable` key is present, we still require all sections to be
   present in `Sections` and `Excluded` lists. No changes here, we are still strict.

Differential revision: https://reviews.llvm.org/D81655
2020-06-15 12:43:16 +03:00
..
COFF [COFF] Widen PE32Header fields to fit 64 bit versions 2019-11-21 12:05:00 +02:00
ELF [yaml2obj] - Introduce the "NoHeaders" key for "SectionHeaderTable" 2020-06-15 12:43:16 +03:00
Minidump [yaml2obj][test] Move tests to binary format specific subdirectories 2019-11-18 09:06:14 -08:00
empty-or-invalid-doc.yaml [yaml2obj/ObjectYAML] - Cleanup the error reporting API, add custom errors handlers. 2019-09-13 16:00:16 +00:00
help.test [yaml2obj] Refactor command line parsing 2020-02-06 01:11:58 -08:00
invalid-yaml.yaml [llvm/test/Object] - Cleanup and move out the yaml2obj tests. 2019-08-06 08:02:25 +00:00
lit.local.cfg [obj2yaml][yaml2obj]Locate all .yaml and .test tests 2019-02-20 15:13:44 +00:00
macro.yaml [yaml2obj] Add -D k=v to preprocess the input YAML 2020-02-07 09:35:00 -08:00
missing_document_tag.yaml [yaml2obj/ObjectYAML] - Cleanup the error reporting API, add custom errors handlers. 2019-09-13 16:00:16 +00:00
multi-doc.yaml [test] yaml2obj -docnum => --docnum= 2020-02-04 10:33:21 -08:00
output-file.yaml [yaml2obj] Refactor command line parsing 2020-02-06 01:11:58 -08:00
unsupported_document_tag.yaml