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

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 4 01:17:20 PST 2021


jhenderson added a comment.

If there's a case where this is useful, I definitely support it. More generally, we may want to be able to do the same with program header table placement. I don't know if we have a use-case for that yet, but it's probably worth keeping it in mind as we design this. `BeforeSecData` is therefore a little bit ambiguous here. For example, between the ELF header and program header table is also "before" the section data. Maybe the key words should be `AfterEhdr`, `AfterPhdrs`, `AfterSections` (or possibly `AtEOF` for the last one). We could probably not have one of `AfterEhdr` or `AfterPhdrs` for now. Longer-term, I could imagine it might be useful to allow arbitrary offsets for the section header table, so we should consider this in our design too.

I've got a few competing ideas, and am listing them here to see what others think.

Option 1: encode location in SectionHeaderTable, possibly using the keyword `Offset` (I think Offset is better than Location, for consistency, with named values like `AfterSections` or `AfterSecData` being special values). The offset would work the same as `Offset` does for sections, and we'd need to effectively insert the section header table block between sections at the requested position, when specified as an arbitrary value.
Option 2: add section header offset property to the FileHeader which controls the section header table position. This is basically the same as the previous idea, but with the location specified in a different place. The advantage with this approach is that in the future, the same approach could be followed with the program header table. It also could sit alongside the `ESHoff` (I forget its exact spelling) field nicely (the latter providing the value in the header itself, whilst the position is determined by a `SectionHeaderOffset` field or similar.
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.

I am kind of leaning towards option 2, but see benefits to all the approaches. What do you think?

(I haven't looked at the new code or test yet. I'll do that after the design has been discussed further)


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

https://reviews.llvm.org/D93678



More information about the llvm-commits mailing list