[PATCH] D77556: [DWARFDataExtractor] Add a "truncating" constructor

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 07:27:43 PDT 2020


labath added a comment.

(Sorry about the delay, last week has been pretty busy for me.)

Replying to these two comments together:

In D77556#1964692 <https://reviews.llvm.org/D77556#1964692>, @dblaikie wrote:

> Looks good - thanks! (I guess at some point we might want a DWARFDataExtractor that can be offset as well - for reading sections in DWP files (essentially create a view of the file based on the index, restricting a CU to only being able to see (& resolve references relative to) the regions described by the index))




@jhenderson wrote:

> I wonder if this should be more generic than the DWARFDataExtractor class, i.e. be in DataExtractor? The concept of limiting length to a specified amount is hardly DWARF specific - ELF sections, for example, sometimes need parsing and have a limited length.
>
> Preumably of course, we'd still want this constructor, but it would just forward to the base class one.


An offseting constructor for a DWARFDataExtractor would be slightly tricky because we would still need to use the "original" offset when resolving relocations. Nothing unsolvable, but it did not seem worth implementing when there's no use case -- dwp files don't have relocations and they deal with this by `substr`-ing the StringRef before they create a DWARFDataExtractor. The same approach can be used for regular DataExtractors, so a substr constructor is not strictly necessary there. However, it would be trivial to add, and it seems like it could come in handy sometimes, so I can add one if you want.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77556





More information about the llvm-commits mailing list