[llvm] [llvm-objdump] Error with relevant message when adding invalid notes (PR #90458)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 30 00:52:15 PDT 2024


https://github.com/jh7370 commented:

I agree with @MaskRay that validating added note sections specifically and unconditionally is suboptimal. However, I also can see the benefit of being able to validate .note sections (and possibly other sections, although not as part of this patch). Did you have a specific use-case in mind @serge-sans-paille (e.g. adding an invalid section caused some misery somewhere)?

I have a few competing ideas that would achieve the goal, whilst still maintaining the ability to add invalid sections:

1. Add a new `--validate-notes` option that validates all .note sections in the final output (so after adding and stripping etc). Possibly "all" is unnecessary and this could be restricted to just the added ones. Pros: opt-in behaviour means users can continue to add invalid notes deliberately. Cons: existing and new users accidentally adding invalid notes will continue to do so.
2. Same as above, but make the option the default and provide a "don't validate" option instead. Bascially the same benefits as 1, without the con of people forgetting to add the option, but inconveniences existing users who are deliberately adding an invalid section for whatever reason.
3. Add a new `--add-note-section` that is the same as `--add-section` but specifically for notes, and would do the validation unconditionally. The existing `--add-section` would continue to be usable for note sections, for backwards and GNU compatibility, but wouldn't do the validation.

Various variations on the above would cover non-note sections too, e.g. `--verify-sections`,
or even only a specific named section (e.g. `--verify-section=...` or `--verify-note-section=...`).

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


More information about the llvm-commits mailing list