[PATCH] D93678: [yaml2obj] - Support selecting the location of the section header table.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 12 06:46:48 PST 2021


grimar added a comment.

In D93678#2476962 <https://reviews.llvm.org/D93678#2476962>, @jhenderson wrote:

> Option 3: Have a separate "Layout" block within the YAML which would allow you to define the layout. It might look a bit like this:
>
>   Layout:
>     - FileHeader
>     - Section1
>     - ProgramHeaders
>     - Section2
>     - SectionHeaders
>     - Section3
>
> I'm not sure how this option would work alongside `Offset` values for sections, or what should happen if e.g. the file header entry were to be omitted.

If we really want to add a way to select where program headers are placed and also to support placing both program headers and section headers at an arbitrary offsets,
then I see the following solution:

Currently, internally, we have a list of Chunks, which consists of sections and a special `Fill` chunk.
If we rename the "Sections" YAML key to "Layout" (or alike), then we might be able to introduce 2 more special optional chunks: `ProgramHeaders` and `SectionHeaders`.

Then we will be able to write YAMLs like this:

  --- !ELF
  FileHeader:
    Class: ELFCLASS64
    Data:  ELFDATA2LSB
    Type:  ET_DYN
  Layout:
    - Name: .section1
      Type: SHT_PROGBITS
      Size: 0
    - Type: SectionHeaders
       Offset: 0x1000
    - Name: .section2
       Type: SHT_PROGBITS
       Offset: 0x1200
    - Type: ProgramHeaders

I.e. it might look kind of close to what you've suggested in "Option 3", but doesn't introduce a one more separate YAML block, but allows to reuse the "Sections" block.

Perhaps, we can just have the "Sections" name unchanged for now and think about changing it (or keeping) later, when the functionality will be committed.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93678/new/

https://reviews.llvm.org/D93678



More information about the llvm-commits mailing list