[llvm] [ELFYAML] Introduce `CustomRawContent` (PR #115707)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 13 06:30:16 PST 2024


jh7370 wrote:

Hi @chapuni. I think you may be overthinking things. The general pattern for sections with special formats is to have a new class for each such section, in ELFYAML.h, derived from `Section`, along with potential other helper classes to represent entries (and sub-entries) in that section (see e.g. `DynamicEntry`, `BBAddrMapEntry`). These classes are named after the section type they are representing (so e.g. `DynamicSection` and `BBAddrMapSection`). They override the `getEntries` method to describe the members they'll have (`GnuHashSection` is a good example here, because it has multiple different elements).

Based on your RFC, I'd expect to see something like `CovMapSection` and `CovFunSection`, with helper classes for things like Expressions and Records. You'll also need to add `LLVM_YAML_IS_SEQUENCE_VECTOR` entries for vector-like types and `MappingTraits` specializations (as with other examples in the header). You'll then need a `writeSectionContent` overload for each of the new section types and make sure to call these in the right places. There are probably various other that will need updating too, but in essence, just do what the existing code does, rather than trying to reinvent the wheel.

It doesn't matter that these sections aren't part of the general ELF ABI. There are other sections that are in the same boat (e.g. the BBAddrMapSection) that are implemented in these files.

I hope that makes more sense.

https://github.com/llvm/llvm-project/pull/115707


More information about the llvm-commits mailing list