[PATCH] D90458: [yaml2obj][WIP] - ProgramHeaders: introduce FirstSec/LastSec instead of Sections list.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 30 06:16:18 PDT 2020


grimar created this revision.
grimar added reviewers: jhenderson, MaskRay.
Herald added subscribers: hiraditya, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
grimar requested review of this revision.

Imagine we have a YAML declaration of few sections: `foo1`, `<unnamed 2>`, `foo3`, `foo4`.

To put them into segment we can do (1*):

  Sections:
   - Section: foo1
   - Section: foo4

or we can use (2*):

  Sections:
   - Section: foo1
   - Section: foo3
   - Section: foo4

or (3*) :

  Sections:
   - Section: foo1
  ## "(index 2)" here is a name that we automatically created for a unnamed section.
   - Section: (index 2)
   - Section: foo3
   - Section: foo4

It looks really confusing that we don't have to list all of sections.

At first I've tried to make this rule stricter and report an error when there is a gap
(i.e. when a section is included into segment, but not listed explicitly).
This did not work perfect, because such approach conflicts with unnamed sections/fills (see (3*)).

So, I suggest to drop "Sections" key and have 2 keys instead: `FirstSec` and `LastSec`.
Both are optional. Also, it is possible to provide only the `FirstSec`, in this case
`LastSec` is assumed to be the same.

Note: there are many test cases failures in `tools/llvm-objdump/*`, `tools/llvm-readobj/*`,
and other places. I've updated all yaml2obj and obj2yaml tests only for now to demonstrate
the new functionality I am suggesting.

I'd like to hear the feedback about this idea, if it is OK, I'll update other tests and add a few new ones.


https://reviews.llvm.org/D90458

Files:
  llvm/include/llvm/ObjectYAML/ELFYAML.h
  llvm/lib/ObjectYAML/ELFEmitter.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/test/tools/obj2yaml/ELF/program-headers.yaml
  llvm/test/tools/yaml2obj/ELF/custom-fill.yaml
  llvm/test/tools/yaml2obj/ELF/dynamic-section-i386.yaml
  llvm/test/tools/yaml2obj/ELF/header-sh-fields.yaml
  llvm/test/tools/yaml2obj/ELF/program-header-address.yaml
  llvm/test/tools/yaml2obj/ELF/program-header-align.yaml
  llvm/test/tools/yaml2obj/ELF/program-header-nobits.yaml
  llvm/test/tools/yaml2obj/ELF/program-header-size-offset.yaml
  llvm/test/tools/yaml2obj/ELF/program-header.yaml
  llvm/tools/obj2yaml/elf2yaml.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90458.301871.patch
Type: text/x-patch
Size: 37661 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201030/b686f3c2/attachment.bin>


More information about the llvm-commits mailing list