[PATCH] D89039: [yaml2obj/obj2yaml] - Add support of 'Size' and 'Content' keys for all sections.

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 9 00:23:55 PDT 2020


jhenderson added a comment.

Given this change, there's a lot of duplicated code across the various section varieties. There are two common patterns I see:

1. Writing using the Content/Size and setting the sh_size field accordingly.
2. Validating that the Content/Size usage doesn't conflict with special entry lists (e.g. explicit relocations/notes etc).

I think we can do better on both counts. For the first, I'd have a generic write method that checks to see if the base Section has a Size/Content field set, and if so, use that, return true if it did, false if not, so that the section-specific code knows whether to continue doing its thing.

For the second point, maybe we could have a templated method that takes the Entries as a templated parameter, as well as the other fields, and does the validation that way. It probably would need to take a string that indicates the name of the field.

On both points, if we can find a way for it to automatically happen without needing to explicitly call the new functions in multiple places, that would be even better, but I don't think that's all that important.

What do you think?


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

https://reviews.llvm.org/D89039



More information about the llvm-commits mailing list