[PATCH] D62278: [obj2yaml] Support dumping program headers.

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 01:09:41 PDT 2019


labath added a comment.

Unfortunately, I don't think this will be enough to make obj2yaml really useful for handling program headers. The interesting thing about program headers is their interconnection with the data described by section headers, and by storing that values verbatim, you're completely ignoring that aspect. This may be enough to capture a file, if the elf file was already produced by yaml2obj, and the yaml hasn't been modified in any way, as then obj2yaml will likely lay things out the same way and the program headers will come out "right".  However, if the elf file was produced by some other tool (including an older version of yaml2obj), then the reconstituted program headers will likely point to garbage.

So, I believe a more sophisticated solution is needed here. I think we will need to somehow capture the segment-to-section relationship symbolically, much like `yaml2obj` allows you to state the sections which are to be contained in a segment, and then adjusts the program headers offset and size fields accordingly. However, that is not going to be that trivial, because there is a bunch of edge cases to consider:

- the segments can contain data not covered by any section, due to alignment or other considerations. The most extreme case of this are elf core files, which contain no sections, and all data is accessible only through program headers. So we'll probably need a way to specify (parts of) segment content directly.
- this means that yaml2obj will need to be able to generate and allocate space for this kind of data in its output. That may mean changing the algorithm it uses to allocate space for the section data, but I don't really have that part thought out.
- the PT_PHDR header is particularly amusing, because it is self-referencing. However, I don't think we use this header for anything right now, so it's probably not too important what we do with it..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62278





More information about the llvm-commits mailing list