[PATCH] D78304: [yaml2obj] - Program headers: introduce the `POffset` and add an additional check for `Offset`

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 20 05:53:23 PDT 2020


jhenderson added a comment.

In D78304#1991909 <https://reviews.llvm.org/D78304#1991909>, @grimar wrote:

> Does it make sense?


I think the problem here is that we have two competing sources of information for how to layout a program header - the Sections list and the Offset key. Possibly me mental model is outdated, but I thought the layout of the program headers had no effect on that of the sections? In other words, I thought that a section offset was based purely on its alignment and the positions and sizes of any sections/fillers/headers before it? Assuming that my model is correct, a program header's offset and size are determined by the contents, if unspecified, but a forced Offset greater than the start offset of some section seems invalid, and should therefore generate an error?

> But when it is not lower its meaning intersects with the section list. It looks like an issue because it is not clear what the correct logic should be probably? E.g. which memory and file size we want to set?

In other words, don't try to derive a memory and file size and just emit an error in this case. It doesn't need to be allowed to create a broken ELF in this instance, because you can always specify the sizes explicitly.

The alternative of course is to completely change yaml2obj's model to lead with program headers, i.e. sections listed in program headers should be placed based on the offset of the program header. I don't think this is necessarily a good change to make though.


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

https://reviews.llvm.org/D78304





More information about the llvm-commits mailing list